@ -13,11 +13,14 @@
app : : app ( ) {
DPRINTLN ( DBG_VERBOSE , F ( " app::app " ) ) ;
mDns = new DNSServer ( ) ;
mWeb = new ESP8266WebServer ( 80 ) ;
//mWeb = new ESP8266WebServer(80);
mUdp = new WiFiUDP ( ) ;
mEep = new eep ( ) ;
Serial . begin ( 115200 ) ;
mWebInst = new web ( this , & mSysConfig , & mConfig , mVersion ) ;
mWebInst - > setup ( ) ;
resetSystem ( ) ;
loadDefaultConfig ( ) ;
@ -41,31 +44,34 @@ void app::setup(uint32_t timeout) {
loadEEpconfig ( ) ;
# ifndef AP_ONLY
if ( false = = sysConfig . apActive )
sysConfig . apActive = setupStation ( mWifiStationTimeout ) ;
if ( false = = apActive )
apActive = setupStation ( mWifiStationTimeout ) ;
# endif
//mWeb->on("/setup", std::bind(&app::showSetup, this));
//mWeb->on("/save", std::bind(&app::showSave, this));
mWeb - > on ( " /cmdstat " , std : : bind ( & app : : showStatistics , this ) ) ;
/*mWeb->on("/cmdstat", std::bind(&app::showStatistics, this));
mWeb - > on ( " /hoymiles " , std : : bind ( & app : : showHoymiles , this ) ) ;
mWeb - > on ( " /livedata " , std : : bind ( & app : : showLiveData , this ) ) ;
mWeb - > on ( " /json " , std : : bind ( & app : : showJSON , this ) ) ;
mWeb - > on ( " /api " , HTTP_POST , std : : bind ( & app : : webapi , this ) ) ;
mWeb - > on ( " /api " , HTTP_POST , std : : bind ( & app : : webapi , this ) ) ; */
# ifndef AP_ONLY
setupMqtt ( ) ;
# endif
mSys - > setup ( & c onfig) ;
mSys - > setup ( & mC onfig) ;
if ( ! mWifiSettingsValid )
if ( ! mWifiSettingsValid ) {
DPRINTLN ( DBG_WARN , F ( " your settings are not valid! check [IP]/setup " ) ) ;
apActive = true ;
mApLastTick = millis ( ) ;
mNextTryTs = ( millis ( ) + ( WIFI_AP_ACTIVE_TIME * 1000 ) ) ;
setupAp ( WIFI_AP_SSID , WIFI_AP_PWD ) ;
}
else {
DPRINTLN ( DBG_INFO , F ( " \n \n ---------------------------------------- " ) ) ;
DPRINTLN ( DBG_INFO , F ( " Welcome to AHOY! " ) ) ;
DPRINT ( DBG_INFO , F ( " \n point your browser to http:// " ) ) ;
if ( sysConfig . apActive )
if ( apActive )
DBGPRINTLN ( F ( " 192.168.1.1 " ) ) ;
else
DBGPRINTLN ( WiFi . localIP ( ) ) ;
@ -78,12 +84,12 @@ void app::setup(uint32_t timeout) {
//-----------------------------------------------------------------------------
void app : : MainLoop ( void ) {
//DPRINTLN(DBG_VERBOSE, F("M"));
if ( sysConfig . apActive ) {
if ( apActive ) {
mDns - > processNextRequest ( ) ;
# ifndef AP_ONLY
if ( checkTicker ( & mNextTryTs , ( WIFI_AP_ACTIVE_TIME * 1000 ) ) ) {
sysConfig . apActive = setupStation ( mWifiStationTimeout ) ;
if ( sysConfig . apActive ) {
apActive = setupStation ( mWifiStationTimeout ) ;
if ( apActive ) {
if ( strlen ( WIFI_AP_PWD ) < 8 )
DPRINTLN ( DBG_ERROR , F ( " password must be at least 8 characters long " ) ) ;
mApLastTick = millis ( ) ;
@ -95,7 +101,7 @@ void app::MainLoop(void) {
if ( millis ( ) - mApLastTick > 10000 ) {
uint8_t cnt = WiFi . softAPgetStationNum ( ) ;
if ( cnt > 0 ) {
DPRINTLN ( DBG_INFO , String ( cnt ) + F ( " clients connected, resetting AP timeout " ) ) ;
DPRINTLN ( DBG_INFO , String ( cnt ) + F ( " client connected, resetting AP timeout " ) ) ;
mNextTryTs = ( millis ( ) + ( WIFI_AP_ACTIVE_TIME * 1000 ) ) ;
}
mApLastTick = millis ( ) ;
@ -104,28 +110,26 @@ void app::MainLoop(void) {
}
# endif
}
mWeb - > handleClient ( ) ;
mWebInst - > loop ( ) ;
if ( checkTicker ( & mUptimeTicker , mUptimeInterval ) ) {
mUptimeSecs + + ;
if ( 0 ! = mTimestamp )
mTimestamp + + ;
else {
if ( ! sysConfig . apActive ) {
if ( ! apActive ) {
mTimestamp = getNtpTime ( ) ;
DPRINTLN ( DBG_INFO , " [NTP]: " + getDateTimeStr ( mTimestamp ) ) ;
}
}
/*if(++mHeapStatCnt >= 10) {
mHeapStatCnt = 0 ;
stats ( ) ;
} */
}
if ( WiFi . status ( ) ! = WL_CONNECTED ) {
if ( ( WiFi . status ( ) ! = WL_CONNECTED ) & & wifiWasEstablished ) {
if ( ! apActive ) {
DPRINTLN ( DBG_INFO , " [WiFi]: Connection Lost " ) ;
setupStation ( mWifiStationTimeout ) ;
}
}
}
//-----------------------------------------------------------------------------
@ -140,7 +144,6 @@ void app::loop(void) {
if ( checkTicker ( & mRxTicker , 5 ) ) {
//DPRINTLN(DBG_VERBOSE, F("app_loops =") + String(app_loops));
app_loops = 0 ;
DPRINT ( DBG_VERBOSE , F ( " a " ) ) ;
bool rxRdy = mSys - > Radio . switchRxCh ( ) ;
@ -150,7 +153,7 @@ void app::loop(void) {
if ( mSys - > Radio . checkPaketCrc ( p - > packet , & len , p - > rxCh ) ) {
// process buffer only on first occurrence
if ( c onfig. serialDebug ) {
if ( mC onfig. serialDebug ) {
DPRINT ( DBG_INFO , " RX " + String ( len ) + " B Ch " + String ( p - > rxCh ) + " | " ) ;
mSys - > Radio . dumpBuf ( NULL , p - > packet , len ) ;
}
@ -257,7 +260,7 @@ void app::loop(void) {
mMqtt . loop ( ) ;
if ( checkTicker ( & mTicker , 1000 ) ) {
if ( ( + + mMqttTicker > = mMqttInterval ) & & ( mMqttInterval ! = 0xffff ) ) {
if ( ( + + mMqttTicker > = mMqttInterval ) & & ( mMqttInterval ! = 0xffff ) & & mMqttActive ) {
mMqttTicker = 0 ;
mMqtt . isConnected ( true ) ;
char topic [ 30 ] , val [ 10 ] ;
@ -288,8 +291,8 @@ void app::loop(void) {
# endif
}
if ( c onfig. serialShowIv ) {
if ( + + mSerialTicker > = c onfig. serialInterval ) {
if ( mC onfig. serialShowIv ) {
if ( + + mSerialTicker > = mC onfig. serialInterval ) {
mSerialTicker = 0 ;
char topic [ 30 ] , val [ 10 ] ;
for ( uint8_t id = 0 ; id < mSys - > getNumInverters ( ) ; id + + ) {
@ -312,15 +315,15 @@ void app::loop(void) {
}
}
if ( + + mSendTicker > = c onfig. sendInterval ) {
if ( + + mSendTicker > = mC onfig. sendInterval ) {
mSendTicker = 0 ;
if ( 0 ! = mTimestamp ) {
if ( c onfig. serialDebug )
if ( mC onfig. serialDebug )
DPRINTLN ( DBG_DEBUG , F ( " Free heap: 0x " ) + String ( ESP . getFreeHeap ( ) , HEX ) ) ;
if ( ! mSys - > BufCtrl . empty ( ) ) {
if ( c onfig. serialDebug )
if ( mC onfig. serialDebug )
DPRINTLN ( DBG_DEBUG , F ( " recbuf not empty! # " ) + String ( mSys - > BufCtrl . getFill ( ) ) ) ;
}
@ -339,7 +342,7 @@ void app::loop(void) {
if ( ! mPayload [ iv - > id ] . complete ) {
mRxFailed + + ;
if ( c onfig. serialDebug ) {
if ( mC onfig. serialDebug ) {
DPRINT ( DBG_INFO , F ( " Inverter # " ) + String ( iv - > id ) + " " ) ;
DPRINTLN ( DBG_INFO , F ( " no Payload received! (retransmits: " ) + String ( mPayload [ iv - > id ] . retransmits ) + " ) " ) ;
}
@ -354,11 +357,11 @@ void app::loop(void) {
mPayload [ iv - > id ] . ts = mTimestamp ;
yield ( ) ;
if ( c onfig. serialDebug )
if ( mC onfig. serialDebug )
DPRINTLN ( DBG_DEBUG , F ( " app:loop WiFi WiFi.status " ) + String ( WiFi . status ( ) ) ) ;
DPRINTLN ( DBG_INFO , F ( " Requesting Inverter SN " ) + String ( iv - > serial . u64 , HEX ) ) ;
if ( iv - > devControlRequest & & iv - > powerLimit [ 0 ] > 0 ) { // prevent to "switch off"
if ( c onfig. serialDebug )
if ( mC onfig. serialDebug )
DPRINTLN ( DBG_INFO , F ( " Devcontrol request " ) + String ( iv - > devControlCmd ) + F ( " power limit " ) + String ( iv - > powerLimit [ 0 ] ) ) ;
mSys - > Radio . sendControlPacket ( iv - > radioId . u64 , iv - > devControlCmd , iv - > powerLimit ) ;
} else {
@ -367,7 +370,7 @@ void app::loop(void) {
}
}
}
else if ( c onfig. serialDebug )
else if ( mC onfig. serialDebug )
DPRINTLN ( DBG_WARN , F ( " time not set, can't request inverter! " ) ) ;
yield ( ) ;
}
@ -422,12 +425,12 @@ void app::processPayload(bool retransmit) {
if ( ! buildPayload ( iv - > id ) ) {
if ( mPayload [ iv - > id ] . requested ) {
if ( retransmit ) {
if ( mPayload [ iv - > id ] . retransmits < c onfig. maxRetransPerPyld ) {
if ( mPayload [ iv - > id ] . retransmits < mC onfig. maxRetransPerPyld ) {
mPayload [ iv - > id ] . retransmits + + ;
if ( mPayload [ iv - > id ] . maxPackId ! = 0 ) {
for ( uint8_t i = 0 ; i < ( mPayload [ iv - > id ] . maxPackId - 1 ) ; i + + ) {
if ( mPayload [ iv - > id ] . len [ i ] = = 0 ) {
if ( c onfig. serialDebug )
if ( mC onfig. serialDebug )
DPRINTLN ( DBG_ERROR , F ( " while retrieving data: Frame " ) + String ( i + 1 ) + F ( " missing: Request Retransmit " ) ) ;
mSys - > Radio . sendCmdPacket ( iv - > radioId . u64 , TX_REQ_INFO , ( SINGLE_FRAME + i ) , true ) ;
break ; // only retransmit one frame per loop
@ -436,7 +439,7 @@ void app::processPayload(bool retransmit) {
}
}
else {
if ( c onfig. serialDebug )
if ( mC onfig. serialDebug )
DPRINTLN ( DBG_ERROR , F ( " while retrieving data: last frame missing: Request Retransmit " ) ) ;
if ( 0x00 ! = mLastPacketId )
mSys - > Radio . sendCmdPacket ( iv - > radioId . u64 , TX_REQ_INFO , mLastPacketId , true ) ;
@ -459,7 +462,7 @@ void app::processPayload(bool retransmit) {
yield ( ) ;
}
offs - = 2 ;
if ( c onfig. serialDebug ) {
if ( mC onfig. serialDebug ) {
DPRINT ( DBG_INFO , F ( " Payload ( " ) + String ( offs ) + " ): " ) ;
mSys - > Radio . dumpBuf ( NULL , payload , offs ) ;
}
@ -568,7 +571,7 @@ void app::cbMqtt(char* topic, byte* payload, unsigned int length) {
//-----------------------------------------------------------------------------
void app : : showStatistics ( void ) {
/*void app::showStatistics(void) {
DPRINTLN ( DBG_VERBOSE , F ( " app::showStatistics " ) ) ;
String content = F ( " Receive success: " ) + String ( mRxSuccess ) + " \n " ;
content + = F ( " Receive fail: " ) + String ( mRxFailed ) + " \n " ;
@ -615,10 +618,11 @@ void app::showStatistics(void) {
content + = F ( " connected \n " ) ;
mWeb - > send ( 200 , F ( " text/plain " ) , content ) ;
}
} */
//-----------------------------------------------------------------------------
void app : : webapi ( void ) { // ToDo
/*void app::webapi(void) { // ToDo
DPRINTLN ( DBG_VERBOSE , F ( " app::api " ) ) ;
DPRINTLN ( DBG_DEBUG , mWeb - > arg ( " plain " ) ) ;
const size_t capacity = 200 ; // Use arduinojson.org/assistant to compute the capacity.
@ -632,23 +636,23 @@ void app::webapi(void) { // ToDo
DPRINTLN ( DBG_INFO , F ( " Will make tx-request 0x15 with subcmd " ) + String ( mSys - > InfoCmd ) ) ;
}
mWeb - > send ( 200 , " text/json " , " {success:true} " ) ;
}
} */
//-----------------------------------------------------------------------------
void app : : showHoymiles ( void ) {
/*void app::showHoymiles(void) {
DPRINTLN ( DBG_VERBOSE , F ( " app::showHoymiles " ) ) ;
String html = FPSTR ( hoymiles_html ) ;
html . replace ( F ( " {DEVICE} " ) , s ysConfig. deviceName ) ;
html . replace ( F ( " {DEVICE} " ) , mS ysConfig. deviceName ) ;
html . replace ( F ( " {VERSION} " ) , version ) ;
html . replace ( F ( " {TS} " ) , String ( config . sendInterval ) + " " ) ;
html . replace ( F ( " {JS_TS} " ) , String ( config . sendInterval * 1000 ) ) ;
mWeb - > send ( 200 , F ( " text/html " ) , html ) ;
}
} */
//-----------------------------------------------------------------------------
void app : : showLiveData ( void ) {
/*void app::showLiveData(void) {
DPRINTLN ( DBG_VERBOSE , F ( " app::showLiveData " ) ) ;
String modHtml ;
for ( uint8_t id = 0 ; id < mSys - > getNumInverters ( ) ; id + + ) {
@ -720,11 +724,11 @@ void app::showLiveData(void) {
}
}
mWeb - > send ( 200 , F ( " text/html " ) , modHtml ) ;
}
} */
//-----------------------------------------------------------------------------
void app : : showJSON ( void ) {
/*void app::showJSON(void) {
DPRINTLN ( DBG_VERBOSE , F ( " app::showJSON " ) ) ;
String modJson ;
@ -747,7 +751,7 @@ void app::showJSON(void) {
// mWeb->send(200, F("text/json"), modJson);
mWeb - > send ( 200 , F ( " application/json " ) , modJson ) ; // the preferred content-type (https://stackoverflow.com/questions/22406077/what-is-the-exact-difference-between-content-type-text-json-and-application-jso)
}
} */
@ -772,7 +776,7 @@ void app::sendMqttDiscoveryConfig(void) {
} else {
snprintf ( name , 32 , " %s CH%d %s " , iv - > name , iv - > assign [ i ] . ch , iv - > getFieldName ( i ) ) ;
}
snprintf ( stateTopic , 64 , " %s/%s/ch%d/%s " , c onfig. mqtt . topic , iv - > name , iv - > assign [ i ] . ch , iv - > getFieldName ( i ) ) ;
snprintf ( stateTopic , 64 , " %s/%s/ch%d/%s " , mC onfig. mqtt . topic , iv - > name , iv - > assign [ i ] . ch , iv - > getFieldName ( i ) ) ;
snprintf ( discoveryTopic , 64 , " %s/sensor/%s/ch%d_%s/config " , MQTT_DISCOVERY_PREFIX , iv - > name , iv - > assign [ i ] . ch , iv - > getFieldName ( i ) ) ;
snprintf ( uniq_id , 32 , " ch%d_%s " , iv - > assign [ i ] . ch , iv - > getFieldName ( i ) ) ;
const char * devCls = getFieldDeviceClass ( iv - > assign [ i ] . fieldId ) ;
@ -839,14 +843,7 @@ void app::setupAp(const char *ssid, const char *pwd) {
WiFi . softAPConfig ( apIp , apIp , IPAddress ( 255 , 255 , 255 , 0 ) ) ;
WiFi . softAP ( ssid , pwd ) ;
mDns - > start ( mDnsPort , " * " , apIp ) ;
/*mWeb->onNotFound([&]() {
showSetup ( ) ;
} ) ;
mWeb - > on ( " / " , std : : bind ( & app : : showSetup , this ) ) ;
mWeb - > begin ( ) ; */
mDns - > start ( 53 , " * " , apIp ) ;
}
@ -864,15 +861,15 @@ bool app::setupStation(uint32_t timeout) {
}
WiFi . mode ( WIFI_STA ) ;
WiFi . begin ( s ysConfig. stationSsid , s ysConfig. stationPwd ) ;
if ( String ( s ysConfig. deviceName ) ! = " " )
WiFi . hostname ( s ysConfig. deviceName ) ;
WiFi . begin ( mS ysConfig. stationSsid , mS ysConfig. stationPwd ) ;
if ( String ( mS ysConfig. deviceName ) ! = " " )
WiFi . hostname ( mS ysConfig. deviceName ) ;
delay ( 2000 ) ;
DPRINTLN ( DBG_INFO , F ( " connect to network ' " ) + String ( s ysConfig. stationSsid ) + F ( " ' ... " ) ) ;
DPRINTLN ( DBG_INFO , F ( " connect to network ' " ) + String ( mS ysConfig. stationSsid ) + F ( " ' ... " ) ) ;
while ( WiFi . status ( ) ! = WL_CONNECTED ) {
delay ( 100 ) ;
if ( cnt % 10 0 = = 0 )
if ( cnt % 4 0 = = 0 )
Serial . println ( " . " ) ;
else
Serial . print ( " . " ) ;
@ -891,7 +888,7 @@ bool app::setupStation(uint32_t timeout) {
Serial . println ( " . " ) ;
if ( false = = startAp ) {
mWeb - > begin ( ) ;
wifiWasEstablished = true ;
}
delay ( 1000 ) ;
@ -903,6 +900,7 @@ bool app::setupStation(uint32_t timeout) {
//-----------------------------------------------------------------------------
void app : : resetSystem ( void ) {
mWifiStationTimeout = 10 ;
wifiWasEstablished = false ;
mNextTryTs = 0 ;
mApLastTick = 0 ;
@ -942,36 +940,36 @@ void app::resetSystem(void) {
//-----------------------------------------------------------------------------
void app : : loadDefaultConfig ( void ) {
memset ( & s ysConfig, 0 , sizeof ( sysConfig_t ) ) ;
memset ( & c onfig, 0 , sizeof ( config_t ) ) ;
snprintf ( v ersion, 12 , " %d.%d.%d " , VERSION_MAJOR , VERSION_MINOR , VERSION_PATCH ) ;
memset ( & mS ysConfig, 0 , sizeof ( sysConfig_t ) ) ;
memset ( & mC onfig, 0 , sizeof ( config_t ) ) ;
snprintf ( mV ersion, 12 , " %d.%d.%d " , VERSION_MAJOR , VERSION_MINOR , VERSION_PATCH ) ;
snprintf ( s ysConfig. deviceName , DEVNAME_LEN , " %s " , DEF_DEVICE_NAME ) ;
snprintf ( mS ysConfig. deviceName , DEVNAME_LEN , " %s " , DEF_DEVICE_NAME ) ;
// wifi
snprintf ( s ysConfig. stationSsid , SSID_LEN , " %s " , FB_WIFI_SSID ) ;
snprintf ( s ysConfig. stationPwd , PWD_LEN , " %s " , FB_WIFI_PWD ) ;
sysConfig . apActive = false ;
snprintf ( mS ysConfig. stationSsid , SSID_LEN , " %s " , FB_WIFI_SSID ) ;
snprintf ( mS ysConfig. stationPwd , PWD_LEN , " %s " , FB_WIFI_PWD ) ;
apActive = false ;
// nrf24
c onfig. sendInterval = SEND_INTERVAL ;
c onfig. maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD ;
mC onfig. sendInterval = SEND_INTERVAL ;
mC onfig. maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD ;
// ntp
snprintf ( c onfig. ntpAddr , NTP_ADDR_LEN , " %s " , NTP_SERVER_NAME ) ;
c onfig. ntpPort = NTP_LOCAL_PORT ;
snprintf ( mC onfig. ntpAddr , NTP_ADDR_LEN , " %s " , NTP_SERVER_NAME ) ;
mC onfig. ntpPort = NTP_LOCAL_PORT ;
// mqtt
snprintf ( c onfig. mqtt . broker , MQTT_ADDR_LEN , " %s " , DEF_MQTT_BROKER ) ;
c onfig. mqtt . port = DEF_MQTT_PORT ;
snprintf ( c onfig. mqtt . user , MQTT_USER_LEN , " %s " , DEF_MQTT_USER ) ;
snprintf ( c onfig. mqtt . pwd , MQTT_PWD_LEN , " %s " , DEF_MQTT_PWD ) ;
snprintf ( c onfig. mqtt . topic , MQTT_TOPIC_LEN , " %s " , DEF_MQTT_TOPIC ) ;
snprintf ( mC onfig. mqtt . broker , MQTT_ADDR_LEN , " %s " , DEF_MQTT_BROKER ) ;
mC onfig. mqtt . port = DEF_MQTT_PORT ;
snprintf ( mC onfig. mqtt . user , MQTT_USER_LEN , " %s " , DEF_MQTT_USER ) ;
snprintf ( mC onfig. mqtt . pwd , MQTT_PWD_LEN , " %s " , DEF_MQTT_PWD ) ;
snprintf ( mC onfig. mqtt . topic , MQTT_TOPIC_LEN , " %s " , DEF_MQTT_TOPIC ) ;
// serial
c onfig. serialInterval = SERIAL_INTERVAL ;
c onfig. serialShowIv = true ;
c onfig. serialDebug = false ;
mC onfig. serialInterval = SERIAL_INTERVAL ;
mC onfig. serialShowIv = true ;
mC onfig. serialDebug = false ;
}
@ -980,11 +978,11 @@ void app::loadEEpconfig(void) {
DPRINTLN ( DBG_VERBOSE , F ( " app::loadEEpconfig " ) ) ;
if ( mWifiSettingsValid )
mEep - > read ( ADDR_CFG_SYS , ( uint8_t * ) & s ysConfig, CFG_SYS_LEN ) ;
mEep - > read ( ADDR_CFG_SYS , ( uint8_t * ) & mS ysConfig, CFG_SYS_LEN ) ;
if ( mSettingsValid ) {
mEep - > read ( ADDR_CFG , ( uint8_t * ) & c onfig, CFG_LEN ) ;
mEep - > read ( ADDR_CFG , ( uint8_t * ) & mC onfig, CFG_LEN ) ;
mSendTicker = c onfig. sendInterval ;
mSendTicker = mC onfig. sendInterval ;
mSerialTicker = 0 ;
// inverter
@ -1012,7 +1010,7 @@ void app::loadEEpconfig(void) {
}
// TODO: the original mqttinterval value is not needed any more
mMqttInterval + = c onfig. sendInterval ;
mMqttInterval + = mC onfig. sendInterval ;
}
}
}
@ -1022,7 +1020,7 @@ void app::loadEEpconfig(void) {
//-----------------------------------------------------------------------------
void app : : setupMqtt ( void ) {
if ( mSettingsValid ) {
if ( c onfig. mqtt . broker [ 0 ] > 0 ) {
if ( mC onfig. mqtt . broker [ 0 ] > 0 ) {
mMqttActive = true ;
if ( mMqttInterval < MIN_MQTT_INTERVAL )
mMqttInterval = MIN_MQTT_INTERVAL ;
@ -1031,14 +1029,14 @@ void app::setupMqtt(void) {
mMqttInterval = 0xffff ;
mMqttTicker = 0 ;
mMqtt . setup ( & c onfig. mqtt , s ysConfig. deviceName ) ;
mMqtt . setup ( & mC onfig. mqtt , mS ysConfig. deviceName ) ;
mMqtt . setCallback ( std : : bind ( & app : : cbMqtt , this , std : : placeholders : : _1 , std : : placeholders : : _2 , std : : placeholders : : _3 ) ) ;
if ( mMqttActive ) {
mMqtt . sendMsg ( " version " , v ersion) ;
mMqtt . sendMsg ( " version " , mV ersion) ;
if ( mMqtt . isConnected ( ) )
mMqtt . sendMsg ( " device " , s ysConfig. deviceName ) ;
mMqtt . sendMsg ( " device " , mS ysConfig. deviceName ) ;
/*char topic[30];
for ( uint8_t i = 0 ; i < MAX_NUM_INVERTERS ; i + + ) {
@ -1062,8 +1060,8 @@ void app::setupMqtt(void) {
void app : : saveValues ( void ) {
DPRINTLN ( DBG_VERBOSE , F ( " app::saveValues " ) ) ;
mEep - > write ( ADDR_CFG_SYS , ( uint8_t * ) & s ysConfig, CFG_SYS_LEN ) ;
mEep - > write ( ADDR_CFG , ( uint8_t * ) & c onfig, CFG_LEN ) ;
mEep - > write ( ADDR_CFG_SYS , ( uint8_t * ) & mS ysConfig, CFG_SYS_LEN ) ;
mEep - > write ( ADDR_CFG , ( uint8_t * ) & mC onfig, CFG_LEN ) ;
Inverter < > * iv ;
for ( uint8_t i = 0 ; i < MAX_NUM_INVERTERS ; i + + ) {
iv = mSys - > getInverterByPos ( i ) ;