|
11 | 11 | // ----------------------------------------------------------------------------
|
12 | 12 |
|
13 | 13 | #include <atomic>
|
| 14 | +#include <cstring> |
14 | 15 |
|
15 | 16 | #include <modm/board.hpp>
|
16 | 17 | #include <modm/debug/logger/logger.hpp>
|
@@ -119,11 +120,13 @@ class RxThread : public modm::sx128x, public modm::pt::Protothread
|
119 | 120 | PT_CALL(radio.getPacketStatus(&packetStatus));
|
120 | 121 | PT_CALL(radio.readBuffer(rxBufferStatus.rxStartBufferPointer, std::span{buffer, rxBufferStatus.rxPayloadLength}));
|
121 | 122 |
|
122 |
| - /// TODO: read frequency error indicator (FEI) from register 0x0954 (MSB) 0x0955, 0x0956 (LSB). |
123 |
| - |
124 |
| - MODM_LOG_DEBUG << "Received Message" << modm::endl; |
125 |
| - MODM_LOG_DEBUG << "Counter: " << reinterpret_cast<uint32_t*>(buffer)[0] << modm::endl; |
126 |
| - MODM_LOG_DEBUG << modm::endl; |
| 123 | + if (rxBufferStatus.rxPayloadLength > 0) |
| 124 | + { |
| 125 | + uint32_t counter; |
| 126 | + std::memcpy((uint8_t *) &counter, buffer, sizeof(counter)); |
| 127 | + MODM_LOG_DEBUG << "Received Message" << modm::endl; |
| 128 | + MODM_LOG_DEBUG << "Counter: " << counter << modm::endl; |
| 129 | + } |
127 | 130 | }
|
128 | 131 | }
|
129 | 132 |
|
@@ -152,7 +155,7 @@ class RxThread : public modm::sx128x, public modm::pt::Protothread
|
152 | 155 | modm::Sx128x< Transport, Reset, Busy > radio;
|
153 | 156 |
|
154 | 157 | private:
|
155 |
| - static constexpr uint8_t bufferSize = 256; |
| 158 | + static constexpr size_t bufferSize = 256; |
156 | 159 | uint8_t buffer[bufferSize];
|
157 | 160 | } rxThread;
|
158 | 161 |
|
@@ -228,7 +231,6 @@ class TxThread : public modm::sx128x, public modm::pt::Protothread
|
228 | 231 | {
|
229 | 232 | PT_CALL(radio.clearIrqStatus(Irq::RxTxTimeout));
|
230 | 233 | irqStatus.reset(Irq::RxTxTimeout);
|
231 |
| - |
232 | 234 | MODM_LOG_DEBUG << "Received a timeout" << modm::endl;
|
233 | 235 | }
|
234 | 236 | }
|
|
0 commit comments