mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-16 10:26:10 +02:00
added DBGXXX definitions to all header files
This commit is contained in:
parent
14c46e86bd
commit
17b186ee04
6 changed files with 91 additions and 184 deletions
|
@ -11,6 +11,12 @@
|
||||||
#include "hmSystem.h"
|
#include "hmSystem.h"
|
||||||
#include "mqtt.h"
|
#include "mqtt.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG_APP
|
||||||
|
#define DBGAPP(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
||||||
|
#else
|
||||||
|
#define DBGAPP(x...) do { (void)0; } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef CircularBuffer<packet_t, PACKET_BUFFER_SIZE> BufferType;
|
typedef CircularBuffer<packet_t, PACKET_BUFFER_SIZE> BufferType;
|
||||||
typedef HmRadio<RF24_CE_PIN, RF24_CS_PIN, RF24_IRQ_PIN, BufferType> RadioType;
|
typedef HmRadio<RF24_CE_PIN, RF24_CS_PIN, RF24_IRQ_PIN, BufferType> RadioType;
|
||||||
typedef Inverter<float> InverterType;
|
typedef Inverter<float> InverterType;
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
|
|
||||||
#include "hmDefines.h"
|
#include "hmDefines.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG_HMINVERTER
|
||||||
|
#define DBGINV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
||||||
|
#else
|
||||||
|
#define DBGINV(x...) do { (void)0; } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For values which are of interest and not transmitted by the inverter can be
|
* For values which are of interest and not transmitted by the inverter can be
|
||||||
* calculated automatically.
|
* calculated automatically.
|
||||||
|
@ -82,9 +88,7 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(void) {
|
void init(void) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
DBGINV(F("hmInverter.h:init"));
|
||||||
DPRINTLN(F("hmInverter.h:init"));
|
|
||||||
#endif
|
|
||||||
getAssignment();
|
getAssignment();
|
||||||
toRadioId();
|
toRadioId();
|
||||||
record = new RECORDTYPE[listLen];
|
record = new RECORDTYPE[listLen];
|
||||||
|
@ -94,9 +98,7 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId) {
|
uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:getPosByChFld"));
|
||||||
//DPRINTLN(F("hmInverter.h:getPosByChFld"));
|
|
||||||
#endif
|
|
||||||
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))
|
||||||
|
@ -106,30 +108,22 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getFieldName(uint8_t pos) {
|
const char *getFieldName(uint8_t pos) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:getFieldName"));
|
||||||
//DPRINTLN(F("hmInverter.h:getFieldName"));
|
|
||||||
#endif
|
|
||||||
return fields[assign[pos].fieldId];
|
return fields[assign[pos].fieldId];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getUnit(uint8_t pos) {
|
const char *getUnit(uint8_t pos) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:getUnit"));
|
||||||
//DPRINTLN(F("hmInverter.h:getUnit"));
|
|
||||||
#endif
|
|
||||||
return units[assign[pos].unitId];
|
return units[assign[pos].unitId];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getChannel(uint8_t pos) {
|
uint8_t getChannel(uint8_t pos) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:getChannel"));
|
||||||
//DPRINTLN(F("hmInverter.h:getChannel"));
|
|
||||||
#endif
|
|
||||||
return assign[pos].ch;
|
return assign[pos].ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addValue(uint8_t pos, uint8_t buf[]) {
|
void addValue(uint8_t pos, uint8_t buf[]) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:addValue"));
|
||||||
//DPRINTLN(F("hmInverter.h:addValue"));
|
|
||||||
#endif
|
|
||||||
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;
|
||||||
|
@ -146,16 +140,12 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
RECORDTYPE getValue(uint8_t pos) {
|
RECORDTYPE getValue(uint8_t pos) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:getValue"));
|
||||||
//DPRINTLN(F("hmInverter.h:getValue"));
|
|
||||||
#endif
|
|
||||||
return record[pos];
|
return record[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void doCalculations(void) {
|
void doCalculations(void) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:doCalculations"));
|
||||||
//DPRINTLN(F("hmInverter.h:doCalculations"));
|
|
||||||
#endif
|
|
||||||
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);
|
||||||
|
@ -164,14 +154,12 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAvailable(uint32_t timestamp) {
|
bool isAvailable(uint32_t timestamp) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:isAvailable"));
|
||||||
//DPRINTLN(F("hmInverter.h:isAvailable"));
|
|
||||||
#endif
|
|
||||||
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"));
|
//DBGINV(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);
|
||||||
|
@ -180,17 +168,13 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getLastTs(void) {
|
uint32_t getLastTs(void) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:getLastTs"));
|
||||||
//DPRINTLN(F("hmInverter.h:getLastTs"));
|
|
||||||
#endif
|
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void toRadioId(void) {
|
void toRadioId(void) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:toRadioId"));
|
||||||
//DPRINTLN(F("hmInverter.h:toRadioId"));
|
|
||||||
#endif
|
|
||||||
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];
|
||||||
|
@ -200,9 +184,7 @@ class Inverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAssignment(void) {
|
void getAssignment(void) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:getAssignment"));
|
||||||
//DPRINTLN(F("hmInverter.h:getAssignment"));
|
|
||||||
#endif
|
|
||||||
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;
|
||||||
|
@ -235,9 +217,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) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:calcYieldTotalCh0"));
|
||||||
//DPRINTLN(F("hmInverter.h:calcYieldTotalCh0"));
|
|
||||||
#endif
|
|
||||||
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++) {
|
||||||
|
@ -251,9 +231,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) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:calcYieldDayCh0"));
|
||||||
//DPRINTLN(F("hmInverter.h:calcYieldDayCh0"));
|
|
||||||
#endif
|
|
||||||
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++) {
|
||||||
|
@ -267,9 +245,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) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:calcUdcCh"));
|
||||||
//DPRINTLN(F("hmInverter.h:calcUdcCh"));
|
|
||||||
#endif
|
|
||||||
// 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)) {
|
||||||
|
@ -282,9 +258,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) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:calcPowerDcCh0"));
|
||||||
//DPRINTLN(F("hmInverter.h:calcPowerDcCh0"));
|
|
||||||
#endif
|
|
||||||
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++) {
|
||||||
|
@ -298,9 +272,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) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:calcEfficiencyCh0"));
|
||||||
//DPRINTLN(F("hmInverter.h:calcEfficiencyCh0"));
|
|
||||||
#endif
|
|
||||||
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);
|
||||||
|
@ -317,9 +289,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) {
|
||||||
#ifdef DEBUG_HMINVERTER
|
//DBGINV(F("hmInverter.h:calcIrradiation"));
|
||||||
//DPRINTLN(F("hmInverter.h:calcIrradiation"));
|
|
||||||
#endif
|
|
||||||
// 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);
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
#define RX_LOOP_CNT 300
|
#define RX_LOOP_CNT 300
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG_HMRADIO
|
||||||
|
#define DBGHMR(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
||||||
|
#else
|
||||||
|
#define DBGHMR(x...) do { (void)0; } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
const char* const rf24AmpPower[] = {"MIN", "LOW", "HIGH", "MAX"};
|
const char* const rf24AmpPower[] = {"MIN", "LOW", "HIGH", "MAX"};
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,9 +55,7 @@ template <uint8_t CE_PIN, uint8_t CS_PIN, uint8_t IRQ_PIN, class BUFFER, uint64_
|
||||||
class HmRadio {
|
class HmRadio {
|
||||||
public:
|
public:
|
||||||
HmRadio() : mNrf24(CE_PIN, CS_PIN, SPI_SPEED) {
|
HmRadio() : mNrf24(CE_PIN, CS_PIN, SPI_SPEED) {
|
||||||
#ifdef DEBUG_HMRADIO
|
DBGHMR(F("hmRadio.h : HmRadio():mNrf24(CE_PIN: ") + String(CE_PIN) + F(", CS_PIN: ") + String(CS_PIN) + F(", SPI_SPEED: ") + String(SPI_SPEED) + ")");
|
||||||
DPRINTLN(F("hmRadio.h : HmRadio():mNrf24(CE_PIN: ") + String(CE_PIN) + F(", CS_PIN: ") + String(CS_PIN) + F(", SPI_SPEED: ") + String(SPI_SPEED) + ")");
|
|
||||||
#endif
|
|
||||||
mTxChLst[0] = 40;
|
mTxChLst[0] = 40;
|
||||||
//mTxChIdx = 1;
|
//mTxChIdx = 1;
|
||||||
|
|
||||||
|
@ -78,9 +82,7 @@ class HmRadio {
|
||||||
~HmRadio() {}
|
~HmRadio() {}
|
||||||
|
|
||||||
void setup(BUFFER *ctrl) {
|
void setup(BUFFER *ctrl) {
|
||||||
#ifdef DEBUG_HMRADIO
|
DBGHMR(F("hmRadio.h:setup"));
|
||||||
DPRINTLN(F("hmRadio.h:setup"));
|
|
||||||
#endif
|
|
||||||
pinMode(pinIrq, INPUT_PULLUP);
|
pinMode(pinIrq, INPUT_PULLUP);
|
||||||
|
|
||||||
mBufCtrl = ctrl;
|
mBufCtrl = ctrl;
|
||||||
|
@ -145,16 +147,12 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleIntr(void) {
|
void handleIntr(void) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:handleIntr"));
|
||||||
//DPRINTLN(F("hmRadio.h:handleIntr"));
|
|
||||||
#endif
|
|
||||||
mIrqRcvd = true;
|
mIrqRcvd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getDefaultChannel(void) {
|
uint8_t getDefaultChannel(void) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:getDefaultChannel"));
|
||||||
//DPRINTLN(F("hmRadio.h:getDefaultChannel"));
|
|
||||||
#endif
|
|
||||||
return mTxChLst[0];
|
return mTxChLst[0];
|
||||||
}
|
}
|
||||||
/*uint8_t getLastChannel(void) {
|
/*uint8_t getLastChannel(void) {
|
||||||
|
@ -168,9 +166,7 @@ class HmRadio {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void sendTimePacket(uint64_t invId, uint32_t ts) {
|
void sendTimePacket(uint64_t invId, uint32_t ts) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:sendTimePacket"));
|
||||||
//DPRINTLN(F("hmRadio.h:sendTimePacket"));
|
|
||||||
#endif
|
|
||||||
sendCmdPacket(invId, 0x15, 0x80, false);
|
sendCmdPacket(invId, 0x15, 0x80, false);
|
||||||
mTxBuf[10] = 0x0b; // cid
|
mTxBuf[10] = 0x0b; // cid
|
||||||
mTxBuf[11] = 0x00;
|
mTxBuf[11] = 0x00;
|
||||||
|
@ -186,9 +182,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) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:sendCmdPacket"));
|
||||||
//DPRINTLN(F("hmRadio.h:sendCmdPacket"));
|
|
||||||
#endif
|
|
||||||
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));
|
||||||
|
@ -201,9 +195,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) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:checkPaketCrc"));
|
||||||
//DPRINTLN(F("hmRadio.h:checkPaketCrc"));
|
|
||||||
#endif
|
|
||||||
*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;
|
||||||
|
@ -218,10 +210,8 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool switchRxCh(uint16_t addLoop = 0) {
|
bool switchRxCh(uint16_t addLoop = 0) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:switchRxCh"));
|
||||||
//DPRINTLN(F("hmRadio.h:switchRxCh"));
|
//DBGHMR(F("R"));
|
||||||
//DPRINT(F("R"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mRxLoopCnt += addLoop;
|
mRxLoopCnt += addLoop;
|
||||||
if(mRxLoopCnt != 0) {
|
if(mRxLoopCnt != 0) {
|
||||||
|
@ -236,9 +226,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) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:dumpBuf"));
|
||||||
//DPRINTLN(F("hmRadio.h:dumpBuf"));
|
|
||||||
#endif
|
|
||||||
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++) {
|
||||||
|
@ -249,9 +237,7 @@ class HmRadio {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isChipConnected(void) {
|
bool isChipConnected(void) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:isChipConnected"));
|
||||||
//DPRINTLN(F("hmRadio.h:isChipConnected"));
|
|
||||||
#endif
|
|
||||||
return mNrf24.isChipConnected();
|
return mNrf24.isChipConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,11 +252,9 @@ 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) {
|
||||||
#ifdef DEBUG_HMRADIO
|
//DBGHMR(F("hmRadio.h:sendPacket"));
|
||||||
//DPRINTLN(F("hmRadio.h:sendPacket"));
|
//DBGHMR("sent packet: #" + String(mSendCnt));
|
||||||
//DPRINTLN("sent packet: #" + String(mSendCnt));
|
|
||||||
//dumpBuf("SEN ", buf, len);
|
//dumpBuf("SEN ", buf, len);
|
||||||
#endif
|
|
||||||
if(mSerialDebug) {
|
if(mSerialDebug) {
|
||||||
DPRINT("Transmit " + String(len) + " | ");
|
DPRINT("Transmit " + String(len) + " | ");
|
||||||
dumpBuf(NULL, buf, len);
|
dumpBuf(NULL, buf, len);
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
#include "hmRadio.h"
|
#include "hmRadio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_HMSYSTEM
|
||||||
|
#define DBGHMS(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
||||||
|
#else
|
||||||
|
#define DBGHMS(x...) do { (void)0; } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class RADIO, class BUFFER, uint8_t MAX_INVERTER=3, class INVERTERTYPE=Inverter<float>>
|
template <class RADIO, class BUFFER, uint8_t MAX_INVERTER=3, class INVERTERTYPE=Inverter<float>>
|
||||||
class HmSystem {
|
class HmSystem {
|
||||||
|
@ -24,16 +28,12 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
#ifdef DEBUG_HMSYSTEM
|
DBGHMS(F("hmSystem.h:setup"));
|
||||||
DPRINTLN(F("hmSystem.h:setup"));
|
|
||||||
#endif
|
|
||||||
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[]) {
|
||||||
#ifdef DEBUG_HMSYSTEM
|
DBGHMS(F("hmSystem.h:addInverter"));
|
||||||
DPRINTLN(F("hmSystem.h:addInverter"));
|
|
||||||
#endif
|
|
||||||
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;
|
||||||
|
@ -70,9 +70,7 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
INVERTERTYPE *findInverter(uint8_t buf[]) {
|
INVERTERTYPE *findInverter(uint8_t buf[]) {
|
||||||
#ifdef DEBUG_HMSYSTEM
|
//DBGHMS(F("hmSystem.h:findInverter"));
|
||||||
//DPRINTLN(F("hmSystem.h:findInverter"));
|
|
||||||
#endif
|
|
||||||
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];
|
||||||
|
@ -86,9 +84,7 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
INVERTERTYPE *getInverterByPos(uint8_t pos) {
|
INVERTERTYPE *getInverterByPos(uint8_t pos) {
|
||||||
#ifdef DEBUG_HMSYSTEM
|
//DBGHMS(F("hmSystem.h:getInverterByPos"));
|
||||||
//DPRINTLN(F("hmSystem.h:getInverterByPos"));
|
|
||||||
#endif
|
|
||||||
if(mInverter[pos].serial.u64 != 0ULL)
|
if(mInverter[pos].serial.u64 != 0ULL)
|
||||||
return &mInverter[pos];
|
return &mInverter[pos];
|
||||||
else
|
else
|
||||||
|
@ -96,9 +92,7 @@ class HmSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getNumInverters(void) {
|
uint8_t getNumInverters(void) {
|
||||||
#ifdef DEBUG_HMSYSTEM
|
//DBGHMS(F("hmSystem.h:getNumInverters"));
|
||||||
//DPRINTLN(F("hmSystem.h:getNumInverters"));
|
|
||||||
#endif
|
|
||||||
return mNumInv;
|
return mNumInv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,7 @@ Main::Main(void) {
|
||||||
|
|
||||||
mEep = new eep();
|
mEep = new eep();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::Main"));
|
||||||
DPRINTLN(F("Main::Main"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mUptimeSecs = 0;
|
mUptimeSecs = 0;
|
||||||
mUptimeTicker = 0xffffffff;
|
mUptimeTicker = 0xffffffff;
|
||||||
|
@ -42,9 +40,7 @@ Main::Main(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::setup(uint32_t timeout) {
|
void Main::setup(uint32_t timeout) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::setup"));
|
||||||
DPRINTLN(F("Main::setup"));
|
|
||||||
#endif
|
|
||||||
bool startAp = mApActive;
|
bool startAp = mApActive;
|
||||||
mLimit = timeout;
|
mLimit = timeout;
|
||||||
|
|
||||||
|
@ -73,9 +69,7 @@ void Main::setup(uint32_t timeout) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::loop(void) {
|
void Main::loop(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("M"));
|
||||||
//DPRINT(F("M"));
|
|
||||||
#endif
|
|
||||||
if(mApActive) {
|
if(mApActive) {
|
||||||
mDns->processNextRequest();
|
mDns->processNextRequest();
|
||||||
#ifndef AP_ONLY
|
#ifndef AP_ONLY
|
||||||
|
@ -124,9 +118,7 @@ void Main::loop(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Main::getConfig(void) {
|
bool Main::getConfig(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::getConfig"));
|
||||||
DPRINTLN(F("Main::getConfig"));
|
|
||||||
#endif
|
|
||||||
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);
|
||||||
|
@ -149,9 +141,7 @@ bool Main::getConfig(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::setupAp(const char *ssid, const char *pwd) {
|
void Main::setupAp(const char *ssid, const char *pwd) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::setupAp"));
|
||||||
DPRINTLN(F("Main::setupAp"));
|
|
||||||
#endif
|
|
||||||
IPAddress apIp(192, 168, 1, 1);
|
IPAddress apIp(192, 168, 1, 1);
|
||||||
|
|
||||||
DPRINTLN(F("\n---------\nAP MODE\nSSDI: ")
|
DPRINTLN(F("\n---------\nAP MODE\nSSDI: ")
|
||||||
|
@ -159,9 +149,7 @@ void Main::setupAp(const char *ssid, const char *pwd) {
|
||||||
+ String(pwd) + F("\nActive for: ")
|
+ String(pwd) + F("\nActive for: ")
|
||||||
+ String(WIFI_AP_ACTIVE_TIME) + F(" seconds")
|
+ String(WIFI_AP_ACTIVE_TIME) + F(" seconds")
|
||||||
+ F("\n---------\n"));
|
+ F("\n---------\n"));
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN("DBG: " + String(mNextTryTs));
|
||||||
DPRINTLN("DBG: " + String(mNextTryTs));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
WiFi.softAPConfig(apIp, apIp, IPAddress(255, 255, 255, 0));
|
WiFi.softAPConfig(apIp, apIp, IPAddress(255, 255, 255, 0));
|
||||||
|
@ -180,9 +168,7 @@ void Main::setupAp(const char *ssid, const char *pwd) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Main::setupStation(uint32_t timeout) {
|
bool Main::setupStation(uint32_t timeout) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::setupStation"));
|
||||||
DPRINTLN(F("Main::setupStation"));
|
|
||||||
#endif
|
|
||||||
int32_t cnt;
|
int32_t cnt;
|
||||||
bool startAp = false;
|
bool startAp = false;
|
||||||
|
|
||||||
|
@ -232,9 +218,7 @@ bool Main::setupStation(uint32_t timeout) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showSetup(void) {
|
void Main::showSetup(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::showSetup"));
|
||||||
DPRINTLN(F("Main::showSetup"));
|
|
||||||
#endif
|
|
||||||
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)
|
||||||
|
@ -252,9 +236,7 @@ void Main::showSetup(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showCss(void) {
|
void Main::showCss(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::showCss"));
|
||||||
DPRINTLN(F("Main::showCss"));
|
|
||||||
#endif
|
|
||||||
mWeb->send(200, "text/css", FPSTR(style_css));
|
mWeb->send(200, "text/css", FPSTR(style_css));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,9 +252,7 @@ void Main::showSave(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::saveValues(bool webSend = true) {
|
void Main::saveValues(bool webSend = true) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::saveValues"));
|
||||||
DPRINTLN(F("Main::saveValues"));
|
|
||||||
#endif
|
|
||||||
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);
|
||||||
|
@ -306,9 +286,7 @@ void Main::saveValues(bool webSend = true) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::updateCrc(void) {
|
void Main::updateCrc(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::updateCrc"));
|
||||||
DPRINTLN(F("Main::updateCrc"));
|
|
||||||
#endif
|
|
||||||
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));
|
||||||
|
@ -319,9 +297,7 @@ void Main::updateCrc(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showUptime(void) {
|
void Main::showUptime(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("Main::showUptime"));
|
||||||
//DPRINTLN(F("Main::showUptime"));
|
|
||||||
#endif
|
|
||||||
char time[20] = {0};
|
char time[20] = {0};
|
||||||
|
|
||||||
int upTimeSc = uint32_t((mUptimeSecs) % 60);
|
int upTimeSc = uint32_t((mUptimeSecs) % 60);
|
||||||
|
@ -337,18 +313,14 @@ void Main::showUptime(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showTime(void) {
|
void Main::showTime(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("Main::showTime"));
|
||||||
//DPRINTLN(F("Main::showTime"));
|
|
||||||
#endif
|
|
||||||
mWeb->send(200, "text/plain", getDateTimeStr(mTimestamp));
|
mWeb->send(200, "text/plain", getDateTimeStr(mTimestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showNotFound(void) {
|
void Main::showNotFound(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::showNotFound - ") + mWeb->uri());
|
||||||
DPRINTLN(F("Main::showNotFound - ") + mWeb->uri());
|
|
||||||
#endif
|
|
||||||
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: ");
|
||||||
|
@ -367,9 +339,7 @@ void Main::showNotFound(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showReboot(void) {
|
void Main::showReboot(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::showReboot"));
|
||||||
DPRINTLN(F("Main::showReboot"));
|
|
||||||
#endif
|
|
||||||
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();
|
||||||
|
@ -379,9 +349,7 @@ void Main::showReboot(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::showFactoryRst(void) {
|
void Main::showFactoryRst(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("Main::showFactoryRst"));
|
||||||
DPRINTLN(F("Main::showFactoryRst"));
|
|
||||||
#endif
|
|
||||||
String content = "";
|
String content = "";
|
||||||
int refresh = 3;
|
int refresh = 3;
|
||||||
if(mWeb->args() > 0) {
|
if(mWeb->args() > 0) {
|
||||||
|
@ -410,9 +378,7 @@ void Main::showFactoryRst(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
time_t Main::getNtpTime(void) {
|
time_t Main::getNtpTime(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("Main::getNtpTime"));
|
||||||
//DPRINTLN(F("Main::getNtpTime"));
|
|
||||||
#endif
|
|
||||||
time_t date = 0;
|
time_t date = 0;
|
||||||
IPAddress timeServer;
|
IPAddress timeServer;
|
||||||
uint8_t buf[NTP_PACKET_SIZE];
|
uint8_t buf[NTP_PACKET_SIZE];
|
||||||
|
@ -450,9 +416,7 @@ time_t Main::getNtpTime(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Main::sendNTPpacket(IPAddress& address) {
|
void Main::sendNTPpacket(IPAddress& address) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("Main::sendNTPpacket"));
|
||||||
//DPRINTLN(F("Main::sendNTPpacket"));
|
|
||||||
#endif
|
|
||||||
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
|
||||||
|
@ -473,9 +437,7 @@ void Main::sendNTPpacket(IPAddress& address) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
String Main::getDateTimeStr(time_t t) {
|
String Main::getDateTimeStr(time_t t) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("Main::getDateTimeStr"));
|
||||||
//DPRINTLN(F("Main::getDateTimeStr"));
|
|
||||||
#endif
|
|
||||||
char str[20] = {0};
|
char str[20] = {0};
|
||||||
if(0 == t)
|
if(0 == t)
|
||||||
sprintf(str, "n/a");
|
sprintf(str, "n/a");
|
||||||
|
@ -489,9 +451,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) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("Main::offsetDayLightSaving"));
|
||||||
//DPRINTLN(F("Main::offsetDayLightSaving"));
|
|
||||||
#endif
|
|
||||||
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
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG_HMMAIN
|
||||||
|
#define DBGMAIN(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
||||||
|
#else
|
||||||
|
#define DBGMAIN(x...) do { (void)0; } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
const byte mDnsPort = 53;
|
const byte mDnsPort = 53;
|
||||||
|
|
||||||
|
@ -41,9 +46,7 @@ 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) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("main.h:buildEEpCrc"));
|
||||||
DPRINTLN(F("main.h:buildEEpCrc"));
|
|
||||||
#endif
|
|
||||||
uint8_t buf[32];
|
uint8_t buf[32];
|
||||||
uint16_t crc = 0xffff;
|
uint16_t crc = 0xffff;
|
||||||
uint8_t len;
|
uint8_t len;
|
||||||
|
@ -59,22 +62,16 @@ class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkEEpCrc(uint32_t start, uint32_t length, uint32_t crcPos) {
|
bool checkEEpCrc(uint32_t start, uint32_t length, uint32_t crcPos) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("main.h:checkEEpCrc"));
|
||||||
//DPRINTLN(F("main.h:checkEEpCrc"));
|
|
||||||
#endif
|
|
||||||
uint16_t crcRd, crcCheck;
|
uint16_t crcRd, crcCheck;
|
||||||
crcCheck = buildEEpCrc(start, length);
|
crcCheck = buildEEpCrc(start, length);
|
||||||
mEep->read(crcPos, &crcRd);
|
mEep->read(crcPos, &crcRd);
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN("CRC RD: " + String(crcRd, HEX) + " CRC CALC: " + String(crcCheck, HEX));
|
||||||
//DPRINTLN("CRC RD: " + String(crcRd, HEX) + " CRC CALC: " + String(crcCheck, HEX));
|
|
||||||
#endif
|
|
||||||
return (crcCheck == crcRd);
|
return (crcCheck == crcRd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void eraseSettings(bool all = false) {
|
void eraseSettings(bool all = false) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("main.h:eraseSettings"));
|
||||||
//DPRINTLN(F("main.h:eraseSettings"));
|
|
||||||
#endif
|
|
||||||
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;
|
||||||
|
@ -90,9 +87,7 @@ class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool checkTicker(uint32_t *ticker, uint32_t interval) {
|
inline bool checkTicker(uint32_t *ticker, uint32_t interval) {
|
||||||
#ifdef DEBUG_HMMAIN
|
//DBGMAIN(F("c"));
|
||||||
//DPRINT(F("c"));
|
|
||||||
#endif
|
|
||||||
uint32_t mil = millis();
|
uint32_t mil = millis();
|
||||||
if(mil >= *ticker) {
|
if(mil >= *ticker) {
|
||||||
*ticker = mil + interval;
|
*ticker = mil + interval;
|
||||||
|
@ -107,9 +102,7 @@ class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
void stats(void) {
|
void stats(void) {
|
||||||
#ifdef DEBUG_HMMAIN
|
DBGMAIN(F("main.h:stats"));
|
||||||
DPRINTLN(F("main.h:stats"));
|
|
||||||
#endif
|
|
||||||
uint32_t free;
|
uint32_t free;
|
||||||
uint16_t max;
|
uint16_t max;
|
||||||
uint8_t frag;
|
uint8_t frag;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue