nguyen hoang
/
Dot-Examples-Khang290319
publish
Diff: examples/inc/RadioEvent.h
- Revision:
- 35:f6486829a451
- Parent:
- 21:09d05faf0e13
- Child:
- 37:f1053cb17d4f
--- a/examples/inc/RadioEvent.h Wed Apr 24 12:50:08 2019 +0000 +++ b/examples/inc/RadioEvent.h Thu May 02 09:29:05 2019 -0500 @@ -3,15 +3,26 @@ #include "dot_util.h" #include "mDotEvent.h" +#include "Fota.h" class RadioEvent : public mDotEvent { - + public: RadioEvent() {} - + virtual ~RadioEvent() {} - + + virtual void PacketRx(uint8_t port, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot, uint8_t retries, uint32_t address, bool dupRx) { + mDotEvent::PacketRx(port, payload, size, rssi, snr, ctrl, slot, retries, address, dupRx); + +#if ACTIVE_EXAMPLE == FOTA_EXAMPLE + if(port == 200 || port == 201 || port == 202) { + Fota::getInstance()->processCmd(payload, port, size); + } +#endif + } + /*! * MAC layer event callback prototype. * @@ -19,7 +30,7 @@ * \param [IN] info Details about MAC events occurred */ virtual void MacEvent(LoRaMacEventFlags* flags, LoRaMacEventInfo* info) { - + if (mts::MTSLog::getLogLevel() == mts::MTSLog::TRACE_LEVEL) { std::string msg = "OK"; switch (info->Status) { @@ -51,19 +62,19 @@ break; } logTrace("Event: %s", msg.c_str()); - + logTrace("Flags Tx: %d Rx: %d RxData: %d RxSlot: %d LinkCheck: %d JoinAccept: %d", flags->Bits.Tx, flags->Bits.Rx, flags->Bits.RxData, flags->Bits.RxSlot, flags->Bits.LinkCheck, flags->Bits.JoinAccept); logTrace("Info: Status: %d ACK: %d Retries: %d TxDR: %d RxPort: %d RxSize: %d RSSI: %d SNR: %d Energy: %d Margin: %d Gateways: %d", info->Status, info->TxAckReceived, info->TxNbRetries, info->TxDatarate, info->RxPort, info->RxBufferSize, info->RxRssi, info->RxSnr, info->Energy, info->DemodMargin, info->NbGateways); } - + if (flags->Bits.Rx) { - + logDebug("Rx %d bytes", info->RxBufferSize); if (info->RxBufferSize > 0) { - // print RX data as string and hexadecimal + // print RX data as string and hexadecimal std::string rx((const char*)info->RxBuffer, info->RxBufferSize); printf("Rx data: %s [%s]\r\n", rx.c_str(), mts::Text::bin2hexString(info->RxBuffer, info->RxBufferSize).c_str()); }