Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ libevse-security:
# OCPP
libocpp:
git: https://github.com/EVerest/libocpp.git
git_tag: 2c727f86e9ff988bdf13fcf5b049f0d5c3650384
git_tag: v0.31.0
cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP"
# Josev
Josev:
Expand Down
15 changes: 15 additions & 0 deletions modules/EVSE/OCPP/OCPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,18 @@

this->process_session_event(evse_id, session_event);
});

evse->subscribe_powermeter_public_key_ocmf([this, evse_id](std::string public_key_ocmf) {
if (!this->started) {
this->event_queue.emplace(evse_id, PowermeterPublicKey{public_key_ocmf});
return;
}

if (!this->charge_point->set_powermeter_public_key(evse_id, public_key_ocmf)) {
EVLOG_error << "Failed to set powermeter public key for evse_id: " << evse_id;
}
});

evse_id++;
}

Expand Down Expand Up @@ -1077,6 +1089,9 @@
[&](const types::system::FirmwareUpdateStatus& fw) {
charge_point->on_firmware_update_status_notification(
fw.request_id, conversions::to_ocpp_firmware_status_notification(fw.firmware_update_status));
},
[&](const PowermeterPublicKey public_key) {

Check warning on line 1093 in modules/EVSE/OCPP/OCPP.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EVSE/OCPP/OCPP.cpp#L1093

Function parameter 'public_key' should be passed by const reference.
this->charge_point->set_powermeter_public_key(queued_event.evse_id, public_key.value);
}},
queued_event.data);
}
Expand Down
9 changes: 6 additions & 3 deletions modules/EVSE/OCPP/OCPP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@

struct ErrorRaised : public Everest::error::Error {};
struct ErrorCleared : public Everest::error::Error {};
struct PowermeterPublicKey {
std::string value;

Check warning on line 52 in modules/EVSE/OCPP/OCPP.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EVSE/OCPP/OCPP.hpp#L52

struct member 'PowermeterPublicKey::value' is never used.
};

using EventData = std::variant<types::evse_manager::SessionEvent, ErrorRaised, ErrorCleared, types::system::LogStatus,
types::system::FirmwareUpdateStatus>;
types::system::FirmwareUpdateStatus, PowermeterPublicKey>;

struct Event {
EventData data;
int32_t evse_id;
EventData data;

explicit Event(int32_t evse_id_, EventData data_) : evse_id(evse_id_), data(std::move(data_)) {
Event(int32_t evse_id_, EventData data_) : evse_id(evse_id_), data(std::move(data_)) {
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void powermeterImpl::init() {
}

void powermeterImpl::ready() {
this->publish_public_key_ocmf("TESTPUBLICKEY" + std::to_string(this->mod->config.connector_id));
}

types::powermeter::TransactionStartResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ active_modules:
yeti_driver_2:
module: YetiSimulator
config_module:
connector_id: 1
connector_id: 2
car_simulator_1:
module: EvManager
config_module:
Expand Down
127 changes: 127 additions & 0 deletions tests/ocpp_tests/test_sets/ocpp16/eichrecht.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import pytest

from everest.testing.core_utils.controller.test_controller_interface import (

Check warning on line 3 in tests/ocpp_tests/test_sets/ocpp16/eichrecht.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/ocpp_tests/test_sets/ocpp16/eichrecht.py#L3

'everest.testing.core_utils.controller.test_controller_interface.TestController' imported but unused (F401)

Check warning on line 3 in tests/ocpp_tests/test_sets/ocpp16/eichrecht.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/ocpp_tests/test_sets/ocpp16/eichrecht.py#L3

Unused TestController imported from everest.testing.core_utils.controller.test_controller_interface
TestController,
)
from everest.testing.ocpp_utils.charge_point_utils import (
wait_for_and_validate,
TestUtility,
)
from everest.testing.ocpp_utils.central_system import ChargePoint16
from everest.testing.ocpp_utils.fixtures import test_utility, charge_point_v16

Check warning on line 11 in tests/ocpp_tests/test_sets/ocpp16/eichrecht.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/ocpp_tests/test_sets/ocpp16/eichrecht.py#L11

'everest.testing.ocpp_utils.fixtures.test_utility' imported but unused (F401)

Check warning on line 11 in tests/ocpp_tests/test_sets/ocpp16/eichrecht.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/ocpp_tests/test_sets/ocpp16/eichrecht.py#L11

Unused test_utility imported from everest.testing.ocpp_utils.fixtures
from everest_test_utils import get_everest_config_path_str

from ocpp.v16 import call_result


@pytest.mark.asyncio
@pytest.mark.everest_core_config(
get_everest_config_path_str("everest-config-two-connectors.yaml")
)
async def test_meter_public_key(
charge_point_v16: ChargePoint16, test_utility: TestUtility

Check warning on line 22 in tests/ocpp_tests/test_sets/ocpp16/eichrecht.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/ocpp_tests/test_sets/ocpp16/eichrecht.py#L22

redefinition of unused 'test_utility' from line 11 (F811)
):
await charge_point_v16.get_configuration_req(key=["MeterPublicKey[1]"])
assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
call_result.GetConfiguration(
[{"key": "MeterPublicKey[1]", "readonly": True, "value": "TESTPUBLICKEY1"}]
),
)

await charge_point_v16.get_configuration_req(key=["MeterPublicKey[2]"])
assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
call_result.GetConfiguration(
[{"key": "MeterPublicKey[2]", "readonly": True, "value": "TESTPUBLICKEY2"}]
),
)

await charge_point_v16.get_configuration_req(key=["MeterPublicKey[3]"])

assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
{"unknownKey": ["MeterPublicKey[3]"]}
)

test_utility.messages.clear()

response : call_result.GetConfiguration = await charge_point_v16.get_configuration_req()

assert any(
entry['key'] == "MeterPublicKey[1]" and entry['value'] == "TESTPUBLICKEY1"
for entry in response.configuration_key)

assert any(
entry['key'] == "MeterPublicKey[2]" and entry['value'] == "TESTPUBLICKEY2"
for entry in response.configuration_key)

Check notice on line 64 in tests/ocpp_tests/test_sets/ocpp16/eichrecht.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/ocpp_tests/test_sets/ocpp16/eichrecht.py#L64

Trailing whitespace
await charge_point_v16.get_configuration_req(key=["MeterPublicKey[]"])

assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
{"unknownKey": ["MeterPublicKey[]"]}
)

await charge_point_v16.get_configuration_req(key=["MeterPublicKey[MeterPublicKey[1]]"])

assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
{"unknownKey": ["MeterPublicKey[MeterPublicKey[1]]"]}
)

await charge_point_v16.get_configuration_req(key=["MeterPublicKey[1X"])

assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
{"unknownKey": ["MeterPublicKey[1X"]}
)

await charge_point_v16.get_configuration_req(key=["MeterPublicKey[1X]"])

assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
{"unknownKey": ["MeterPublicKey[1X]"]}
)

await charge_point_v16.get_configuration_req(key=["MeterPublicKey[banana]"])

assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
{"unknownKey": ["MeterPublicKey[banana]"]}
)

await charge_point_v16.get_configuration_req(key=["MeterPublicKey[0]"])

assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"GetConfiguration",
{"unknownKey": ["MeterPublicKey[0]"]}
)

await charge_point_v16.change_configuration_req(
key="MeterPublicKey[1]", value="TEST"
)
assert await wait_for_and_validate(
test_utility,
charge_point_v16,
"ChangeConfiguration",
{"status": "Rejected"}
)
Loading