added DEBUG_FLAGs to config.h

This commit is contained in:
stefan123t 2022-06-16 11:28:49 +02:00
parent e05d2220cb
commit 20c145013e
7 changed files with 161 additions and 0 deletions

View file

@ -49,7 +49,9 @@ template <uint8_t CE_PIN, uint8_t CS_PIN, uint8_t IRQ_PIN, class BUFFER, uint64_
class HmRadio {
public:
HmRadio() : mNrf24(CE_PIN, CS_PIN, SPI_SPEED) {
#ifdef DEBUG_HMRADIO
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;
//mTxChIdx = 1;
@ -76,7 +78,9 @@ class HmRadio {
~HmRadio() {}
void setup(BUFFER *ctrl) {
#ifdef DEBUG_HMRADIO
DPRINTLN(F("hmRadio.h:setup"));
#endif
pinMode(pinIrq, INPUT_PULLUP);
mBufCtrl = ctrl;
@ -141,12 +145,16 @@ class HmRadio {
}
void handleIntr(void) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:handleIntr"));
#endif
mIrqRcvd = true;
}
uint8_t getDefaultChannel(void) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:getDefaultChannel"));
#endif
return mTxChLst[0];
}
/*uint8_t getLastChannel(void) {
@ -160,7 +168,9 @@ class HmRadio {
}*/
void sendTimePacket(uint64_t invId, uint32_t ts) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:sendTimePacket"));
#endif
sendCmdPacket(invId, 0x15, 0x80, false);
mTxBuf[10] = 0x0b; // cid
mTxBuf[11] = 0x00;
@ -176,7 +186,9 @@ class HmRadio {
}
void sendCmdPacket(uint64_t invId, uint8_t mid, uint8_t pid, bool calcCrc = true) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:sendCmdPacket"));
#endif
memset(mTxBuf, 0, MAX_RF_PAYLOAD_SIZE);
mTxBuf[0] = mid; // message id
CP_U32_BigEndian(&mTxBuf[1], (invId >> 8));
@ -189,7 +201,9 @@ class HmRadio {
}
bool checkPaketCrc(uint8_t buf[], uint8_t *len, uint8_t rxCh) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:checkPaketCrc"));
#endif
*len = (buf[0] >> 2);
if(*len > (MAX_RF_PAYLOAD_SIZE - 2))
*len = MAX_RF_PAYLOAD_SIZE - 2;
@ -204,8 +218,10 @@ class HmRadio {
}
bool switchRxCh(uint16_t addLoop = 0) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:switchRxCh"));
//DPRINT(F("R"));
#endif
mRxLoopCnt += addLoop;
if(mRxLoopCnt != 0) {
@ -220,7 +236,9 @@ class HmRadio {
}
void dumpBuf(const char *info, uint8_t buf[], uint8_t len) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:dumpBuf"));
#endif
if(NULL != info)
DPRINT(String(info));
for(uint8_t i = 0; i < len; i++) {
@ -231,7 +249,9 @@ class HmRadio {
}
bool isChipConnected(void) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:isChipConnected"));
#endif
return mNrf24.isChipConnected();
}
@ -246,9 +266,11 @@ class HmRadio {
private:
void sendPacket(uint64_t invId, uint8_t buf[], uint8_t len, bool clear=false) {
#ifdef DEBUG_HMRADIO
//DPRINTLN(F("hmRadio.h:sendPacket"));
//DPRINTLN("sent packet: #" + String(mSendCnt));
//dumpBuf("SEN ", buf, len);
#endif
if(mSerialDebug) {
DPRINT("Transmit " + String(len) + " | ");
dumpBuf(NULL, buf, len);