libmDot0mbed5
Fork of libmDot-mbed5 by
mDotEvent.h@26:17479e0039f6, 2016-08-30 (annotated)
- Committer:
- Jenkins@KEILDM1.dc.multitech.prv
- Date:
- Tue Aug 30 11:48:00 2016 -0500
- Revision:
- 26:17479e0039f6
- Parent:
- 19:f3a46d2bb9b3
update from git revision 2.0.6-5-g26d9b3f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
16:b630e18103e5 | 1 | #ifndef MDOT_EVENT_H |
Mike Fiore |
16:b630e18103e5 | 2 | #define MDOT_EVENT_H |
Mike Fiore |
16:b630e18103e5 | 3 | |
Mike Fiore |
16:b630e18103e5 | 4 | #include "mDot.h" |
Mike Fiore |
16:b630e18103e5 | 5 | #include "MacEvents.h" |
Mike Fiore |
16:b630e18103e5 | 6 | #include "MTSLog.h" |
Mike Fiore |
16:b630e18103e5 | 7 | #include "MTSText.h" |
Mike Fiore |
16:b630e18103e5 | 8 | |
Mike Fiore |
16:b630e18103e5 | 9 | typedef union { |
Mike Fiore |
16:b630e18103e5 | 10 | uint8_t Value; |
Mike Fiore |
16:b630e18103e5 | 11 | struct { |
Mike Fiore |
16:b630e18103e5 | 12 | uint8_t :1; |
Mike Fiore |
16:b630e18103e5 | 13 | uint8_t Tx :1; |
Mike Fiore |
16:b630e18103e5 | 14 | uint8_t Rx :1; |
Mike Fiore |
16:b630e18103e5 | 15 | uint8_t RxData :1; |
Mike Fiore |
16:b630e18103e5 | 16 | uint8_t RxSlot :2; |
Mike Fiore |
16:b630e18103e5 | 17 | uint8_t LinkCheck :1; |
Mike Fiore |
16:b630e18103e5 | 18 | uint8_t JoinAccept :1; |
Mike Fiore |
16:b630e18103e5 | 19 | } Bits; |
Mike Fiore |
16:b630e18103e5 | 20 | } LoRaMacEventFlags; |
Mike Fiore |
16:b630e18103e5 | 21 | |
Mike Fiore |
16:b630e18103e5 | 22 | typedef enum { |
Mike Fiore |
16:b630e18103e5 | 23 | LORAMAC_EVENT_INFO_STATUS_OK = 0, |
Mike Fiore |
16:b630e18103e5 | 24 | LORAMAC_EVENT_INFO_STATUS_ERROR, |
Mike Fiore |
16:b630e18103e5 | 25 | LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT, |
Mike Fiore |
16:b630e18103e5 | 26 | LORAMAC_EVENT_INFO_STATUS_RX_TIMEOUT, |
Mike Fiore |
16:b630e18103e5 | 27 | LORAMAC_EVENT_INFO_STATUS_RX_ERROR, |
Mike Fiore |
16:b630e18103e5 | 28 | LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL, |
Mike Fiore |
16:b630e18103e5 | 29 | LORAMAC_EVENT_INFO_STATUS_DOWNLINK_FAIL, |
Mike Fiore |
16:b630e18103e5 | 30 | LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL, |
Mike Fiore |
16:b630e18103e5 | 31 | LORAMAC_EVENT_INFO_STATUS_MIC_FAIL, |
Mike Fiore |
16:b630e18103e5 | 32 | } LoRaMacEventInfoStatus; |
Mike Fiore |
16:b630e18103e5 | 33 | |
Mike Fiore |
16:b630e18103e5 | 34 | /*! |
Mike Fiore |
16:b630e18103e5 | 35 | * LoRaMAC event information |
Mike Fiore |
16:b630e18103e5 | 36 | */ |
Mike Fiore |
16:b630e18103e5 | 37 | typedef struct { |
Mike Fiore |
16:b630e18103e5 | 38 | LoRaMacEventInfoStatus Status; |
Mike Fiore |
16:b630e18103e5 | 39 | lora::DownlinkControl Ctrl; |
Mike Fiore |
16:b630e18103e5 | 40 | bool TxAckReceived; |
Mike Fiore |
16:b630e18103e5 | 41 | uint8_t TxNbRetries; |
Mike Fiore |
16:b630e18103e5 | 42 | uint8_t TxDatarate; |
Mike Fiore |
16:b630e18103e5 | 43 | uint8_t RxPort; |
Mike Fiore |
16:b630e18103e5 | 44 | uint8_t *RxBuffer; |
Mike Fiore |
16:b630e18103e5 | 45 | uint8_t RxBufferSize; |
Mike Fiore |
16:b630e18103e5 | 46 | int16_t RxRssi; |
Mike Fiore |
16:b630e18103e5 | 47 | uint8_t RxSnr; |
Mike Fiore |
16:b630e18103e5 | 48 | uint16_t Energy; |
Mike Fiore |
16:b630e18103e5 | 49 | uint8_t DemodMargin; |
Mike Fiore |
16:b630e18103e5 | 50 | uint8_t NbGateways; |
Mike Fiore |
16:b630e18103e5 | 51 | } LoRaMacEventInfo; |
Mike Fiore |
16:b630e18103e5 | 52 | |
Mike Fiore |
16:b630e18103e5 | 53 | class mDotEvent: public lora::MacEvents { |
Mike Fiore |
16:b630e18103e5 | 54 | public: |
Mike Fiore |
16:b630e18103e5 | 55 | |
Mike Fiore |
16:b630e18103e5 | 56 | mDotEvent() |
Mike Fiore |
16:b630e18103e5 | 57 | : |
Mike Fiore |
16:b630e18103e5 | 58 | LinkCheckAnsReceived(false), |
Mike Fiore |
16:b630e18103e5 | 59 | DemodMargin(0), |
Mike Fiore |
16:b630e18103e5 | 60 | NbGateways(0), |
Mike Fiore |
16:b630e18103e5 | 61 | PacketReceived(false), |
Mike Fiore |
16:b630e18103e5 | 62 | RxPort(0), |
Mike Fiore |
16:b630e18103e5 | 63 | RxPayloadSize(0), |
Mike Fiore |
16:b630e18103e5 | 64 | PongReceived(false), |
Mike Fiore |
16:b630e18103e5 | 65 | PongRssi(0), |
Mike Fiore |
16:b630e18103e5 | 66 | PongSnr(0), |
Mike Fiore |
16:b630e18103e5 | 67 | AckReceived(false), |
Mike Fiore |
16:b630e18103e5 | 68 | TxNbRetries(0) |
Mike Fiore |
16:b630e18103e5 | 69 | { |
Mike Fiore |
16:b630e18103e5 | 70 | memset(&_flags, 0, sizeof(LoRaMacEventFlags)); |
Mike Fiore |
16:b630e18103e5 | 71 | memset(&_info, 0, sizeof(LoRaMacEventInfo)); |
Mike Fiore |
16:b630e18103e5 | 72 | } |
Mike Fiore |
16:b630e18103e5 | 73 | |
Mike Fiore |
16:b630e18103e5 | 74 | virtual ~mDotEvent() { |
Mike Fiore |
16:b630e18103e5 | 75 | } |
Mike Fiore |
16:b630e18103e5 | 76 | |
Mike Fiore |
16:b630e18103e5 | 77 | virtual void MacEvent(LoRaMacEventFlags *flags, LoRaMacEventInfo *info) { |
Mike Fiore |
16:b630e18103e5 | 78 | if (mts::MTSLog::getLogLevel() == mts::MTSLog::TRACE_LEVEL) { |
Mike Fiore |
16:b630e18103e5 | 79 | std::string msg = "OK"; |
Mike Fiore |
16:b630e18103e5 | 80 | switch (info->Status) { |
Mike Fiore |
16:b630e18103e5 | 81 | case LORAMAC_EVENT_INFO_STATUS_ERROR: |
Mike Fiore |
16:b630e18103e5 | 82 | msg = "ERROR"; |
Mike Fiore |
16:b630e18103e5 | 83 | break; |
Mike Fiore |
16:b630e18103e5 | 84 | case LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT: |
Mike Fiore |
16:b630e18103e5 | 85 | msg = "TX_TIMEOUT"; |
Mike Fiore |
16:b630e18103e5 | 86 | break; |
Mike Fiore |
16:b630e18103e5 | 87 | case LORAMAC_EVENT_INFO_STATUS_RX_TIMEOUT: |
Mike Fiore |
16:b630e18103e5 | 88 | msg = "RX_TIMEOUT"; |
Mike Fiore |
16:b630e18103e5 | 89 | break; |
Mike Fiore |
16:b630e18103e5 | 90 | case LORAMAC_EVENT_INFO_STATUS_RX_ERROR: |
Mike Fiore |
16:b630e18103e5 | 91 | msg = "RX_ERROR"; |
Mike Fiore |
16:b630e18103e5 | 92 | break; |
Mike Fiore |
16:b630e18103e5 | 93 | case LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL: |
Mike Fiore |
16:b630e18103e5 | 94 | msg = "JOIN_FAIL"; |
Mike Fiore |
16:b630e18103e5 | 95 | break; |
Mike Fiore |
16:b630e18103e5 | 96 | case LORAMAC_EVENT_INFO_STATUS_DOWNLINK_FAIL: |
Mike Fiore |
16:b630e18103e5 | 97 | msg = "DOWNLINK_FAIL"; |
Mike Fiore |
16:b630e18103e5 | 98 | break; |
Mike Fiore |
16:b630e18103e5 | 99 | case LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL: |
Mike Fiore |
16:b630e18103e5 | 100 | msg = "ADDRESS_FAIL"; |
Mike Fiore |
16:b630e18103e5 | 101 | break; |
Mike Fiore |
16:b630e18103e5 | 102 | case LORAMAC_EVENT_INFO_STATUS_MIC_FAIL: |
Mike Fiore |
16:b630e18103e5 | 103 | msg = "MIC_FAIL"; |
Mike Fiore |
16:b630e18103e5 | 104 | break; |
Mike Fiore |
16:b630e18103e5 | 105 | default: |
Mike Fiore |
16:b630e18103e5 | 106 | break; |
Mike Fiore |
16:b630e18103e5 | 107 | } |
Mike Fiore |
16:b630e18103e5 | 108 | logTrace("Event: %s", msg.c_str()); |
Mike Fiore |
16:b630e18103e5 | 109 | |
Mike Fiore |
16:b630e18103e5 | 110 | logTrace("Flags Tx: %d Rx: %d RxData: %d RxSlot: %d LinkCheck: %d JoinAccept: %d", |
Mike Fiore |
16:b630e18103e5 | 111 | flags->Bits.Tx, flags->Bits.Rx, flags->Bits.RxData, flags->Bits.RxSlot, flags->Bits.LinkCheck, flags->Bits.JoinAccept); |
Mike Fiore |
16:b630e18103e5 | 112 | logTrace("Info: Status: %d ACK: %d Retries: %d TxDR: %d RxPort: %d RxSize: %d RSSI: %d SNR: %d Energy: %d Margin: %d Gateways: %d", |
Mike Fiore |
16:b630e18103e5 | 113 | info->Status, info->TxAckReceived, info->TxNbRetries, info->TxDatarate, info->RxPort, info->RxBufferSize, |
Mike Fiore |
16:b630e18103e5 | 114 | info->RxRssi, info->RxSnr, info->Energy, info->DemodMargin, info->NbGateways); |
Mike Fiore |
16:b630e18103e5 | 115 | } |
Mike Fiore |
16:b630e18103e5 | 116 | } |
Mike Fiore |
16:b630e18103e5 | 117 | |
Mike Fiore |
16:b630e18103e5 | 118 | virtual void TxDone(uint8_t dr) { |
Mike Fiore |
16:b630e18103e5 | 119 | RxPayloadSize = 0; |
Mike Fiore |
16:b630e18103e5 | 120 | LinkCheckAnsReceived = false; |
Mike Fiore |
16:b630e18103e5 | 121 | PacketReceived = false; |
Mike Fiore |
16:b630e18103e5 | 122 | AckReceived = false; |
Mike Fiore |
16:b630e18103e5 | 123 | PongReceived = false; |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 124 | TxNbRetries = 0; |
Mike Fiore |
16:b630e18103e5 | 125 | |
Mike Fiore |
16:b630e18103e5 | 126 | logDebug("mDotEvent - TxDone"); |
Mike Fiore |
16:b630e18103e5 | 127 | memset(&_flags, 0, sizeof(LoRaMacEventFlags)); |
Mike Fiore |
16:b630e18103e5 | 128 | memset(&_info, 0, sizeof(LoRaMacEventInfo)); |
Mike Fiore |
16:b630e18103e5 | 129 | |
Mike Fiore |
16:b630e18103e5 | 130 | _flags.Bits.Tx = 1; |
Mike Fiore |
16:b630e18103e5 | 131 | _info.TxDatarate = dr; |
Mike Fiore |
16:b630e18103e5 | 132 | _info.Status = LORAMAC_EVENT_INFO_STATUS_OK; |
Mike Fiore |
16:b630e18103e5 | 133 | Notify(); |
Mike Fiore |
16:b630e18103e5 | 134 | } |
Mike Fiore |
16:b630e18103e5 | 135 | |
Mike Fiore |
16:b630e18103e5 | 136 | void Notify() { |
Mike Fiore |
16:b630e18103e5 | 137 | MacEvent(&_flags, &_info); |
Mike Fiore |
16:b630e18103e5 | 138 | } |
Mike Fiore |
16:b630e18103e5 | 139 | |
Mike Fiore |
16:b630e18103e5 | 140 | virtual void TxTimeout(void) { |
Mike Fiore |
16:b630e18103e5 | 141 | logDebug("mDotEvent - TxTimeout"); |
Mike Fiore |
16:b630e18103e5 | 142 | |
Mike Fiore |
16:b630e18103e5 | 143 | _flags.Bits.Tx = 1; |
Mike Fiore |
16:b630e18103e5 | 144 | _info.Status = LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT; |
Mike Fiore |
16:b630e18103e5 | 145 | Notify(); |
Mike Fiore |
16:b630e18103e5 | 146 | } |
Mike Fiore |
16:b630e18103e5 | 147 | |
Mike Fiore |
16:b630e18103e5 | 148 | virtual void JoinAccept(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) { |
Mike Fiore |
16:b630e18103e5 | 149 | logDebug("mDotEvent - JoinAccept"); |
Mike Fiore |
16:b630e18103e5 | 150 | |
Mike Fiore |
16:b630e18103e5 | 151 | _flags.Bits.Tx = 0; |
Mike Fiore |
16:b630e18103e5 | 152 | _flags.Bits.JoinAccept = 1; |
Mike Fiore |
16:b630e18103e5 | 153 | _info.Status = LORAMAC_EVENT_INFO_STATUS_OK; |
Mike Fiore |
16:b630e18103e5 | 154 | Notify(); |
Mike Fiore |
16:b630e18103e5 | 155 | } |
Mike Fiore |
16:b630e18103e5 | 156 | |
Mike Fiore |
16:b630e18103e5 | 157 | virtual void JoinFailed(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) { |
Mike Fiore |
16:b630e18103e5 | 158 | logDebug("mDotEvent - JoinFailed"); |
Mike Fiore |
16:b630e18103e5 | 159 | |
Mike Fiore |
16:b630e18103e5 | 160 | _flags.Bits.Tx = 0; |
Mike Fiore |
16:b630e18103e5 | 161 | _flags.Bits.JoinAccept = 1; |
Mike Fiore |
16:b630e18103e5 | 162 | _info.Status = LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL; |
Mike Fiore |
16:b630e18103e5 | 163 | Notify(); |
Mike Fiore |
16:b630e18103e5 | 164 | } |
Mike Fiore |
16:b630e18103e5 | 165 | |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 166 | virtual void MissedAck(uint8_t retries) { |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 167 | logDebug("mDotEvent - MissedAck : retries %u", retries); |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 168 | TxNbRetries = retries; |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 169 | _info.TxNbRetries = retries; |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 170 | } |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 171 | |
Mike Fiore |
16:b630e18103e5 | 172 | 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 = 0) { |
Mike Fiore |
16:b630e18103e5 | 173 | logDebug("mDotEvent - PacketRx"); |
Mike Fiore |
16:b630e18103e5 | 174 | RxPort = port; |
Mike Fiore |
16:b630e18103e5 | 175 | PacketReceived = true; |
Mike Fiore |
16:b630e18103e5 | 176 | |
Mike Fiore |
16:b630e18103e5 | 177 | memcpy(RxPayload, payload, size); |
Mike Fiore |
16:b630e18103e5 | 178 | RxPayloadSize = size; |
Mike Fiore |
16:b630e18103e5 | 179 | |
Mike Fiore |
16:b630e18103e5 | 180 | if (ctrl.Bits.Ack) { |
Mike Fiore |
16:b630e18103e5 | 181 | AckReceived = true; |
Mike Fiore |
16:b630e18103e5 | 182 | } |
Mike Fiore |
16:b630e18103e5 | 183 | |
Mike Fiore |
16:b630e18103e5 | 184 | if (mts::MTSLog::getLogLevel() == mts::MTSLog::TRACE_LEVEL) { |
Mike Fiore |
16:b630e18103e5 | 185 | std::string packet = mts::Text::bin2hexString(RxPayload, size); |
Mike Fiore |
16:b630e18103e5 | 186 | logTrace("Payload: %s", packet.c_str()); |
Mike Fiore |
16:b630e18103e5 | 187 | } |
Mike Fiore |
16:b630e18103e5 | 188 | |
Mike Fiore |
16:b630e18103e5 | 189 | _flags.Bits.Tx = 0; |
Mike Fiore |
16:b630e18103e5 | 190 | _flags.Bits.Rx = 1; |
Mike Fiore |
16:b630e18103e5 | 191 | _flags.Bits.RxData = size > 0; |
Mike Fiore |
16:b630e18103e5 | 192 | _flags.Bits.RxSlot = slot; |
Mike Fiore |
16:b630e18103e5 | 193 | _info.RxBuffer = payload; |
Mike Fiore |
16:b630e18103e5 | 194 | _info.RxBufferSize = size; |
Mike Fiore |
16:b630e18103e5 | 195 | _info.RxPort = port; |
Mike Fiore |
16:b630e18103e5 | 196 | _info.RxRssi = rssi; |
Mike Fiore |
16:b630e18103e5 | 197 | _info.RxSnr = snr; |
Mike Fiore |
16:b630e18103e5 | 198 | _info.TxAckReceived = AckReceived; |
Jenkins@KEILDM1.dc.multitech.prv | 26:17479e0039f6 | 199 | _info.TxNbRetries = retries; |
Mike Fiore |
16:b630e18103e5 | 200 | _info.Status = LORAMAC_EVENT_INFO_STATUS_OK; |
Mike Fiore |
16:b630e18103e5 | 201 | Notify(); |
Mike Fiore |
16:b630e18103e5 | 202 | } |
Mike Fiore |
16:b630e18103e5 | 203 | |
Mike Fiore |
16:b630e18103e5 | 204 | virtual void RxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot) { |
Mike Fiore |
16:b630e18103e5 | 205 | logDebug("mDotEvent - RxDone"); |
Mike Fiore |
16:b630e18103e5 | 206 | } |
Mike Fiore |
16:b630e18103e5 | 207 | |
Mike Fiore |
16:b630e18103e5 | 208 | virtual void Pong(int16_t m_rssi, int8_t m_snr, int16_t s_rssi, int8_t s_snr) { |
Mike Fiore |
16:b630e18103e5 | 209 | logDebug("mDotEvent - Pong"); |
Mike Fiore |
16:b630e18103e5 | 210 | PongReceived = true; |
Mike Fiore |
16:b630e18103e5 | 211 | PongRssi = s_rssi; |
Mike Fiore |
16:b630e18103e5 | 212 | PongSnr = s_snr; |
Mike Fiore |
16:b630e18103e5 | 213 | } |
Mike Fiore |
16:b630e18103e5 | 214 | |
Mike Fiore |
16:b630e18103e5 | 215 | virtual void NetworkLinkCheck(int16_t m_rssi, int8_t m_snr, int8_t s_snr, uint8_t s_gateways) { |
Mike Fiore |
16:b630e18103e5 | 216 | logDebug("mDotEvent - NetworkLinkCheck"); |
Mike Fiore |
16:b630e18103e5 | 217 | LinkCheckAnsReceived = true; |
Mike Fiore |
16:b630e18103e5 | 218 | DemodMargin = s_snr; |
Mike Fiore |
16:b630e18103e5 | 219 | NbGateways = s_gateways; |
Mike Fiore |
16:b630e18103e5 | 220 | |
Mike Fiore |
16:b630e18103e5 | 221 | _flags.Bits.Tx = 0; |
Mike Fiore |
16:b630e18103e5 | 222 | _flags.Bits.LinkCheck = 1; |
Mike Fiore |
16:b630e18103e5 | 223 | _info.RxRssi = m_rssi; |
Mike Fiore |
16:b630e18103e5 | 224 | _info.RxSnr = m_snr; |
Mike Fiore |
16:b630e18103e5 | 225 | _info.DemodMargin = s_snr; |
Mike Fiore |
16:b630e18103e5 | 226 | _info.NbGateways = s_gateways; |
Mike Fiore |
16:b630e18103e5 | 227 | _info.Status = LORAMAC_EVENT_INFO_STATUS_OK; |
Mike Fiore |
16:b630e18103e5 | 228 | Notify(); |
Mike Fiore |
16:b630e18103e5 | 229 | } |
Mike Fiore |
16:b630e18103e5 | 230 | |
Mike Fiore |
16:b630e18103e5 | 231 | virtual void RxTimeout(uint8_t slot) { |
Mike Fiore |
16:b630e18103e5 | 232 | // logDebug("mDotEvent - RxTimeout"); |
Mike Fiore |
16:b630e18103e5 | 233 | |
Mike Fiore |
16:b630e18103e5 | 234 | _flags.Bits.Tx = 0; |
Mike Fiore |
16:b630e18103e5 | 235 | _flags.Bits.RxSlot = slot; |
Mike Fiore |
16:b630e18103e5 | 236 | _info.Status = LORAMAC_EVENT_INFO_STATUS_RX_TIMEOUT; |
Mike Fiore |
16:b630e18103e5 | 237 | Notify(); |
Mike Fiore |
16:b630e18103e5 | 238 | } |
Mike Fiore |
16:b630e18103e5 | 239 | |
Mike Fiore |
16:b630e18103e5 | 240 | virtual void RxError(uint8_t slot) { |
Mike Fiore |
16:b630e18103e5 | 241 | logDebug("mDotEvent - RxError"); |
Mike Fiore |
16:b630e18103e5 | 242 | |
Mike Fiore |
16:b630e18103e5 | 243 | memset(&_flags, 0, sizeof(LoRaMacEventFlags)); |
Mike Fiore |
16:b630e18103e5 | 244 | memset(&_info, 0, sizeof(LoRaMacEventInfo)); |
Mike Fiore |
16:b630e18103e5 | 245 | |
Mike Fiore |
16:b630e18103e5 | 246 | _flags.Bits.RxSlot = slot; |
Mike Fiore |
16:b630e18103e5 | 247 | _info.Status = LORAMAC_EVENT_INFO_STATUS_RX_ERROR; |
Mike Fiore |
16:b630e18103e5 | 248 | Notify(); |
Mike Fiore |
16:b630e18103e5 | 249 | } |
Mike Fiore |
16:b630e18103e5 | 250 | |
Mike Fiore |
16:b630e18103e5 | 251 | virtual uint8_t MeasureBattery(void) { |
Mike Fiore |
16:b630e18103e5 | 252 | return 255; |
Mike Fiore |
16:b630e18103e5 | 253 | } |
Mike Fiore |
16:b630e18103e5 | 254 | |
Mike Fiore |
16:b630e18103e5 | 255 | bool LinkCheckAnsReceived; |
Mike Fiore |
16:b630e18103e5 | 256 | uint8_t DemodMargin; |
Mike Fiore |
16:b630e18103e5 | 257 | uint8_t NbGateways; |
Mike Fiore |
16:b630e18103e5 | 258 | |
Mike Fiore |
16:b630e18103e5 | 259 | bool PacketReceived; |
Mike Fiore |
16:b630e18103e5 | 260 | uint8_t RxPort; |
Mike Fiore |
16:b630e18103e5 | 261 | uint8_t RxPayload[255]; |
Mike Fiore |
16:b630e18103e5 | 262 | uint8_t RxPayloadSize; |
Mike Fiore |
16:b630e18103e5 | 263 | |
Mike Fiore |
16:b630e18103e5 | 264 | bool PongReceived; |
Mike Fiore |
16:b630e18103e5 | 265 | int16_t PongRssi; |
Mike Fiore |
16:b630e18103e5 | 266 | int16_t PongSnr; |
Mike Fiore |
16:b630e18103e5 | 267 | |
Mike Fiore |
16:b630e18103e5 | 268 | bool AckReceived; |
Mike Fiore |
16:b630e18103e5 | 269 | uint8_t TxNbRetries; |
Mike Fiore |
16:b630e18103e5 | 270 | |
Mike Fiore |
16:b630e18103e5 | 271 | LoRaMacEventFlags& Flags() { |
Mike Fiore |
16:b630e18103e5 | 272 | return _flags; |
Mike Fiore |
16:b630e18103e5 | 273 | } |
Mike Fiore |
16:b630e18103e5 | 274 | LoRaMacEventInfo& Info() { |
Mike Fiore |
16:b630e18103e5 | 275 | return _info; |
Mike Fiore |
16:b630e18103e5 | 276 | } |
Mike Fiore |
16:b630e18103e5 | 277 | |
Mike Fiore |
16:b630e18103e5 | 278 | private: |
Mike Fiore |
16:b630e18103e5 | 279 | |
Mike Fiore |
16:b630e18103e5 | 280 | LoRaMacEventFlags _flags; |
Mike Fiore |
16:b630e18103e5 | 281 | LoRaMacEventInfo _info; |
Mike Fiore |
16:b630e18103e5 | 282 | |
Mike Fiore |
16:b630e18103e5 | 283 | // |
Mike Fiore |
16:b630e18103e5 | 284 | // /*! |
Mike Fiore |
16:b630e18103e5 | 285 | // * MAC layer event callback prototype. |
Mike Fiore |
16:b630e18103e5 | 286 | // * |
Mike Fiore |
16:b630e18103e5 | 287 | // * \param [IN] flags Bit field indicating the MAC events occurred |
Mike Fiore |
16:b630e18103e5 | 288 | // * \param [IN] info Details about MAC events occurred |
Mike Fiore |
16:b630e18103e5 | 289 | // */ |
Mike Fiore |
16:b630e18103e5 | 290 | // virtual void MacEvent(LoRaMacEventFlags *flags, LoRaMacEventInfo *info) { |
Mike Fiore |
16:b630e18103e5 | 291 | // logDebug("mDotEvent"); |
Mike Fiore |
16:b630e18103e5 | 292 | // |
Mike Fiore |
16:b630e18103e5 | 293 | // if (flags->Bits.Rx) { |
Mike Fiore |
16:b630e18103e5 | 294 | // logDebug("Rx"); |
Mike Fiore |
16:b630e18103e5 | 295 | // |
Mike Fiore |
16:b630e18103e5 | 296 | // // Event Object must delete RxBuffer |
Mike Fiore |
16:b630e18103e5 | 297 | // delete[] info->RxBuffer; |
Mike Fiore |
16:b630e18103e5 | 298 | // } |
Mike Fiore |
16:b630e18103e5 | 299 | // } |
Mike Fiore |
16:b630e18103e5 | 300 | // |
Mike Fiore |
16:b630e18103e5 | 301 | |
Mike Fiore |
16:b630e18103e5 | 302 | }; |
Mike Fiore |
16:b630e18103e5 | 303 | |
Mike Fiore |
16:b630e18103e5 | 304 | #endif // __MDOT_EVENT_H__ |