From a00ab4e48d450d3198ad8c2010e313a73a55b3d6 Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 25 Apr 2022 21:40:35 +0200 Subject: [PATCH 1/6] * fix eep endless loop --- tools/esp8266/defines.h | 2 +- tools/esp8266/eep.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 765ba2b2..b91fe2d2 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -25,7 +25,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 2 -#define VERSION_PATCH 4 +#define VERSION_PATCH 5 //------------------------------------- diff --git a/tools/esp8266/eep.h b/tools/esp8266/eep.h index da1450b0..a49cae67 100644 --- a/tools/esp8266/eep.h +++ b/tools/esp8266/eep.h @@ -37,7 +37,7 @@ class eep { } void read(uint32_t addr, uint8_t data[], uint16_t length) { - for(uint8_t i = 0; i < length; i ++) { + for(uint16_t i = 0; i < length; i ++) { *(data++) = EEPROM.read(addr++); } } @@ -78,7 +78,7 @@ class eep { } void write(uint32_t addr, uint8_t data[], uint16_t length) { - for(uint8_t i = 0; i < length; i ++) { + for(uint16_t i = 0; i < length; i ++) { EEPROM.write(addr++, data[i]); } EEPROM.commit(); From df9f050313762d4cb2fa164d407eb827bc2f7e4a Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 25 Apr 2022 22:44:12 +0200 Subject: [PATCH 2/6] * added erase application settings * HM1500 as selectable in setup * Added new commands to statistic (0x82, 0x83) --- tools/esp8266/app.cpp | 55 ++++++++++++++++++------------- tools/esp8266/app.h | 11 +++++-- tools/esp8266/defines.h | 2 +- tools/esp8266/hmInverters.h | 4 +-- tools/esp8266/hmRadio.h | 1 - tools/esp8266/html/h/setup_html.h | 2 +- tools/esp8266/html/h/style_css.h | 2 +- tools/esp8266/html/setup.html | 3 ++ tools/esp8266/html/style.css | 10 ++++++ tools/esp8266/main.cpp | 5 ++- tools/esp8266/main.h | 11 +++++++ 11 files changed, 71 insertions(+), 35 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 0c6c499e..4c81e95d 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -13,8 +13,8 @@ app::app() : Main() { mMqttTicker = NULL; mMqttEvt = false; - memset(mCmds, 0, sizeof(uint32_t)); - memset(mChannelStat, 0, sizeof(uint32_t)); + memset(mCmds, 0, sizeof(uint32_t)*DBG_CMD_LIST_LEN); + //memset(mChannelStat, 0, sizeof(uint32_t) * 4); mSys = new HmSystemType(); } @@ -30,13 +30,14 @@ app::~app(void) { void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { Main::setup(ssid, pwd, timeout); - mWeb->on("/", std::bind(&app::showIndex, this)); - mWeb->on("/setup", std::bind(&app::showSetup, this)); - mWeb->on("/save", std::bind(&app::showSave, this)); - mWeb->on("/cmdstat", std::bind(&app::showCmdStatistics, this)); - mWeb->on("/hoymiles", std::bind(&app::showHoymiles, this)); - mWeb->on("/livedata", std::bind(&app::showLiveData, this)); - mWeb->on("/mqttstate", std::bind(&app::showMqtt, this)); + mWeb->on("/", std::bind(&app::showIndex, this)); + mWeb->on("/setup", std::bind(&app::showSetup, this)); + mWeb->on("/save", std::bind(&app::showSave, this)); + mWeb->on("/erase", std::bind(&app::showErase, 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("/mqttstate", std::bind(&app::showMqtt, this)); if(mSettingsValid) { uint16_t interval; @@ -125,13 +126,15 @@ void app::loop(void) { else if(*cmd == 0x02) mCmds[1]++; else if(*cmd == 0x03) mCmds[2]++; else if(*cmd == 0x81) mCmds[3]++; - else if(*cmd == 0x84) mCmds[4]++; - else mCmds[5]++; + else if(*cmd == 0x82) mCmds[4]++; + else if(*cmd == 0x83) mCmds[5]++; + else if(*cmd == 0x84) mCmds[6]++; + else mCmds[7]++; - if(p->sendCh == 23) mChannelStat[0]++; + /*if(p->sendCh == 23) mChannelStat[0]++; else if(p->sendCh == 40) mChannelStat[1]++; else if(p->sendCh == 61) mChannelStat[2]++; - else mChannelStat[3]++; + else mChannelStat[3]++;*/ } } mSys->BufCtrl.popBack(); @@ -319,20 +322,26 @@ void app::showSave(void) { //----------------------------------------------------------------------------- -void app::showCmdStatistics(void) { +void app::showErase() { + eraseSettings(); + showReboot(); +} + + +//----------------------------------------------------------------------------- +void app::showStatistics(void) { String content = "CMDs:\n"; - content += String("0x01: ") + String(mCmds[0]) + String("\n"); - content += String("0x02: ") + String(mCmds[1]) + String("\n"); - content += String("0x03: ") + String(mCmds[2]) + String("\n"); - content += String("0x81: ") + String(mCmds[3]) + String("\n"); - content += String("0x84: ") + String(mCmds[4]) + String("\n"); - content += String("other: ") + String(mCmds[5]) + String("\n"); - - content += "\nCHANNELs:\n"; + for(uint8_t i = 0; i < DBG_CMD_LIST_LEN; i ++) { + content += String("0x") + String(dbgCmds[i], HEX) + String(": ") + String(mCmds[i]) + String("\n"); + } + content += String("other: ") + String(mCmds[DBG_CMD_LIST_LEN]) + String("\n\n"); + + /*content += "\nCHANNELs:\n"; content += String("23: ") + String(mChannelStat[0]) + String("\n"); content += String("40: ") + String(mChannelStat[1]) + String("\n"); content += String("61: ") + String(mChannelStat[2]) + String("\n"); - content += String("75: ") + String(mChannelStat[3]) + String("\n"); + content += String("75: ") + String(mChannelStat[3]) + String("\n");*/ + mWeb->send(200, "text/plain", content); } diff --git a/tools/esp8266/app.h b/tools/esp8266/app.h index c4cabcdd..e666bf20 100644 --- a/tools/esp8266/app.h +++ b/tools/esp8266/app.h @@ -22,6 +22,9 @@ const char* const wemosPins[] = {"D3 (GPIO0)", "TX (GPIO1)", "D4 (GPIO2)", "RX ( const char* const pinNames[] = {"CS", "CE", "IRQ"}; const char* const pinArgNames[] = {"pinCs", "pinCe", "pinIrq"}; +const uint8_t dbgCmds[] = {0x01, 0x02, 0x03, 0x81, 0x82, 0x83, 0x84}; +#define DBG_CMD_LIST_LEN 7 + class app : public Main { public: app(); @@ -42,7 +45,8 @@ class app : public Main { void showIndex(void); void showSetup(void); void showSave(void); - void showCmdStatistics(void); + void showErase(void); + void showStatistics(void); void showHoymiles(void); void showLiveData(void); void showMqtt(void); @@ -65,6 +69,7 @@ class app : public Main { return ret; } + uint8_t mState; bool mKeyPressed; @@ -73,8 +78,8 @@ class app : public Main { Ticker *mSendTicker; bool mFlagSend; - uint32_t mCmds[6]; - uint32_t mChannelStat[4]; + uint32_t mCmds[DBG_CMD_LIST_LEN+1]; + //uint32_t mChannelStat[4]; uint32_t mRecCnt; // mqtt diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index b91fe2d2..c94668cc 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -25,7 +25,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 2 -#define VERSION_PATCH 5 +#define VERSION_PATCH 6 //------------------------------------- diff --git a/tools/esp8266/hmInverters.h b/tools/esp8266/hmInverters.h index 1da3f62c..df9cc147 100644 --- a/tools/esp8266/hmInverters.h +++ b/tools/esp8266/hmInverters.h @@ -21,7 +21,7 @@ enum {CH0 = 0, CH1, CH2, CH3, CH4}; enum {CMD01 = 0x01, CMD02, CMD03, CMD82 = 0x82, CMD83, CMD84}; enum {INV_TYPE_HM600 = 0, INV_TYPE_HM1200, INV_TYPE_HM400}; -const char* const invTypes[] = {"HM600", "HM1200", "HM400"}; +const char* const invTypes[] = {"HM600", "HM1200 / HM1500", "HM400"}; #define NUM_INVERTER_TYPES 3 typedef struct { @@ -97,7 +97,7 @@ const byteAssign_t hm600assignment[] = { //------------------------------------- -// HM1200, HM1500? +// HM1200, HM1500 //------------------------------------- const byteAssign_t hm1200assignment[] = { { FLD_UDC, UNIT_V, CH1, CMD01, 3, 2, 10 }, diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index 70e710e0..ea0120fc 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -79,7 +79,6 @@ class HmRadio { // enable only receiving interrupts mNrf24.maskIRQ(true, true, false); - // Use lo PA level, as a higher level will disturb CH340 serial usb adapter mNrf24.setPALevel(RF24_PA_MAX); mNrf24.startListening(); diff --git a/tools/esp8266/html/h/setup_html.h b/tools/esp8266/html/h/setup_html.h index f4e99a1a..0fb05a10 100644 --- a/tools/esp8266/html/h/setup_html.h +++ b/tools/esp8266/html/h/setup_html.h @@ -1,4 +1,4 @@ #ifndef __SETUP_H__ #define __SETUP_H__ -const char setup_html[] PROGMEM = "Setup - {DEVICE}

Setup

Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.

WiFi

Device Host Name

Inverter

{INVERTERS}

General

Pinout (Wemos)

{PINOUT}

MQTT

 

Home

Update Firmware

AHOY - {VERSION}

"; +const char setup_html[] PROGMEM = "Setup - {DEVICE}

Setup

Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.

WiFi

Device Host Name

ERASE SETTINGS (not WiFi)

Inverter

{INVERTERS}

General

Pinout (Wemos)

{PINOUT}

MQTT

 

Home

Update Firmware

AHOY - {VERSION}

"; #endif /*__SETUP_H__*/ diff --git a/tools/esp8266/html/h/style_css.h b/tools/esp8266/html/h/style_css.h index cf8ac694..dc3639c4 100644 --- a/tools/esp8266/html/h/style_css.h +++ b/tools/esp8266/html/h/style_css.h @@ -1,4 +1,4 @@ #ifndef __STYLE_H__ #define __STYLE_H__ -const char style_css[] PROGMEM = "h1 {margin:0;padding:20pt;font-size:22pt;color:#fff;background-color:#006ec0;display:block;text-transform:uppercase;}html, body {font-family:Arial;margin:0;padding:0;}p {text-align:justify;font-size:13pt;}.des {margin-top:35px;font-size:14pt;color:#006ec0;}.subdes {font-size:13pt;color:#006ec0;margin-left:7px;}.fw {width:60px;display:block;float:left;}.color {width:50px;height:50px;border:1px solid #ccc;}.range {width:300px;}a:link, a:visited {text-decoration:none;font-size:13pt;color:#006ec0;}a:hover, a:focus {color:#f00;}#content {padding:15px 15px 60px 15px;}#footer {position:fixed;bottom:0px;height:45px;background-color:#006ec0;width:100%;}#footer p {color:#fff;padding-left:20px;padding-right:20px;font-size:10pt !important;}#footer a {color:#fff;}div.content {background-color:#fff;padding-bottom:65px;overflow:hidden;}input, select {padding:7px;font-size:13pt;}input.text, select {width:70%;box-sizing:border-box;margin-bottom:10px;border:1px solid #ccc;}input.btn {background-color:#006ec0;color:#fff;border:0px;float:right;text-transform:uppercase;}input.cb {margin-bottom:20px;}label {width:20%;display:inline-block;font-size:12pt;padding-right:10px;margin-left:10px;}.left {float:left;}.right {float:right;}div.ch {width:250px;height:410px;background-color:#006ec0;display:inline-block;margin-right:20px;margin-bottom:20px;}div.ch .value, div.ch .info, div.ch .head {color:#fff;display:block;width:100%;text-align:center;}div.ch .unit {font-size:19px;margin-left:10px;}div.ch .value {margin-top:20px;font-size:30px;}div.ch .info {margin-top:3px;font-size:10px;}div.ch .head {background-color:#003c80;padding:10px 0 10px 0;}"; +const char style_css[] PROGMEM = "h1 {margin:0;padding:20pt;font-size:22pt;color:#fff;background-color:#006ec0;display:block;text-transform:uppercase;}html, body {font-family:Arial;margin:0;padding:0;}p {text-align:justify;font-size:13pt;}.des {margin-top:35px;font-size:14pt;color:#006ec0;}.subdes {font-size:13pt;color:#006ec0;margin-left:7px;}.fw {width:60px;display:block;float:left;}.color {width:50px;height:50px;border:1px solid #ccc;}.range {width:300px;}a:link, a:visited {text-decoration:none;font-size:13pt;color:#006ec0;}a:hover, a:focus {color:#f00;}a.erase {background-color:#006ec0;color:#fff;padding:7px;display:inline-block;margin-top:30px;float:right;}#content {padding:15px 15px 60px 15px;}#footer {position:fixed;bottom:0px;height:45px;background-color:#006ec0;width:100%;}#footer p {color:#fff;padding-left:20px;padding-right:20px;font-size:10pt !important;}#footer a {color:#fff;}div.content {background-color:#fff;padding-bottom:65px;overflow:hidden;}input, select {padding:7px;font-size:13pt;}input.text, select {width:70%;box-sizing:border-box;margin-bottom:10px;border:1px solid #ccc;}input.btn {background-color:#006ec0;color:#fff;border:0px;float:right;margin:10px 0 30px;text-transform:uppercase;}input.cb {margin-bottom:20px;}label {width:20%;display:inline-block;font-size:12pt;padding-right:10px;margin-left:10px;}.left {float:left;}.right {float:right;}div.ch {width:250px;height:410px;background-color:#006ec0;display:inline-block;margin-right:20px;margin-bottom:20px;}div.ch .value, div.ch .info, div.ch .head {color:#fff;display:block;width:100%;text-align:center;}div.ch .unit {font-size:19px;margin-left:10px;}div.ch .value {margin-top:20px;font-size:30px;}div.ch .info {margin-top:3px;font-size:10px;}div.ch .head {background-color:#003c80;padding:10px 0 10px 0;}"; #endif /*__STYLE_H__*/ diff --git a/tools/esp8266/html/setup.html b/tools/esp8266/html/setup.html index 0ab66fff..b78608f3 100644 --- a/tools/esp8266/html/setup.html +++ b/tools/esp8266/html/setup.html @@ -22,6 +22,9 @@ + + ERASE SETTINGS (not WiFi) +

Inverter

{INVERTERS}

General

diff --git a/tools/esp8266/html/style.css b/tools/esp8266/html/style.css index 5eb5f7dc..21d5340f 100644 --- a/tools/esp8266/html/style.css +++ b/tools/esp8266/html/style.css @@ -57,6 +57,15 @@ a:hover, a:focus { color: #f00; } +a.erase { + background-color: #006ec0; + color: #fff; + padding: 7px; + display: inline-block; + margin-top: 30px; + float: right; +} + #content { padding: 15px 15px 60px 15px; } @@ -103,6 +112,7 @@ input.btn { color: #fff; border: 0px; float: right; + margin: 10px 0 30px; text-transform: uppercase; } diff --git a/tools/esp8266/main.cpp b/tools/esp8266/main.cpp index 61b2075c..746c11e7 100644 --- a/tools/esp8266/main.cpp +++ b/tools/esp8266/main.cpp @@ -90,9 +90,8 @@ bool Main::getConfig(void) { memset(mStationPwd, 0, PWD_LEN); memset(mDeviceName, 0, DEVNAME_LEN); - // erase eeprom - uint8_t buf[ADDR_NEXT-ADDR_START_SETTINGS] = {0}; - mEep->write(ADDR_START_SETTINGS, buf, (ADDR_NEXT-ADDR_START_SETTINGS)); + // erase application settings except wifi settings + eraseSettings(); } return mApActive; diff --git a/tools/esp8266/main.h b/tools/esp8266/main.h index 9014b6fb..6e096789 100644 --- a/tools/esp8266/main.h +++ b/tools/esp8266/main.h @@ -53,6 +53,17 @@ class Main { return (crcCheck == crcRd); } + void eraseSettings(void) { + uint8_t buf[64] = {0}; + uint16_t addr = ADDR_START_SETTINGS, end; + do { + end = addr += 64; + if(end > (ADDR_SETTINGS_CRC + 2)) + end = (ADDR_SETTINGS_CRC + 2 - addr); + mEep->write(ADDR_START_SETTINGS, buf, (ADDR_NEXT-ADDR_START_SETTINGS)); + } while(addr < ADDR_START_SETTINGS); + } + char mStationSsid[SSID_LEN]; char mStationPwd[PWD_LEN]; bool mWifiSettingsValid; From 04d31200cbcf1db02f30ac7fcbd4eb16cfdeda5a Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 25 Apr 2022 23:28:59 +0200 Subject: [PATCH 3/6] * NRF24 amlifierer power level can be configured in web setup * fixed MQTT status (was inverted) * fixed interval uint from seconds to ms --- tools/esp8266/app.cpp | 22 ++++++++++++++++++++-- tools/esp8266/defines.h | 8 ++++++-- tools/esp8266/hmRadio.h | 12 ++++++++++-- tools/esp8266/html/h/setup_html.h | 2 +- tools/esp8266/html/setup.html | 6 +++++- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 4c81e95d..6d4056c2 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -68,6 +68,9 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { mEep->read(ADDR_PINOUT+2, &mSys->Radio.pinIrq); + // nrf24 amplifier power + mEep->read(ADDR_RF24_AMP_PWR, &mSys->Radio.AmplifierPower); + // mqtt uint8_t mqttAddr[MQTT_ADDR_LEN]; char mqttUser[MQTT_USER_LEN]; @@ -93,7 +96,7 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { mSys->setup(); - if(!mSettingsValid) + if(!mWifiSettingsValid) Serial.println("Warn: your settings are not valid! check [IP]/setup"); } @@ -285,6 +288,17 @@ void app::showSetup(void) { html.replace("{PINOUT}", String(pinout)); + // nrf24l01+ + String rf24; + for(uint8_t i = 0; i <= 3; i++) { + rf24 += ""; + } + html.replace("{RF24}", String(rf24)); + + if(mSettingsValid) { mEep->read(ADDR_INV_INTERVAL, &interval); html.replace("{INV_INTERVAL}", String(interval)); @@ -409,7 +423,7 @@ void app::showLiveData(void) { //----------------------------------------------------------------------------- void app::showMqtt(void) { String txt = "connected"; - if(mMqtt.isConnected()) + if(!mMqtt.isConnected()) txt = "not " + txt; mWeb->send(200, "text/plain", txt); } @@ -456,6 +470,10 @@ void app::saveValues(bool webSend = true) { } + // nrf24 amplifier power + mSys->Radio.AmplifierPower = mWeb->arg(String(pinArgNames[i])).toInt() & 0x03; + mEep->write(ADDR_RF24_AMP_PWR, mSys->Radio.AmplifierPower); + // mqtt uint8_t mqttAddr[MQTT_ADDR_LEN] = {0}; char mqttUser[MQTT_USER_LEN]; diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index c94668cc..74bb4f90 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -25,7 +25,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 2 -#define VERSION_PATCH 6 +#define VERSION_PATCH 7 //------------------------------------- @@ -50,6 +50,8 @@ typedef struct { #define PINOUT_LEN 3 // 3 pins: CS, CE, IRQ +#define RF24_AMP_PWR_LEN 1 + #define MQTT_ADDR_LEN 4 // IP #define MQTT_USER_LEN 16 #define MQTT_PWD_LEN 32 @@ -66,7 +68,9 @@ typedef struct { #define ADDR_PINOUT ADDR_START_SETTINGS -#define ADDR_INV_ADDR ADDR_PINOUT + PINOUT_LEN +#define ADDR_RF24_AMP_PWR ADDR_PINOUT + PINOUT_LEN + +#define ADDR_INV_ADDR ADDR_RF24_AMP_PWR + RF24_AMP_PWR_LEN #define ADDR_INV_NAME ADDR_INV_ADDR + INV_ADDR_LEN #define ADDR_INV_TYPE ADDR_INV_NAME + INV_NAME_LEN #define ADDR_INV_INTERVAL ADDR_INV_TYPE + INV_TYPE_LEN diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index ea0120fc..02989ec9 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -13,6 +13,10 @@ #define DUMMY_RADIO_ID ((uint64_t)0xDEADBEEF01ULL) +const char* const rf24AmpPower[] = {"MIN", "LOW", "HIGH", "MAX"}; + + + //----------------------------------------------------------------------------- // MACROS //----------------------------------------------------------------------------- @@ -54,7 +58,8 @@ class HmRadio { pinCe = CE_PIN; pinIrq = IRQ_PIN; - mSendCnt = 0; + AmplifierPower = 1; + mSendCnt = 0; } ~HmRadio() {} @@ -79,7 +84,8 @@ class HmRadio { // enable only receiving interrupts mNrf24.maskIRQ(true, true, false); - mNrf24.setPALevel(RF24_PA_MAX); + Serial.println("RF24 Amp Pwr: RF24_PA_" + String(rf24AmpPower[AmplifierPower])); + mNrf24.setPALevel(AmplifierPower & 0x03); mNrf24.startListening(); Serial.println("Radio Config:"); @@ -180,6 +186,8 @@ class HmRadio { uint8_t pinCe; uint8_t pinIrq; + uint8_t AmplifierPower; + private: void sendPacket(uint64_t invId, uint8_t buf[], uint8_t len) { //Serial.println("sent packet: #" + String(mSendCnt)); diff --git a/tools/esp8266/html/h/setup_html.h b/tools/esp8266/html/h/setup_html.h index 0fb05a10..83000eb7 100644 --- a/tools/esp8266/html/h/setup_html.h +++ b/tools/esp8266/html/h/setup_html.h @@ -1,4 +1,4 @@ #ifndef __SETUP_H__ #define __SETUP_H__ -const char setup_html[] PROGMEM = "Setup - {DEVICE}

Setup

Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.

WiFi

Device Host Name

ERASE SETTINGS (not WiFi)

Inverter

{INVERTERS}

General

Pinout (Wemos)

{PINOUT}

MQTT

 

Home

Update Firmware

AHOY - {VERSION}

"; +const char setup_html[] PROGMEM = "Setup - {DEVICE}

Setup

Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.

WiFi

Device Host Name

ERASE SETTINGS (not WiFi)

Inverter

{INVERTERS}

General

Pinout (Wemos)

{PINOUT}

Radio (NRF24L01+)

MQTT

 

Home

Update Firmware

AHOY - {VERSION}

"; #endif /*__SETUP_H__*/ diff --git a/tools/esp8266/html/setup.html b/tools/esp8266/html/setup.html index b78608f3..93f91b6e 100644 --- a/tools/esp8266/html/setup.html +++ b/tools/esp8266/html/setup.html @@ -34,6 +34,10 @@

Pinout (Wemos)

{PINOUT} +

Radio (NRF24L01+)

+ + +

MQTT

@@ -43,7 +47,7 @@ - +

 

From 657cbec9314a5db2d902f7ee718af29a99bfe1ac Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 25 Apr 2022 23:31:52 +0200 Subject: [PATCH 4/6] fix issue #10 --- tools/esp8266/hmSystem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/esp8266/hmSystem.h b/tools/esp8266/hmSystem.h index 0d40803f..70afe6b7 100644 --- a/tools/esp8266/hmSystem.h +++ b/tools/esp8266/hmSystem.h @@ -138,7 +138,7 @@ class HmSystem { void getAssignment(inverter_t *p) { if(INV_TYPE_HM600 == p->type) { - p->listLen = (uint8_t)(HM1200_LIST_LEN); + p->listLen = (uint8_t)(HM600_LIST_LEN); p->assign = (byteAssign_t*)hm600assignment; } else if(INV_TYPE_HM1200 == p->type) { From 169bf8c7c8aa9d06e34e6bd54a1e5315a4097b09 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 26 Apr 2022 08:50:36 +0200 Subject: [PATCH 5/6] * try to avoid exceptions, added yield * try to fix DNS problems --- tools/esp8266/app.cpp | 5 ++++- tools/esp8266/defines.h | 2 +- tools/esp8266/main.cpp | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index 6d4056c2..aace1c53 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -150,7 +150,8 @@ void app::loop(void) { inv = mSys->getInverterByPos(i); if(NULL != inv) { mSys->Radio.sendTimePacket(inv->radioId.u64, mTimestamp); - delay(20); + yield(); + delay(100); } } } @@ -171,6 +172,7 @@ void app::loop(void) { snprintf(val, 10, "%.3f", mSys->getValue(iv, i)); mMqtt.sendMsg(topic, val); delay(20); + yield(); } } } @@ -187,6 +189,7 @@ void app::loop(void) { snprintf(val, 10, "%.3f %s", mSys->getValue(iv, i), mSys->getUnit(iv, i)); Serial.println(String(topic) + ": " + String(val)); } + yield(); } } } diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index 74bb4f90..d974e9eb 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -25,7 +25,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 2 -#define VERSION_PATCH 7 +#define VERSION_PATCH 8 //------------------------------------- diff --git a/tools/esp8266/main.cpp b/tools/esp8266/main.cpp index 746c11e7..25b68c71 100644 --- a/tools/esp8266/main.cpp +++ b/tools/esp8266/main.cpp @@ -43,8 +43,6 @@ void Main::setup(const char *ssid, const char *pwd, uint32_t timeout) { mWeb->onNotFound (std::bind(&Main::showNotFound, this)); startAp = getConfig(); - if(String(mDeviceName) != "") - WiFi.hostname(mDeviceName); if(false == startAp) startAp = setupStation(timeout); @@ -126,6 +124,8 @@ bool Main::setupStation(uint32_t timeout) { WiFi.mode(WIFI_STA); WiFi.begin(mStationSsid, mStationPwd); + if(String(mDeviceName) != "") + WiFi.hostname(mDeviceName); delay(5000); Serial.println("wait for network"); From a9b7fd05999147f2853de43fc75cfccbc1fb709a Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 26 Apr 2022 22:49:00 +0200 Subject: [PATCH 6/6] * added IP address to serial console on successful connect to station WiFi * fix: RF24 power setting configuration * added RF24 isChipConnected * added MQTT port configuration * fix offsets for HM400 and HM600 inverters * added warning if configuration was changed without reboot --- tools/esp8266/app.cpp | 41 +++++++++++++++++++++----- tools/esp8266/app.h | 4 +-- tools/esp8266/defines.h | 6 ++-- tools/esp8266/hmInverters.h | 48 +++++++++++++++---------------- tools/esp8266/hmRadio.h | 38 +++++++++++++++--------- tools/esp8266/html/h/setup_html.h | 2 +- tools/esp8266/html/setup.html | 2 ++ tools/esp8266/mqtt.h | 4 +-- 8 files changed, 92 insertions(+), 53 deletions(-) diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index aace1c53..63670a14 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -10,9 +10,12 @@ app::app() : Main() { mSendTicker = new Ticker(); mFlagSend = false; + mShowRebootRequest = false; + mMqttTicker = NULL; mMqttEvt = false; + memset(mCmds, 0, sizeof(uint32_t)*DBG_CMD_LIST_LEN); //memset(mChannelStat, 0, sizeof(uint32_t) * 4); @@ -52,7 +55,7 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { mEep->read(ADDR_INV_TYPE + i, &invType); if(0ULL != invSerial) { mSys->addInverter(invName, invSerial, invType); - Serial.println("add inverter: " + String(invName) + ", SN: " + String(invSerial, HEX) + ", type: " + String(invType)); + DPRINTLN("add inverter: " + String(invName) + ", SN: " + String(invSerial, HEX) + ", type: " + String(invType)); } } @@ -73,6 +76,7 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { // mqtt uint8_t mqttAddr[MQTT_ADDR_LEN]; + uint16_t mqttPort; char mqttUser[MQTT_USER_LEN]; char mqttPwd[MQTT_PWD_LEN]; char mqttTopic[MQTT_TOPIC_LEN]; @@ -81,13 +85,14 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { mEep->read(ADDR_MQTT_PWD, mqttPwd, MQTT_PWD_LEN); mEep->read(ADDR_MQTT_TOPIC, mqttTopic, MQTT_TOPIC_LEN); mEep->read(ADDR_MQTT_INTERVAL, &interval); + mEep->read(ADDR_MQTT_PORT, &mqttPort); char addr[16] = {0}; sprintf(addr, "%d.%d.%d.%d", mqttAddr[0], mqttAddr[1], mqttAddr[2], mqttAddr[3]); if(interval < 1000) interval = 1000; - mMqtt.setup(addr, mqttTopic, mqttUser, mqttPwd); + mMqtt.setup(addr, mqttTopic, mqttUser, mqttPwd, mqttPort); mMqttTicker = new Ticker(); mMqttTicker->attach_ms(interval, std::bind(&app::mqttTicker, this)); @@ -97,7 +102,15 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) { mSys->setup(); if(!mWifiSettingsValid) - Serial.println("Warn: your settings are not valid! check [IP]/setup"); + DPRINTLN("Warn: your settings are not valid! check [IP]/setup"); + else { + DPRINTLN("\n\n----------------------------------------"); + DPRINTLN("Welcome to AHOY!"); + DPRINT("\npoint your browser to http://"); + DPRINTLN(WiFi.localIP()); + DPRINTLN("to configure your device"); + DPRINTLN("----------------------------------------\n"); + } } @@ -114,7 +127,7 @@ void app::loop(void) { // process buffer only on first occurrence if((0 != len) && (0 == rptCnt)) { uint8_t *cmd = &p->packet[11]; - //Serial.println("CMD " + String(*cmd, HEX)); + //DPRINTLN("CMD " + String(*cmd, HEX)); //mSys->Radio.dumpBuf("Payload ", p->packet, len); inverter_t *iv = mSys->findInverter(&p->packet[3]); @@ -187,7 +200,7 @@ void app::loop(void) { if(0.0f != mSys->getValue(iv, i)) { snprintf(topic, 30, "%s/ch%d/%s", iv->name, iv->assign[i].ch, mSys->getFieldName(iv, i)); snprintf(val, 10, "%.3f %s", mSys->getValue(iv, i), mSys->getUnit(iv, i)); - Serial.println(String(topic) + ": " + String(val)); + DPRINTLN(String(topic) + ": " + String(val)); } yield(); } @@ -307,12 +320,15 @@ void app::showSetup(void) { html.replace("{INV_INTERVAL}", String(interval)); uint8_t mqttAddr[MQTT_ADDR_LEN] = {0}; + uint16_t mqttPort; mEep->read(ADDR_MQTT_ADDR, mqttAddr, MQTT_ADDR_LEN); mEep->read(ADDR_MQTT_INTERVAL, &interval); + mEep->read(ADDR_MQTT_PORT, &mqttPort); char addr[16] = {0}; sprintf(addr, "%d.%d.%d.%d", mqttAddr[0], mqttAddr[1], mqttAddr[2], mqttAddr[3]); html.replace("{MQTT_ADDR}", String(addr)); + html.replace("{MQTT_PORT}", String(mqttPort)); html.replace("{MQTT_USER}", String(mMqtt.getUser())); html.replace("{MQTT_PWD}", String(mMqtt.getPwd())); html.replace("{MQTT_TOPIC}", String(mMqtt.getTopic())); @@ -322,6 +338,7 @@ void app::showSetup(void) { html.replace("{INV_INTERVAL}", "1000"); html.replace("{MQTT_ADDR}", ""); + html.replace("{MQTT_PORT}", "1883"); html.replace("{MQTT_USER}", ""); html.replace("{MQTT_PWD}", ""); html.replace("{MQTT_TOPIC}", "/inverter"); @@ -359,6 +376,12 @@ void app::showStatistics(void) { content += String("61: ") + String(mChannelStat[2]) + String("\n"); content += String("75: ") + String(mChannelStat[3]) + String("\n");*/ + if(!mSys->Radio.isChipConnected()) + content += "WARNING! your NRF24 module can't be reached, check the wiring\n"; + + if(mShowRebootRequest) + content += "INFO: reboot your ESP to apply all your configuration changes!\n"; + mWeb->send(200, "text/plain", content); } @@ -474,11 +497,12 @@ void app::saveValues(bool webSend = true) { // nrf24 amplifier power - mSys->Radio.AmplifierPower = mWeb->arg(String(pinArgNames[i])).toInt() & 0x03; + mSys->Radio.AmplifierPower = mWeb->arg("rf24Power").toInt() & 0x03; mEep->write(ADDR_RF24_AMP_PWR, mSys->Radio.AmplifierPower); // mqtt uint8_t mqttAddr[MQTT_ADDR_LEN] = {0}; + uint16_t mqttPort; char mqttUser[MQTT_USER_LEN]; char mqttPwd[MQTT_PWD_LEN]; char mqttTopic[MQTT_TOPIC_LEN]; @@ -493,7 +517,9 @@ void app::saveValues(bool webSend = true) { mWeb->arg("mqttPwd").toCharArray(mqttPwd, MQTT_PWD_LEN); mWeb->arg("mqttTopic").toCharArray(mqttTopic, MQTT_TOPIC_LEN); interval = mWeb->arg("mqttInterval").toInt(); + mqttPort = mWeb->arg("mqttPort").toInt(); mEep->write(ADDR_MQTT_ADDR, mqttAddr, MQTT_ADDR_LEN); + mEep->write(ADDR_MQTT_PORT, mqttPort); mEep->write(ADDR_MQTT_USER, mqttUser, MQTT_USER_LEN); mEep->write(ADDR_MQTT_PWD, mqttPwd, MQTT_PWD_LEN); mEep->write(ADDR_MQTT_TOPIC, mqttTopic, MQTT_TOPIC_LEN); @@ -503,6 +529,7 @@ void app::saveValues(bool webSend = true) { if((mWeb->arg("reboot") == "on")) showReboot(); else { + mShowRebootRequest = true; mWeb->send(200, "text/html", "Setup saved" "

saved

"); } @@ -520,6 +547,6 @@ void app::updateCrc(void) { uint16_t crc; crc = buildEEpCrc(ADDR_START_SETTINGS, (ADDR_NEXT - ADDR_START_SETTINGS)); - //Serial.println("new CRC: " + String(crc, HEX)); + //DPRINTLN("new CRC: " + String(crc, HEX)); mEep->write(ADDR_SETTINGS_CRC, crc); } diff --git a/tools/esp8266/app.h b/tools/esp8266/app.h index e666bf20..2fdc130d 100644 --- a/tools/esp8266/app.h +++ b/tools/esp8266/app.h @@ -69,9 +69,7 @@ class app : public Main { return ret; } - - uint8_t mState; - bool mKeyPressed; + bool mShowRebootRequest; HmSystemType *mSys; diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index d974e9eb..fa96dd02 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -25,7 +25,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 2 -#define VERSION_PATCH 8 +#define VERSION_PATCH 9 //------------------------------------- @@ -57,6 +57,7 @@ typedef struct { #define MQTT_PWD_LEN 32 #define MQTT_TOPIC_LEN 32 #define MQTT_INTERVAL_LEN 2 // uint16_t +#define MQTT_PORT_LEN 2 // uint16_t #define ADDR_START 0 @@ -81,7 +82,8 @@ typedef struct { #define ADDR_MQTT_TOPIC ADDR_MQTT_PWD + MQTT_PWD_LEN #define ADDR_MQTT_INTERVAL ADDR_MQTT_TOPIC + MQTT_TOPIC_LEN -#define ADDR_NEXT ADDR_MQTT_INTERVAL + MQTT_INTERVAL_LEN +#define ADDR_MQTT_PORT ADDR_MQTT_INTERVAL + MQTT_INTERVAL_LEN +#define ADDR_NEXT ADDR_MQTT_PORT + MQTT_PORT_LEN #define ADDR_SETTINGS_CRC 400 diff --git a/tools/esp8266/hmInverters.h b/tools/esp8266/hmInverters.h index df9cc147..0226a8cf 100644 --- a/tools/esp8266/hmInverters.h +++ b/tools/esp8266/hmInverters.h @@ -60,16 +60,16 @@ typedef struct { // HM400 HM350?, HM300? //------------------------------------- const byteAssign_t hm400assignment[] = { - { FLD_UDC, UNIT_V, CH1, CMD01, 14, 2, 10 }, - { FLD_IDC, UNIT_A, CH1, CMD01, 16, 2, 100 }, - { FLD_PDC, UNIT_W, CH1, CMD01, 18, 2, 10 }, - { FLD_YT, UNIT_KWH, CH1, CMD01, 20, 4, 1000 }, - { FLD_YD, UNIT_WH, CH1, CMD01, 24, 2, 1000 }, - { FLD_UAC, UNIT_V, CH0, CMD01, 26, 2, 10 }, - { FLD_F, UNIT_HZ, CH0, CMD82, 12, 2, 100 }, - { FLD_PAC, UNIT_W, CH0, CMD82, 14, 2, 10 }, - { FLD_IAC, UNIT_A, CH0, CMD82, 18, 2, 100 }, - { FLD_T, UNIT_C, CH0, CMD82, 22, 2, 10 } + { FLD_UDC, UNIT_V, CH1, CMD01, 3, 2, 10 }, + { FLD_IDC, UNIT_A, CH1, CMD01, 5, 2, 100 }, + { FLD_PDC, UNIT_W, CH1, CMD01, 7, 2, 10 }, + { FLD_YT, UNIT_KWH, CH1, CMD01, 9, 4, 1000 }, + { FLD_YD, UNIT_WH, CH1, CMD01, 13, 2, 1000 }, + { FLD_UAC, UNIT_V, CH0, CMD01, 15, 2, 10 }, + { FLD_F, UNIT_HZ, CH0, CMD82, 1, 2, 100 }, + { FLD_PAC, UNIT_W, CH0, CMD82, 3, 2, 10 }, + { FLD_IAC, UNIT_A, CH0, CMD82, 7, 2, 100 }, + { FLD_T, UNIT_C, CH0, CMD82, 11, 2, 10 } }; #define HM400_LIST_LEN (sizeof(hm400assignment) / sizeof(byteAssign_t)) @@ -78,20 +78,20 @@ const byteAssign_t hm400assignment[] = { // HM600, HM700 //------------------------------------- const byteAssign_t hm600assignment[] = { - { FLD_UDC, UNIT_V, CH1, CMD01, 14, 2, 10 }, - { FLD_IDC, UNIT_A, CH1, CMD01, 16, 2, 100 }, - { FLD_PDC, UNIT_W, CH1, CMD01, 18, 2, 10 }, - { FLD_UDC, UNIT_V, CH2, CMD01, 20, 2, 10 }, - { FLD_IDC, UNIT_A, CH2, CMD01, 22, 2, 100 }, - { FLD_PDC, UNIT_W, CH2, CMD01, 24, 2, 10 }, - { FLD_YW, UNIT_WH, CH0, CMD02, 12, 2, 1 }, - { FLD_YT, UNIT_WH, CH0, CMD02, 14, 4, 1 }, - { FLD_YD, UNIT_WH, CH1, CMD02, 18, 2, 1 }, - { FLD_YD, UNIT_WH, CH2, CMD02, 20, 2, 1 }, - { FLD_UAC, UNIT_V, CH0, CMD02, 22, 2, 10 }, - { FLD_F, UNIT_HZ, CH0, CMD02, 24, 2, 100 }, - { FLD_IAC, UNIT_A, CH0, CMD02, 26, 2, 10 }, - { FLD_T, UNIT_C, CH0, CMD83, 18, 2, 10 } + { FLD_UDC, UNIT_V, CH1, CMD01, 3, 2, 10 }, + { FLD_IDC, UNIT_A, CH1, CMD01, 5, 2, 100 }, + { FLD_PDC, UNIT_W, CH1, CMD01, 7, 2, 10 }, + { FLD_UDC, UNIT_V, CH2, CMD01, 9, 2, 10 }, + { FLD_IDC, UNIT_A, CH2, CMD01, 11, 2, 100 }, + { FLD_PDC, UNIT_W, CH2, CMD01, 13, 2, 10 }, + { FLD_YW, UNIT_WH, CH0, CMD02, 1, 2, 1 }, + { FLD_YT, UNIT_KWH, CH0, CMD02, 3, 4, 1000 }, + { FLD_YD, UNIT_WH, CH1, CMD02, 7, 2, 1 }, + { FLD_YD, UNIT_WH, CH2, CMD02, 9, 2, 1 }, + { FLD_UAC, UNIT_V, CH0, CMD02, 11, 2, 10 }, + { FLD_F, UNIT_HZ, CH0, CMD02, 13, 2, 100 }, + { FLD_IAC, UNIT_A, CH0, CMD02, 15, 2, 10 }, + { FLD_T, UNIT_C, CH0, CMD83, 7, 2, 10 } }; #define HM600_LIST_LEN (sizeof(hm600assignment) / sizeof(byteAssign_t)) diff --git a/tools/esp8266/hmRadio.h b/tools/esp8266/hmRadio.h index 02989ec9..65a098a5 100644 --- a/tools/esp8266/hmRadio.h +++ b/tools/esp8266/hmRadio.h @@ -64,7 +64,7 @@ class HmRadio { ~HmRadio() {} void setup(BUFFER *ctrl) { - //Serial.println("HmRadio::setup, pins: " + String(pinCs) + ", " + String(pinCe) + ", " + String(pinIrq)); + //DPRINTLN("HmRadio::setup, pins: " + String(pinCs) + ", " + String(pinCe) + ", " + String(pinIrq)); pinMode(pinIrq, INPUT_PULLUP); mBufCtrl = ctrl; @@ -84,14 +84,18 @@ class HmRadio { // enable only receiving interrupts mNrf24.maskIRQ(true, true, false); - Serial.println("RF24 Amp Pwr: RF24_PA_" + String(rf24AmpPower[AmplifierPower])); + DPRINTLN("RF24 Amp Pwr: RF24_PA_" + String(rf24AmpPower[AmplifierPower])); mNrf24.setPALevel(AmplifierPower & 0x03); mNrf24.startListening(); - Serial.println("Radio Config:"); + DPRINTLN("Radio Config:"); mNrf24.printPrettyDetails(); mSendChannel = getDefaultChannel(); + + if(!mNrf24.isChipConnected()) { + DPRINTLN("WARNING! your NRF24 module can't be reached, check the wiring"); + } } void handleIntr(void) { @@ -182,6 +186,21 @@ class HmRadio { return valid; } + void dumpBuf(const char *info, uint8_t buf[], uint8_t len) { + DPRINT(String(info)); + for(uint8_t i = 0; i < len; i++) { + if(buf[i] < 10) + DPRINT("0"); + DHEX(buf[i]); + DPRINT(" "); + } + DPRINTLN(""); + } + + bool isChipConnected(void) { + return mNrf24.isChipConnected(); + } + uint8_t pinCs; uint8_t pinCe; uint8_t pinIrq; @@ -190,7 +209,7 @@ class HmRadio { private: void sendPacket(uint64_t invId, uint8_t buf[], uint8_t len) { - //Serial.println("sent packet: #" + String(mSendCnt)); + //DPRINTLN("sent packet: #" + String(mSendCnt)); //dumpBuf("SEN ", buf, len); DISABLE_IRQ; @@ -202,7 +221,7 @@ class HmRadio { mSendChannel = getDefaultChannel(); #endif mNrf24.setChannel(mSendChannel); - //Serial.println("CH: " + String(mSendChannel)); + //DPRINTLN("CH: " + String(mSendChannel)); mNrf24.openWritingPipe(invId); // TODO: deprecated mNrf24.setCRCLength(RF24_CRC_16); @@ -237,15 +256,6 @@ class HmRadio { mDtuIdCrc = crc16nrf24(tmp, BIT_CNT(5)); } - void dumpBuf(const char *info, uint8_t buf[], uint8_t len) { - Serial.print(String(info)); - for(uint8_t i = 0; i < len; i++) { - Serial.print(buf[i], HEX); - Serial.print(" "); - } - Serial.println(); - } - uint8_t mChanOut[4]; uint8_t mChanIdx; uint16_t mDtuIdCrc; diff --git a/tools/esp8266/html/h/setup_html.h b/tools/esp8266/html/h/setup_html.h index 83000eb7..95f1236f 100644 --- a/tools/esp8266/html/h/setup_html.h +++ b/tools/esp8266/html/h/setup_html.h @@ -1,4 +1,4 @@ #ifndef __SETUP_H__ #define __SETUP_H__ -const char setup_html[] PROGMEM = "Setup - {DEVICE}

Setup

Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.

WiFi

Device Host Name

ERASE SETTINGS (not WiFi)

Inverter

{INVERTERS}

General

Pinout (Wemos)

{PINOUT}

Radio (NRF24L01+)

MQTT

 

Home

Update Firmware

AHOY - {VERSION}

"; +const char setup_html[] PROGMEM = "Setup - {DEVICE}

Setup

Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.

WiFi

Device Host Name

ERASE SETTINGS (not WiFi)

Inverter

{INVERTERS}

General

Pinout (Wemos)

{PINOUT}

Radio (NRF24L01+)

MQTT

 

Home

Update Firmware

AHOY - {VERSION}

"; #endif /*__SETUP_H__*/ diff --git a/tools/esp8266/html/setup.html b/tools/esp8266/html/setup.html index 93f91b6e..5103c412 100644 --- a/tools/esp8266/html/setup.html +++ b/tools/esp8266/html/setup.html @@ -41,6 +41,8 @@

MQTT

+ + diff --git a/tools/esp8266/mqtt.h b/tools/esp8266/mqtt.h index b3247d14..4f9bc4b7 100644 --- a/tools/esp8266/mqtt.h +++ b/tools/esp8266/mqtt.h @@ -20,9 +20,9 @@ class mqtt { delete mClient; } - void setup(const char *broker, const char *topic, const char *user, const char *pwd) { + void setup(const char *broker, const char *topic, const char *user, const char *pwd, uint16_t port) { mAddressSet = true; - mClient->setServer(broker, 1883); + mClient->setServer(broker, port); snprintf(mUser, MQTT_USER_LEN, "%s", user); snprintf(mPwd, MQTT_PWD_LEN, "%s", pwd);