mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-30 17:26:12 +02:00
add method entry debug statements
This commit is contained in:
parent
ae1272ccf0
commit
b1906f0f31
8 changed files with 90 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
app::app() : Main() {
|
app::app() : Main() {
|
||||||
|
DPRINTLN(F("app::app():Main"));
|
||||||
mSendTicker = 0xffff;
|
mSendTicker = 0xffff;
|
||||||
mSendInterval = 0;
|
mSendInterval = 0;
|
||||||
mMqttTicker = 0xffff;
|
mMqttTicker = 0xffff;
|
||||||
|
@ -40,6 +41,7 @@ app::~app(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::setup(uint32_t timeout) {
|
void app::setup(uint32_t timeout) {
|
||||||
|
DPRINTLN(F("app::setup"));
|
||||||
Main::setup(timeout);
|
Main::setup(timeout);
|
||||||
|
|
||||||
mWeb->on("/", std::bind(&app::showIndex, this));
|
mWeb->on("/", std::bind(&app::showIndex, this));
|
||||||
|
@ -150,9 +152,15 @@ void app::setup(uint32_t timeout) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::loop(void) {
|
void app::loop(void) {
|
||||||
|
//DPRINT(F("a"));
|
||||||
|
//DPRINTLN(F("a"));
|
||||||
|
//app_loops++;
|
||||||
Main::loop();
|
Main::loop();
|
||||||
|
|
||||||
if(checkTicker(&mRxTicker, 5)) {
|
if(checkTicker(&mRxTicker, 5)) {
|
||||||
|
//DPRINTLN(F("app_loops =") + String(app_loops));
|
||||||
|
//app_loops=0;
|
||||||
|
//DPRINT(F("a"));
|
||||||
bool rxRdy = mSys->Radio.switchRxCh();
|
bool rxRdy = mSys->Radio.switchRxCh();
|
||||||
|
|
||||||
if(!mSys->BufCtrl.empty()) {
|
if(!mSys->BufCtrl.empty()) {
|
||||||
|
@ -288,6 +296,7 @@ void app::loop(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::handleIntr(void) {
|
void app::handleIntr(void) {
|
||||||
|
DPRINTLN(F("app::handleIntr"));
|
||||||
mSys->Radio.handleIntr();
|
mSys->Radio.handleIntr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +304,7 @@ void app::handleIntr(void) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool app::buildPayload(uint8_t id) {
|
bool app::buildPayload(uint8_t id) {
|
||||||
//DPRINTLN("Payload");
|
//DPRINTLN("Payload");
|
||||||
|
DPRINTLN(F("app::buildPayload"));
|
||||||
uint16_t crc = 0xffff, crcRcv;
|
uint16_t crc = 0xffff, crcRcv;
|
||||||
if(mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
|
if(mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
|
||||||
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
||||||
|
@ -318,6 +328,8 @@ bool app::buildPayload(uint8_t id) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::processPayload(bool retransmit) {
|
void app::processPayload(bool retransmit) {
|
||||||
|
//DPRINTLN(F("app::processPayload"));
|
||||||
|
//DPRINT(F("p"));
|
||||||
for(uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
for(uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
||||||
Inverter<> *iv = mSys->getInverterByPos(id);
|
Inverter<> *iv = mSys->getInverterByPos(id);
|
||||||
if(NULL != iv) {
|
if(NULL != iv) {
|
||||||
|
@ -373,6 +385,7 @@ void app::processPayload(bool retransmit) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::showIndex(void) {
|
void app::showIndex(void) {
|
||||||
|
DPRINTLN(F("app::showIndex"));
|
||||||
String html = FPSTR(index_html);
|
String html = FPSTR(index_html);
|
||||||
html.replace(F("{DEVICE}"), mDeviceName);
|
html.replace(F("{DEVICE}"), mDeviceName);
|
||||||
html.replace(F("{VERSION}"), mVersion);
|
html.replace(F("{VERSION}"), mVersion);
|
||||||
|
@ -384,6 +397,7 @@ void app::showIndex(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::showSetup(void) {
|
void app::showSetup(void) {
|
||||||
|
DPRINTLN(F("app::showSetup"));
|
||||||
// overrides same method in main.cpp
|
// overrides same method in main.cpp
|
||||||
|
|
||||||
uint16_t interval;
|
uint16_t interval;
|
||||||
|
@ -512,12 +526,14 @@ void app::showSetup(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::showSave(void) {
|
void app::showSave(void) {
|
||||||
|
DPRINTLN(F("app::showSave"));
|
||||||
saveValues(true);
|
saveValues(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::showErase() {
|
void app::showErase() {
|
||||||
|
DPRINTLN(F("app::showErase"));
|
||||||
eraseSettings();
|
eraseSettings();
|
||||||
showReboot();
|
showReboot();
|
||||||
}
|
}
|
||||||
|
@ -525,6 +541,7 @@ void app::showErase() {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::showStatistics(void) {
|
void app::showStatistics(void) {
|
||||||
|
DPRINTLN(F("app::showStatistics"));
|
||||||
String content = F("Receive success: ") + String(mRxSuccess) + "\n";
|
String content = F("Receive success: ") + String(mRxSuccess) + "\n";
|
||||||
content += F("Receive fail: ") + String(mRxFailed) + "\n";
|
content += F("Receive fail: ") + String(mRxFailed) + "\n";
|
||||||
content += F("Send Cnt: ") + String(mSys->Radio.mSendCnt) + String("\n\n");
|
content += F("Send Cnt: ") + String(mSys->Radio.mSendCnt) + String("\n\n");
|
||||||
|
@ -573,6 +590,7 @@ void app::showStatistics(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::showHoymiles(void) {
|
void app::showHoymiles(void) {
|
||||||
|
DPRINTLN(F("app::showHoymiles"));
|
||||||
String html = FPSTR(hoymiles_html);
|
String html = FPSTR(hoymiles_html);
|
||||||
html.replace(F("{DEVICE}"), mDeviceName);
|
html.replace(F("{DEVICE}"), mDeviceName);
|
||||||
html.replace(F("{VERSION}"), mVersion);
|
html.replace(F("{VERSION}"), mVersion);
|
||||||
|
@ -584,6 +602,7 @@ void app::showHoymiles(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::showLiveData(void) {
|
void app::showLiveData(void) {
|
||||||
|
DPRINTLN(F("app::showLiveData"));
|
||||||
String modHtml;
|
String modHtml;
|
||||||
for(uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
for(uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
||||||
Inverter<> *iv = mSys->getInverterByPos(id);
|
Inverter<> *iv = mSys->getInverterByPos(id);
|
||||||
|
@ -655,6 +674,7 @@ void app::showLiveData(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::saveValues(bool webSend = true) {
|
void app::saveValues(bool webSend = true) {
|
||||||
|
DPRINTLN(F("app::saveValues"));
|
||||||
Main::saveValues(false); // general configuration
|
Main::saveValues(false); // general configuration
|
||||||
|
|
||||||
if(mWeb->args() > 0) {
|
if(mWeb->args() > 0) {
|
||||||
|
@ -756,6 +776,7 @@ void app::saveValues(bool webSend = true) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::updateCrc(void) {
|
void app::updateCrc(void) {
|
||||||
|
DPRINTLN(F("app::updateCrc"));
|
||||||
Main::updateCrc();
|
Main::updateCrc();
|
||||||
|
|
||||||
uint16_t crc;
|
uint16_t crc;
|
||||||
|
|
|
@ -43,6 +43,7 @@ class app : public Main {
|
||||||
void loop(void);
|
void loop(void);
|
||||||
void handleIntr(void);
|
void handleIntr(void);
|
||||||
|
|
||||||
|
uint8_t app_loops;
|
||||||
uint8_t getIrqPin(void) {
|
uint8_t getIrqPin(void) {
|
||||||
return mSys->Radio.pinIrq;
|
return mSys->Radio.pinIrq;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(void) {
|
void init(void) {
|
||||||
|
DPRINTLN(F("hmInverter.h:init"));
|
||||||
getAssignment();
|
getAssignment();
|
||||||
toRadioId();
|
toRadioId();
|
||||||
record = new RECORDTYPE[listLen];
|
record = new RECORDTYPE[listLen];
|
||||||
|
@ -89,6 +90,7 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId) {
|
uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId) {
|
||||||
|
DPRINTLN(F("hmInverter.h:getPosByChFld"));
|
||||||
uint8_t pos = 0;
|
uint8_t pos = 0;
|
||||||
for(; pos < listLen; pos++) {
|
for(; pos < listLen; pos++) {
|
||||||
if((assign[pos].ch == channel) && (assign[pos].fieldId == fieldId))
|
if((assign[pos].ch == channel) && (assign[pos].fieldId == fieldId))
|
||||||
|
@ -98,18 +100,22 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getFieldName(uint8_t pos) {
|
const char *getFieldName(uint8_t pos) {
|
||||||
|
DPRINTLN(F("hmInverter.h:getFieldName"));
|
||||||
return fields[assign[pos].fieldId];
|
return fields[assign[pos].fieldId];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getUnit(uint8_t pos) {
|
const char *getUnit(uint8_t pos) {
|
||||||
|
DPRINTLN(F("hmInverter.h:getUnit"));
|
||||||
return units[assign[pos].unitId];
|
return units[assign[pos].unitId];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getChannel(uint8_t pos) {
|
uint8_t getChannel(uint8_t pos) {
|
||||||
|
DPRINTLN(F("hmInverter.h:getChannel"));
|
||||||
return assign[pos].ch;
|
return assign[pos].ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addValue(uint8_t pos, uint8_t buf[]) {
|
void addValue(uint8_t pos, uint8_t buf[]) {
|
||||||
|
DPRINTLN(F("hmInverter.h:addValue"));
|
||||||
uint8_t ptr = assign[pos].start;
|
uint8_t ptr = assign[pos].start;
|
||||||
uint8_t end = ptr + assign[pos].num;
|
uint8_t end = ptr + assign[pos].num;
|
||||||
uint16_t div = assign[pos].div;
|
uint16_t div = assign[pos].div;
|
||||||
|
@ -126,10 +132,12 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
RECORDTYPE getValue(uint8_t pos) {
|
RECORDTYPE getValue(uint8_t pos) {
|
||||||
|
DPRINTLN(F("hmInverter.h:getValue"));
|
||||||
return record[pos];
|
return record[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void doCalculations(void) {
|
void doCalculations(void) {
|
||||||
|
DPRINTLN(F("hmInverter.h:doCalculations"));
|
||||||
for(uint8_t i = 0; i < listLen; i++) {
|
for(uint8_t i = 0; i < listLen; i++) {
|
||||||
if(CMD_CALC == assign[i].div) {
|
if(CMD_CALC == assign[i].div) {
|
||||||
record[i] = calcFunctions<RECORDTYPE>[assign[i].start].func(this, assign[i].num);
|
record[i] = calcFunctions<RECORDTYPE>[assign[i].start].func(this, assign[i].num);
|
||||||
|
@ -138,10 +146,12 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAvailable(uint32_t timestamp) {
|
bool isAvailable(uint32_t timestamp) {
|
||||||
|
DPRINTLN(F("hmInverter.h:isAvailable"));
|
||||||
return ((timestamp - ts) < INACT_THRES_SEC);
|
return ((timestamp - ts) < INACT_THRES_SEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isProducing(uint32_t timestamp) {
|
bool isProducing(uint32_t timestamp) {
|
||||||
|
DPRINTLN(F("hmInverter.h:isProducing"));
|
||||||
if(isAvailable(timestamp)) {
|
if(isAvailable(timestamp)) {
|
||||||
uint8_t pos = getPosByChFld(CH0, FLD_PAC);
|
uint8_t pos = getPosByChFld(CH0, FLD_PAC);
|
||||||
return (getValue(pos) > INACT_PWR_THRESH);
|
return (getValue(pos) > INACT_PWR_THRESH);
|
||||||
|
@ -150,11 +160,13 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getLastTs(void) {
|
uint32_t getLastTs(void) {
|
||||||
|
DPRINTLN(F("hmInverter.h:getLastTs"));
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void toRadioId(void) {
|
void toRadioId(void) {
|
||||||
|
DPRINTLN(F("hmInverter.h:toRadioId"));
|
||||||
radioId.u64 = 0ULL;
|
radioId.u64 = 0ULL;
|
||||||
radioId.b[4] = serial.b[0];
|
radioId.b[4] = serial.b[0];
|
||||||
radioId.b[3] = serial.b[1];
|
radioId.b[3] = serial.b[1];
|
||||||
|
@ -164,6 +176,7 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAssignment(void) {
|
void getAssignment(void) {
|
||||||
|
DPRINTLN(F("hmInverter.h:getAssignment"));
|
||||||
if(INV_TYPE_1CH == type) {
|
if(INV_TYPE_1CH == type) {
|
||||||
listLen = (uint8_t)(HM1CH_LIST_LEN);
|
listLen = (uint8_t)(HM1CH_LIST_LEN);
|
||||||
assign = (byteAssign_t*)hm1chAssignment;
|
assign = (byteAssign_t*)hm1chAssignment;
|
||||||
|
@ -196,6 +209,7 @@ class Inverter {
|
||||||
|
|
||||||
template<class T=float>
|
template<class T=float>
|
||||||
static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) {
|
static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
DPRINTLN(F("hmInverter.h:calcYieldTotalCh0"));
|
||||||
if(NULL != iv) {
|
if(NULL != iv) {
|
||||||
T yield = 0;
|
T yield = 0;
|
||||||
for(uint8_t i = 1; i <= iv->channels; i++) {
|
for(uint8_t i = 1; i <= iv->channels; i++) {
|
||||||
|
@ -209,6 +223,7 @@ static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
|
||||||
template<class T=float>
|
template<class T=float>
|
||||||
static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) {
|
static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
DPRINTLN(F("hmInverter.h:calcYieldDayCh0"));
|
||||||
if(NULL != iv) {
|
if(NULL != iv) {
|
||||||
T yield = 0;
|
T yield = 0;
|
||||||
for(uint8_t i = 1; i <= iv->channels; i++) {
|
for(uint8_t i = 1; i <= iv->channels; i++) {
|
||||||
|
@ -222,6 +237,7 @@ static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
|
||||||
template<class T=float>
|
template<class T=float>
|
||||||
static T calcUdcCh(Inverter<> *iv, uint8_t arg0) {
|
static T calcUdcCh(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
DPRINTLN(F("hmInverter.h:calcUdcCh"));
|
||||||
// arg0 = channel of source
|
// arg0 = channel of source
|
||||||
for(uint8_t i = 0; i < iv->listLen; i++) {
|
for(uint8_t i = 0; i < iv->listLen; i++) {
|
||||||
if((FLD_UDC == iv->assign[i].fieldId) && (arg0 == iv->assign[i].ch)) {
|
if((FLD_UDC == iv->assign[i].fieldId) && (arg0 == iv->assign[i].ch)) {
|
||||||
|
@ -234,6 +250,7 @@ static T calcUdcCh(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
|
||||||
template<class T=float>
|
template<class T=float>
|
||||||
static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) {
|
static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
DPRINTLN(F("hmInverter.h:calcPowerDcCh0"));
|
||||||
if(NULL != iv) {
|
if(NULL != iv) {
|
||||||
T dcPower = 0;
|
T dcPower = 0;
|
||||||
for(uint8_t i = 1; i <= iv->channels; i++) {
|
for(uint8_t i = 1; i <= iv->channels; i++) {
|
||||||
|
@ -247,6 +264,7 @@ static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
|
||||||
template<class T=float>
|
template<class T=float>
|
||||||
static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) {
|
static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
DPRINTLN(F("hmInverter.h:calcEfficiencyCh0"));
|
||||||
if(NULL != iv) {
|
if(NULL != iv) {
|
||||||
uint8_t pos = iv->getPosByChFld(CH0, FLD_PAC);
|
uint8_t pos = iv->getPosByChFld(CH0, FLD_PAC);
|
||||||
T acPower = iv->getValue(pos);
|
T acPower = iv->getValue(pos);
|
||||||
|
@ -263,6 +281,7 @@ static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
|
||||||
template<class T=float>
|
template<class T=float>
|
||||||
static T calcIrradiation(Inverter<> *iv, uint8_t arg0) {
|
static T calcIrradiation(Inverter<> *iv, uint8_t arg0) {
|
||||||
|
DPRINTLN(F("hmInverter.h:calcIrradiation"));
|
||||||
// arg0 = channel
|
// arg0 = channel
|
||||||
if(NULL != iv) {
|
if(NULL != iv) {
|
||||||
uint8_t pos = iv->getPosByChFld(arg0, FLD_PDC);
|
uint8_t pos = iv->getPosByChFld(arg0, FLD_PDC);
|
||||||
|
|
|
@ -74,6 +74,7 @@ class HmRadio {
|
||||||
~HmRadio() {}
|
~HmRadio() {}
|
||||||
|
|
||||||
void setup(BUFFER *ctrl) {
|
void setup(BUFFER *ctrl) {
|
||||||
|
DPRINTLN(F("hmRadio.h:setup"));
|
||||||
pinMode(pinIrq, INPUT_PULLUP);
|
pinMode(pinIrq, INPUT_PULLUP);
|
||||||
|
|
||||||
mBufCtrl = ctrl;
|
mBufCtrl = ctrl;
|
||||||
|
@ -107,6 +108,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleIntr(void) {
|
void handleIntr(void) {
|
||||||
|
DPRINTLN(F("hmRadio.h:handleIntr"));
|
||||||
uint8_t pipe, len;
|
uint8_t pipe, len;
|
||||||
packet_t *p;
|
packet_t *p;
|
||||||
|
|
||||||
|
@ -134,6 +136,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getDefaultChannel(void) {
|
uint8_t getDefaultChannel(void) {
|
||||||
|
//DPRINTLN(F("hmRadio.h:getDefaultChannel"));
|
||||||
return mTxChLst[0];
|
return mTxChLst[0];
|
||||||
}
|
}
|
||||||
/*uint8_t getLastChannel(void) {
|
/*uint8_t getLastChannel(void) {
|
||||||
|
@ -147,6 +150,7 @@ class HmRadio {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void sendTimePacket(uint64_t invId, uint32_t ts) {
|
void sendTimePacket(uint64_t invId, uint32_t ts) {
|
||||||
|
DPRINTLN(F("hmRadio.h:sendTimePacket"));
|
||||||
sendCmdPacket(invId, 0x15, 0x80, false);
|
sendCmdPacket(invId, 0x15, 0x80, false);
|
||||||
mTxBuf[10] = 0x0b; // cid
|
mTxBuf[10] = 0x0b; // cid
|
||||||
mTxBuf[11] = 0x00;
|
mTxBuf[11] = 0x00;
|
||||||
|
@ -162,6 +166,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendCmdPacket(uint64_t invId, uint8_t mid, uint8_t pid, bool calcCrc = true) {
|
void sendCmdPacket(uint64_t invId, uint8_t mid, uint8_t pid, bool calcCrc = true) {
|
||||||
|
DPRINTLN(F("hmRadio.h:sendCmdPacket"));
|
||||||
memset(mTxBuf, 0, MAX_RF_PAYLOAD_SIZE);
|
memset(mTxBuf, 0, MAX_RF_PAYLOAD_SIZE);
|
||||||
mTxBuf[0] = mid; // message id
|
mTxBuf[0] = mid; // message id
|
||||||
CP_U32_BigEndian(&mTxBuf[1], (invId >> 8));
|
CP_U32_BigEndian(&mTxBuf[1], (invId >> 8));
|
||||||
|
@ -174,6 +179,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkPaketCrc(uint8_t buf[], uint8_t *len, uint8_t rxCh) {
|
bool checkPaketCrc(uint8_t buf[], uint8_t *len, uint8_t rxCh) {
|
||||||
|
DPRINTLN(F("hmRadio.h:checkPaketCrc"));
|
||||||
*len = (buf[0] >> 2);
|
*len = (buf[0] >> 2);
|
||||||
if(*len > (MAX_RF_PAYLOAD_SIZE - 2))
|
if(*len > (MAX_RF_PAYLOAD_SIZE - 2))
|
||||||
*len = MAX_RF_PAYLOAD_SIZE - 2;
|
*len = MAX_RF_PAYLOAD_SIZE - 2;
|
||||||
|
@ -188,6 +194,8 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool switchRxCh(uint8_t addLoop = 0) {
|
bool switchRxCh(uint8_t addLoop = 0) {
|
||||||
|
//DPRINTLN(F("hmRadio.h:switchRxCh"));
|
||||||
|
//DPRINT(F("R"));
|
||||||
mRxLoopCnt += addLoop;
|
mRxLoopCnt += addLoop;
|
||||||
if(mRxLoopCnt != 0) {
|
if(mRxLoopCnt != 0) {
|
||||||
mRxLoopCnt--;
|
mRxLoopCnt--;
|
||||||
|
@ -201,6 +209,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpBuf(const char *info, uint8_t buf[], uint8_t len) {
|
void dumpBuf(const char *info, uint8_t buf[], uint8_t len) {
|
||||||
|
//DPRINTLN(F("hmRadio.h:dumpBuf"));
|
||||||
if(NULL != info)
|
if(NULL != info)
|
||||||
DPRINT(String(info));
|
DPRINT(String(info));
|
||||||
for(uint8_t i = 0; i < len; i++) {
|
for(uint8_t i = 0; i < len; i++) {
|
||||||
|
@ -211,6 +220,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isChipConnected(void) {
|
bool isChipConnected(void) {
|
||||||
|
DPRINTLN(F("hmRadio.h:isChipConnected"));
|
||||||
return mNrf24.isChipConnected();
|
return mNrf24.isChipConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,6 +235,7 @@ class HmRadio {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendPacket(uint64_t invId, uint8_t buf[], uint8_t len, bool clear=false) {
|
void sendPacket(uint64_t invId, uint8_t buf[], uint8_t len, bool clear=false) {
|
||||||
|
DPRINTLN(F("hmRadio.h:sendPacket"));
|
||||||
//DPRINTLN("sent packet: #" + String(mSendCnt));
|
//DPRINTLN("sent packet: #" + String(mSendCnt));
|
||||||
//dumpBuf("SEN ", buf, len);
|
//dumpBuf("SEN ", buf, len);
|
||||||
if(mSerialDebug) {
|
if(mSerialDebug) {
|
||||||
|
|
|
@ -24,10 +24,12 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
DPRINTLN(F("hmSystem.h:setup"));
|
||||||
Radio.setup(&BufCtrl);
|
Radio.setup(&BufCtrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
INVERTERTYPE *addInverter(const char *name, uint64_t serial, uint16_t chMaxPwr[]) {
|
INVERTERTYPE *addInverter(const char *name, uint64_t serial, uint16_t chMaxPwr[]) {
|
||||||
|
DPRINTLN(F("hmSystem.h:addInverter"));
|
||||||
if(MAX_INVERTER <= mNumInv) {
|
if(MAX_INVERTER <= mNumInv) {
|
||||||
DPRINT(F("max number of inverters reached!"));
|
DPRINT(F("max number of inverters reached!"));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -64,6 +66,7 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
INVERTERTYPE *findInverter(uint8_t buf[]) {
|
INVERTERTYPE *findInverter(uint8_t buf[]) {
|
||||||
|
DPRINTLN(F("hmSystem.h:findInverter"));
|
||||||
INVERTERTYPE *p;
|
INVERTERTYPE *p;
|
||||||
for(uint8_t i = 0; i < mNumInv; i++) {
|
for(uint8_t i = 0; i < mNumInv; i++) {
|
||||||
p = &mInverter[i];
|
p = &mInverter[i];
|
||||||
|
@ -77,6 +80,7 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
INVERTERTYPE *getInverterByPos(uint8_t pos) {
|
INVERTERTYPE *getInverterByPos(uint8_t pos) {
|
||||||
|
//DPRINTLN(F("hmSystem.h:getInverterByPos"));
|
||||||
if(mInverter[pos].serial.u64 != 0ULL)
|
if(mInverter[pos].serial.u64 != 0ULL)
|
||||||
return &mInverter[pos];
|
return &mInverter[pos];
|
||||||
else
|
else
|
||||||
|
@ -84,6 +88,7 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getNumInverters(void) {
|
uint8_t getNumInverters(void) {
|
||||||
|
//DPRINTLN(F("hmSystem.h:getNumInverters"));
|
||||||
return mNumInv;
|
return mNumInv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ Main::Main(void) {
|
||||||
|
|
||||||
mEep = new eep();
|
mEep = new eep();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
DPRINTLN(F("Main::Main"));
|
||||||
|
|
||||||
mUptimeSecs = 0;
|
mUptimeSecs = 0;
|
||||||
mUptimeTicker = 0xffffffff;
|
mUptimeTicker = 0xffffffff;
|
||||||
|
@ -39,6 +40,7 @@ Main::Main(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::setup(uint32_t timeout) {
|
void Main::setup(uint32_t timeout) {
|
||||||
|
DPRINTLN(F("Main::setup"));
|
||||||
bool startAp = mApActive;
|
bool startAp = mApActive;
|
||||||
mLimit = timeout;
|
mLimit = timeout;
|
||||||
|
|
||||||
|
@ -67,6 +69,7 @@ void Main::setup(uint32_t timeout) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::loop(void) {
|
void Main::loop(void) {
|
||||||
|
//DPRINT(F("M"));
|
||||||
if(mApActive) {
|
if(mApActive) {
|
||||||
mDns->processNextRequest();
|
mDns->processNextRequest();
|
||||||
#ifndef AP_ONLY
|
#ifndef AP_ONLY
|
||||||
|
@ -115,6 +118,7 @@ void Main::loop(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Main::getConfig(void) {
|
bool Main::getConfig(void) {
|
||||||
|
DPRINTLN(F("Main::getConfig"));
|
||||||
bool mApActive = false;
|
bool mApActive = false;
|
||||||
|
|
||||||
mWifiSettingsValid = checkEEpCrc(ADDR_START, ADDR_WIFI_CRC, ADDR_WIFI_CRC);
|
mWifiSettingsValid = checkEEpCrc(ADDR_START, ADDR_WIFI_CRC, ADDR_WIFI_CRC);
|
||||||
|
@ -137,6 +141,7 @@ bool Main::getConfig(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::setupAp(const char *ssid, const char *pwd) {
|
void Main::setupAp(const char *ssid, const char *pwd) {
|
||||||
|
DPRINTLN(F("Main::setupAp"));
|
||||||
IPAddress apIp(192, 168, 1, 1);
|
IPAddress apIp(192, 168, 1, 1);
|
||||||
|
|
||||||
DPRINTLN(F("\n---------\nAP MODE\nSSDI: ")
|
DPRINTLN(F("\n---------\nAP MODE\nSSDI: ")
|
||||||
|
@ -163,6 +168,7 @@ void Main::setupAp(const char *ssid, const char *pwd) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Main::setupStation(uint32_t timeout) {
|
bool Main::setupStation(uint32_t timeout) {
|
||||||
|
DPRINTLN(F("Main::setupStation"));
|
||||||
int32_t cnt;
|
int32_t cnt;
|
||||||
bool startAp = false;
|
bool startAp = false;
|
||||||
|
|
||||||
|
@ -212,6 +218,7 @@ bool Main::setupStation(uint32_t timeout) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showSetup(void) {
|
void Main::showSetup(void) {
|
||||||
|
DPRINTLN(F("Main::showSetup"));
|
||||||
String html = FPSTR(setup_html);
|
String html = FPSTR(setup_html);
|
||||||
html.replace(F("{SSID}"), mStationSsid);
|
html.replace(F("{SSID}"), mStationSsid);
|
||||||
// PWD will be left at the default value (for protection)
|
// PWD will be left at the default value (for protection)
|
||||||
|
@ -229,18 +236,21 @@ void Main::showSetup(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showCss(void) {
|
void Main::showCss(void) {
|
||||||
|
DPRINTLN(F("Main::showCss"));
|
||||||
mWeb->send(200, "text/css", FPSTR(style_css));
|
mWeb->send(200, "text/css", FPSTR(style_css));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showSave(void) {
|
void Main::showSave(void) {
|
||||||
|
DPRINTLN(F("Main::showSave"));
|
||||||
saveValues(true);
|
saveValues(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::saveValues(bool webSend = true) {
|
void Main::saveValues(bool webSend = true) {
|
||||||
|
DPRINTLN(F("Main::saveValues"));
|
||||||
if(mWeb->args() > 0) {
|
if(mWeb->args() > 0) {
|
||||||
if(mWeb->arg("ssid") != "") {
|
if(mWeb->arg("ssid") != "") {
|
||||||
memset(mStationSsid, 0, SSID_LEN);
|
memset(mStationSsid, 0, SSID_LEN);
|
||||||
|
@ -273,6 +283,7 @@ void Main::saveValues(bool webSend = true) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::updateCrc(void) {
|
void Main::updateCrc(void) {
|
||||||
|
DPRINTLN(F("Main::updateCrc"));
|
||||||
uint16_t crc;
|
uint16_t crc;
|
||||||
crc = buildEEpCrc(ADDR_START, ADDR_WIFI_CRC);
|
crc = buildEEpCrc(ADDR_START, ADDR_WIFI_CRC);
|
||||||
//Serial.println("new CRC: " + String(crc, HEX));
|
//Serial.println("new CRC: " + String(crc, HEX));
|
||||||
|
@ -282,6 +293,7 @@ void Main::updateCrc(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showUptime(void) {
|
void Main::showUptime(void) {
|
||||||
|
DPRINTLN(F("Main::showUptime"));
|
||||||
char time[20] = {0};
|
char time[20] = {0};
|
||||||
|
|
||||||
int upTimeSc = uint32_t((mUptimeSecs) % 60);
|
int upTimeSc = uint32_t((mUptimeSecs) % 60);
|
||||||
|
@ -297,12 +309,14 @@ void Main::showUptime(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showTime(void) {
|
void Main::showTime(void) {
|
||||||
|
DPRINTLN(F("Main::showTime"));
|
||||||
mWeb->send(200, "text/plain", getDateTimeStr(mTimestamp));
|
mWeb->send(200, "text/plain", getDateTimeStr(mTimestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showNotFound(void) {
|
void Main::showNotFound(void) {
|
||||||
|
DPRINTLN(F("Main::showNotFound"));
|
||||||
String msg = F("File Not Found\n\nURI: ");
|
String msg = F("File Not Found\n\nURI: ");
|
||||||
msg += mWeb->uri();
|
msg += mWeb->uri();
|
||||||
msg += F("\nMethod: ");
|
msg += F("\nMethod: ");
|
||||||
|
@ -321,6 +335,7 @@ void Main::showNotFound(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showReboot(void) {
|
void Main::showReboot(void) {
|
||||||
|
DPRINTLN(F("Main::showReboot"));
|
||||||
mWeb->send(200, F("text/html"), F("<!doctype html><html><head><title>Rebooting ...</title><meta http-equiv=\"refresh\" content=\"10; URL=/\"></head><body>rebooting ... auto reload after 10s</body></html>"));
|
mWeb->send(200, F("text/html"), F("<!doctype html><html><head><title>Rebooting ...</title><meta http-equiv=\"refresh\" content=\"10; URL=/\"></head><body>rebooting ... auto reload after 10s</body></html>"));
|
||||||
delay(1000);
|
delay(1000);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
|
@ -330,6 +345,7 @@ void Main::showReboot(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showFactoryRst(void) {
|
void Main::showFactoryRst(void) {
|
||||||
|
DPRINTLN(F("Main::showFactoryRst"));
|
||||||
String content = "";
|
String content = "";
|
||||||
int refresh = 3;
|
int refresh = 3;
|
||||||
if(mWeb->args() > 0) {
|
if(mWeb->args() > 0) {
|
||||||
|
@ -358,6 +374,7 @@ void Main::showFactoryRst(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
time_t Main::getNtpTime(void) {
|
time_t Main::getNtpTime(void) {
|
||||||
|
DPRINTLN(F("Main::getNtpTime"));
|
||||||
time_t date = 0;
|
time_t date = 0;
|
||||||
IPAddress timeServer;
|
IPAddress timeServer;
|
||||||
uint8_t buf[NTP_PACKET_SIZE];
|
uint8_t buf[NTP_PACKET_SIZE];
|
||||||
|
@ -395,6 +412,7 @@ time_t Main::getNtpTime(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::sendNTPpacket(IPAddress& address) {
|
void Main::sendNTPpacket(IPAddress& address) {
|
||||||
|
DPRINTLN(F("Main::sendNTPpacket"));
|
||||||
uint8_t buf[NTP_PACKET_SIZE] = {0};
|
uint8_t buf[NTP_PACKET_SIZE] = {0};
|
||||||
|
|
||||||
buf[0] = B11100011; // LI, Version, Mode
|
buf[0] = B11100011; // LI, Version, Mode
|
||||||
|
@ -415,6 +433,7 @@ void Main::sendNTPpacket(IPAddress& address) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
String Main::getDateTimeStr(time_t t) {
|
String Main::getDateTimeStr(time_t t) {
|
||||||
|
DPRINTLN(F("Main::getDateTimeStr"));
|
||||||
char str[20] = {0};
|
char str[20] = {0};
|
||||||
sprintf(str, "%04d-%02d-%02d %02d:%02d:%02d", year(t), month(t), day(t), hour(t), minute(t), second(t));
|
sprintf(str, "%04d-%02d-%02d %02d:%02d:%02d", year(t), month(t), day(t), hour(t), minute(t), second(t));
|
||||||
return String(str);
|
return String(str);
|
||||||
|
@ -425,6 +444,7 @@ String Main::getDateTimeStr(time_t t) {
|
||||||
// calculates the daylight saving time for middle Europe. Input: Unixtime in UTC
|
// calculates the daylight saving time for middle Europe. Input: Unixtime in UTC
|
||||||
// from: https://forum.arduino.cc/index.php?topic=172044.msg1278536#msg1278536
|
// from: https://forum.arduino.cc/index.php?topic=172044.msg1278536#msg1278536
|
||||||
time_t Main::offsetDayLightSaving (uint32_t local_t) {
|
time_t Main::offsetDayLightSaving (uint32_t local_t) {
|
||||||
|
DPRINTLN(F("Main::offsetDayLightSaving"));
|
||||||
int m = month (local_t);
|
int m = month (local_t);
|
||||||
if(m < 3 || m > 10) return 0; // no DSL in Jan, Feb, Nov, Dez
|
if(m < 3 || m > 10) return 0; // no DSL in Jan, Feb, Nov, Dez
|
||||||
if(m > 3 && m < 10) return 1; // DSL in Apr, May, Jun, Jul, Aug, Sep
|
if(m > 3 && m < 10) return 1; // DSL in Apr, May, Jun, Jul, Aug, Sep
|
||||||
|
|
|
@ -41,12 +41,14 @@ class Main {
|
||||||
virtual void updateCrc(void);
|
virtual void updateCrc(void);
|
||||||
|
|
||||||
inline uint16_t buildEEpCrc(uint32_t start, uint32_t length) {
|
inline uint16_t buildEEpCrc(uint32_t start, uint32_t length) {
|
||||||
|
DPRINTLN(F("main.h:buildEEpCrc"));
|
||||||
uint8_t buf[length];
|
uint8_t buf[length];
|
||||||
mEep->read(start, buf, length);
|
mEep->read(start, buf, length);
|
||||||
return crc16(buf, length);
|
return crc16(buf, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkEEpCrc(uint32_t start, uint32_t length, uint32_t crcPos) {
|
bool checkEEpCrc(uint32_t start, uint32_t length, uint32_t crcPos) {
|
||||||
|
DPRINTLN(F("main.h:checkEEpCrc"));
|
||||||
uint16_t crcRd, crcCheck;
|
uint16_t crcRd, crcCheck;
|
||||||
crcCheck = buildEEpCrc(start, length);
|
crcCheck = buildEEpCrc(start, length);
|
||||||
mEep->read(crcPos, &crcRd);
|
mEep->read(crcPos, &crcRd);
|
||||||
|
@ -55,6 +57,7 @@ class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
void eraseSettings(bool all = false) {
|
void eraseSettings(bool all = false) {
|
||||||
|
DPRINTLN(F("main.h:eraseSettings"));
|
||||||
uint8_t buf[64] = {0};
|
uint8_t buf[64] = {0};
|
||||||
uint16_t addr = (all) ? ADDR_START : ADDR_START_SETTINGS;
|
uint16_t addr = (all) ? ADDR_START : ADDR_START_SETTINGS;
|
||||||
uint16_t end;
|
uint16_t end;
|
||||||
|
@ -69,6 +72,7 @@ class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool checkTicker(uint32_t *ticker, uint32_t interval) {
|
inline bool checkTicker(uint32_t *ticker, uint32_t interval) {
|
||||||
|
//DPRINT(F("c"));
|
||||||
uint32_t mil = millis();
|
uint32_t mil = millis();
|
||||||
if(mil >= *ticker) {
|
if(mil >= *ticker) {
|
||||||
*ticker = mil + interval;
|
*ticker = mil + interval;
|
||||||
|
@ -83,6 +87,7 @@ class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
void stats(void) {
|
void stats(void) {
|
||||||
|
DPRINTLN(F("main.h:stats"));
|
||||||
uint32_t free;
|
uint32_t free;
|
||||||
uint16_t max;
|
uint16_t max;
|
||||||
uint8_t frag;
|
uint8_t frag;
|
||||||
|
|
|
@ -21,6 +21,7 @@ class mqtt {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(const char *broker, const char *topic, const char *user, const char *pwd, uint16_t port) {
|
void setup(const char *broker, const char *topic, const char *user, const char *pwd, uint16_t port) {
|
||||||
|
DPRINTLN(F("mqtt.h:setup"));
|
||||||
mAddressSet = true;
|
mAddressSet = true;
|
||||||
mClient->setServer(broker, port);
|
mClient->setServer(broker, port);
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ class mqtt {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendMsg(const char *topic, const char *msg) {
|
void sendMsg(const char *topic, const char *msg) {
|
||||||
|
DPRINTLN(F("mqtt.h:sendMsg"));
|
||||||
if(mAddressSet) {
|
if(mAddressSet) {
|
||||||
char top[64];
|
char top[64];
|
||||||
snprintf(top, 64, "%s/%s", mTopic, topic);
|
snprintf(top, 64, "%s/%s", mTopic, topic);
|
||||||
|
@ -41,24 +43,29 @@ class mqtt {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isConnected(bool doRecon = false) {
|
bool isConnected(bool doRecon = false) {
|
||||||
|
DPRINTLN(F("mqtt.h:isConnected"));
|
||||||
if(doRecon)
|
if(doRecon)
|
||||||
reconnect();
|
reconnect();
|
||||||
return mClient->connected();
|
return mClient->connected();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getUser(void) {
|
char *getUser(void) {
|
||||||
|
DPRINTLN(F("mqtt.h:getUser"));
|
||||||
return mUser;
|
return mUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getPwd(void) {
|
char *getPwd(void) {
|
||||||
|
DPRINTLN(F("mqtt.h:getPwd"));
|
||||||
return mPwd;
|
return mPwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getTopic(void) {
|
char *getTopic(void) {
|
||||||
|
DPRINTLN(F("mqtt.h:getTopic"));
|
||||||
return mTopic;
|
return mTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
//DPRINT(F("m"));
|
||||||
//if(!mClient->connected())
|
//if(!mClient->connected())
|
||||||
// reconnect();
|
// reconnect();
|
||||||
mClient->loop();
|
mClient->loop();
|
||||||
|
@ -66,6 +73,7 @@ class mqtt {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reconnect(void) {
|
void reconnect(void) {
|
||||||
|
DPRINTLN(F("mqtt.h:reconnect"));
|
||||||
if(!mClient->connected()) {
|
if(!mClient->connected()) {
|
||||||
String mqttId = "ESP-" + String(random(0xffff), HEX);
|
String mqttId = "ESP-" + String(random(0xffff), HEX);
|
||||||
if((strlen(mUser) > 0) && (strlen(mPwd) > 0))
|
if((strlen(mUser) > 0) && (strlen(mPwd) > 0))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue