Skip to content

Commit 015504d

Browse files
committed
Retrieve the serial numbers of the WiFi module and EVSE module
Fixes Station Serial Number #218
1 parent 4d39a60 commit 015504d

File tree

11 files changed

+40
-13
lines changed

11 files changed

+40
-13
lines changed

gui

platformio.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ lib_deps =
3636
jeremypoulter/[email protected]
3737
jeremypoulter/Micro [email protected]
3838
jeremypoulter/[email protected]
39-
jeremypoulter/[email protected].7
39+
jeremypoulter/[email protected].9
4040
jeremypoulter/[email protected]
4141
jeremypoulter/[email protected]
4242
jeremypoulter/[email protected]
@@ -283,6 +283,7 @@ board_build.partitions = ${common.build_partitions}
283283
#https://github.com/OpenEVSE/ESP32_WiFi_V3.x/blob/master/docs/wired-ethernet.md
284284
extends = env:openevse_esp32-gateway
285285
framework = arduino, espidf
286+
upload_speed = 921600
286287
build_flags =
287288
${common.build_flags}
288289
-D RX2=16

src/emonesp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160

161161
extern String currentfirmware;
162162
extern String buildenv;
163+
extern String serial;
163164

164165
void restart_system();
165166

src/evse_man.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ class EvseManager : public MicroTasks::Task
379379
const char *getFirmwareVersion() {
380380
return _monitor.getFirmwareVersion();
381381
}
382+
const char *getSerial() {
383+
return _monitor.getSerial();
384+
}
382385
long getMinCurrent() {
383386
return _monitor.getMinCurrent();
384387
}

src/evse_monitor.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@
6262
#define EVSE_MONITOR_FLAGS_BOOT_READY (1 << 1)
6363
#define EVSE_MONITOR_CURRENT_BOOT_READY (1 << 2)
6464
#define EVSE_MONITOR_ENERGY_BOOT_READY (1 << 3)
65+
#define EVSE_MONITOR_SERIAL_BOOT_READY (1 << 5)
6566

6667
#define EVSE_MONITOR_BOOT_READY ( \
6768
EVSE_MONITOR_FAULT_COUNT_BOOT_READY | \
6869
EVSE_MONITOR_FLAGS_BOOT_READY | \
6970
EVSE_MONITOR_CURRENT_BOOT_READY | \
70-
EVSE_MONITOR_ENERGY_BOOT_READY \
71+
EVSE_MONITOR_ENERGY_BOOT_READY | \
72+
EVSE_MONITOR_SERIAL_BOOT_READY \
7173
)
7274

7375
#define EVSE_MONITOR_SESSION_COMPLETE_MASK OPENEVSE_VFLAG_EV_CONNECTED
@@ -245,6 +247,16 @@ void EvseMonitor::evseBoot(const char *firmware)
245247
}
246248
});
247249

250+
_openevse.getSerial([this](int ret, const char *serial)
251+
{
252+
if(RAPI_RESPONSE_OK == ret)
253+
{
254+
DBUGF("serial = %s", serial);
255+
snprintf(_serial, sizeof(_serial), "%s", serial);
256+
_boot_ready.ready(EVSE_MONITOR_SERIAL_BOOT_READY);
257+
}
258+
});
259+
248260
_openevse.heartbeatEnable(EVSE_HEATBEAT_INTERVAL, EVSE_HEARTBEAT_CURRENT, [this](int ret, int interval, int current, int triggered) {
249261
_heartbeat = RAPI_RESPONSE_OK == ret;
250262
});

src/evse_monitor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class EvseMonitor : public MicroTasks::Task
146146
bool _heartbeat;
147147

148148
char _firmware_version[32];
149+
char _serial[16];
149150

150151
#ifdef ENABLE_MCP9808
151152
Adafruit_MCP9808 _mcp9808;
@@ -294,6 +295,9 @@ class EvseMonitor : public MicroTasks::Task
294295
const char *getFirmwareVersion() {
295296
return _firmware_version;
296297
}
298+
const char *getSerial() {
299+
return _serial;
300+
}
297301

298302
// Register for events
299303
void onStateChange(MicroTasks::EventListener *listner) {

src/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static uint32_t last_mem = 0;
7878
#define ESCAPEQUOTE(A) TEXTIFY(A)
7979
String currentfirmware = ESCAPEQUOTE(BUILD_TAG);
8080
String buildenv = ESCAPEQUOTE(BUILD_ENV_NAME);
81+
String serial;
8182

8283
ArduinoOcppTask ocpp = ArduinoOcppTask();
8384

@@ -98,6 +99,9 @@ void setup()
9899
DEBUG.printf("IDF version: %s\n", ESP.getSdkVersion());
99100
DEBUG.printf("Free: %d\n", ESPAL.getFreeHeap());
100101

102+
serial = ESPAL.getLongId();
103+
serial.toUpperCase();
104+
101105
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
102106
DEBUG.println("LittleFS Mount Failed");
103107
return;

src/web_server_config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ handleConfigGet(MongooseHttpServerRequest *request, MongooseHttpServerResponseSt
2929
doc["espinfo"] = ESPAL.getChipInfo();
3030
doc["buildenv"] = buildenv;
3131
doc["version"] = currentfirmware;
32+
doc["evse_serial"] = evse.getSerial();
33+
doc["wifi_serial"] = serial;
3234
doc["diodet"] = evse.isDiodeCheckDisabled() ? 1 : 0;
3335
doc["gfcit"] = evse.isGfiTestDisabled() ? 1 : 0;
3436
doc["groundt"] = evse.isGroundCheckDisabled() ? 1 : 0;

src/web_static/web_server.home.html.h

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/web_static/web_server.lib.js.h

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)