ISO 15118

repository·main·Indexed 42 days ago

https://github.com/ecog-io/iso15118

A Python implementation of the ISO 15118-2 and ISO 15118-20 protocols, as well as DIN SPEC 70121, for communication between Electric Vehicle Communication Controllers (EVCC) and Supply Equipment Communication Controllers (SECC). Version 0.31.2.

Tokens
4.1K
Snippets
14
Records
17
Agent score
54%

What's inside ISO 15118

  1. IPv6 Requirements and Docker Network Mode

    main

    ISO 15118 communication requires the network interface to have an IPv6 link-local address assigned.

    • Docker Default: Uses an internal ipv6_net network. This works for isolated testing of EVCC and SECC containers but prevents the host machine from reaching the link-local addresses.
    • Host Mode: To allow the host to interact with the link-local addresses (e.g., via HomePlug Green PHY), you must use network_mode: host. This is currently only fully supported on Linux. To use this, copy the contents of docker-compose-host-mode.yml into your main docker-compose.yml file.
  2. Install ISO15118 locally

    main

    To run the project locally, follow these steps:

    1. Generate Certificates: Use the create_certs.sh script located in iso15118/shared/pki/ to generate certificates for ISO 15118-2 and 15118-20.
    2. Install JRE: If using the Java-based EXI codec (EXIficient), install a JRE (e.g., openjdk-17-jre).
    3. Configure Environment: Copy .env.dev.local to .env. Ensure the NETWORK_INTERFACE key matches your actual network interface (default is eth0).
    4. Install Dependencies: Use Poetry to manage dependencies.
    5. Run Controllers: Use the provided Makefile to start the SECC or EVCC.
    $ make install-local
    $ make run-secc
  3. Run ISO15118 using Docker

    main

    Using Docker is the recommended way to start the project as it automatically handles certificate generation, tests, linting, and spawns both the SECC and EVCC containers. When using Docker, make dev automatically uses the .env.dev.docker file, so you do not need to manually create a .env file.

    $ make build
    $ make dev
  4. Install and configure JRE for EXI codec

    main

    A Java Runtime Environment (JRE) is required if using the Java-based EXI codec (EXIficient). On Ubuntu, you can install it via apt. If the default version is outdated, install openjdk-17-jre and use update-alternatives to set it as the default.

    # Install default JRE
    sudo apt update && sudo apt install -y default-jre
    
    # Install specific version
    sudo apt install openjdk-17-jre
    
    # Query installed versions
    update-alternatives --query java
    
    # Configure default version
    update-alternatives --config java
  5. Service architecture in Docker Compose

    main

    The ISO15118 deployment consists of the following services:

    • secc: The SECC (Supply Equipment Communication Controller) service. It depends on redis and connects to the ipv6_net network.
    • evcc: The EVCC (Electric Vehicle Communication Controller) service. It depends on both redis and secc and connects to the ipv6_net network.
    • redis: A Redis instance (version 6.2.6-alpine) used for data persistence or messaging. It exposes port 6379 to the host.
  6. Configure local environment variables

    main

    The project uses .env files for configuration. For local development, copy .env.dev.local to .env.

    Important: You must set the NETWORK_INTERFACE variable in your .env file to match your system's network interface (e.g., eth0, wlan0). The values in .env directly configure secc_settings.py and evcc_settings.py.

  7. Configure ISO15118 via environment variables

    main

    The ISO15118 implementation can be customized by setting environment variables. These variables allow you to control network interfaces, security enforcement, PKI paths, logging verbosity, and supported communication protocols.

    Key configuration areas include:

    • Networking: Specify the NETWORK_INTERFACE (default eth0).
    • Security: Control TLS enforcement via SECC_ENFORCE_TLS, enable TLS 1.3 via ENABLE_TLS_1_3, and set authentication modes via AUTH_MODES.
    • PKI: Define the certificate location using PKI_PATH (defaults to <CWD>/iso15118/shared/pki/).
    • Logging: Adjust LOG_LEVEL and enable message logging for EXI JSON (MESSAGE_LOG_JSON) or EXI Bytestream (MESSAGE_LOG_EXI) when the log level is set to DEBUG.
    | ENV | Default Value | Description |
    | ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
    | NETWORK_INTERFACE | `eth0` | HomePlug Green PHY Network Interface from which the high-level communication (HLC) will be established |
    | SECC_ENFORCE_TLS  | `False` | Whether or not the SECC will enforce a TLS connection |
    | PKI_PATH          | `<CWD>/iso15118/shared/pki/` | Path for the location of the PKI where the certificates are located. By default, the system will look for the PKI directory under the current working directory |
    | LOG_LEVEL         | `INFO` | Level of the Python log service |
    | MESSAGE_LOG_JSON  | `True` | Whether or not to log the EXI JSON messages (only works if log level is set to DEBUG) |
    | MESSAGE_LOG_EXI   | `False` | Whether or not to log the EXI Bytestream messages (only works if log level is set to DEBUG) |
    | PROTOCOLS         | `DIN_SPEC_70121,ISO_15118_2,ISO_15118_20_AC,ISO_15118_20_DC` | Enabled communication protocols on SECC. |
    | AUTH_MODES        | `EIM,PNC` | Selected authentication modes for SECC |
    | USE_CPO_BACKEND   | `False` | Indicates if backend integration is available to fetch certificates |
    | ENABLE_TLS_1_3    | `False` | Enables TLS 1.3 for SECC-EVCC communication. |
  8. Run ISO15118 using Docker Compose

    main

    The project can be deployed using Docker Compose, which orchestrates three main services: secc, evcc, and redis. The setup uses a custom IPv6 bridge network (ipv6_net) to facilitate communication between services.

    To run the stack, ensure you have Docker and Docker Compose installed, then use the standard compose command from the root of the repository.

    docker compose up
  9. Run the SECC (Supply Equipment Communication Controller)

    main

    You can start the SECC using the Makefile or by calling the start script directly via Poetry. The Makefile approach is recommended for convenience.

    # Using Makefile
    $ make install-local
    $ make run-secc
    
    # Using Poetry directly
    $ poetry install
    $ poetry run python iso15118/secc/start_secc.py
  10. Generate ISO 15118 certificates

    main

    The create_certs.sh script in iso15118/shared/pki/ is used to generate certificates for the different protocol versions. Use the -v flag to specify the version.

    $ cd iso15118/shared/pki/
    $ ./create_certs.sh -v iso-2
    $ ./create_certs.sh -v iso-20
  11. Run the EVCC (Electric Vehicle Communication Controller)

    main

    The EVCC can be started via the Makefile. You can pass specific configuration files (found in iso15118/shared/examples/evcc/) as a command-line argument to test different modes like AC, DC, or TLS settings.

    # Standard run
    $ make install-local
    $ make run-evcc
    
    # Run with a specific configuration file
    $ make run-evcc config=path_of_config_file
  12. EVCC Configuration Settings Reference

    main

    When running the EVCC, the following settings can be configured (typically via the configuration file passed to make run-evcc):

    | Setting | Default Value | Description |
    |-----------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------|
    | supportedProtocols | `DIN_SPEC_70121,ISO_15118_2,ISO_15118_20_AC,ISO_15118_20_DC` | Enabled communication protocols on EVCC |
    | supportedEnergyServices| `AC` | Selected energy services mode for EVCC |
    | useTls | `True` | Whether or not the EVCC signals the preference to communicate with a TLS connection |
    | enforceTls | `False` | Whether or not the EVCC will only accept TLS connections |
    | isCertInstallNeeded | `False` | Indicates if the installation of a contract certificate is needed |
    | energyTransferMode | `AC_three_phase_core` | Energy transfer mode requested for the current charging session |
    | sdpRetryCycles | `1` | Indicates how often shall SDP (SECC Discovery Protocol) retries happen before reverting to using nominal duty cycle PWM-based charging |
    | maxContractCerts | `3` | Maximum amount of contract certificates the EV stores |
    | maxSupportingPoints | `1024` | Indicates the maximum number of entries the EVCC supports within the sub-elements of a ScheduleTuple |