Skip to content

Commit 315a3e2

Browse files
committed
esp32.cpp: Add custom OCPP key to configure MaxCurrent of the controller
1 parent 210cd4a commit 315a3e2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

SmartEVSE-3/src/esp32.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,10 @@ void ocppInit() {
22132213

22142214
//load OCPP library modules: Mongoose WS adapter and Core OCPP library
22152215

2216+
// Declare custom "ConfigureMaxCurrent" key
2217+
// Parameters: key name, default value, filename for persistence (optional, use CONFIGURATION_FN for default), readonly, rebootRequired, restricted
2218+
MicroOcpp::declareConfiguration<int>("ConfigureMaxCurrent", 16, CONFIGURATION_FN, false, false, true);
2219+
22162220
auto filesystem = MicroOcpp::makeDefaultFilesystemAdapter(
22172221
MicroOcpp::FilesystemOpt::Use_Mount_FormatOnFail // Enable FS access, mount LittleFS here, format data partition if necessary
22182222
);
@@ -2428,6 +2432,18 @@ void ocppLoop() {
24282432

24292433
mocpp_loop();
24302434

2435+
// handle Configuration updates
2436+
2437+
auto config = MicroOcpp::getConfigurationPublic("ConfigureMaxCurrent");
2438+
if (config) {
2439+
uint16_t current = config->getInt();
2440+
// Check against max and min currents, only write settings when value changes
2441+
if ((current >= 6) && (current <= 80) && (MaxCurrent != current)) {
2442+
MaxCurrent = current;
2443+
write_settings();
2444+
}
2445+
}
2446+
24312447
//handle RFID input
24322448

24332449
if (OcppTrackLastRfidUpdate != OcppLastRfidUpdate) {

0 commit comments

Comments
 (0)