From e884fc5bc0764ae2f5222ef138e7b7c34b3a527c Mon Sep 17 00:00:00 2001 From: Timothy Yin Date: Mon, 16 Mar 2026 17:17:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(firmware):=20=E6=9B=B4=E6=96=B0=20OCPP=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BB=A5=E6=94=AF=E6=8C=81=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hardware/firmware/src/config.h | 6 ++++-- hardware/firmware/src/main.cpp | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) 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(