### Install Dependencies and Run SECC Source: https://github.com/ecog-io/iso15118/blob/master/README.md Installs local dependencies and starts the SECC controller. This is the primary method for setting up and running the SECC. ```bash $ make install-local $ make run-secc ``` -------------------------------- ### Install Dependencies and Run EVCC Source: https://github.com/ecog-io/iso15118/blob/master/README.md Installs local dependencies and starts the EVCC controller. Use this command to set up and run the EVCC. ```bash $ make install-local $ make run-evcc ``` -------------------------------- ### Manual SECC Startup with Poetry Source: https://github.com/ecog-io/iso15118/blob/master/README.md Manually installs dependencies using Poetry and then starts the SECC controller script. This is an alternative to using the Makefile for SECC startup. ```bash $ poetry install $ poetry run python iso15118/secc/start_secc.py ``` -------------------------------- ### Configure Free Certificate Installation Service Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Determine if the certificate installation service is offered free of charge. ```shell FREE_CERT_INSTALL_SERVICE=True ``` -------------------------------- ### Run EVCC with a Specific Configuration File Source: https://github.com/ecog-io/iso15118/blob/master/README.md Starts the EVCC controller and applies a custom configuration from a specified file path. This allows for flexible testing of different EVCC setups. ```bash $ make run-evcc config=path_of_config_file ``` -------------------------------- ### Install Default JRE Source: https://github.com/ecog-io/iso15118/blob/master/README.md Installs the default Java Runtime Environment using apt on Debian-based systems. ```bash sudo apt update && sudo apt install -y default-jre ``` -------------------------------- ### Configure Offering Certificate Installation Service Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Enable or disable the offering of certificate installation or update services. ```shell ALLOW_CERT_INSTALL_SERVICE=True ``` -------------------------------- ### Start SECC (Server) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Starts the Supply Equipment Communication Controller (SECC) in server mode. Configuration is typically managed in `iso15118/secc/secc_settings.py`. ```bash make run-secc ``` -------------------------------- ### Query Installed Java Versions Source: https://github.com/ecog-io/iso15118/blob/master/README.md Displays information about all installed Java versions on the system. ```bash update-alternatives --query java ``` -------------------------------- ### Build and Run Docker Source: https://github.com/ecog-io/iso15118/blob/master/README.md Builds the Docker image and starts the development environment with containers for SECC and EVCC. ```bash $ make build $ make dev ``` -------------------------------- ### Get Certificate Install Response (ISO 15118) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Processes the certificate installation response from the EVSE. This method takes the new certificate as input and returns a status or error message. ```python async def get_certificate_install_response( self, certificate: bytes ) -> Optional[str] ``` -------------------------------- ### Start EVCC (Client) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Starts the Electric Vehicle Communication Controller (EVCC) in client mode. Configuration is typically managed in `iso15118/evcc/evcc_settings.py`. ```bash make run-evcc ``` -------------------------------- ### Complete SECC Setup with Configuration Loading Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Demonstrates loading SECC configuration from environment variables and initializing the SECC simulator. ```python from iso15118.secc.secc_settings import Config as SECCConfig from iso15118.secc.controller.simulator import SECCSimulator # Load configuration seCC_config = SECCConfig() secc_config.load_envs(env_path=".env") # Verify settings print(f"Interface: {secc_config.iface}") print(f"Log level: {secc_config.log_level}") print(f"Protocols: {[p.value for p in secc_config.supported_protocols]}") print(f"Auth modes: {[a.value for a in secc_config.supported_auth_options]}") # Create controller with settings evse_controller = SECCSimulator(config=secc_config) ``` -------------------------------- ### Install Local Dependencies Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Installs local dependencies for the iso15118 project. Ensure you are in the project's root directory. ```bash cd /workspace/home/iso15118 make install-local ``` -------------------------------- ### Complete EVCC Setup with Configuration Loading Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Demonstrates loading EVCC configuration from environment variables and initializing the EV simulator. ```python from iso15118.evcc.evcc_settings import Config as EVCCConfig from iso15118.evcc.controller.simulator import EVSimulator # Load configuration evcc_config = EVCCConfig() evcc_config.load_envs(env_path=".env") print(f"Interface: {evcc_config.iface}") print(f"EV config: {evcc_config.ev_config_file_path}") # Load EV configuration from file import json with open(evcc_config.ev_config_file_path) as f: ev_config_data = json.load(f) # Create controller ev_controller = EVSimulator(config=ev_config_data) ``` -------------------------------- ### Start UDP Server for SDP Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/transport-layer.md Starts a UDP server to handle SECC Discovery Protocol (SDP) broadcast responses on port 15118. The ready_event signals when the server is active. ```python async def start(self, ready_event: asyncio.Event, iface: str) -> None ``` -------------------------------- ### SECC UDPServer - Start Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/transport-layer.md Starts the UDP server for SECC Discovery Protocol (SDP) responses. It listens for SDP requests and sends appropriate responses. ```APIDOC ## UDPServer - start ### Description Starts the UDP server for handling SECC Discovery Protocol (SDP) responses. This server is responsible for responding to SDP requests on the designated port. ### Method `async def start(self, ready_event: asyncio.Event, iface: str)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **ready_event** (asyncio.Event) - Required - Event to signal when ready - **iface** (str) - Required - Network interface (e.g., "eth0") ### Request Example ```python # Assuming ready_event is an asyncio.Event instance await server.start(ready_event, iface="eth0") ``` ### Response #### Success Response None #### Response Example None ### Purpose Listens for SDP requests and sends SDP responses on port 15118. ``` -------------------------------- ### Set Supported Protocols with Priority Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Example of setting supported protocols where the first entry has the highest priority during negotiation. ```shell PROTOCOLS=ISO_15118_2,DIN_SPEC_70121 ``` -------------------------------- ### Install OpenJDK 17 JRE Source: https://github.com/ecog-io/iso15118/blob/master/README.md Installs OpenJDK 17 JRE on Ubuntu systems, which may be required if the default version is not recent enough. ```bash sudo apt install openjdk-17-jre ``` -------------------------------- ### Start EVCC with Specific Configuration Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Starts the Electric Vehicle Communication Controller (EVCC) with a specific JSON configuration file. This allows for customized charging parameters. ```bash make run-evcc config=iso15118/shared/examples/evcc/iso15118_2/evcc_config_pnc_dc.json ``` -------------------------------- ### Start Plain TCP Server Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/transport-layer.md Initiates a plain TCP server without encryption. Use the ready_event to confirm server readiness. ```python ready_event = asyncio.Event() await server.start_no_tls(ready_event) await ready_event.wait() print(f"TCP server ready on {server.ipv6_address_host}:{server.port}") ``` -------------------------------- ### get_certificate_install_response Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Processes certificate installation response from EVSE. ```APIDOC ## get_certificate_install_response ### Description Processes certificate installation response from EVSE. ### Method POST ### Endpoint /evcc/certificate_install_response ### Parameters #### Request Body - **certificate** (bytes) - Required - New certificate from EVSE ### Returns Optional[str] - Status or error message ### Applicable Protocols ISO 15118-2, ISO 15118-20 ``` -------------------------------- ### Get DC Charge Parameter (ISO 15118-2) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Provides DC charging parameters for ISO 15118-2, including maximum current, voltage, and state of charge (SOC). Use this for older ISO 15118-2 DC charging setups. ```python async def get_dc_charge_parameter_v2(self) -> DCEVChargeParameter ``` ```python params = await controller.get_dc_charge_parameter_v2() print(f"Max current: {params.ev_max_charge_current.get_decimal_value()}A") print(f"Max voltage: {params.ev_max_voltage_limit.get_decimal_value()}V") print(f"Current SOC: {params.ev_energy_capacity.get_decimal_value()}%") ``` -------------------------------- ### SessionStateMachine Constructor Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/communication-session.md Initializes the state machine with a starting state and communication session reference. ```APIDOC ## SessionStateMachine Constructor ### Description Initializes the state machine with a starting state and communication session reference. ### Parameters #### Path Parameters - **start_state** (Type[State]) - Required - Initial state class for the state machine - **comm_session** (Union[EVCCCommunicationSession, SECCCommunicationSession]) - Required - Communication session instance ### Request Example ```python from iso15118.evcc.states.sap_states import WaitForSupportedAppProtocolRes state_machine = SessionStateMachine( start_state=WaitForSupportedAppProtocolRes, comm_session=evcc_session ) ``` ``` -------------------------------- ### SECC TCPServer - Start No TLS Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/transport-layer.md Starts a plain TCP server without encryption for SECC. This is used for unencrypted communication with EVCC clients. ```APIDOC ## TCPServer - start_no_tls ### Description Starts a plain TCP server without encryption. This method is used when secure communication is not required. ### Method `async def start_no_tls(self, ready_event: asyncio.Event)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **ready_event** (asyncio.Event) - Required - Event to signal when server is ready ### Request Example ```python ready_event = asyncio.Event() await server.start_no_tls(ready_event) await ready_event.wait() print(f"TCP server ready on {server.ipv6_address_host}:{server.port}") ``` ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### Configure Default Java Version Source: https://github.com/ecog-io/iso15118/blob/master/README.md Configures the default Java version by interactively selecting from installed versions. ```bash update-alternatives --config java ``` -------------------------------- ### Initialize V2GCommunicationSession Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/communication-session.md Initializes a V2G communication session with a network interface, starting state, and a communication handler. ```python from iso15118.evcc.comm_session_handler import EVCCCommunicationHandler from iso15118.evcc.states.sap_states import WaitForSupportedAppProtocolRes handler = EVCCCommunicationHandler() session = V2GCommunicationSession( iface="eth0", start_state=WaitForSupportedAppProtocolRes, handler=handler ) ``` -------------------------------- ### SECC TCPServer - Start TLS Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/transport-layer.md Starts a TLS-encrypted TCP server for SECC. It listens for incoming EVCC connections and can be configured to use TLS for secure communication. ```APIDOC ## TCPServer - start_tls ### Description Starts a TLS-encrypted TCP server. This method configures the server to accept incoming connections securely using TLS. ### Method `async def start_tls(self, ready_event: asyncio.Event)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **ready_event** (asyncio.Event) - Required - Event to signal when server is ready ### Request Example ```python import asyncio from iso15118.secc.transport.tcp_server import TCPServer # Assuming session_queue and iface are defined server = TCPServer(session_queue, iface="eth0") ready_event = asyncio.Event() # Start TLS server await server.start_tls(ready_event) # Wait for server to be ready await ready_event.wait() print(f"TLS server ready on {server.ipv6_address_host}:{server.port}") ``` ### Response #### Success Response None #### Response Example None ### Errors - OSError: If port binding fails - SSL errors: If TLS context creation fails ``` -------------------------------- ### Search Documentation with Grep Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/INDEX.md Use grep to search for specific topics, code examples, or error references within the documentation files. ```bash # Find all references to a topic grep -r "SessionSetup" /workspace/home/output/ # Find all code examples grep -B2 -A2 "```python" /workspace/home/output/ # Find error references grep -r "SDPFailedError" /workspace/home/output/ ``` -------------------------------- ### ISO 15118-2 Certificate Installation Message Structure Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Defines the fields for CertificateInstallationReq and CertificateInstallationRes messages in ISO 15118-2. ```protobuf CertificateInstallationReq ├── SessionID (bytes) ├── SubCertificates (bytes) - DER-encoded certs ├── PrivateKey (bytes, encrypted) └── ListOfRootCertificateIDs (list) CertificateInstallationRes ├── ResponseCode (enum) ├── SessionID (bytes) ├── SAProvisioningCertificateChain (bytes) ├── EVSECertificate (bytes) ├── CertificateInstallationStatus (enum) └── TimeStamp (int) ``` -------------------------------- ### Get Supported Authentication Options Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves a list of all supported authentication options. This information is crucial for determining available authentication methods. ```python async def get_supported_auth_options(self) -> List[AuthEnum] ``` -------------------------------- ### Authorization Setup Request and Response Structure Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Defines the structure for setting up authorization services, including specifying authorization service IDs and optional EMAID lists. ```protobuf AuthorizationSetupReq ├── Header (MessageHeader) └── AuthorizationServices (AuthorizationService list) ├── AuthorizationServiceID (enum) │ ├── EIM │ └── PnC └── EMAIDList (list, optional) AuthorizationSetupRes ├── Header (MessageHeader) ├── ResponseCode (enum) ├── AuthorizationServices (AuthorizationService list) └── EVSEStatus (EVSEStatus) ``` -------------------------------- ### Minimal Environment Configuration Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Example of a minimal .env file for configuring the ISO 15118 environment, including network interface, logging level, and PKI certificate paths. ```bash # Network NETWORK_INTERFACE=eth0 # Logging LOG_LEVEL=INFO # PKI certificates PKI_PATH=./iso15118/shared/pki/ ``` -------------------------------- ### Start TLS-encrypted TCP Server Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/transport-layer.md Initiates a TLS-encrypted TCP server. Ensure the TCPServer is initialized and the ready_event is used to signal when the server is operational. ```python import asyncio from iso15118.secc.transport.tcp_server import TCPServer server = TCPServer(session_queue, iface="eth0") ready_event = asyncio.Event() # Start TLS server await server.start_tls(ready_event) # Wait for server to be ready await ready_event.wait() print(f"TLS server ready on {server.ipv6_address_host}:{server.port}") ``` -------------------------------- ### Implement EVSEControllerInterface (SECC) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Python example for implementing the EVSEControllerInterface on the SECC side. This class handles EVSE hardware integration and status updates. ```python from iso15118.secc.controller.interface import EVSEControllerInterface, ServiceStatus from iso15118.shared.messages.enums import Protocol class MyEVSEController(EVSEControllerInterface): async def set_status(self, status: ServiceStatus) -> None: # Update EVSE status self._evse_status = status async def get_evse_id(self, protocol: Protocol) -> str: return "DE*MyCharger*12345678" async def is_authorized(self, **kwargs) -> AuthorizationResponse: # Check if EV is authorized to charge return AuthorizationResponse( authorization_status=AuthorizationStatus.ACCEPTED ) # Implement other required methods... ``` -------------------------------- ### ISO 15118-20 Session Setup Message Structure Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Defines the fields for SessionSetupReq and SessionSetupRes messages in ISO 15118-20. ```protobuf SessionSetupReq ├── Header (MessageHeader) ├── EVCCID (string) - VIN or EMAID └── EVChargePort (enum, optional) ├── AC_singlePhase ├── AC_threePhase ├── DC_Core ├── DC_Extended ├── DC_Unique └── DC_ComboCore SessionSetupRes ├── Header (MessageHeader) ├── ResponseCode (enum) ├── EVSEID (string) └── EVSEStatus (EVSEStatus) ``` -------------------------------- ### Example SECC Configuration Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Defines the configuration parameters for a SECC, including supported protocols, authentication modes, and AC/DC charging parameters. ```json { "evse_id": "DE*ABC*12345678", "supported_protocols": [ "ISO_15118_2", "ISO_15118_20_AC" ], "auth_modes": ["EIM", "PNC"], "enforce_tls": false, "ac_parameters": { "voltage": 230, "frequency": 50, "max_current": 32 }, "dc_parameters": { "voltage_min": 200, "voltage_max": 850, "current_max": 350 } } ``` -------------------------------- ### V2GCommunicationSession Constructor Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/communication-session.md Initializes a V2G communication session with a specified network interface, starting state, and communication handler. ```APIDOC ## V2GCommunicationSession Constructor ### Description Initializes a V2G communication session. ### Parameters #### Path Parameters - **iface** (str) - Yes - Network interface (e.g., "eth0") - **start_state** (Type[State]) - Yes - Initial state - **handler** (Union[EVCCCommunicationHandler, SECCCommunicationHandler]) - Yes - Communication handler ### Request Example ```python from iso15118.evcc.comm_session_handler import EVCCCommunicationHandler from iso15118.evcc.states.sap_states import WaitForSupportedAppProtocolRes handler = EVCCCommunicationHandler() session = V2GCommunicationSession( iface="eth0", start_state=WaitForSupportedAppProtocolRes, handler=handler ) ``` ``` -------------------------------- ### Example EVCC Configuration Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Defines the configuration parameters for an EVCC, including supported protocols, battery capacity, and charging current limits. ```json { "supported_protocols": [ "ISO_15118_2", "ISO_15118_20_AC" ], "battery_capacity": 75000, "energy_mode": "AC_three_phase_core", "use_tls": true, "enforce_tls": false, "max_charge_current_ac": 32, "max_charge_current_dc": 200, "max_voltage": 400 } ``` -------------------------------- ### Initialize SessionStateMachine Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/communication-session.md Initializes the state machine with a starting state and communication session reference. Use this to set up the state machine for a new communication session. ```python from iso15118.evcc.states.sap_states import WaitForSupportedAppProtocolRes state_machine = SessionStateMachine( start_state=WaitForSupportedAppProtocolRes, comm_session=evcc_session ) ``` -------------------------------- ### Get Meter Info V2 for ISO 15118-2 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Retrieves smart meter information from the EVSE for ISO 15118-2. ```python async def get_meter_info_v2(self) -> MeterInfoV2 ``` ```python meter_info = await controller.get_meter_info_v2() print(f"Meter reading: {meter_info.meter_reading} Wh") print(f"Timestamp: {meter_info.meter_status}") ``` -------------------------------- ### Get Meter Info V20 for ISO 15118-20 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Retrieves smart meter information from the EVSE for ISO 15118-20. ```python async def get_meter_info_v20(self) -> MeterInfoV20 ``` -------------------------------- ### Handle MACAddressNotFound Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/errors.md Example of catching MACAddressNotFound during EVCC controller initialization when retrieving the EVCCID. Handle by addressing MAC address retrieval issues. ```python from iso15118.shared.exceptions import MACAddressNotFound try: evcc_id = await controller.get_evcc_id(Protocol.ISO_15118_2, "eth0") except MACAddressNotFound: print("Cannot retrieve MAC address from network interface") ``` -------------------------------- ### Physical Value Representation Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Illustrates the structure for representing physical values, including value, multiplier, and unit, with examples for voltage, current, and power. ```protobuf PhysicalValue = value × 10^multiplier [unit] Examples: ├── 230V = PhysicalValue(value=230, multiplier=0, unit=VOLTAGE) ├── 32A = PhysicalValue(value=32, multiplier=0, unit=AMPERE) ├── 7.4kW = PhysicalValue(value=74, multiplier=2, unit=WATT) └── 50kWh = PhysicalValue(value=50, multiplier=3, unit=WATT_HOURS) ``` -------------------------------- ### Implement EVControllerInterface (EVCC) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Python example for implementing the EVControllerInterface on the EVCC side. This class handles EV hardware integration and provides EVCC identification. ```python from iso15118.evcc.controller.interface import EVControllerInterface from iso15118.shared.messages.enums import Protocol class MyEVController(EVControllerInterface): async def get_evcc_id(self, protocol: Protocol, iface: str) -> str: # Return MAC address for DIN/ISO-2 or VIN for ISO-20 if protocol == Protocol.ISO_15118_20_AC: return "EVID1234567890AB" return "00:1f:29:b0:a1:cd" async def get_energy_transfer_mode(self, protocol: Protocol): return EnergyTransferModeEnum.AC_THREE_PHASE_CORE # Implement other required methods... ``` -------------------------------- ### Handle SDPFailedError Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/errors.md Example of how to catch and handle an SDPFailedError during EVCC charging station discovery. This suggests user action or waiting if discovery fails. ```python from iso15118.shared.exceptions import SDPFailedError try: await evcc.start_charging() except SDPFailedError: print("Could not discover charging station after retries") # User should move closer to charging station or wait ``` -------------------------------- ### Configure CPO Backend Integration Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Enable or disable the integration with a Charge Point Operator (CPO) backend. This is required for contract certificate installation. ```shell USE_CPO_BACKEND=False ``` -------------------------------- ### Get DC Pre-Charge Response Parameters (ISO 15118-20) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Provides DC pre-charge response parameters for ISO 15118-20, indicating the pre-charge status. ```python async def get_dc_pre_charge_res_params(self) -> DCPreChargeRes ``` -------------------------------- ### Create Certificates Script Help Source: https://github.com/ecog-io/iso15118/blob/master/README.md Displays the help message for the certificate creation script, located in iso15118/shared/pki/. ```bash $ cd iso15118/shared/pki/ $ ./create_certs.sh -h ``` -------------------------------- ### Get PKI Path from Shared Settings Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Retrieves the configured PKI path from the shared settings. Ensure the path points to a valid directory with necessary certificates. ```python from iso15118.shared.settings import shared_settings, SettingKey pki_path = shared_settings.get(SettingKey.PKI_PATH) print(f"PKI location: {pki_path}") ``` -------------------------------- ### SECC Server Startup (TCP and UDP) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/transport-layer.md Initializes and starts both a TCP server (with or without TLS) and a UDP server for SDP responses. This is essential for an SECC to listen for incoming EVCC connections and respond to discovery requests. ```python import asyncio from iso15118.secc.transport.tcp_server import TCPServer from iso15118.secc.transport.udp_server import UDPServer async def start_secc_servers(iface: str, use_tls: bool): session_queue = asyncio.Queue() # Start TCP server tcp_server = TCPServer(session_queue, iface=iface) tcp_ready = asyncio.Event() if use_tls: tcp_task = asyncio.create_task(tcp_server.start_tls(tcp_ready)) else: tcp_task = asyncio.create_task(tcp_server.start_no_tls(tcp_ready)) await tcp_ready.wait() print(f"SECC TCP{'S' if use_tls else ''} server ready on " f"{tcp_server.ipv6_address_host}:{tcp_server.port}") # Start UDP server for SDP udp_server = UDPServer() udp_ready = asyncio.Event() udp_task = asyncio.create_task(udp_server.start(udp_ready, iface=iface)) await udp_ready.wait() print(f"SECC SDP server ready") return tcp_task, udp_task, session_queue ``` -------------------------------- ### Monitor Message Exchange with EXI Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Use the EXI codec to get a JSON string representation of a message for monitoring and analysis. Ensure the 'message' variable is defined. ```python from iso15118.shared.exi_codec import EXI # Get JSON representation of message json_str = EXI.get_json_string(message) print(json_str) ``` -------------------------------- ### Get Random Available TCP Port Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/shared-utilities.md Gets a random available TCP port within the ephemeral range (49152-65535). ```python from iso15118.shared.network import get_tcp_port port = get_tcp_port() print(f"Using port: {port}") ``` -------------------------------- ### Get DC Pre-Charge Request Parameters (ISO 15118-20) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Provides DC pre-charge request parameters for ISO 15118-20. This method is used to configure pre-charging settings for DC charging. ```python async def get_dc_pre_charge_req_params(self) -> DCPreChargeReq ``` -------------------------------- ### Get DC Charge Parameters V2 for ISO 15118-2 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Provides DC charging parameters for ISO 15118-2. Retrieves DC charging capabilities such as current and voltage limits. ```python async def get_dc_charge_params_v2(self) -> DCEVSEChargeParameter ``` -------------------------------- ### Load and Print Supported Authentication Modes Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Loads environment variables and iterates through the configured supported authentication options, printing each one. ```python from iso15118.shared.messages.enums import AuthEnum config = Config() config.load_envs() for auth in config.supported_auth_options: print(f"Supporting: {auth.value}") ``` -------------------------------- ### Get Charge Progress V20 (ISO 15118-20) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves charging progress information for ISO 15118-20. This method is essential for tracking the progress of charging sessions under the latest standard. ```python async def get_charge_progress_v20(self) -> ChargeProgressV20 ``` -------------------------------- ### Get AC Charge Parameters V2 for ISO 15118-2 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Provides AC charging parameters for ISO 15118-2. Retrieves AC charging capabilities like nominal voltage. ```python async def get_ac_charge_params_v2(self) -> ACEVSEChargeParameter ``` ```python ac_params = await controller.get_ac_charge_params_v2() print(f"Rated voltage: {ac_params.evse_nominal_voltage.get_decimal_value()}V") ``` -------------------------------- ### Initialize EVCC Configuration Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Instantiate the EVCC configuration class and load environment variables from a specified path. ```python from iso15118.evcc.evcc_settings import Config config = Config() config.load_envs(env_path="/path/to/.env") ``` -------------------------------- ### Get DC Cable Check Request Parameters (ISO 15118-20) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Provides DC cable check request parameters for ISO 15118-20. Use this to initiate a cable check before DC charging. ```python async def get_dc_cable_check_req_params(self) -> DCCableCheckReq ``` -------------------------------- ### Run Session State Machine Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/communication-session.md Executes the state machine loop, processing messages and transitioning states until a terminal state is reached. Use this to start the main session processing. ```python # Run the session state machine terminal_state = await state_machine.run() if isinstance(terminal_state, Terminate): print("Session terminated successfully") print(f"Reason: {terminal_state.stop_reason}") elif isinstance(terminal_state, Pause): print("Session paused, awaiting resumption") ``` -------------------------------- ### Load and Print Supported Protocols Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Loads environment variables and iterates through the configured supported protocols, printing each one. ```python from iso15118.shared.messages.enums import Protocol config = Config() config.load_envs() # config.supported_protocols is List[Protocol] for protocol in config.supported_protocols: print(f"Supporting: {protocol.value}") ``` -------------------------------- ### get_tcp_port Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/shared-utilities.md Gets a random available TCP port within the ephemeral port range (49152-65535). ```APIDOC ## get_tcp_port ### Description Gets a random available TCP port in ephemeral range (49152-65535). ### Method `get_tcp_port() -> int` ### Returns - int - Available port number ### Example ```python from iso15118.shared.network import get_tcp_port port = get_tcp_port() print(f"Using port: {port}") ``` ``` -------------------------------- ### get_current_time Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/shared-utilities.md Retrieves the current Unix timestamp in seconds. Used in session setup and for metering data. ```APIDOC ## get_current_time ### Description Gets current Unix timestamp in seconds. ### Method def ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Returns int - Current timestamp ### Example: ```python from iso15118.shared.utils import get_current_time timestamp = get_current_time() print(f"Current time: {timestamp}") ``` ``` -------------------------------- ### Create Environment File Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Copies the development local environment file to be used by the application. This file typically contains configuration settings. ```bash cp .env.dev.local .env ``` -------------------------------- ### Load and Print EVCC Configuration File Path Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Loads environment variables and prints the configured path for the EVCC configuration file. ```python config = Config() config.load_envs() print(f"EV config: {config.ev_config_file_path}") ``` -------------------------------- ### Handle InvalidMessageError Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/errors.md Example of catching InvalidMessageError during message decoding. Handle by requesting retransmission or terminating the session. ```python from iso15118.shared.exceptions import InvalidMessageError try: decoded_message = EXI.decode_iso15118_2_message(exi_bytes) except InvalidMessageError as e: print(f"Invalid message: {e}") # Request retransmission or terminate session ``` -------------------------------- ### Initialize SECC Configuration Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Initializes the SECC configuration object and loads environment variables from a specified .env file. ```python from iso15118.secc.secc_settings import Config config = Config() config.load_envs(env_path="/path/to/.env") ``` -------------------------------- ### Get EVCC Identifier for ISO 15118-20 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves the EVCC identifier, which is a VIN-like string for ISO 15118-20 protocol. ```python # For ISO 15118-20: returns VIN-like identifier evcc_id = await controller.get_evcc_id(Protocol.ISO_15118_20_AC, "eth0") # Returns: "EVID20123456789" (15 characters) ``` -------------------------------- ### Get Link-Local IPv6 Address String Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/shared-utilities.md Retrieves just the IPv6 link-local address as a string for a specified network interface. ```python from iso15118.shared.network import get_link_local_addr ipv6 = get_link_local_addr("eth0") print(f"IPv6 address: {ipv6}") ``` -------------------------------- ### Handle NoLinkLocalAddressError Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/errors.md Example of catching NoLinkLocalAddressError during TCP/TLS client connection. Configure IPv6 on the interface if this error occurs. ```python from iso15118.shared.exceptions import NoLinkLocalAddressError try: # Connect to charging station await tcp_client.connect() except NoLinkLocalAddressError: print("IPv6 link-local address not found on interface") # Configure IPv6 on the interface ``` -------------------------------- ### Configuration Validation with Exception Handling Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Demonstrates how to catch `InvalidSettingsValueError` during configuration loading for SECC settings, providing details about the error. ```python from iso15118.shared.exceptions import InvalidSettingsValueError from iso15118.secc.secc_settings import Config try: config = Config() config.load_envs() except InvalidSettingsValueError as e: print(f"Configuration error in {e.entity}") print(f" Setting: {e.setting}") print(f" Invalid value: {e.invalid_value}") ``` -------------------------------- ### Get Authorization Token Type Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves the type of authorization token being used by the EV. This method is applicable to all charging protocols. ```python async def get_authorization_token_type(self) -> Optional[AuthorizationTokenType] ``` -------------------------------- ### Get Energy Transfer Mode for DC Charging Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves the energy transfer mode, specifically for DC extended charging. ```python mode = await controller.get_energy_transfer_mode(Protocol.ISO_15118_2) elif mode == EnergyTransferModeEnum.DC_EXTENDED: print("DC extended charging") ``` -------------------------------- ### Development Environment File Template (.env.dev.local) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Template for a local development environment file, specifying network interface, log level, and SECC/EVCC specific settings. ```bash NETWORK_INTERFACE=eth0 LOG_LEVEL=DEBUG MESSAGE_LOG_JSON=True MESSAGE_LOG_EXI=False ENABLE_TLS_1_3=False PKI_PATH=./iso15118/shared/pki/ # SECC settings SECC_ENFORCE_TLS=False PROTOCOLS=ISO_15118_2,ISO_15118_20_AC AUTH_MODES=EIM,PNC FREE_CHARGING_SERVICE=False USE_CPO_BACKEND=False # EVCC settings EVCC_CONFIG_PATH=iso15118/shared/examples/evcc/iso15118_2/evcc_config_eim_ac.json ``` -------------------------------- ### Get Energy Transfer Mode for AC Charging Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves the energy transfer mode, specifically for AC three-phase charging. ```python mode = await controller.get_energy_transfer_mode(Protocol.ISO_15118_2) if mode == EnergyTransferModeEnum.AC_THREE_PHASE_CORE: print("AC 3-phase charging") ``` -------------------------------- ### Get EVSE Identifier Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Retrieves the protocol-specific EVSE identifier. This method must be implemented by subclasses and is applicable to all supported protocols. ```python evse_id = await controller.get_evse_id(Protocol.ISO_15118_2) # Returns: "DE*abc*1234*1" ``` -------------------------------- ### Handle InvalidV2GTPMessageError Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/errors.md Example of catching InvalidV2GTPMessageError during V2GTP message parsing. Handle by dropping the message and waiting for the next one. ```python from iso15118.shared.exceptions import InvalidV2GTPMessageError from iso15118.shared.messages.v2gtp import V2GTPMessage try: message = V2GTPMessage.from_bytes(raw_bytes) except InvalidV2GTPMessageError: print("Received malformed V2GTP message") # Drop message and wait for next ``` -------------------------------- ### Get Selected Authentication Option Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves the selected authentication option, which can be either EIM or PnC. This method is applicable across all protocols. ```python async def get_selected_auth_option(self) -> AuthEnum ``` -------------------------------- ### Define NoSupportedEnergyServices Exception Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/errors.md This exception is raised when no energy services are configured in the SECC settings during initialization for ISO 15118-20. ```python class NoSupportedEnergyServices(Exception): pass ``` -------------------------------- ### Get EVCC Identifier for ISO 15118-2 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves the EVCC identifier, which is the MAC address in hex format for ISO 15118-2 protocol. ```python # For ISO 15118-2: returns MAC address evcc_id = await controller.get_evcc_id(Protocol.ISO_15118_2, "eth0") # Returns: "001F29B0A1CD" (12 hex characters) ``` -------------------------------- ### Get EVSE Status V2 for ISO 15118-2 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Provides EVSE status for ISO 15118-2. Returns the current status of the EVSE. ```python async def get_evse_status_v2(self) -> Union[ACEVSEStatus, DCEVSEStatus] ``` -------------------------------- ### Set Supported Authentication Modes Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Configure the authentication modes supported by the SECC. Common modes include EIM and PNC. ```shell AUTH_MODES=EIM,PNC ``` -------------------------------- ### Get Energy Service List for ISO 15118-20 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Provides the list of available energy services offered by the EVSE for ISO 15118-20. ```python async def get_energy_service_list(self) -> ServiceList ``` ```python services = await controller.get_energy_service_list() # ServiceList contains AC, DC, and VAS services with pricing ``` -------------------------------- ### ServiceStatus Enum Definition Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Defines the possible status values for the EVSE service, including READY, STARTING, STOPPING, ERROR, and BUSY. ```python class ServiceStatus(str, Enum): READY = "ready" STARTING = "starting" STOPPING = "stopping" ERROR = "error" BUSY = "busy" ``` -------------------------------- ### Service Selection Request and Response Structure Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Defines the structure for selecting energy and value-added services. Includes message headers and selected service identifiers. ```protobuf ServiceSelectionReq ├── Header (MessageHeader) ├── SelectedEnergyService (SelectedEnergyService) │ ├── ServiceID (int) │ └── ParameterSetID (int, optional) └── SelectedVAS (SelectedVAS list, optional) ServiceSelectionRes ├── Header (MessageHeader) ├── ResponseCode (enum) └── EVSEStatus (EVSEStatus) ``` -------------------------------- ### Docker Development Environment File Template (.env.dev.docker) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Template for a Docker development environment file, specifying network interface, log level, and SECC/EVCC specific settings for containerized deployment. ```bash NETWORK_INTERFACE=eth0 LOG_LEVEL=INFO MESSAGE_LOG_JSON=False MESSAGE_LOG_EXI=False ENABLE_TLS_1_3=False PKI_PATH=/pki/ # SECC settings SECC_ENFORCE_TLS=False PROTOCOLS=DIN_SPEC_70121,ISO_15118_2,ISO_15118_20_AC,ISO_15118_20_DC AUTH_MODES=EIM,PNC FREE_CHARGING_SERVICE=False USE_CPO_BACKEND=False ``` -------------------------------- ### Handle MessageProcessingError Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/errors.md Example of catching MessageProcessingError when processing an incoming message. Handle by sending an error response or transitioning to an error state. ```python from iso15118.shared.exceptions import MessageProcessingError try: response = await state.process_message(incoming_message) except MessageProcessingError as e: print(f"Cannot process message: {e.message_name}") # Send error response or transition to error state ``` -------------------------------- ### Load SECC Settings Programmatically Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Loads SECC specific configuration settings from environment variables and provides access to them via the Config object. ```python from iso15118.secc.secc_settings import Config config = Config() config.load_envs() # Loads from .env in current directory # Access properties print(config.iface) print(config.log_level) print(config.enforce_tls) print(config.supported_protocols) print(config.supported_auth_options) ``` -------------------------------- ### Service Detail Request and Response Structure Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Defines the structure for requesting and receiving detailed service information. Includes message headers and service-specific parameters. ```protobuf ServiceDetailReq ├── Header (MessageHeader) └── ServiceID (int) ServiceDetailRes ├── Header (MessageHeader) ├── ResponseCode (enum) ├── ServiceID (int) ├── ServiceParameterList (ServiceParameterList) │ └── ParameterSet (list) │ └── Parameter (list) │ ├── Name (string) │ └── Value (string) └── EVSEStatus (EVSEStatus) ``` -------------------------------- ### Enable TLS 1.3 Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Enables TLS 1.3 for SECC-EVCC communication, offering improved performance and security. Requires Python 3.10+ for full support. ```bash ENABLE_TLS_1_3=False ``` -------------------------------- ### get_supported_auth_options Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/evcc-controller-interface.md Retrieves the list of supported authentication options. ```APIDOC ## get_supported_auth_options ### Description Retrieves the list of supported authentication options. ### Method GET ### Endpoint /evcc/supported_auth_options ### Returns List[AuthEnum] - Supported authentication modes ### Applicable Protocols All ``` -------------------------------- ### Get EV Data Context Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Retrieves the EV data context, which contains session information such as EV ID, charging profile, and preferences. ```python def get_ev_data_context(self) -> EVDataContext ``` -------------------------------- ### Set PKI Path Environment Variable Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Specifies the location of the PKI directory containing certificates and keys. This setting is optional and defaults to a local directory if not provided. ```bash PKI_PATH= ``` -------------------------------- ### Get DC Charge Loop Response Parameters (ISO 15118-20) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Provides DC charge loop response parameters for ISO 15118-20. ```python async def get_dc_charge_loop_res_params( self, control_mode: ControlMode, ) -> Union[ScheduledDCChargeLoopResParams, DynamicDCChargeLoopResParams] ``` -------------------------------- ### Get EVSE Status (ISO 15118-20) Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/api-reference/secc-controller-interface.md Provides the current EVSE status for ISO 15118-20 communication. This method must be implemented by subclasses. ```python async def get_evse_status_v20(self) -> EVSEStatus ``` -------------------------------- ### Get TLS 1.3 Setting in Python Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Retrieves the setting for enabling TLS 1.3 from shared settings. TLS 1.2 is the default if this is not enabled. ```python from iso15118.shared.settings import shared_settings, SettingKey enable_tls13 = shared_settings.get(SettingKey.ENABLE_TLS_1_3) if enable_tls13: # Use TLS 1.3 context ``` -------------------------------- ### Check and Enable IPv6 Link-Local Address Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/README.md Verify the IPv6 configuration for a network interface and enable it if necessary. This is crucial for network communication in certain environments. ```bash # Check IPv6 configuration ip addr show eth0 # Enable IPv6 if needed sudo sysctl -w net.ipv6.conf.eth0.disable_ipv6=0 ``` -------------------------------- ### Power Delivery Request and Response Structure Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Defines the structure for initiating and confirming power delivery, including charge progress and optional power profiles. ```protobuf PowerDeliveryReq ├── Header (MessageHeader) ├── ChargeProgress (enum) │ ├── Start │ └── Stop ├── EVPowerProfile (EVPowerProfile, optional) │ └── TimeInterval (list) │ ├── Start (int) │ └── Duration (int) └── EVAbsolutePriceSchedule (optional) PowerDeliveryRes ├── Header (MessageHeader) ├── ResponseCode (enum) └── EVSEStatus (EVSEStatus) ``` -------------------------------- ### Set Supported Protocols Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Define the communication protocols supported by the SECC. The order matters as it indicates priority during negotiation. ```shell PROTOCOLS=DIN_SPEC_70121,ISO_15118_2,ISO_15118_20_AC,ISO_15118_20_DC ``` -------------------------------- ### Authorization Request and Response Structure Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Defines the structure for initiating and responding to authorization requests, supporting EIM and PnC modes with optional token information. ```protobuf AuthorizationReq ├── Header (MessageHeader) ├── AuthorizationMode (enum) │ ├── EIM │ └── PnC ├── EMAIDList (list, optional) └── IdToken (IdToken, optional) ├── TokenType (enum) └── Token (bytes) AuthorizationRes ├── Header (MessageHeader) ├── ResponseCode (enum) ├── AuthorizationStatus (enum) │ ├── Accepted │ ├── Rejected │ └── Ongoing └── EVSEStatus (EVSEStatus) ``` -------------------------------- ### DC Charge Parameter Discovery Request and Response Structure Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/message-reference.md Defines the request and response structures for DC charge parameter discovery, including EV and EVSE maximum/minimum current, voltage, and power. ```protobuf DCChargeParameterDiscoveryReq ├── Header (MessageHeader) ├── DCEVChargeParameter (DCEVChargeParameter) │ ├── EVMaxChargeCurrent (RationalNumber) │ ├── EVMaxChargeVoltage (RationalNumber) │ ├── EVEnergyCapacity (RationalNumber, optional) │ ├── EVEnergyRequest (RationalNumber, optional) │ ├── EVStateOfCharge (int, optional) │ ├── EVMinChargeCurrent (RationalNumber, optional) │ ├── EVMinChargeVoltage (RationalNumber, optional) │ └── EVOperatingSchedule (list, optional) └── RequestedEnergyTransferMode (enum) DCChargeParameterDiscoveryRes ├── Header (MessageHeader) ├── ResponseCode (enum) ├── DCChargeParameterDiscoveryResParams │ ├── EVSEMaxChargeCurrent (RationalNumber) │ ├── EVSEMaxChargeVoltage (RationalNumber) │ ├── EVSEMaxChargePower (RationalNumber) │ ├── EVSEMinChargeCurrent (RationalNumber, optional) │ ├── EVSEMinChargeVoltage (RationalNumber, optional) │ └── EVSEPeakCurrentRipple (RationalNumber, optional) └── EVSEStatus (EVSEStatus) ``` -------------------------------- ### Enable Raw EXI Byte Logging Source: https://github.com/ecog-io/iso15118/blob/master/_autodocs/configuration.md Enables logging of raw EXI byte streams for debugging. This setting has a significant performance impact and is only effective when the log level is DEBUG. ```bash MESSAGE_LOG_EXI=False ```