diff --git a/src/WeatherSensor.cpp b/src/WeatherSensor.cpp index 29afc7a1..33be6651 100644 --- a/src/WeatherSensor.cpp +++ b/src/WeatherSensor.cpp @@ -62,7 +62,6 @@ // 20230613 Fixed rain value in 7 in 1 decoder // 20230708 Added startup flag in 6-in-1 and 7-in-1 decoder; added sensor type in 7-in-1 decoder // 20230710 Added verbose log message with de-whitened data (7-in-1 and lightning decoder) -// 20230716 Added decodeMessage() to separate decoding function from receiving function // // ToDo: // - @@ -232,7 +231,32 @@ DecodeStatus WeatherSensor::getMessage(void) #endif log_d("%s R [%02X] RSSI: %0.1f", RECEIVER_CHIP, recvData[0], rssi); - decode_res = decodeMessage(recvData, sizeof(recvData)); + #ifdef BRESSER_7_IN_1 + decode_res = decodeBresser7In1Payload(&recvData[1], sizeof(recvData) - 1); + #endif + #ifdef BRESSER_6_IN_1 + if (decode_res == DECODE_INVALID || + decode_res == DECODE_PAR_ERR || + decode_res == DECODE_CHK_ERR || + decode_res == DECODE_DIG_ERR) { + decode_res = decodeBresser6In1Payload(&recvData[1], sizeof(recvData) - 1); + } + #endif + #ifdef BRESSER_5_IN_1 + if (decode_res == DECODE_INVALID || + decode_res == DECODE_PAR_ERR || + decode_res == DECODE_CHK_ERR || + decode_res == DECODE_DIG_ERR) { + decode_res = decodeBresser5In1Payload(&recvData[1], sizeof(recvData) - 1); + } + #endif + #ifdef BRESSER_LIGHTNING + if (decode_res == DECODE_INVALID || + decode_res == DECODE_PAR_ERR || + decode_res == DECODE_CHK_ERR) { + decode_res = decodeBresserLightningPayload(&recvData[1], sizeof(recvData) - 1); + } + #endif } // if (recvData[0] == 0xD4) else if (state == RADIOLIB_ERR_RX_TIMEOUT) { log_v("T"); @@ -246,40 +270,6 @@ DecodeStatus WeatherSensor::getMessage(void) return decode_res; } - -DecodeStatus WeatherSensor::decodeMessage(uint8_t *msg, uint8_t msgSize) { - DecodeStatus decode_res = DECODE_INVALID; - - #ifdef BRESSER_7_IN_1 - decode_res = decodeBresser7In1Payload(&recvData[1], sizeof(recvData) - 1); - if (decode_res == DECODE_OK || - decode_res == DECODE_FULL || - decode_res == DECODE_SKIP) { - return decode_res; - } - #endif - #ifdef BRESSER_6_IN_1 - decode_res = decodeBresser6In1Payload(&recvData[1], sizeof(recvData) - 1); - if (decode_res == DECODE_OK || - decode_res == DECODE_FULL || - decode_res == DECODE_SKIP) { - return decode_res; - } - #endif - #ifdef BRESSER_5_IN_1 - decode_res = decodeBresser5In1Payload(&recvData[1], sizeof(recvData) - 1); - if (decode_res == DECODE_OK || - decode_res == DECODE_FULL || - decode_res == DECODE_SKIP) { - return decode_res; - } - #endif - #ifdef BRESSER_LIGHTNING - decode_res = decodeBresserLightningPayload(&recvData[1], sizeof(recvData) - 1); - #endif - return decode_res; -} - // // Generate sample data for testing //