Bleeding edge development version of the mDot library for mbed 5. This version of the library is not guaranteed to be stable or well tested and should not be used in production or deployment scenarios.

Dependents:   mDot-IKS01A1 mDot-IKS01A1 mDot-Examples mDot-IKS01A1-Explora ... more

Fork of libmDot-dev-mbed2-deprecated by MultiTech

The Dot library provides a LoRaWan certified stack for LoRa communication using MultiTech mDot and xDot devices. The stack is compatible with mbed 5.

Dot Library Version 3 Updates

Dot Library versions 3.x.x require a channel plan to be injected into the stack. Channel plans are included with the 3.x.x Dot Library releases. The following code snippet demonstrates how to create a channel plan and inject it into the stack.

#include "mDot.h"
#include "channel_plans.h"

int main() {
    ChannelPlan* plan = new lora::ChannelPlan_US915();
    assert(plan);
    mDot* dot = mDot::getInstance(plan);
    assert(dot);

    // ...
}

Dot devices must not be deployed with software using a different channel plan than the Dot's default plan! This functionality is for development and testing only!

Multicast Sessions

Multicast sessions and packet rx events in library. When in Class C mode Multicast downlinks can be received. Recieved packets should be filtered on address, counter value will be maintained in the session or can be set explicitly depending on Application support to share Multicast Address, Keys and Counters.

mDot.h

        /**
         * Add a multicast session address and keys
         * Downlink counter is set to 0
         * Up to 3 MULTICAST_SESSIONS can be set
         */
        int32_t setMulticastSession(uint8_t index, uint32_t addr, const uint8_t* nsk, const uint8_t* dsk);
 
        /**
         * Set a multicast session counter
         * Up to 3 MULTICAST_SESSIONS can be set
         */
        int32_t setMulticastDownlinkCounter(uint8_t index, uint32_t count);

mDotEvent.h

The address field was added to PacketRx event.

        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);

The name of the repository can be used to determine which device the stack was compiled for and if it's a development or production-ready build:

A changelog for the Dot library can be found here.

The Dot library version and the version of mbed-os it was compiled against can both be found in the commit message for that revision of the Dot library. Building your application with the same version of mbed-os as what was used to build the Dot library is highly recommended!

The Dot-Examples repository demonstrates how to use the Dot library in a custom application.

The mDot and xDot platform pages have lots of platform specific information and document potential issues, gotchas, etc, and provide instructions for getting started with development. Please take a look at the platform page before starting development as they should answer many questions you will have.

Committer:
Jenkins@KEILDM1.dc.multitech.prv
Date:
Fri Oct 26 16:14:07 2018 -0500
Revision:
183:f205b2eea7c2
Parent:
180:a78812699800
mdot-library revision 3.1.0-49-g926b83a and mbed-os revision mbed-os-5.9.6

Who changed what in which revision?

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