diff --git a/hardware/firmware/src/config.h b/hardware/firmware/src/config.h index b9a2d4b..40efec8 100644 --- a/hardware/firmware/src/config.h +++ b/hardware/firmware/src/config.h @@ -9,5 +9,7 @@ #define CFG_CP_FW_VERSION "1.0.0" #define CFG_CP_MODAL "Helios DA One" #define CFG_CP_VENDOR "RayineElec" -// #define CFG_AUTHORIZATIONKEY "my_secret_key" -#define CFG_AUTHORIZATIONKEY nullptr +// OCPP Security Profile 1: Basic Auth password (username = chargePointIdentifier) +// Set to nullptr to disable authentication +// #define CFG_OCPP_PASSWORD "my_password" +#define CFG_OCPP_PASSWORD nullptr diff --git a/hardware/firmware/src/main.cpp b/hardware/firmware/src/main.cpp index c3cfcd9..2e735d4 100644 --- a/hardware/firmware/src/main.cpp +++ b/hardware/firmware/src/main.cpp @@ -37,7 +37,7 @@ char cpSerial[13]; // OCPP Configuration Variables char ocpp_backend[128]; char cp_identifier[64]; -char auth_key[64]; +char ocpp_password[64]; bool shouldSaveConfig = false; // callback notifying us of the need to save config @@ -169,13 +169,13 @@ void setup() Preferences preferences; preferences.begin("ocpp-config", false); String b = preferences.getString("backend", CFG_OCPP_BACKEND); - String a = preferences.getString("auth_key", CFG_AUTHORIZATIONKEY ? CFG_AUTHORIZATIONKEY : ""); + String p = preferences.getString("ocpp_password", CFG_OCPP_PASSWORD ? CFG_OCPP_PASSWORD : ""); Serial.printf("\n[OCPP] Loaded Backend URL: %s\n", b.c_str()); - Serial.printf("[OCPP] Loaded Auth Key length: %d\n", a.length()); + Serial.printf("[OCPP] Loaded Password length: %d\n", p.length()); strncpy(ocpp_backend, b.c_str(), sizeof(ocpp_backend)); - strncpy(auth_key, a.c_str(), sizeof(auth_key)); + strncpy(ocpp_password, p.c_str(), sizeof(ocpp_password)); WiFiManager wm; wm.setSaveConfigCallback(saveConfigCallback); @@ -184,10 +184,10 @@ void setup() // Use autocomplete=off to prevent browsers from autofilling old URLs after a reset WiFiManagerParameter custom_ocpp_backend("backend", "OCPP Backend URL", ocpp_backend, 128, "autocomplete=\"off\""); - WiFiManagerParameter custom_auth_key("auth_key", "Auth Key (leave blank if none)", auth_key, 64, "autocomplete=\"off\""); + WiFiManagerParameter custom_ocpp_password("ocpp_password", "OCPP 连接密码 (Basic Auth, 没有请留空)", ocpp_password, 64, "autocomplete=\"off\" type=\"password\""); wm.addParameter(&custom_ocpp_backend); - wm.addParameter(&custom_auth_key); + wm.addParameter(&custom_ocpp_password); const char *customHeadElement = R"rawliteral(