mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 23:46:37 +02:00
* V0.4.15
* reduced debug messages * fixes after merge
This commit is contained in:
parent
44b31f765c
commit
2d37b2657d
7 changed files with 43 additions and 44 deletions
|
@ -301,15 +301,14 @@ void app::loop(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::handleIntr(void) {
|
void app::handleIntr(void) {
|
||||||
DPRINTLN(F("app::handleIntr"));
|
//DPRINTLN(F("app::handleIntr"));
|
||||||
mSys->Radio.handleIntr();
|
mSys->Radio.handleIntr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool app::buildPayload(uint8_t id) {
|
bool app::buildPayload(uint8_t id) {
|
||||||
//DPRINTLN("Payload");
|
//DPRINTLN(F("app::buildPayload"));
|
||||||
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;
|
||||||
|
@ -549,7 +548,7 @@ void app::showErase() {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::showStatistics(void) {
|
void app::showStatistics(void) {
|
||||||
DPRINTLN(F("app::showStatistics"));
|
//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");
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 4
|
#define VERSION_MINOR 4
|
||||||
#define VERSION_PATCH 14
|
#define VERSION_PATCH 15
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
|
|
@ -90,7 +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"));
|
//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))
|
||||||
|
@ -100,22 +100,22 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getFieldName(uint8_t pos) {
|
const char *getFieldName(uint8_t pos) {
|
||||||
DPRINTLN(F("hmInverter.h:getFieldName"));
|
//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"));
|
//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"));
|
//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"));
|
//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;
|
||||||
|
@ -132,12 +132,12 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
RECORDTYPE getValue(uint8_t pos) {
|
RECORDTYPE getValue(uint8_t pos) {
|
||||||
DPRINTLN(F("hmInverter.h:getValue"));
|
//DPRINTLN(F("hmInverter.h:getValue"));
|
||||||
return record[pos];
|
return record[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void doCalculations(void) {
|
void doCalculations(void) {
|
||||||
DPRINTLN(F("hmInverter.h:doCalculations"));
|
//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);
|
||||||
|
@ -146,12 +146,12 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAvailable(uint32_t timestamp) {
|
bool isAvailable(uint32_t timestamp) {
|
||||||
DPRINTLN(F("hmInverter.h:isAvailable"));
|
//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"));
|
//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);
|
||||||
|
@ -160,13 +160,13 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getLastTs(void) {
|
uint32_t getLastTs(void) {
|
||||||
DPRINTLN(F("hmInverter.h:getLastTs"));
|
//DPRINTLN(F("hmInverter.h:getLastTs"));
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void toRadioId(void) {
|
void toRadioId(void) {
|
||||||
DPRINTLN(F("hmInverter.h:toRadioId"));
|
//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];
|
||||||
|
@ -176,7 +176,7 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAssignment(void) {
|
void getAssignment(void) {
|
||||||
DPRINTLN(F("hmInverter.h:getAssignment"));
|
//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;
|
||||||
|
@ -209,7 +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"));
|
//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++) {
|
||||||
|
@ -223,7 +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"));
|
//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++) {
|
||||||
|
@ -237,7 +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"));
|
//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)) {
|
||||||
|
@ -250,7 +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"));
|
//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++) {
|
||||||
|
@ -264,7 +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"));
|
//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);
|
||||||
|
@ -281,7 +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"));
|
//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);
|
||||||
|
|
|
@ -141,7 +141,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleIntr(void) {
|
void handleIntr(void) {
|
||||||
DPRINTLN(F("hmRadio.h:handleIntr"));
|
//DPRINTLN(F("hmRadio.h:handleIntr"));
|
||||||
mIrqRcvd = true;
|
mIrqRcvd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ class HmRadio {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void sendTimePacket(uint64_t invId, uint32_t ts) {
|
void sendTimePacket(uint64_t invId, uint32_t ts) {
|
||||||
DPRINTLN(F("hmRadio.h:sendTimePacket"));
|
//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;
|
||||||
|
@ -176,7 +176,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"));
|
//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));
|
||||||
|
@ -189,7 +189,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"));
|
//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;
|
||||||
|
@ -203,7 +203,7 @@ class HmRadio {
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool switchRxCh(uint8_t addLoop = 0) {
|
bool switchRxCh(uint16_t addLoop = 0) {
|
||||||
//DPRINTLN(F("hmRadio.h:switchRxCh"));
|
//DPRINTLN(F("hmRadio.h:switchRxCh"));
|
||||||
//DPRINT(F("R"));
|
//DPRINT(F("R"));
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isChipConnected(void) {
|
bool isChipConnected(void) {
|
||||||
DPRINTLN(F("hmRadio.h:isChipConnected"));
|
//DPRINTLN(F("hmRadio.h:isChipConnected"));
|
||||||
return mNrf24.isChipConnected();
|
return mNrf24.isChipConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,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(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) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
INVERTERTYPE *findInverter(uint8_t buf[]) {
|
INVERTERTYPE *findInverter(uint8_t buf[]) {
|
||||||
DPRINTLN(F("hmSystem.h:findInverter"));
|
//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];
|
||||||
|
|
|
@ -293,7 +293,7 @@ void Main::updateCrc(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showUptime(void) {
|
void Main::showUptime(void) {
|
||||||
DPRINTLN(F("Main::showUptime"));
|
//DPRINTLN(F("Main::showUptime"));
|
||||||
char time[20] = {0};
|
char time[20] = {0};
|
||||||
|
|
||||||
int upTimeSc = uint32_t((mUptimeSecs) % 60);
|
int upTimeSc = uint32_t((mUptimeSecs) % 60);
|
||||||
|
@ -309,14 +309,14 @@ void Main::showUptime(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showTime(void) {
|
void Main::showTime(void) {
|
||||||
DPRINTLN(F("Main::showTime"));
|
//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"));
|
DPRINTLN(F("Main::showNotFound - ") + mWeb->uri());
|
||||||
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: ");
|
||||||
|
@ -374,7 +374,7 @@ void Main::showFactoryRst(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
time_t Main::getNtpTime(void) {
|
time_t Main::getNtpTime(void) {
|
||||||
DPRINTLN(F("Main::getNtpTime"));
|
//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];
|
||||||
|
@ -412,7 +412,7 @@ time_t Main::getNtpTime(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::sendNTPpacket(IPAddress& address) {
|
void Main::sendNTPpacket(IPAddress& address) {
|
||||||
DPRINTLN(F("Main::sendNTPpacket"));
|
//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
|
||||||
|
@ -433,7 +433,7 @@ void Main::sendNTPpacket(IPAddress& address) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
String Main::getDateTimeStr(time_t t) {
|
String Main::getDateTimeStr(time_t t) {
|
||||||
DPRINTLN(F("Main::getDateTimeStr"));
|
//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);
|
||||||
|
@ -444,7 +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"));
|
//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
|
||||||
|
|
|
@ -31,7 +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"));
|
//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);
|
||||||
|
@ -44,24 +44,24 @@ class mqtt {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isConnected(bool doRecon = false) {
|
bool isConnected(bool doRecon = false) {
|
||||||
DPRINTLN(F("mqtt.h:isConnected"));
|
//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"));
|
//DPRINTLN(F("mqtt.h:getUser"));
|
||||||
return mUser;
|
return mUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getPwd(void) {
|
char *getPwd(void) {
|
||||||
DPRINTLN(F("mqtt.h:getPwd"));
|
//DPRINTLN(F("mqtt.h:getPwd"));
|
||||||
return mPwd;
|
return mPwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getTopic(void) {
|
char *getTopic(void) {
|
||||||
DPRINTLN(F("mqtt.h:getTopic"));
|
//DPRINTLN(F("mqtt.h:getTopic"));
|
||||||
return mTopic;
|
return mTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class mqtt {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reconnect(void) {
|
void reconnect(void) {
|
||||||
DPRINTLN(F("mqtt.h:reconnect"));
|
//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