mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-28 09:28:51 +00:00
Zmartcharge support (#1007)
* ZC initial implementation * ZmartCharge * Fixed zc bug * Adjustments to ZmartCharge connection
This commit is contained in:
@@ -26,6 +26,9 @@ ADC_MODE(ADC_VCC);
|
||||
#if defined(AMS_CLOUD)
|
||||
#include "CloudConnector.h"
|
||||
#endif
|
||||
#if defined(ZMART_CHARGE)
|
||||
#include "ZmartChargeCloudConnector.h"
|
||||
#endif
|
||||
|
||||
#define WDT_TIMEOUT 120
|
||||
#if defined(SLOW_PROC_TRIGGER_MS)
|
||||
@@ -182,6 +185,11 @@ AmsFirmwareUpdater updater(&Debug, &hw, &meterState);
|
||||
AmsDataStorage ds(&Debug);
|
||||
#if defined(_CLOUDCONNECTOR_H)
|
||||
CloudConnector *cloud = NULL;
|
||||
#endif
|
||||
#if defined(ZMART_CHARGE)
|
||||
ZmartChargeCloudConnector *zcloud = NULL;
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
__NOINIT_ATTR EnergyAccountingRealtimeData rtd;
|
||||
#else
|
||||
EnergyAccountingRealtimeData rtd;
|
||||
@@ -694,6 +702,36 @@ void loop() {
|
||||
cloud->update(meterState, ea);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ZMART_CHARGE)
|
||||
if(config.isZmartChargeConfigChanged()) {
|
||||
ZmartChargeConfig zcc;
|
||||
if(config.getZmartChargeConfig(zcc) && zcc.enabled) {
|
||||
if(zcloud == NULL) {
|
||||
zcloud = new ZmartChargeCloudConnector(&Debug, (char*) commonBuffer);
|
||||
}
|
||||
zcloud->setup(zcc.baseUrl, zcc.token);
|
||||
} else if(zcloud != NULL) {
|
||||
delete zcloud;
|
||||
zcloud = NULL;
|
||||
}
|
||||
config.ackZmartChargeConfig();
|
||||
}
|
||||
if(zcloud != NULL) {
|
||||
zcloud->update(meterState);
|
||||
if(zcloud->isConfigChanged()) {
|
||||
ZmartChargeConfig zcc;
|
||||
if(config.getZmartChargeConfig(zcc)) {
|
||||
const char* newBaseUrl = zcloud->getBaseUrl();
|
||||
memset(zcc.baseUrl, 0, 64);
|
||||
memcpy(zcc.baseUrl, newBaseUrl, strlen(newBaseUrl));
|
||||
config.setZmartChargeConfig(zcc);
|
||||
config.ackZmartChargeConfig();
|
||||
}
|
||||
zcloud->ackConfigChanged();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
start = millis();
|
||||
handleUiLanguage();
|
||||
end = millis();
|
||||
|
||||
Reference in New Issue
Block a user