Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: libmDot-mbed5 ISL29011
RadioEvent.h
00001 #ifndef __RADIO_EVENT_H__ 00002 #define __RADIO_EVENT_H__ 00003 00004 #include "dot_util.h" 00005 #include "mDotEvent.h" 00006 #include "Fota.h" 00007 00008 class RadioEvent : public mDotEvent 00009 { 00010 00011 public: 00012 RadioEvent() {} 00013 00014 virtual ~RadioEvent() {} 00015 00016 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) { 00017 mDotEvent::PacketRx(port, payload, size, rssi, snr, ctrl, slot, retries, address, dupRx); 00018 00019 #if ACTIVE_EXAMPLE == FOTA_EXAMPLE 00020 if(port == 200 || port == 201 || port == 202) { 00021 Fota::getInstance()->processCmd(payload, port, size); 00022 } 00023 #endif 00024 } 00025 00026 /*! 00027 * MAC layer event callback prototype. 00028 * 00029 * \param [IN] flags Bit field indicating the MAC events occurred 00030 * \param [IN] info Details about MAC events occurred 00031 */ 00032 virtual void MacEvent(LoRaMacEventFlags* flags, LoRaMacEventInfo* info) { 00033 00034 if (mts::MTSLog::getLogLevel() == mts::MTSLog::TRACE_LEVEL) { 00035 std::string msg = "OK"; 00036 switch (info->Status) { 00037 case LORAMAC_EVENT_INFO_STATUS_ERROR: 00038 msg = "ERROR"; 00039 break; 00040 case LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT: 00041 msg = "TX_TIMEOUT"; 00042 break; 00043 case LORAMAC_EVENT_INFO_STATUS_RX_TIMEOUT: 00044 msg = "RX_TIMEOUT"; 00045 break; 00046 case LORAMAC_EVENT_INFO_STATUS_RX_ERROR: 00047 msg = "RX_ERROR"; 00048 break; 00049 case LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL: 00050 msg = "JOIN_FAIL"; 00051 break; 00052 case LORAMAC_EVENT_INFO_STATUS_DOWNLINK_FAIL: 00053 msg = "DOWNLINK_FAIL"; 00054 break; 00055 case LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL: 00056 msg = "ADDRESS_FAIL"; 00057 break; 00058 case LORAMAC_EVENT_INFO_STATUS_MIC_FAIL: 00059 msg = "MIC_FAIL"; 00060 break; 00061 default: 00062 break; 00063 } 00064 logTrace("Event: %s", msg.c_str()); 00065 00066 logTrace("Flags Tx: %d Rx: %d RxData: %d RxSlot: %d LinkCheck: %d JoinAccept: %d", 00067 flags->Bits.Tx, flags->Bits.Rx, flags->Bits.RxData, flags->Bits.RxSlot, flags->Bits.LinkCheck, flags->Bits.JoinAccept); 00068 logTrace("Info: Status: %d ACK: %d Retries: %d TxDR: %d RxPort: %d RxSize: %d RSSI: %d SNR: %d Energy: %d Margin: %d Gateways: %d", 00069 info->Status, info->TxAckReceived, info->TxNbRetries, info->TxDatarate, info->RxPort, info->RxBufferSize, 00070 info->RxRssi, info->RxSnr, info->Energy, info->DemodMargin, info->NbGateways); 00071 } 00072 00073 if (flags->Bits.Rx) { 00074 00075 logDebug("Rx %d bytes", info->RxBufferSize); 00076 if (info->RxBufferSize > 0) { 00077 #if ACTIVE_EXAMPLE != FOTA_EXAMPLE 00078 // print RX data as string and hexadecimal 00079 std::string rx((const char*)info->RxBuffer, info->RxBufferSize); 00080 printf("Rx data: %s [%s]\r\n", rx.c_str(), mts::Text::bin2hexString(info->RxBuffer, info->RxBufferSize).c_str()); 00081 #endif 00082 } 00083 } 00084 } 00085 }; 00086 00087 #endif 00088
Generated on Wed Jul 13 2022 00:37:31 by
1.7.2