diff --git a/examples/nucleo_g474re/sx128x_lora/main.cpp b/examples/nucleo_g474re/sx128x_lora/main.cpp index faecccdb54..54b0282ed2 100644 --- a/examples/nucleo_g474re/sx128x_lora/main.cpp +++ b/examples/nucleo_g474re/sx128x_lora/main.cpp @@ -11,6 +11,7 @@ // ---------------------------------------------------------------------------- #include +#include #include #include @@ -119,11 +120,13 @@ class RxThread : public modm::sx128x, public modm::pt::Protothread PT_CALL(radio.getPacketStatus(&packetStatus)); PT_CALL(radio.readBuffer(rxBufferStatus.rxStartBufferPointer, std::span{buffer, rxBufferStatus.rxPayloadLength})); - /// TODO: read frequency error indicator (FEI) from register 0x0954 (MSB) 0x0955, 0x0956 (LSB). - - MODM_LOG_DEBUG << "Received Message" << modm::endl; - MODM_LOG_DEBUG << "Counter: " << reinterpret_cast(buffer)[0] << modm::endl; - MODM_LOG_DEBUG << modm::endl; + if (rxBufferStatus.rxPayloadLength > 0) + { + uint32_t counter; + std::memcpy((uint8_t *) &counter, buffer, sizeof(counter)); + MODM_LOG_DEBUG << "Received Message" << modm::endl; + MODM_LOG_DEBUG << "Counter: " << counter << modm::endl; + } } } @@ -152,7 +155,7 @@ class RxThread : public modm::sx128x, public modm::pt::Protothread modm::Sx128x< Transport, Reset, Busy > radio; private: - static constexpr uint8_t bufferSize = 256; + static constexpr size_t bufferSize = 256; uint8_t buffer[bufferSize]; } rxThread; @@ -228,7 +231,6 @@ class TxThread : public modm::sx128x, public modm::pt::Protothread { PT_CALL(radio.clearIrqStatus(Irq::RxTxTimeout)); irqStatus.reset(Irq::RxTxTimeout); - MODM_LOG_DEBUG << "Received a timeout" << modm::endl; } }