Stable version of the xDot library for mbed 5. This version of the library is suitable for deployment scenarios.

Dependents:   Dot-Examples XDOT-Devicewise Dot-Examples-delujoc Dot-Examples_receive ... more

Fork of libxDot-dev-mbed5-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.

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.

FOTA

Full FOTA support is only available with mDot, xDot does not have the required external flash. xDot can use the FOTA example to dynamically join a multicast session only. After joining the multicast session the received Fragmentation packets could be handed to a host MCU for processing and at completion the firmware can be loaded into the xDot using the bootloader and y-modem. See xDot Developer Guide.

  • Add the following code to allow Fota to use the Dot instance

examples/src/fota_example.cpp

    // Initialize FOTA singleton
    Fota::getInstance(dot);
  • Add fragmentation handling the the PacketRx event

examples/inc/RadioEvent.h

    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
    }

The FOTA implementation has a few differences from the LoRaWAN Protocol

  • Fragmentation Indexing starts at 0
  • McKEKey is 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
  • Start Time is a count-down in seconds to start of session

Files at this revision

API Documentation at this revision

Comitter:
Jenkins@KEILDM1.dc.multitech.prv
Date:
Tue Apr 23 08:51:44 2019 -0500
Parent:
15:47c194c843d5
Child:
17:02ac4868b5a2
Commit message:
mdot-library revision 3.2.0 and mbed-os revision mbed-os-5.11.1

Changed in this revision

ChannelPlan.h Show annotated file Show diff for this revision Revisions of this file
Fota/Fota.h Show annotated file Show diff for this revision Revisions of this file
Fota/MulticastGroup/MulticastGroup.h Show annotated file Show diff for this revision Revisions of this file
Lora.h Show annotated file Show diff for this revision Revisions of this file
MTS-Lora/vendor/multitech/MTS-Utils/MTSLog.h Show annotated file Show diff for this revision Revisions of this file
MacEvents.h Show annotated file Show diff for this revision Revisions of this file
Mote.h Show annotated file Show diff for this revision Revisions of this file
SxRadio.h Show annotated file Show diff for this revision Revisions of this file
libxDot-ARMCC.ar Show annotated file Show diff for this revision Revisions of this file
libxDot-GCC_ARM.a Show annotated file Show diff for this revision Revisions of this file
mDot.h Show annotated file Show diff for this revision Revisions of this file
mDotEvent.h Show annotated file Show diff for this revision Revisions of this file
plans/ChannelPlan_AS923.h Show annotated file Show diff for this revision Revisions of this file
plans/ChannelPlan_AU915.h Show annotated file Show diff for this revision Revisions of this file
plans/ChannelPlan_EU868.h Show annotated file Show diff for this revision Revisions of this file
plans/ChannelPlan_IN865.h Show annotated file Show diff for this revision Revisions of this file
plans/ChannelPlan_KR920.h Show annotated file Show diff for this revision Revisions of this file
plans/ChannelPlan_RU864.h Show annotated file Show diff for this revision Revisions of this file
plans/ChannelPlan_US915.h Show annotated file Show diff for this revision Revisions of this file
plans/ChannelPlans.h Show annotated file Show diff for this revision Revisions of this file
--- a/ChannelPlan.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/ChannelPlan.h	Tue Apr 23 08:51:44 2019 -0500
@@ -16,6 +16,8 @@
 #ifndef __CHANNEL_STRATEGY_H__
 #define __CHANNEL_STRATEGY_H__
 
+#include "mbed_events.h"
+
 #include "Lora.h"
 #include "SxRadio.h"
 #include <vector>
@@ -59,6 +61,7 @@
                 AS923 = DYNAMIC | 0x02,
                 KR920 = DYNAMIC | 0x03,
                 AS923_JAPAN = DYNAMIC | 0x04,
+                RU864 = DYNAMIC | 0x05,
 
                 NONE = 0xFF,
             };
@@ -96,6 +99,11 @@
             virtual void SetSettings(Settings* settings);
 
             /**
+             * Setter for the event queue
+             */
+            virtual void SetEventQueue(EventQueue* queue);
+
+            /**
              * Get the next channel to use to transmit
              * @return LORA_OK if channel was found
              * @return LORA_NO_CHANS_ENABLED
@@ -256,9 +264,14 @@
              * Set the SxRadio rx config provided window
              * @param window to be opened
              * @param continuous keep window open
+             * @param wnd_growth factor to increase the rx window by
+             * @param pad_ms time in milliseconds to add to computed window size
              * @return LORA_OK
              */
-            virtual uint8_t SetRxConfig(uint8_t window, bool continuous) = 0;
+            virtual uint8_t SetRxConfig(uint8_t window,
+                                        bool continuous,
+                                        uint16_t wnd_growth = 1,
+                                        uint16_t pad_ms = 0) = 0;
 
             /**
              * Set frequency sub band if supported by plan
@@ -468,8 +481,9 @@
             /**
              * Get time on air with current settings
              * @param bytes number of bytes to be sent
+             * @param cfg for setting up the radio before getting time on air
              */
-            virtual uint32_t GetTimeOnAir(uint8_t bytes);
+            virtual uint32_t GetTimeOnAir(uint8_t bytes, RadioCfg_t cfg = TX_RADIO_CFG);
 
             /**
              * Reset the duty timers with the current time off air
@@ -556,11 +570,39 @@
              * use to clear downlink channels on join
              */
             virtual void ClearChannels();
-    
+
+            /**
+             * Check if this packet is a beacon and if so extract parameters needed
+             * @param payload of potential beacon
+             * @param size of the packet
+             * @param [out] data extracted from the beacon if this packet was indeed a beacon
+             * @return true if this packet is beacon, false if not
+             */
+            virtual bool DecodeBeacon(const uint8_t* payload,
+                                      size_t size,
+                                      BeaconData_t& data) = 0;
+
+            /**
+             * Update class B beacon and ping slot settings if frequency hopping enabled
+             * @param time received in the last beacon
+             * @param period of the beacon
+             * @param devAddr of this end device
+             */
+            virtual void FrequencyHop(uint32_t time, uint32_t period, uint32_t devAddr) { }
+
+
+            /*
+             * Get default number of channels for a plan
+             */
+            virtual uint8_t GetNumDefaultChans();
         protected:
 
             SxRadio* GetRadio();                //!< Get pointer to the SxRadio object or assert if it is null
             Settings* GetSettings();            //!< Get pointer to the settings object or assert if it is null
+            /**
+             * 16 bit ITU-T CRC implementation
+             */
+            uint16_t CRC16(const uint8_t* data, size_t size);
 
             uint8_t _txChannel;                 //!< Current channel for transmit
             uint8_t _txFrequencySubBand;        //!< Current frequency sub band for hybrid operation
@@ -578,9 +620,6 @@
             uint32_t _minFrequency;             //!< Minimum Frequency
             uint32_t _maxFrequency;             //!< Maximum Frequency
 
-            Channel _beaconChannel;             //!< Beacon window settings
-            Channel _beaconRxChannel;           //!< Beacon slot rx window settings
-
             uint8_t _minDatarate;               //!< Minimum datarate to accept in ADR request
             uint8_t _maxDatarate;               //!< Maximum datarate to accept in ADR request
 
@@ -599,18 +638,19 @@
             uint8_t _numChans;                  //!< Number of total channels in plan
             uint8_t _numChans125k;              //!< Number of 125K  channels in plan
             uint8_t _numChans500k;              //!< Number of 500K channels in plan
-
+            uint8_t _numDefaultChans;           //!< Number of default channels in plan
+            
             uint16_t _LBT_TimeUs;               //!< Sample time in us for LBT
             int8_t _LBT_Threshold;              //!< Threshold in dBm for LBT
 
             std::vector<uint16_t> _channelMask; //!< Bit mask for currently enabled channels
 
             Timer _dutyCycleTimer;              //!< Timer for tracking time-off-air
-            RtosTimer _txDutyTimer;             //!< Event timer for expiration of time-off-air
+            int _txDutyEvtId;                   //!< Event ID for expiration of time-off-air
 
             bool _txDutyCyclePending;           //!< Flag for pending duty cycle event
 
-            static void OnTxDutyCycleEvent(const void* arg);    //!< Rtos callback for duty cycle event
+            void OnTxDutyCycleEvent();          //!< Callback for duty cycle event
             void OnTxDutyCycleEventBottom();                    //!< Callback for duty cycle event
 
             static const uint8_t* TX_POWERS;                    //!< List of available tx powers
@@ -625,6 +665,7 @@
 
             SxRadio* _radio;                    //!< Injected SxRadio dependency
             Settings* _settings;                //!< Current settings
+            EventQueue* _evtQueue;              //!< mbed Event Queue
     };
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Fota/Fota.h	Tue Apr 23 08:51:44 2019 -0500
@@ -0,0 +1,37 @@
+#ifndef FOTA_H
+#define FOTA_H
+#include "mDot.h"
+#ifdef FOTA
+#include "FragmentationSession.h"
+#endif
+#include "MulticastGroup.h"
+
+class Fota {
+
+    public:
+        Fota(mDot* dot);
+        ~Fota();
+
+        static Fota* getInstance(mDot* dot);
+        static Fota* getInstance();
+        void processCmd(uint8_t* payload, uint8_t port, uint8_t size);
+        void reset();
+        void enable(bool enabled);
+        bool enable();
+        void fixEventQueue();
+        int32_t timeToStart();
+
+    private:
+        static void start();
+
+        bool _enabled;
+        Thread _send_thread;
+        uint8_t p[242];
+        static Fota* _instance;
+        mDot* _dot;
+#ifdef FOTA
+        FragmentationSession* _frag_session;
+#endif
+        MulticastGroup* _mc_group;
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Fota/MulticastGroup/MulticastGroup.h	Tue Apr 23 08:51:44 2019 -0500
@@ -0,0 +1,63 @@
+#ifndef MULTICASTGROUP_H
+#define MULTICASTGROUP_H
+#include "mDot.h"
+#include "mbed.h"
+#define GPS_EPOCH 315986400
+#define MULTICAST_SESSIONS 3
+
+class MulticastGroup {
+    public:
+        MulticastGroup(mDot* dot, std::vector<uint8_t>* ret, bool* filled);
+        ~MulticastGroup();
+        void reset();
+        //void newTime();
+        void processCmd(uint8_t* payload, uint8_t size);
+        int32_t timeToStart();
+        void fixEventQueue();
+
+    private:
+        enum McGroup {
+            PACKAGE_VERSION_MC,
+            STATUS,
+            SETUP,
+            DELETE,
+            CLASS_C_SESSION,
+            DATA_BLOCK_AUTH
+        };
+
+        typedef struct {
+            bool valid;
+            uint8_t dr;
+            uint8_t fragGroup;
+            uint16_t timeout;
+            uint32_t tme;
+            uint32_t freq;
+            uint32_t addr;
+            uint32_t max_frame_count;
+            int32_t timetostart;
+            int32_t class_c_end;
+            int32_t class_c_start;
+            time_t time_setup;
+        } mcgroup;
+        
+        bool* _filled;
+        uint8_t _groupId;
+        uint8_t _ans;
+        uint8_t _delay;
+        uint8_t _token;
+        uint8_t _dr;
+        uint32_t _freq;
+        uint32_t _frame_count;
+        time_t _now;
+        
+        mDot* _dot; 
+        Thread _event_thread;
+        EventQueue _switch_class_queue;
+        mcgroup _mcGroup[MULTICAST_SESSIONS];
+        std::vector<uint8_t>* _ret;
+        std::string _org_class;
+
+        void setupClassC(uint8_t id);
+        static void switchClass(uint32_t freq, uint8_t dr, std::string newClass);
+};
+#endif
--- a/Lora.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/Lora.h	Tue Apr 23 08:51:44 2019 -0500
@@ -103,110 +103,15 @@
     const uint16_t RX2_DELAY_OFFSET = 1000;                     //!< Delay between first and second window
     const uint16_t RXC_OFFSET = 50;                             //!< Time between end of RXC after TX and RX1
 
-    const uint8_t US915_125K_NUM_CHANS = 64;                    //!< Number of 125k channels in US915 channel plan
-    const uint8_t US915_500K_NUM_CHANS = 8;                     //!< Number of 500k channels in US915 channel plan
-
-    const uint32_t US915_125K_FREQ_BASE = 902300000;            //!< Frequency base for 125k US915 uplink channels
-    const uint32_t US915_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k US915 uplink channels
-
-    const uint32_t US915_500K_FREQ_BASE = 903000000;            //!< Frequency base for 500k US915 uplink channels
-    const uint32_t US915_500K_FREQ_STEP = 1600000;              //!< Frequency step for 500k US915 uplink channels
-
-    const uint32_t US915_500K_DBASE = 923300000;                //!< Frequency base for 500k US915 downlink channels
-    const uint32_t US915_500K_DSTEP = 600000;                   //!< Frequency step for 500k US915 downlink channels
-
-    const uint32_t US915_FREQ_MIN = 902000000;
-    const uint32_t US915_FREQ_MAX = 928000000;
-
-    const uint8_t US915_MIN_DATARATE = (uint8_t) DR_0;       //!< Minimum transmit datarate for US915
-    const uint8_t US915_MAX_DATARATE = (uint8_t) DR_4;       //!< Maximum transmit datarate for US915
-
-    const uint8_t US915_MIN_DATARATE_OFFSET = (uint8_t) 0;       //!< Minimum transmit datarate for US915
-    const uint8_t US915_MAX_DATARATE_OFFSET = (uint8_t) 3;       //!< Maximum transmit datarate for US915
-
-    const uint8_t AU915_125K_NUM_CHANS = 64;                    //!< Number of 125k channels in AU915 channel plan
-    const uint8_t AU915_500K_NUM_CHANS = 8;                     //!< Number of 500k channels in AU915 channel plan
-
-    const uint32_t AU915_125K_FREQ_BASE = 915200000;            //!< Frequency base for 125k AU915 uplink channels
-    const uint32_t AU915_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k AU915 uplink channels
-
-    const uint32_t AU915_500K_FREQ_BASE = 915900000;            //!< Frequency base for 500k AU915 uplink channels
-    const uint32_t AU915_500K_FREQ_STEP = 1600000;              //!< Frequency step for 500k AU915 uplink channels
-
-    const uint32_t AU915_500K_DBASE = 923300000;                //!< Frequency base for 500k AU915 downlink channels
-    const uint32_t AU915_500K_DSTEP = 600000;                   //!< Frequency step for 500k AU915 downlink channels
-
-    const uint32_t AU915_FREQ_MIN = 915000000;
-    const uint32_t AU915_FREQ_MAX = 928000000;
-
-    const uint8_t AU915_MIN_DATARATE = (uint8_t) DR_0;       //!< Minimum transmit datarate for AU915
-    const uint8_t AU915_MAX_DATARATE = (uint8_t) DR_6;       //!< Maximum transmit datarate for AU915
-
-    const uint8_t AU915_MIN_DATARATE_OFFSET = (uint8_t) 0;       //!< Minimum transmit datarate for AU915
-    const uint8_t AU915_MAX_DATARATE_OFFSET = (uint8_t) 5;       //!< Maximum transmit datarate for AU915
-
-    const uint8_t EU868_125K_NUM_CHANS = 16;                    //!< Number of 125k channels in EU868 channel plan
-    const uint8_t EU868_DEFAULT_NUM_CHANS = 3;                  //!< Number of default channels in EU868 channel plan
-    const uint32_t EU868_125K_FREQ_BASE = 868100000;            //!< Frequency base for 125k EU868 uplink channels
-    const uint32_t EU868_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k EU868 uplink channels
-    const uint32_t EU868_RX2_FREQ = 869525000;                  //!< Frequency default for second rx window in EU868
-
-    const uint8_t EU868_TX_POWER_MAX = 14;                      //!< Max power for EU868 channel plan
-
-    const uint8_t KR920_125K_NUM_CHANS = 16;                    //!< Number of 125k channels in KR920 channel plan
-    const uint8_t KR920_DEFAULT_NUM_CHANS = 3;                  //!< Number of default channels in KR920 channel plan
-    const uint32_t KR920_125K_FREQ_BASE = 868100000;            //!< Frequency base for 125k KR920 uplink channels
-    const uint32_t KR920_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k KR920 uplink channels
-    const uint32_t KR920_RX2_FREQ = 869525000;                  //!< Frequency default for second rx window in KR920
-
-    const uint8_t KR920_TX_POWER_MAX = 14;                      //!< Max power for KR920 channel plan
-
-    const uint8_t AS923_125K_NUM_CHANS = 16;                    //!< Number of 125k channels in AS923 channel plan
-    const uint8_t AS923_DEFAULT_NUM_CHANS = 2;                  //!< Number of default channels in AS923 channel plan
-    const uint32_t AS923_125K_FREQ_BASE = 868100000;            //!< Frequency base for 125k AS923 uplink channels
-    const uint32_t AS923_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k AS923 uplink channels
-    const uint32_t AS923_RX2_FREQ = 869525000;                  //!< Frequency default for second rx window in AS923
-
-    const uint8_t AS923_TX_POWER_MAX = 14;                      //!< Max power for AS923 channel plan
-
-    const uint8_t IN865_125K_NUM_CHANS = 16;                    //!< Number of 125k channels in IN865 channel plan
-    const uint8_t IN865_DEFAULT_NUM_CHANS = 3;                  //!< Number of default channels in IN865 channel plan
-    const uint32_t IN865_125K_DEF_FREQ_1 = 865062500;
-    const uint32_t IN865_125K_DEF_FREQ_2 = 865402500;
-    const uint32_t IN865_125K_DEF_FREQ_3 = 865985000;
-    const uint32_t IN865_RX2_FREQ = 866550000;                  //!< Frequency default for second rx window in IN865
-
-    const uint8_t IN865_TX_POWER_MAX = 30;                      //!< Max power for IN865 channel plan
-
-    // 0.1% duty cycle 863-868
-    // Limiting to 865-868 allows for 1% duty cycle
-    const uint32_t EU868_MILLI_FREQ_MIN = 865000000;
-    const uint32_t EU868_MILLI_FREQ_MAX = 868000000;
-
-    const uint32_t EU868_MILLI_1_FREQ_MIN = 868700000;
-    const uint32_t EU868_MILLI_1_FREQ_MAX = 869200000;
-
-    // 1% duty cycle
-    const uint32_t EU868_CENTI_FREQ_MIN = 868000000;
-    const uint32_t EU868_CENTI_FREQ_MAX = 868600000;
-
-    // 10% duty cycle
-    const uint32_t EU868_DECI_FREQ_MIN = 869400000;
-    const uint32_t EU868_DECI_FREQ_MAX = 869650000;
-
-    // Below 7dBm there is no duty cycle for these frequencies
-    // Up to 14dBm there is 1% duty cycle
-    const uint32_t EU868_VAR_FREQ_MIN = 869700000;
-    const uint32_t EU868_VAR_FREQ_MAX = 870000000;
-
-    const uint32_t EU868_FREQ_MIN = 863000000;
-    const uint32_t EU868_FREQ_MAX = 870000000;
-
-    const uint8_t EU868_MIN_DATARATE = (uint8_t) DR_0;       //!< Minimum transmit datarate for EU868
-    const uint8_t EU868_MAX_DATARATE = (uint8_t) DR_7;       //!< Maximum transmit datarate for EU868
-
-    const uint8_t EU868_MIN_DATARATE_OFFSET = (uint8_t) 0;       //!< Minimum transmit datarate for US915
-    const uint8_t EU868_MAX_DATARATE_OFFSET = (uint8_t) 5;       //!< Maximum transmit datarate for US915
+    const uint16_t BEACON_PREAMBLE_LENGTH = 10U;                //!< Beacon preamble length
+    const uint16_t DEFAULT_BEACON_PERIOD = 128U;                //!< Default period of the beacon (in seconds)
+    const uint16_t PING_SLOT_LENGTH = 30U;                      //!< Duration of each class B ping slot (in milliseconds)
+    const uint16_t BEACON_RESERVED_TIME = 2120U;                //!< Time reserved for beacon broadcast (in milliseconds)
+    const uint16_t BEACON_GUARD_TIME = 3000U;                   //!< Guard time before beacon transmission where no ping slots can be scheduled (in milliseconds)
+    const uint32_t MAX_BEACONLESS_OP_TIME = 7200U;              //!< Maximum time to operate in class B since last beacon received (in seconds)
+    const uint16_t MAX_CLASS_B_WINDOW_GROWTH = 3U;              //!< Maximum window growth factor for beacons and ping slots in beacon-less operation
+    const uint16_t DEFAULT_PING_NB = 1U;                        //!< Default number of ping slots per beacon interval
+    const uint16_t CLS_B_PAD = 15U;                             //!< Pad added to the beginning of ping slot rx windows (in milliseconds)
 
     const int16_t DEFAULT_FREE_CHAN_RSSI_THRESHOLD = -90;       //!< Threshold for channel activity detection (CAD) dBm
 
@@ -225,8 +130,8 @@
     const uint8_t PKT_JOIN_DL_SETTINGS = 11;                    //!< Index to downlink settings in Join Accept message
     const uint8_t PKT_JOIN_RX_DELAY = 12;                       //!< Index to rx delay in Join Accept message
 
-    const uint8_t ADR_ACK_LIMIT = 64;                           //!< Number of packets without ADR ACK Request
-    const uint8_t ADR_ACK_DELAY = 32;                           //!< Number of packets to expect ADR ACK Response within
+    const uint8_t DEFAULT_ADR_ACK_LIMIT = 64;                   //!< Number of packets without ADR ACK Request
+    const uint8_t DEFAULT_ADR_ACK_DELAY = 32;                   //!< Number of packets to expect ADR ACK Response within
 
     const uint16_t ACK_TIMEOUT = 2000;                          //!< Base millisecond timeout to resend after missed ACK
     const uint16_t ACK_TIMEOUT_RND = 1000;                      //!< Random millisecond adjustment to resend after missed ACK
@@ -297,7 +202,9 @@
         LINK_RX1,       //!< Link has first received window open
         LINK_RX2,       //!< Link has second received window open
         LINK_RXC,       //!< Link has class C received window open
-        LINK_P2P,       //!< Link is busy sending
+        LINK_RX_BEACON, //!< Link has a beacon receive window open
+        LINK_RX_PING,   //!< Link has a ping slot receive window open
+        LINK_P2P        //!< Link is busy sending
     };
 
     /**
@@ -332,18 +239,27 @@
 
 
     /**
-     * Received window used by Link
+     * Receive window used by Link
      */
     enum ReceiveWindows {
         RX_1 = 1,           //!< First receive window
         RX_2,               //!< Second receive window
+        RX_SLOT,            //!< Ping slot receive window
         RX_BEACON,          //!< Beacon receive window
-        RX_SLOT,            //!< Ping Slot receive window
         RXC,                //!< Class C continuous window
         RX_TEST
     };
 
     /**
+     * Beacon info descriptors for the GwSpecific Info field
+     */
+    enum BeaconInfoDesc {
+        GPS_FIRST_ANTENNA = 0,    //!< GPS coordinates of the gateway's first antenna
+        GPS_SECOND_ANTENNA,       //!< GPS coordinates of the gateway's second antenna
+        GPS_THIRD_ANTENNA,        //!< GPS coordinates of the gateway's third antenna
+    };
+
+    /**
      * Datarate range for a Channel
      */
     typedef union {
@@ -366,7 +282,8 @@
             uint8_t Crc;
             uint8_t TxIQ;
             uint8_t RxIQ;
-            uint8_t SymbolTimeout();
+            uint8_t SymbolTimeout(uint16_t pad_ms = 0);
+            float Timeout();
             Datarate();
     } Datarate;
 
@@ -401,6 +318,16 @@
     } DutyBand;
 
     /**
+     * Beacon data content (w/o CRCs and RFUs)
+     */
+    typedef struct {
+        uint32_t Time;
+        uint8_t InfoDesc;
+        uint32_t Latitude;
+        uint32_t Longitude;
+    } BeaconData_t;
+
+    /**
      * Device configuration
      */
     typedef struct {
@@ -422,6 +349,8 @@
             uint8_t AckAttempts;        //!< Number of attempts to send packet and receive an ACK from server
             uint8_t Retries;            //!< Number of times to resend a packet without receiving an ACK, redundancy
             uint8_t ADREnabled;         //!< Enable adaptive datarate
+            uint16_t AdrAckLimit;       //!< Number of uplinks without a downlink to allow before setting ADRACKReq
+            uint16_t AdrAckDelay;       //!< Number of downlinks to expect ADR ACK Response within
             uint8_t CADEnabled;         //!< Enable listen before talk/channel activity detection
             uint8_t RepeaterMode;       //!< Limit payloads to repeater compatible sizes
             uint8_t TxPower;            //!< Default radio output power in dBm
@@ -430,12 +359,13 @@
             uint32_t TxFrequency;       //!< Frequency for P2P transmit
             int8_t AntennaGain;         //!< Antenna Gain
             uint8_t DisableEncryption;  //!< Disable Encryption
-            uint8_t DisableCRC;        //!< Disable CRC on uplink packets
+            uint8_t DisableCRC;         //!< Disable CRC on uplink packets
             uint16_t P2PACKTimeout;
             uint16_t P2PACKBackoff;
             uint8_t JoinRx1DatarateOffset;  //!< Offset for datarate for first window
             uint32_t JoinRx2Frequency;      //!< Frequency used in second window
             uint8_t JoinRx2DatarateIndex;   //!< Datarate for second window
+            uint8_t PingPeriodicity;        //!< Number of ping slots to open in a beacon interval (2^(7-PingPeriodicity))
     } NetworkConfig;
 
     /**
@@ -444,9 +374,15 @@
      */
     typedef struct {
             uint8_t Joined;                     //!< State of session
+            uint8_t Class;                      //!< Operating class of device
             uint8_t Rx1DatarateOffset;          //!< Offset for datarate for first window
             uint32_t Rx2Frequency;              //!< Frequency used in second window
             uint8_t Rx2DatarateIndex;           //!< Datarate for second window
+            uint32_t BeaconFrequency;           //!< Frequency used for the beacon window
+            bool BeaconFreqHop;                 //!< Beacon frequency hopping enable
+            uint32_t PingSlotFrequency;         //!< Frequency used for ping slot windows
+            uint8_t PingSlotDatarateIndex;      //!< Datarate for the ping slots
+            bool PingSlotFreqHop;               //!< Ping slot frequency hopping enable
             uint8_t TxPower;                    //!< Current total radiated output power in dBm
             uint8_t TxDatarate;                 //!< Current datarate can be changed when ADR is enabled
             uint32_t Address;                   //!< Network address
@@ -490,15 +426,6 @@
     } MulticastSession;
 
     /**
-     * Application configuration
-     */
-    typedef struct {
-            uint8_t Port;                   //!< Port used by application
-            uint8_t AppEUI;                 //!< Application ID
-            uint8_t AppKey[16];             //!< Application Key
-    } ApplicationConfig;
-
-    /**
      * Statistics of current network session
      */
     typedef struct Statistics {
@@ -539,7 +466,6 @@
             DeviceConfig Device;
             NetworkConfig Network;
             NetworkSession Session;
-            ApplicationConfig Applications[MAX_APPS];
             MulticastSession Multicast[MAX_MULTICAST_SESSIONS];
             Statistics Stats;
             Testing Test;
@@ -636,13 +562,16 @@
         MOTE_MAC_RX_TIMING_SETUP_ANS = 0x08,
         MOTE_MAC_TX_PARAM_SETUP_ANS = 0x09,
         MOTE_MAC_DL_CHANNEL_ANS = 0x0A,
+        MOTE_MAC_REKEY_IND = 0x0B,
+        MOTE_MAC_ADR_PARAM_SETUP_ANS = 0x0C,
+        MOTE_MAC_DEVICE_TIME_REQ = 0x0D,
+        MOTE_MAC_REJOIN_PARAM_SETUP_ANS = 0x0F,
 
         /* Class B */
-        MOTE_MAC_PING_SLOT_INFO_REQ = 0x0B,
-        MOTE_MAC_PING_SLOT_FREQ_ANS = 0x0C,
-        MOTE_MAC_PING_SLOT_CHANNEL_ANS = 0x0D,
-        MOTE_MAC_BEACON_TIMING_REQ = 0x0E,
-        MOTE_MAC_BEACON_FREQ_ANS = 0x0F,
+        MOTE_MAC_PING_SLOT_INFO_REQ = 0x10,
+        MOTE_MAC_PING_SLOT_CHANNEL_ANS = 0x11,
+        MOTE_MAC_BEACON_TIMING_REQ = 0x12,
+        MOTE_MAC_BEACON_FREQ_ANS = 0x13,
 
         /* Multitech */
         MOTE_MAC_PING_REQ = 0x80,
@@ -668,13 +597,17 @@
         SRV_MAC_RX_TIMING_SETUP_REQ = 0x08,
         SRV_MAC_TX_PARAM_SETUP_REQ = 0x09,
         SRV_MAC_DL_CHANNEL_REQ = 0x0A,
+        SRV_MAC_REKEY_CONF = 0x0B,
+        SRV_MAC_ADR_PARAM_SETUP_REQ = 0x0C,
+        SRV_MAC_DEVICE_TIME_ANS = 0x0D,
+        SRV_MAC_FORCE_REJOIN_REQ = 0x0E,
+        SRV_MAC_REJOIN_PARAM_SETUP_REQ = 0x0F,
 
         /* Class B */
-        SRV_MAC_PING_SLOT_INFO_ANS = 0x0B,
-        SRV_MAC_PING_SLOT_FREQ_REQ = 0x0C,
-        SRV_MAC_PING_SLOT_CHANNEL_REQ = 0x0D,
-        SRV_MAC_BEACON_TIMING_ANS = 0x0E,
-        SRV_MAC_BEACON_FREQ_REQ = 0x0F,
+        SRV_MAC_PING_SLOT_INFO_ANS = 0x10,
+        SRV_MAC_PING_SLOT_CHANNEL_REQ = 0x11,
+        SRV_MAC_BEACON_TIMING_ANS = 0x12,
+        SRV_MAC_BEACON_FREQ_REQ = 0x13,
 
         /* Multitech */
         SRV_MAC_PING_ANS = 0x80,
@@ -687,6 +620,15 @@
     } ServerCommand;
 
     /**
+     * Radio configuration options
+     */
+    typedef enum RadioCfg {
+        NO_RADIO_CFG,
+        TX_RADIO_CFG,
+        RX_RADIO_CFG
+    } RadioCfg_t;
+
+    /**
      * Random seed for software RNG
      */
     void srand(uint32_t seed);
--- a/MTS-Lora/vendor/multitech/MTS-Utils/MTSLog.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/MTS-Lora/vendor/multitech/MTS-Utils/MTSLog.h	Tue Apr 23 08:51:44 2019 -0500
@@ -16,6 +16,14 @@
 
 #define __CLASSNAME__ className(__PRETTY_FUNCTION__)
 
+#ifdef MTS_TIMESTAMP_LOG
+#define __LOG__(logLevel, format, ...)                                   \
+    mts::MTSLog::printMessage(logLevel, "%s| [%s] " format "\r\n", \
+                              mts::MTSLog::getTime().c_str(), mts::MTSLog::getLogLevelString(logLevel), ##__VA_ARGS__)
+#else
+#define __LOG__(logLevel, format, ...)                                   \
+    mts::MTSLog::printMessage(logLevel, "[%s] " format "\r\n", mts::MTSLog::getLogLevelString(logLevel), ##__VA_ARGS__)
+#endif
 
 #ifdef MTS_DEBUG
 #define logFatal(format, ...) \
@@ -32,17 +40,17 @@
     mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "%s:%s:%d| [%s] " format "\r\n", __CLASSNAME__, __func__, __LINE__, mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
 #else
 #define logFatal(format, ...) \
-    mts::MTSLog::printMessage(mts::MTSLog::FATAL_LEVEL, "[%s] " format "\r\n", mts::MTSLog::FATAL_LABEL, ##__VA_ARGS__)
+    __LOG__(mts::MTSLog::FATAL_LEVEL, format, ##__VA_ARGS__)
 #define logError(format, ...) \
-    mts::MTSLog::printMessage(mts::MTSLog::ERROR_LEVEL, "[%s] " format "\r\n", mts::MTSLog::ERROR_LABEL, ##__VA_ARGS__)
+    __LOG__(mts::MTSLog::ERROR_LEVEL, format, ##__VA_ARGS__)
 #define logWarning(format, ...) \
-    mts::MTSLog::printMessage(mts::MTSLog::WARNING_LEVEL, "[%s] " format "\r\n", mts::MTSLog::WARNING_LABEL, ##__VA_ARGS__)
+    __LOG__(mts::MTSLog::WARNING_LEVEL, format, ##__VA_ARGS__)
 #define logInfo(format, ...) \
-    mts::MTSLog::printMessage(mts::MTSLog::INFO_LEVEL, "[%s] " format "\r\n", mts::MTSLog::INFO_LABEL, ##__VA_ARGS__)
+    __LOG__(mts::MTSLog::INFO_LEVEL, format, ##__VA_ARGS__)
 #define logDebug(format, ...) \
-    mts::MTSLog::printMessage(mts::MTSLog::DEBUG_LEVEL, "[%s] " format "\r\n", mts::MTSLog::DEBUG_LABEL, ##__VA_ARGS__)
+    __LOG__(mts::MTSLog::DEBUG_LEVEL, format, ##__VA_ARGS__)
 #define logTrace(format, ...) \
-    mts::MTSLog::printMessage(mts::MTSLog::TRACE_LEVEL, "[%s] " format "\r\n", mts::MTSLog::TRACE_LABEL, ##__VA_ARGS__)
+    __LOG__(mts::MTSLog::TRACE_LEVEL, format, ##__VA_ARGS__)
 #endif
 
 namespace mts {
@@ -84,6 +92,11 @@
     /** Get string representation of the current log level.
      */
     static const char* getLogLevelString();
+    static const char* getLogLevelString(int level);
+
+    /** Get a formatted time string as HH:MM:SS
+     */
+    static std::string getTime();
 
     static const char* NONE_LABEL;
     static const char* FATAL_LABEL;
--- a/MacEvents.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/MacEvents.h	Tue Apr 23 08:51:44 2019 -0500
@@ -34,6 +34,10 @@
             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, uint32_t address=0, bool dupRx=false) = 0;
             virtual void RxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot) = 0;
 
+            virtual void BeaconRx(const BeaconData_t& beacon_data, int16_t rssi, int8_t snr) = 0;
+            virtual void BeaconLost() = 0;
+            virtual void ServerTime(uint32_t seconds, uint8_t sub_seconds) = 0;
+
             virtual void Pong(int16_t m_rssi, int8_t m_snr, int16_t s_rssi, int8_t s_snr) = 0;
             virtual void NetworkLinkCheck(int16_t m_rssi, int8_t m_snr, int8_t s_snr, uint8_t s_gateways) = 0;
 
--- a/Mote.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/Mote.h	Tue Apr 23 08:51:44 2019 -0500
@@ -16,8 +16,11 @@
 #ifndef __LORA_MOTE_H__
 #define __LORA_MOTE_H__
 
-#include "rtos.h"
+#include "mbed.h"
+#include "mbed_events.h"
+
 #include "MacEvents.h"
+
 #include <vector>
 
 class SxRadio;
@@ -91,6 +94,19 @@
             virtual void RxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot);
 
             /**
+             * Fired when a beacon is received
+             * @param beacon_data parsed from the beacon payload
+             * @param rssi of received beacon
+             * @param snr of received beacon
+             */
+            virtual void BeaconRx(const BeaconData_t& beacon_data, int16_t rssi, int8_t snr);
+
+            /**
+             * Fired upon losing beacon synchronization (120 minutes elapsed from last beacon reception)
+             */
+            virtual void BeaconLost();
+
+            /**
              * Fired if rx window times out
              * @param slot rx window that timed out
              */
@@ -121,6 +137,13 @@
             virtual void NetworkLinkCheck(int16_t m_rssi, int8_t m_snr, int8_t s_snr, uint8_t s_gateways);
 
             /**
+             * Fired upon receiving a server time answer
+             * @param seconds from the GPS epoch
+             * @param sub_seconds from the GPS epoch
+             */
+            virtual void ServerTime(uint32_t seconds, uint8_t sub_seconds);
+
+            /**
              * Callback to for device to measure the battery level and report to server
              * @return battery level 0-255, 0 - external power, 1-254 level min-max, 255 device unable to measure battery
              */
@@ -293,6 +316,10 @@
         private:
             ChannelPlan* _plan;
             MoteEvents _events;
+
+            // Event queue objects for timing events
+            EventQueue _evtQueue;
+            Thread _dispatch_thread;
     };
 
 }
--- a/SxRadio.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/SxRadio.h	Tue Apr 23 08:51:44 2019 -0500
@@ -45,7 +45,7 @@
         RF_CAD,
     }RadioState_t;
 
-    SxRadio(uint32_t WakeupTime) : WakeupTime(WakeupTime), State(RF_IDLE), Modem(MODEM_LORA) { }
+    SxRadio(uint32_t WakeupTime) : WakeupTime(WakeupTime), freq_offset(0), State(RF_IDLE), Modem(MODEM_LORA) { }
     virtual ~SxRadio() {};
 
     /*!
@@ -67,9 +67,10 @@
     /*!
      * \brief Configures the radio with the given modem
      *
-     * \param [IN] modem Modem to be used [0: FSK, 1: LoRa] 
+     * \param [IN] modem Modem to be used [0: FSK, 1: LoRa]
      */
     virtual void SetModem( RadioModems_t modem ) = 0;
+	virtual RadioModems_t GetModem( void ) { return Modem; }
     /*!
      * \brief Sets the channel frequency
      *
@@ -90,7 +91,7 @@
     /*!
      * \brief Generates a 32 bits random value based on the RSSI readings
      *
-     * \remark This function sets the radio in LoRa modem mode and disables 
+     * \remark This function sets the radio in LoRa modem mode and disables
      *         all interrupts.
      *         After calling this function either Radio.SetRxConfig or
      *         Radio.SetTxConfig functions must be called.
@@ -105,22 +106,22 @@
      * \param [IN] bandwidth    Sets the bandwidth
      *                          FSK : >= 2600 and <= 250000 Hz
      *                          LoRa: [0: 125 kHz, 1: 250 kHz,
-     *                                 2: 500 kHz, 3: Reserved] 
+     *                                 2: 500 kHz, 3: Reserved]
      * \param [IN] datarate     Sets the Datarate
      *                          FSK : 600..300000 bits/s
      *                          LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
      *                                10: 1024, 11: 2048, 12: 4096  chips]
      * \param [IN] coderate     Sets the coding rate (LoRa only)
      *                          FSK : N/A ( set to 0 )
-     *                          LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] 
-     * \param [IN] bandwidthAfc Sets the AFC Bandwidth (FSK only) 
+     *                          LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
+     * \param [IN] bandwidthAfc Sets the AFC Bandwidth (FSK only)
      *                          FSK : >= 2600 and <= 250000 Hz
-     *                          LoRa: N/A ( set to 0 ) 
+     *                          LoRa: N/A ( set to 0 )
      * \param [IN] preambleLen  Sets the Preamble length
-     *                          FSK : Number of bytes 
+     *                          FSK : Number of bytes
      *                          LoRa: Length in symbols (the hardware adds 4 more symbols)
-     * \param [IN] symbTimeout  Sets the RxSingle timeout value (LoRa only) 
-     *                          FSK : N/A ( set to 0 ) 
+     * \param [IN] symbTimeout  Sets the RxSingle timeout value (LoRa only)
+     *                          FSK : N/A ( set to 0 )
      *                          LoRa: timeout in symbols
      * \param [IN] fixLen       Fixed length packets [0: variable, 1: fixed]
      * \param [IN] payloadLen   Sets payload length when fixed length is used
@@ -136,6 +137,9 @@
      *                          LoRa: [0: not inverted, 1: inverted]
      * \param [IN] rxContinuous Sets the reception in continuous mode
      *                          [false: single mode, true: continuous mode]
+     * \param [IN] fskPad       Duration in ms to increase FSK rx window
+     *                          FSK: time in ms to increase FSK rx window duration
+     *                          LoRa: N/A
      */
     virtual void SetRxConfig( RadioModems_t modem, uint32_t bandwidth,
                               uint32_t datarate, uint8_t coderate,
@@ -143,11 +147,11 @@
                               uint16_t symbTimeout, bool fixLen,
                               uint8_t payloadLen,
                               bool crcOn, bool FreqHopOn, uint8_t HopPeriod,
-                              bool iqInverted, bool rxContinuous ) = 0;
+                              bool iqInverted, bool rxContinuous , uint32_t fskPad = 0) = 0;
     /*!
      * \brief Sets the transmission parameters
      *
-     * \param [IN] modem        Radio modem to be used [0: FSK, 1: LoRa] 
+     * \param [IN] modem        Radio modem to be used [0: FSK, 1: LoRa]
      * \param [IN] power        Sets the output power [dBm]
      * \param [IN] fdev         Sets the frequency deviation (FSK only)
      *                          FSK : [Hz]
@@ -155,16 +159,16 @@
      * \param [IN] bandwidth    Sets the bandwidth (LoRa only)
      *                          FSK : 0
      *                          LoRa: [0: 125 kHz, 1: 250 kHz,
-     *                                 2: 500 kHz, 3: Reserved] 
+     *                                 2: 500 kHz, 3: Reserved]
      * \param [IN] datarate     Sets the Datarate
      *                          FSK : 600..300000 bits/s
      *                          LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
      *                                10: 1024, 11: 2048, 12: 4096  chips]
      * \param [IN] coderate     Sets the coding rate (LoRa only)
      *                          FSK : N/A ( set to 0 )
-     *                          LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] 
+     *                          LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
      * \param [IN] preambleLen  Sets the preamble length
-     *                          FSK : Number of bytes 
+     *                          FSK : Number of bytes
      *                          LoRa: Length in symbols (the hardware adds 4 more symbols)
      * \param [IN] fixLen       Fixed length packets [0: variable, 1: fixed]
      * \param [IN] crcOn        Enables disables the CRC [0: OFF, 1: ON]
@@ -179,13 +183,15 @@
      *                          LoRa: [0: not inverted, 1: inverted]
      * \param [IN] timeout      Transmission timeout [us]
      */
-    virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev, 
+    virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev,
                               uint32_t bandwidth, uint32_t datarate,
                               uint8_t coderate, uint16_t preambleLen,
                               bool fixLen, bool crcOn, bool FreqHopOn,
                               uint8_t HopPeriod, bool iqInverted, uint32_t timeout ) = 0;
 
-    virtual void SetTxContinuous(bool enable) = 0;
+    virtual void SetTxPower(int8_t power) = 0;
+
+    virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time ) = 0;
 
     /*!
      * \brief Checks if the given RF frequency is supported by the hardware
@@ -269,6 +275,7 @@
     virtual void ReadBuffer( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
 
     virtual void SignalMacEvent(void) {};
+    virtual void SignalLinkEvent(void) {};
 
     virtual void ResetRadio(void) {};
 
@@ -277,9 +284,17 @@
     void GrabMutex(void) { mutex.lock(); }
     void ReleaseMutex(void) { mutex.unlock(); }
 
+    int32_t GetFrequencyOffset() { return freq_offset; }
+    void SetFrequencyOffset(int32_t offset) { freq_offset = offset; }
+
     const uint32_t WakeupTime;
 
+
+
+
 protected:
+    int32_t freq_offset;
+
     RadioState_t State;
 
     RadioModems_t Modem;
@@ -288,6 +303,7 @@
      * Access protection
      */
     Mutex mutex;
+
 };
 
 #endif // __SXRADIO_H__
Binary file libxDot-ARMCC.ar has changed
Binary file libxDot-GCC_ARM.a has changed
--- a/mDot.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/mDot.h	Tue Apr 23 08:51:44 2019 -0500
@@ -1,4 +1,30 @@
-// TODO: add license header
+/**********************************************************************
+* COPYRIGHT 2015 MULTI-TECH SYSTEMS, INC.
+*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*   1. Redistributions of source code must retain the above copyright notice,
+*      this list of conditions and the following disclaimer.
+*   2. Redistributions in binary form must reproduce the above copyright notice,
+*      this list of conditions and the following disclaimer in the documentation
+*      and/or other materials provided with the distribution.
+*   3. Neither the name of MULTI-TECH SYSTEMS, INC. nor the names of its contributors
+*      may be used to endorse or promote products derived from this software
+*      without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+******************************************************************************
+*/
 
 #ifndef MDOT_H
 #define MDOT_H
@@ -35,9 +61,14 @@
         void waitForPacket();
         void waitForLinkCheck();
 
+
+        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
         void setActivityLedState(const uint8_t& state);
+
+        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
         uint8_t getActivityLedState();
 
+        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
         void blinkActivityLed(void) {
             if (_activity_led) {
                 int val = _activity_led->read();
@@ -51,6 +82,9 @@
         uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);
         void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);
 
+        void RTC_DisableWakeupTimer();
+        void RTC_EnableWakeupTimer();
+
         void enterStopMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM);
         void enterStandbyMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM);
 
@@ -63,12 +97,12 @@
 
         std::string _last_error;
         static const uint32_t _baud_rates[];
-        uint8_t _activity_led_state;
+        uint8_t _activity_led_state; //deprecated will be removed
         Ticker _tick;
-        DigitalOut* _activity_led;
-        bool _activity_led_enable;
-        PinName _activity_led_pin;
-        bool _activity_led_external;
+        DigitalOut* _activity_led; //deprecated will be removed
+        bool _activity_led_enable; //deprecated will be removed
+        PinName _activity_led_pin;  //deprecated will be removed
+        bool _activity_led_external; //deprecated will be removed
         uint8_t _linkFailCount;
         uint8_t _class;
         InterruptIn* _wakeup;
@@ -127,7 +161,8 @@
 
         enum RX_Output {
             HEXADECIMAL,
-            BINARY
+            BINARY,
+            EXTENDED
         };
 
         enum DataRates {
@@ -161,11 +196,6 @@
             FSB_8
         };
 
-        enum JoinByteOrder {
-            LSB,
-            MSB
-        };
-
         enum wakeup_mode {
             RTC_ALARM,
             INTERRUPT,
@@ -264,7 +294,7 @@
         static mDot* getInstance(lora::ChannelPlan* plan);
 
         /**
-	 * Can only be used after a dot has 
+	 * Can only be used after a dot has
          * configured with a plan
          * @returns pointer to mDot object
          */
@@ -328,41 +358,29 @@
          */
         void seedRandom(uint32_t seed);
 
+        /**
+         * @returns true if MAC command answers are ready to be sent
+         */
+        bool hasMacCommands();
+
 
         uint8_t setChannelPlan(lora::ChannelPlan* plan);
 
         lora::Settings* getSettings();
 
-        /**
-         * Enable or disable the activity LED.
-         * @param enable true to enable the LED, false to disable
-         */
+        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
         void setActivityLedEnable(const bool& enable);
 
-        /**
-         * Find out if the activity LED is enabled
-         * @returns true if activity LED is enabled, false if disabled
-         */
+        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
         bool getActivityLedEnable();
 
-        /**
-         * Use a different pin for the activity LED.
-         * The default is XBEE_RSSI.
-         * @param pin the new pin to use
-         */
+        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
         void setActivityLedPin(const PinName& pin);
 
-        /**
-         * Use an external DigitalOut object for the activity LED.
-         * The pointer must stay valid!
-         * @param pin the DigitalOut object to use
-         */
+        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
         void setActivityLedPin(DigitalOut* pin);
 
-        /**
-         * Find out what pin the activity LED is on
-         * @returns the pin the activity LED is using
-         */
+        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
         PinName getActivityLedPin();
 
         /**
@@ -723,18 +741,6 @@
         int32_t setMulticastDownlinkCounter(uint8_t index, uint32_t count);
 
         /**
-         * Set join byte order
-         * @param order 0:LSB 1:MSB
-         */
-        uint32_t setJoinByteOrder(uint8_t order);
-
-        /**
-         * Get join byte order
-         * @returns byte order to use in joins 0:LSB 1:MSB
-         */
-        uint8_t getJoinByteOrder();
-
-        /**
          * Attempt to join network
          * each attempt will be made with a random datarate up to the configured datarate
          * JoinRequest backoff between tries is enforced to 1% for 1st hour, 0.1% for 1-10 hours and 0.01% after 10 hours
@@ -903,6 +909,12 @@
         uint32_t getNextTxMs();
 
         /**
+         * Get available bytes for payload
+         * @returns bytes
+         */
+        uint8_t getNextTxMaxSize();
+
+        /**
          * Get join delay in seconds
          *  Defaults to 5 seconds
          *  Must match join delay setting of the network server
@@ -1077,6 +1089,7 @@
          * @returns spreading factor and bandwidth
          */
         std::string getDataRateDetails(uint8_t rate);
+        MBED_DEPRECATED("Will be removed in 3.3.0")
         std::string getDateRateDetails(uint8_t rate);
 
 
@@ -1194,6 +1207,21 @@
         uint8_t getMinTxPower();
 
         /**
+         * Set ping slot periodicity
+         * Specify the the number of ping slots in a given beacon interval
+         * Note: Must switch back to class A for the change to take effect
+         * @param exp - number_of_pings = 2^(7 - exp) where 0 <= exp <= 7
+         * @returns MDOT_OK if success
+         */
+        uint32_t setPingPeriodicity(uint8_t exp);
+
+        /**
+         * Get ping slot periodicity
+         * @returns exp = 7 - log2(number_of_pings)
+         */
+        uint8_t getPingPeriodicity();
+
+        /**
          *
          * get/set adaptive data rate
          * configure data rates and power levels based on signal to noise of packets received at gateway
@@ -1204,17 +1232,28 @@
         bool getAdr();
 
         /**
-         * Set forward error correction bytes
-         * @param bytes 1 - 4 bytes
-         * @returns MDOT_OK if success
+         * Set the ADR ACK Limit
+         * @param limit - ADR ACK limit
          */
-        int32_t setFec(const uint8_t& bytes);
+        void setAdrAckLimit(uint16_t limit);
 
         /**
-         * Get forward error correction bytes
-         * @returns bytes (1 - 4)
+         * Get the ADR ACK Limit
+         * @returns ADR ACK limit
          */
-        uint8_t getFec();
+        uint16_t getAdrAckLimit();
+
+        /**
+         * Set the ADR ACK Delay
+         * @param delay - ADR ACK delay
+         */
+        void setAdrAckDelay(uint16_t delay);
+
+        /**
+         * Get the ADR ACK Delay
+         * @returns ADR ACK delay
+         */
+        uint16_t getAdrAckDelay();
 
         /**
          * Enable/disable CRC checking of packets
@@ -1404,6 +1443,26 @@
          */
         int8_t getLbtThreshold();
 
+        /**
+         * Get Radio Frequency Offset
+         * Used for fine calibration of radio frequencies
+         * @returns frequency offset in MHz
+         */
+        int32_t getFrequencyOffset();
+        /**
+         * Get Radio Frequency Offset
+         * Used for fine calibration of radio frequencies
+         * @param offset frequency offset in MHz
+         */
+        void setFrequencyOffset(int32_t offset);
+
+        /**
+         * Get GPS time from network server
+         * Sends a DeviceTimeReq command to the network server
+         * @returns time since GPS epoch, 0 on failure
+         */
+        uint64_t getGPSTime();
+
 #if defined(TARGET_MTS_MDOT_F411RE)
         ///////////////////////////////////////////////////////////////////
         // Filesystem (Non Volatile Memory) Operation Functions for mDot //
@@ -1481,11 +1540,15 @@
         // file - name of file
         // returns true if successful
         bool moveUserFileToFirmwareUpgrade(const char* file);
+
+        // Return total size of all files saved in FLASH
+        // Does not include SPIFFS overhead
+        uint32_t getUsedSpace();
 #else
         ///////////////////////////////////////////////////////////////
         // EEPROM (Non Volatile Memory) Operation Functions for xDot //
         ///////////////////////////////////////////////////////////////
-        
+
         // Write to EEPROM
         // addr - address to write to (0 - 0x17FF)
         // data - data to write
@@ -1557,8 +1620,6 @@
         uint8_t getRxDataRate();
 
         // get/set TX/RX frequency
-        // if frequency band == FB_868 (Europe), must be between 863000000 - 870000000
-        // if frequency band == FB_915 (United States), must be between 902000000-928000000
         // if set to 0, device will hop frequencies
         // set function returns MDOT_OK if success
         int32_t setTxFrequency(const uint32_t& freq);
@@ -1566,16 +1627,8 @@
         int32_t setRxFrequency(const uint32_t& freq);
         uint32_t getRxFrequency();
 
-        // get/set TX/RX inverted
-        // true == signal is inverted
-        // set function returns MDOT_OK if success
-        int32_t setTxInverted(const bool& on);
-        bool getTxInverted();
-        int32_t setRxInverted(const bool& on);
-        bool getRxInverted();
-
         // get/set RX output mode
-        // valid options are HEXADECIMAL and BINARY
+        // valid options are HEXADECIMAL, BINARY, and EXTENDED
         // set function returns MDOT_OK if success
         int32_t setRxOutput(const uint8_t& mode);
         uint8_t getRxOutput();
@@ -1644,67 +1697,39 @@
 
         void openRxWindow(uint32_t timeout, uint8_t bandwidth = 0);
         void closeRxWindow();
-        void sendContinuous(bool enable=true);
+        void sendContinuous(bool enable=true, uint32_t timeout=0, uint32_t frequency=0, int8_t txpower=-1);
         int32_t setDeviceId(const std::vector<uint8_t>& id);
         int32_t setProtectedAppEUI(const std::vector<uint8_t>& appEUI);
         int32_t setProtectedAppKey(const std::vector<uint8_t>& appKey);
         int32_t setDefaultFrequencyBand(const uint8_t& band);
         bool saveProtectedConfig();
-        // resets the radio/mac/link 
+        // resets the radio/mac/link
         void resetRadio();
         int32_t setRadioMode(const uint8_t& mode);
         std::map<uint8_t, uint8_t> dumpRegisters();
         void eraseFlash();
 
-        // deprecated - use setWakeInterval
-        int32_t setSerialWakeInterval(const uint32_t& interval);
-        // deprecated - use getWakeInterval
-        uint32_t getSerialWakeInterval();
-
-        // deprecated - use setWakeDelay
-        int32_t setSerialWakeDelay(const uint32_t& delay);
-        // deprecated - use setWakeDelay
-        uint32_t getSerialWakeDelay();
-
-        // deprecated - use setWakeTimeout
-        int32_t setSerialReceiveTimeout(const uint16_t& timeout);
-        // deprecated - use getWakeTimeout
-        uint16_t getSerialReceiveTimeout();
-
         void setWakeupCallback(void (*function)(void));
 
         template<typename T>
         void setWakeupCallback(T *object, void (T::*member)(void)) {
             _wakeup_callback.attach(object, member);
         }
-        
-        lora::ChannelPlan* getChannelPlan(void);  
+
+        lora::ChannelPlan* getChannelPlan(void);
 
         uint32_t setRx2DataRate(uint8_t dr);
         uint8_t getRx2DataRate();
 
-        void mcGroupKeys(uint8_t *mcKeyEncrypt, uint32_t addr, uint8_t groupId, uint32_t frame_count);  
+        void mcGroupKeys(uint8_t *mcKeyEncrypt, uint32_t addr, uint8_t groupId, uint32_t frame_count);
     private:
-        typedef enum {
-            AUTO_SLEEP_EVT_CFG,
-            AUTO_SLEEP_EVT_TXDONE,
-            AUTO_SLEEP_EVT_RX1_TIMEOUT,
-            AUTO_SLEEP_EVT_CLEANUP
-        } AutoSleepEvent_t;
-
-        typedef enum {
-            USER_SLEEP,
-            AUTO_SLEEP
-        } SleepClient_t;
 
         void sleep_ms(uint32_t interval,
                       uint8_t wakeup_mode = RTC_ALARM,
-                      bool deepsleep = true,
-                      SleepClient_t sleep_client = USER_SLEEP);
+                      bool deepsleep = true);
 
-        void auto_sleep(AutoSleepEvent_t evt);
 
-        void wakeup(SleepClient_t sleep_client);
+        void wakeup();
 
         mdot_stats _stats;
 
--- a/mDotEvent.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/mDotEvent.h	Tue Apr 23 08:51:44 2019 -0500
@@ -1,3 +1,31 @@
+/**********************************************************************
+* COPYRIGHT 2015 MULTI-TECH SYSTEMS, INC.
+*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*   1. Redistributions of source code must retain the above copyright notice,
+*      this list of conditions and the following disclaimer.
+*   2. Redistributions in binary form must reproduce the above copyright notice,
+*      this list of conditions and the following disclaimer in the documentation
+*      and/or other materials provided with the distribution.
+*   3. Neither the name of MULTI-TECH SYSTEMS, INC. nor the names of its contributors
+*      may be used to endorse or promote products derived from this software
+*      without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+******************************************************************************
+*/
+
 #ifndef MDOT_EVENT_H
 #define MDOT_EVENT_H
 
@@ -63,13 +91,15 @@
           PacketReceived(false),
           RxPort(0),
           RxPayloadSize(0),
+          BeaconLocked(false),
           PongReceived(false),
           PongRssi(0),
           PongSnr(0),
+          ServerTimeReceived(false),
+          ServerTimeSeconds(0U),
           AckReceived(false),
           DuplicateRx(false),
-          TxNbRetries(0),
-          _sleep_cb(NULL)
+          TxNbRetries(0)
         {
             memset(&_flags, 0, sizeof(LoRaMacEventFlags));
             memset(&_info, 0, sizeof(LoRaMacEventInfo));
@@ -122,12 +152,12 @@
         virtual void TxStart() {
             logDebug("mDotEvent - TxStart");
 
-            // Fire auto sleep cfg event if enabled
-            if (_sleep_cb)
-                _sleep_cb(mDot::AUTO_SLEEP_EVT_CFG);
         }
 
         virtual void TxDone(uint8_t dr) {
+            _timeSinceTx.reset();
+            _timeSinceTx.start();
+
             RxPayloadSize = 0;
             LinkCheckAnsReceived = false;
             PacketReceived = false;
@@ -145,9 +175,6 @@
             _info.Status = LORAMAC_EVENT_INFO_STATUS_OK;
             Notify();
 
-            // If configured, we can sleep until the rx window opens
-            if (_sleep_cb)
-                _sleep_cb(mDot::AUTO_SLEEP_EVT_TXDONE);
         }
 
         void Notify() {
@@ -170,8 +197,6 @@
             _info.Status = LORAMAC_EVENT_INFO_STATUS_OK;
             Notify();
 
-            if (_sleep_cb)
-                _sleep_cb(mDot::AUTO_SLEEP_EVT_CLEANUP);
         }
 
         virtual void JoinFailed(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) {
@@ -182,8 +207,6 @@
             _info.Status = LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL;
             Notify();
 
-            if (_sleep_cb)
-                _sleep_cb(mDot::AUTO_SLEEP_EVT_CLEANUP);
         }
 
         virtual void MissedAck(uint8_t retries) {
@@ -230,8 +253,17 @@
         virtual void RxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot) {
             logDebug("mDotEvent - RxDone");
 
-            if (_sleep_cb)
-                _sleep_cb(mDot::AUTO_SLEEP_EVT_CLEANUP);
+        }
+
+        virtual void BeaconRx(const lora::BeaconData_t& beacon_data, int16_t rssi, int8_t snr) {
+            logDebug("mDotEvent - BeaconRx");
+            BeaconLocked = true;
+            BeaconData = beacon_data;
+        }
+
+        virtual void BeaconLost() {
+            logDebug("mDotEvent - BeaconLost");
+            BeaconLocked = false;
         }
 
         virtual void Pong(int16_t m_rssi, int8_t m_snr, int16_t s_rssi, int8_t s_snr) {
@@ -241,6 +273,17 @@
             PongSnr = s_snr;
         }
 
+        virtual void ServerTime(uint32_t seconds, uint8_t sub_seconds) {
+            logDebug("mDotEvent - ServerTime");
+            ServerTimeReceived = true;
+
+            uint64_t current_server_time_ms = static_cast<uint64_t>(seconds) * 1000 +
+                static_cast<uint16_t>(sub_seconds) * 4 + _timeSinceTx.read_ms();
+
+            ServerTimeSeconds = static_cast<uint32_t>(current_server_time_ms / 1000);
+            ServerTimeMillis = static_cast<uint16_t>(current_server_time_ms % 1000);
+        }
+
         virtual void NetworkLinkCheck(int16_t m_rssi, int8_t m_snr, int8_t s_snr, uint8_t s_gateways) {
             logDebug("mDotEvent - NetworkLinkCheck");
             LinkCheckAnsReceived = true;
@@ -265,13 +308,6 @@
             _info.Status = LORAMAC_EVENT_INFO_STATUS_RX_TIMEOUT;
             Notify();
 
-            if (_sleep_cb) {
-                // If this is the first rx window we can sleep until the next one
-                if (slot == 1)
-                    _sleep_cb(mDot::AUTO_SLEEP_EVT_RX1_TIMEOUT);
-                else
-                    _sleep_cb(mDot::AUTO_SLEEP_EVT_CLEANUP);
-            }
         }
 
         virtual void RxError(uint8_t slot) {
@@ -284,22 +320,12 @@
             _info.Status = LORAMAC_EVENT_INFO_STATUS_RX_ERROR;
             Notify();
 
-            if (_sleep_cb)
-                _sleep_cb(mDot::AUTO_SLEEP_EVT_CLEANUP);
         }
 
         virtual uint8_t MeasureBattery(void) {
             return 255;
         }
 
-        void AttachSleepCallback(Callback<void(mDot::AutoSleepEvent_t)> cb) {
-            _sleep_cb = cb;
-        }
-
-        void DetachSleepCallback() {
-            _sleep_cb = NULL;
-        }
-
         bool LinkCheckAnsReceived;
         uint8_t DemodMargin;
         uint8_t NbGateways;
@@ -309,10 +335,17 @@
         uint8_t RxPayload[255];
         uint8_t RxPayloadSize;
 
+        bool BeaconLocked;
+        lora::BeaconData_t BeaconData;
+
         bool PongReceived;
         int16_t PongRssi;
         int16_t PongSnr;
 
+        bool ServerTimeReceived;
+        uint32_t ServerTimeSeconds;
+        uint16_t ServerTimeMillis;
+
         bool AckReceived;
         bool DuplicateRx;
         uint8_t TxNbRetries;
@@ -325,12 +358,12 @@
         }
 
     private:
-        /* Hook to inject a sleep method in between receive windows */
-        Callback<void(mDot::AutoSleepEvent_t)> _sleep_cb;
 
         LoRaMacEventFlags _flags;
         LoRaMacEventInfo _info;
 
+        Timer _timeSinceTx;
+
 //
 //        /*!
 //         * MAC layer event callback prototype.
--- a/plans/ChannelPlan_AS923.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/plans/ChannelPlan_AS923.h	Tue Apr 23 08:51:44 2019 -0500
@@ -1,9 +1,29 @@
-/**   __  ___     ____  _    ______        __     ____         __                  ____
- *   /  |/  /_ __/ / /_(_)__/_  __/__ ____/ /    / __/_ _____ / /____ __ _  ___   /  _/__  ____
- *  / /|_/ / // / / __/ /___// / / -_) __/ _ \  _\ \/ // (_-</ __/ -_)  ' \(_-<  _/ // _ \/ __/ __
- * /_/  /_/\_,_/_/\__/_/    /_/  \__/\__/_//_/ /___/\_, /___/\__/\__/_/_/_/___/ /___/_//_/\__/ /_/
- * Copyright (C) 2015 by Multi-Tech Systems        /___/
- *
+/**********************************************************************
+* COPYRIGHT 2015 MULTI-TECH SYSTEMS, INC.
+*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*   1. Redistributions of source code must retain the above copyright notice,
+*      this list of conditions and the following disclaimer.
+*   2. Redistributions in binary form must reproduce the above copyright notice,
+*      this list of conditions and the following disclaimer in the documentation
+*      and/or other materials provided with the distribution.
+*   3. Neither the name of MULTI-TECH SYSTEMS, INC. nor the names of its contributors
+*      may be used to endorse or promote products derived from this software
+*      without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+******************************************************************************
  *
  * @author Jason Reiss
  * @date   10-31-2015
@@ -23,6 +43,14 @@
 
 namespace lora {
 
+    const uint8_t  AS923_125K_NUM_CHANS = 16;        //!< Number of 125k channels in AS923 channel plan
+    const uint8_t  AS923_DEFAULT_NUM_CHANS = 2;      //!< Number of default channels in AS923 channel plan
+    const uint32_t AS923_125K_FREQ_BASE = 923200000; //!< Frequency base for 125k AS923 uplink channels
+    const uint32_t AS923_125K_FREQ_STEP = 200000;    //!< Frequency step for 125k AS923 uplink channels
+    const uint32_t AS923_RX2_FREQ = 923200000;       //!< Frequency default for second rx window in AS923
+    const uint8_t  AS923_BEACON_DR = DR_3;           //!< Default beacon datarate
+    const uint32_t AS923_BEACON_FREQ = 923400000U;   //!< Default beacon broadcast frequency
+
     class ChannelPlan_AS923: public lora::ChannelPlan {
         public:
             /**
@@ -95,9 +123,14 @@
              * Set the SxRadio rx config provided window
              * @param window to be opened
              * @param continuous keep window open
+             * @param wnd_growth factor to increase the rx window by
+             * @param pad_ms time in milliseconds to add to computed window size
              * @return LORA_OK
              */
-            virtual uint8_t SetRxConfig(uint8_t window, bool continuous);
+            virtual uint8_t SetRxConfig(uint8_t window,
+                                        bool continuous,
+                                        uint16_t wnd_growth,
+                                        uint16_t pad_ms);
 
             /**
              * Set frequency sub band if supported by plan
@@ -230,14 +263,36 @@
              */
             virtual void DecrementDatarate();
 
+            /**
+             * Check if this packet is a beacon and if so extract parameters needed
+             * @param payload of potential beacon
+             * @param size of the packet
+             * @param [out] data extracted from the beacon if this packet was indeed a beacon
+             * @return true if this packet is beacon, false if not
+             */
+            virtual bool DecodeBeacon(const uint8_t* payload,
+                                      size_t size,
+                                      BeaconData_t& data);
+
+
+            virtual uint8_t GetMinDatarate();
+
         protected:
 
             static const uint8_t AS923_TX_POWERS[8];                    //!< List of available tx powers
-            static const uint8_t AS923_RADIO_POWERS[21];                 //!< List of calibrated tx powers
+            static const uint8_t AS923_RADIO_POWERS[21];                //!< List of calibrated tx powers
             static const uint8_t AS923_MAX_PAYLOAD_SIZE[];              //!< List of max payload sizes for each datarate
-            static const uint8_t AS923_MAX_PAYLOAD_SIZE_400[];              //!< List of max payload sizes for each datarate
+            static const uint8_t AS923_MAX_PAYLOAD_SIZE_400[];          //!< List of max payload sizes for each datarate
             static const uint8_t AS923_MAX_PAYLOAD_SIZE_REPEATER[];     //!< List of repeater compatible max payload sizes for each datarate
-            static const uint8_t AS923_MAX_PAYLOAD_SIZE_REPEATER_400[];     //!< List of repeater compatible max payload sizes for each datarate
+            static const uint8_t AS923_MAX_PAYLOAD_SIZE_REPEATER_400[]; //!< List of repeater compatible max payload sizes for each datarate
+            static const uint8_t MAX_ERP_VALUES[];                      //!< Lookup table for Max EIRP (dBm) codes
+            typedef struct __attribute__((packed)) {
+                uint8_t RFU[2];
+                uint8_t Time[4];
+                uint8_t CRC1[2];
+                uint8_t GwSpecific[7];
+                uint8_t CRC2[2];
+            } BCNPayload;
     };
 }
 
--- a/plans/ChannelPlan_AU915.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/plans/ChannelPlan_AU915.h	Tue Apr 23 08:51:44 2019 -0500
@@ -23,6 +23,32 @@
 
 namespace lora {
 
+    const uint8_t AU915_125K_NUM_CHANS = 64;                    //!< Number of 125k channels in AU915 channel plan
+    const uint8_t AU915_500K_NUM_CHANS = 8;                     //!< Number of 500k channels in AU915 channel plan
+
+    const uint32_t AU915_125K_FREQ_BASE = 915200000;            //!< Frequency base for 125k AU915 uplink channels
+    const uint32_t AU915_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k AU915 uplink channels
+
+    const uint32_t AU915_500K_FREQ_BASE = 915900000;            //!< Frequency base for 500k AU915 uplink channels
+    const uint32_t AU915_500K_FREQ_STEP = 1600000;              //!< Frequency step for 500k AU915 uplink channels
+
+    const uint32_t AU915_500K_DBASE = 923300000;                //!< Frequency base for 500k AU915 downlink channels
+    const uint32_t AU915_500K_DSTEP = 600000;                   //!< Frequency step for 500k AU915 downlink channels
+
+    const uint32_t AU915_FREQ_MIN = 915000000;
+    const uint32_t AU915_FREQ_MAX = 928000000;
+
+    const uint8_t AU915_MIN_DATARATE = (uint8_t) DR_0;          //!< Minimum transmit datarate for AU915
+    const uint8_t AU915_MAX_DATARATE = (uint8_t) DR_6;          //!< Maximum transmit datarate for AU915
+
+    const uint8_t AU915_MIN_DATARATE_OFFSET = (uint8_t) 0;      //!< Minimum transmit datarate for AU915
+    const uint8_t AU915_MAX_DATARATE_OFFSET = (uint8_t) 5;      //!< Maximum transmit datarate for AU915
+
+    const uint8_t  AU915_BEACON_DR = DR_8;                      //!< Default beacon datarate
+    const uint32_t AU915_BEACON_FREQ_BASE = 923300000U;         //!< Base beacon broadcast frequency
+    const uint32_t AU915_BEACON_FREQ_STEP = 600000U;            //!< Step size for beacon frequencies
+    const uint8_t  AU915_BEACON_CHANNELS = 8U;                  //!< Number of beacon channels
+
     class ChannelPlan_AU915 : public lora::ChannelPlan {
         public:
 
@@ -129,9 +155,14 @@
              * Set the SxRadio rx config provided window
              * @param window to be opened
              * @param continuous keep window open
+             * @param wnd_growth factor to increase the rx window by
+             * @param pad_ms time in milliseconds to add to computed window size
              * @return LORA_OK
              */
-            virtual uint8_t SetRxConfig(uint8_t window, bool continuous);
+            virtual uint8_t SetRxConfig(uint8_t window,
+                                        bool continuous,
+                                        uint16_t wnd_growth,
+                                        uint16_t pad_ms);
 
             /**
              * Set frequency sub band if supported by plan
@@ -244,17 +275,60 @@
              */
             virtual void EnableDefaultChannels();
 
+            /**
+             * Called when MAC layer doesn't know about a command.
+             * Use to add custom or new mac command handling
+             * @return LORA_OK
+             */
+            virtual uint8_t HandleMacCommand(uint8_t* payload, uint8_t& index);
+
+            /**
+             * Get max payload size for current datarate
+             * @return size in bytes
+             */
+            virtual uint8_t GetMaxPayloadSize();
+
             virtual uint8_t GetMinDatarate();
 
             virtual uint8_t GetMaxDatarate();
 
+            /**
+             * Check if this packet is a beacon and if so extract parameters needed
+             * @param payload of potential beacon
+             * @param size of the packet
+             * @param [out] data extracted from the beacon if this packet was indeed a beacon
+             * @return true if this packet is beacon, false if not
+             */
+            virtual bool DecodeBeacon(const uint8_t* payload,
+                                      size_t size,
+                                      BeaconData_t& data);
+
+            /**
+             * Update class B beacon and ping slot settings if frequency hopping enabled
+             * @param time received in the last beacon
+             * @param period of the beacon
+             * @param devAddr of this end device
+             */
+            virtual void FrequencyHop(uint32_t time, uint32_t period, uint32_t devAddr);
+
         protected:
 
             static const uint8_t AU915_TX_POWERS[11];                   //!< List of available tx powers
             static const uint8_t AU915_RADIO_POWERS[21];                //!< List of calibrated tx powers
             static const uint8_t AU915_MAX_PAYLOAD_SIZE[];              //!< List of max payload sizes for each datarate
+            static const uint8_t AU915_MAX_PAYLOAD_SIZE_400[];          //!< List of max payload sizes for each datarate
             static const uint8_t AU915_MAX_PAYLOAD_SIZE_REPEATER[];     //!< List of repeater compatible max payload sizes for each datarate
+            static const uint8_t AU915_MAX_PAYLOAD_SIZE_REPEATER_400[]; //!< List of repeater compatible max payload sizes for each datarate
+            static const uint8_t MAX_ERP_VALUES[];                      //!< Lookup table for Max EIRP (dBm) codes
 
+            typedef struct __attribute__((packed)) {
+                uint8_t RFU1[3];
+                uint8_t Time[4];
+                uint8_t CRC1[2];
+                uint8_t GwSpecific[7];
+                uint8_t RFU2[1];
+                uint8_t CRC2[2];
+            } BCNPayload;
     };
 }
 
--- a/plans/ChannelPlan_EU868.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/plans/ChannelPlan_EU868.h	Tue Apr 23 08:51:44 2019 -0500
@@ -23,6 +23,47 @@
 
 namespace lora {
 
+    const uint8_t EU868_125K_NUM_CHANS = 16;                    //!< Number of 125k channels in EU868 channel plan
+    const uint8_t EU868_DEFAULT_NUM_CHANS = 3;                  //!< Number of defualt channels in EU868 channel plan
+    const uint32_t EU868_125K_FREQ_BASE = 868100000;            //!< Frequency base for 125k EU868 uplink channels
+    const uint32_t EU868_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k EU868 uplink channels
+    const uint32_t EU868_RX2_FREQ = 869525000;                  //!< Frequency default for second rx window in EU868
+
+    const uint8_t EU868_TX_POWER_MAX = 14;                      //!< Max power for EU868 channel plan
+
+    // 0.1% duty cycle 863-868
+    // Limiting to 865-868 allows for 1% duty cycle
+    const uint32_t EU868_MILLI_FREQ_MIN = 865000000;
+    const uint32_t EU868_MILLI_FREQ_MAX = 868000000;
+
+    const uint32_t EU868_MILLI_1_FREQ_MIN = 868700000;
+    const uint32_t EU868_MILLI_1_FREQ_MAX = 869200000;
+
+    // 1% duty cycle
+    const uint32_t EU868_CENTI_FREQ_MIN = 868000000;
+    const uint32_t EU868_CENTI_FREQ_MAX = 868600000;
+
+    // 10% duty cycle
+    const uint32_t EU868_DECI_FREQ_MIN = 869400000;
+    const uint32_t EU868_DECI_FREQ_MAX = 869650000;
+
+    // Below 7dBm there is no duty cycle for these frequencies
+    // Up to 14dBm there is 1% duty cycle
+    const uint32_t EU868_VAR_FREQ_MIN = 869700000;
+    const uint32_t EU868_VAR_FREQ_MAX = 870000000;
+
+    const uint32_t EU868_FREQ_MIN = 863000000;
+    const uint32_t EU868_FREQ_MAX = 870000000;
+
+    const uint8_t EU868_MIN_DATARATE = (uint8_t) DR_0;           //!< Minimum transmit datarate for EU868
+    const uint8_t EU868_MAX_DATARATE = (uint8_t) DR_7;           //!< Maximum transmit datarate for EU868
+
+    const uint8_t EU868_MIN_DATARATE_OFFSET = (uint8_t) 0;       //!< Minimum transmit datarate for US915
+    const uint8_t EU868_MAX_DATARATE_OFFSET = (uint8_t) 5;       //!< Maximum transmit datarate for US915
+
+    const uint8_t  EU868_BEACON_DR = DR_3;                       //!< Default beacon datarate
+    const uint32_t EU868_BEACON_FREQ = 869525000U;               //!< Default beacon broadcast frequency
+
     class ChannelPlan_EU868 : public lora::ChannelPlan {
         public:
             /**
@@ -95,9 +136,14 @@
              * Set the SxRadio rx config provided window
              * @param window to be opened
              * @param continuous keep window open
+             * @param wnd_growth factor to increase the rx window by
+             * @param pad_ms time in milliseconds to add to computed window size
              * @return LORA_OK
              */
-            virtual uint8_t SetRxConfig(uint8_t window, bool continuous);
+            virtual uint8_t SetRxConfig(uint8_t window,
+                                        bool continuous,
+                                        uint16_t wnd_growth,
+                                        uint16_t pad_ms);
 
             /**
              * Set frequency sub band if supported by plan
@@ -107,12 +153,6 @@
             virtual uint8_t SetFrequencySubBand(uint8_t sub_band);
 
             /**
-             * Get time on air with current settings
-             * @param bytes number of bytes to be sent
-             */
-            virtual uint32_t GetTimeOnAir(uint8_t bytes);
-
-            /**
              * Callback for ACK timeout event
              * @return LORA_OK
              */
@@ -218,12 +258,31 @@
              */
             virtual void EnableDefaultChannels();
 
+            /**
+             * Check if this packet is a beacon and if so extract parameters needed
+             * @param payload of potential beacon
+             * @param size of the packet
+             * @param [out] data extracted from the beacon if this packet was indeed a beacon
+             * @return true if this packet is beacon, false if not
+             */
+            virtual bool DecodeBeacon(const uint8_t* payload,
+                                      size_t size,
+                                      BeaconData_t& data);
+
         protected:
 
             static const uint8_t EU868_TX_POWERS[8];                    //!< List of available tx powers
             static const uint8_t EU868_RADIO_POWERS[21];                 //!< List of calibrated tx powers
             static const uint8_t EU868_MAX_PAYLOAD_SIZE[];              //!< List of max payload sizes for each datarate
             static const uint8_t EU868_MAX_PAYLOAD_SIZE_REPEATER[];     //!< List of repeater compatible max payload sizes for each datarate
+
+            typedef struct __attribute__((packed)) {
+                uint8_t RFU[2];
+                uint8_t Time[4];
+                uint8_t CRC1[2];
+                uint8_t GwSpecific[7];
+                uint8_t CRC2[2];
+            } BCNPayload;
     };
 }
 
--- a/plans/ChannelPlan_IN865.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/plans/ChannelPlan_IN865.h	Tue Apr 23 08:51:44 2019 -0500
@@ -23,6 +23,16 @@
 
 namespace lora {
 
+    const uint8_t  IN865_125K_NUM_CHANS = 16;         //!< Number of 125k channels in IN865 channel plan
+    const uint8_t  IN865_DEFAULT_NUM_CHANS = 3;       //!< Number of default channels in IN865 channel plan
+    const uint32_t IN865_125K_DEF_FREQ_1 = 865062500;
+    const uint32_t IN865_125K_DEF_FREQ_2 = 865402500;
+    const uint32_t IN865_125K_DEF_FREQ_3 = 865985000;
+    const uint32_t IN865_RX2_FREQ = 866550000;        //!< Frequency default for second rx window in IN865
+    const uint8_t  IN865_TX_POWER_MAX = 30;           //!< Max power for IN865 channel plan
+    const uint8_t  IN865_BEACON_DR = DR_4;            //!< Default beacon datarate
+    const uint32_t IN865_BEACON_FREQ = 866550000U;    //!< Default beacon broadcast frequency
+
     class ChannelPlan_IN865 : public lora::ChannelPlan {
         public:
             /**
@@ -95,9 +105,14 @@
              * Set the SxRadio rx config provided window
              * @param window to be opened
              * @param continuous keep window open
+             * @param wnd_growth factor to increase the rx window by
+             * @param pad_ms time in milliseconds to add to computed window size
              * @return LORA_OK
              */
-            virtual uint8_t SetRxConfig(uint8_t window, bool continuous);
+            virtual uint8_t SetRxConfig(uint8_t window,
+                                        bool continuous,
+                                        uint16_t wnd_growth,
+                                        uint16_t pad_ms);
 
             /**
              * Set frequency sub band if supported by plan
@@ -229,12 +244,32 @@
              */
             virtual void IncrementDatarate();
 
+            /**
+             * Check if this packet is a beacon and if so extract parameters needed
+             * @param payload of potential beacon
+             * @param size of the packet
+             * @param [out] data extracted from the beacon if this packet was indeed a beacon
+             * @return true if this packet is beacon, false if not
+             */
+            virtual bool DecodeBeacon(const uint8_t* payload,
+                                      size_t size,
+                                      BeaconData_t& data);
+
         protected:
 
             static const uint8_t IN865_TX_POWERS[11];                    //!< List of available tx powers
             static const uint8_t IN865_RADIO_POWERS[21];                 //!< List of calibrated tx powers
             static const uint8_t IN865_MAX_PAYLOAD_SIZE[];              //!< List of max payload sizes for each datarate
             static const uint8_t IN865_MAX_PAYLOAD_SIZE_REPEATER[];     //!< List of repeater compatible max payload sizes for each datarate
+
+            typedef struct __attribute__((packed)) {
+                uint8_t RFU1[1];
+                uint8_t Time[4];
+                uint8_t CRC1[2];
+                uint8_t GwSpecific[7];
+                uint8_t RFU2[3];
+                uint8_t CRC2[2];
+            } BCNPayload;
     };
 }
 
--- a/plans/ChannelPlan_KR920.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/plans/ChannelPlan_KR920.h	Tue Apr 23 08:51:44 2019 -0500
@@ -23,6 +23,15 @@
 
 namespace lora {
 
+    const uint8_t  KR920_125K_NUM_CHANS = 16;        //!< Number of 125k channels in KR920 channel plan
+    const uint8_t  KR920_DEFAULT_NUM_CHANS = 3;      //!< Number of default channels in KR920 channel plan
+    const uint32_t KR920_125K_FREQ_BASE = 922100000; //!< Frequency base for 125k KR920 uplink channels
+    const uint32_t KR920_125K_FREQ_STEP = 200000;    //!< Frequency step for 125k KR920 uplink channels
+    const uint32_t KR920_RX2_FREQ = 921900000;       //!< Frequency default for second rx window in KR920
+    const uint8_t  KR920_TX_POWER_MAX = 14;          //!< Max power for KR920 channel plan
+    const uint8_t  KR920_BEACON_DR = DR_3;           //!< Default beacon datarate
+    const uint32_t KR920_BEACON_FREQ = 923100000U;   //!< Default beacon broadcast frequency
+
     class ChannelPlan_KR920 : public lora::ChannelPlan {
         public:
             /**
@@ -95,9 +104,14 @@
              * Set the SxRadio rx config provided window
              * @param window to be opened
              * @param continuous keep window open
+             * @param wnd_growth factor to increase the rx window by
+             * @param pad_ms time in milliseconds to add to computed window size
              * @return LORA_OK
              */
-            virtual uint8_t SetRxConfig(uint8_t window, bool continuous);
+            virtual uint8_t SetRxConfig(uint8_t window,
+                                        bool continuous,
+                                        uint16_t wnd_growth,
+                                        uint16_t pad_ms);
 
             /**
              * Set frequency sub band if supported by plan
@@ -224,12 +238,31 @@
              */
             virtual void DefaultLBT();
 
+            /**
+             * Check if this packet is a beacon and if so extract parameters needed
+             * @param payload of potential beacon
+             * @param size of the packet
+             * @param [out] data extracted from the beacon if this packet was indeed a beacon
+             * @return true if this packet is beacon, false if not
+             */
+            virtual bool DecodeBeacon(const uint8_t* payload,
+                                      size_t size,
+                                      BeaconData_t& data);
+
         protected:
 
             static const uint8_t KR920_TX_POWERS[8];                    //!< List of available tx powers
             static const uint8_t KR920_RADIO_POWERS[21];                 //!< List of calibrated tx powers
             static const uint8_t KR920_MAX_PAYLOAD_SIZE[];              //!< List of max payload sizes for each datarate
             static const uint8_t KR920_MAX_PAYLOAD_SIZE_REPEATER[];     //!< List of repeater compatible max payload sizes for each datarate
+
+            typedef struct __attribute__((packed)) {
+                uint8_t RFU[2];
+                uint8_t Time[4];
+                uint8_t CRC1[2];
+                uint8_t GwSpecific[7];
+                uint8_t CRC2[2];
+            } BCNPayload;
     };
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plans/ChannelPlan_RU864.h	Tue Apr 23 08:51:44 2019 -0500
@@ -0,0 +1,274 @@
+/**   __  ___     ____  _    ______        __     ____         __                  ____
+ *   /  |/  /_ __/ / /_(_)__/_  __/__ ____/ /    / __/_ _____ / /____ __ _  ___   /  _/__  ____
+ *  / /|_/ / // / / __/ /___// / / -_) __/ _ \  _\ \/ // (_-</ __/ -_)  ' \(_-<  _/ // _ \/ __/ __
+ * /_/  /_/\_,_/_/\__/_/    /_/  \__/\__/_//_/ /___/\_, /___/\__/\__/_/_/_/___/ /___/_//_/\__/ /_/
+ * Copyright (C) 2015 by Multi-Tech Systems        /___/
+ *
+ *
+ * @author Jason Reiss
+ * @date   10-31-2015
+ * @brief  lora::ChannelPlan provides an interface for LoRaWAN channel schemes
+ *
+ * @details
+ *
+ */
+
+#ifndef __CHANNEL_PLAN_RU864_H__
+#define __CHANNEL_PLAN_RU864_H__
+
+#include "Lora.h"
+#include "SxRadio.h"
+#include <vector>
+#include "ChannelPlan.h"
+
+namespace lora {
+
+    const uint8_t RU864_125K_NUM_CHANS = 16;                    //!< Number of 125k channels in RU864 channel plan
+    const uint8_t RU864_DEFAULT_NUM_CHANS = 2;                  //!< Number of defualt channels in RU864 channel plan
+    const uint32_t RU864_125K_FREQ_BASE = 868900000;            //!< Frequency base for 125k RU864 uplink channels
+    const uint32_t RU864_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k RU864 uplink channels
+    const uint32_t RU864_RX2_FREQ = 869100000;                  //!< Frequency default for second rx window in RU864
+
+    const uint8_t RU864_TX_POWER_MAX = 16;                      //!< Max power for RU864 channel plan
+
+    // 0.1% duty cycle 864-866
+    const uint32_t RU864_MILLI_FREQ_MIN = 864000000;
+    const uint32_t RU864_MILLI_FREQ_MAX = 865000000;
+
+
+    const uint32_t RU864_FREQ_MIN = 864000000;
+    const uint32_t RU864_FREQ_MAX = 870000000;
+
+    const uint8_t RU864_MIN_DATARATE = (uint8_t) DR_0;           //!< Minimum transmit datarate for RU864
+    const uint8_t RU864_MAX_DATARATE = (uint8_t) DR_7;           //!< Maximum transmit datarate for RU864
+
+    const uint8_t RU864_MIN_DATARATE_OFFSET = (uint8_t) 0;       //!< Minimum transmit datarate for US915
+    const uint8_t RU864_MAX_DATARATE_OFFSET = (uint8_t) 5;       //!< Maximum transmit datarate for US915
+
+    const uint8_t  RU864_BEACON_DR = DR_3;                       //!< Default beacon datarate
+    const uint32_t RU864_BEACON_FREQ = 869100000U;               //!< Default beacon broadcast frequency
+    const uint32_t RU864_PING_SLOT_FREQ = 868900000U;            //!< Default ping slot frequency
+
+    class ChannelPlan_RU864 : public lora::ChannelPlan {
+        public:
+            /**
+             * ChannelPlan constructor
+             * @param radio SxRadio object used to set Tx/Rx config
+             * @param settings Settings object
+             */
+            ChannelPlan_RU864();
+            ChannelPlan_RU864(Settings* settings);
+            ChannelPlan_RU864(SxRadio* radio, Settings* settings);
+
+            /**
+             * ChannelPlan destructor
+             */
+            virtual ~ChannelPlan_RU864();
+
+            /**
+             * Initialize channels, datarates and duty cycle bands according to current channel plan in settings
+             */
+            virtual void Init();
+
+            /**
+             * Get the next channel to use to transmit
+             * @return LORA_OK if channel was found
+             * @return LORA_NO_CHANS_ENABLED
+             */
+            virtual uint8_t GetNextChannel();
+
+            /**
+             * Add a channel to the ChannelPlan
+             * @param index of channel, use -1 to add to end
+             * @param channel settings to add
+             */
+            virtual uint8_t AddChannel(int8_t index, Channel channel);
+
+            /**
+             * Get channel at index
+             * @return Channel
+             */
+            virtual Channel GetChannel(int8_t index);
+
+            /**
+             * Get rx window settings for requested window
+             * RX_1, RX_2, RX_BEACON, RX_SLOT
+             * @param window
+             * @return RxWindow
+             */
+            virtual RxWindow GetRxWindow(uint8_t window);
+
+            /**
+             * Get datarate to use on the join request
+             * @return datarate index
+             */
+            virtual uint8_t GetJoinDatarate();
+
+            /**
+             * Calculate the next time a join request is possible
+             * @param size of join frame
+             * @returns LORA_OK
+             */
+            virtual uint8_t CalculateJoinBackoff(uint8_t size);
+
+            /**
+             * Get next channel and set the SxRadio tx config with current settings
+             * @return LORA_OK
+             */
+            virtual uint8_t SetTxConfig();
+
+            /**
+             * Set the SxRadio rx config provided window
+             * @param window to be opened
+             * @param continuous keep window open
+             * @param wnd_growth factor to increase the rx window by
+             * @param pad_ms time in milliseconds to add to computed window size
+             * @return LORA_OK
+             */
+            virtual uint8_t SetRxConfig(uint8_t window,
+                                        bool continuous,
+                                        uint16_t wnd_growth,
+                                        uint16_t pad_ms);
+
+            /**
+             * Set frequency sub band if supported by plan
+             * @param sub_band
+             * @return LORA_OK
+             */
+            virtual uint8_t SetFrequencySubBand(uint8_t sub_band);
+
+            /**
+             * Callback for ACK timeout event
+             * @return LORA_OK
+             */
+            virtual uint8_t HandleAckTimeout();
+
+            /**
+             * Callback for Join Accept packet to load optional channels
+             * @return LORA_OK
+             */
+            virtual uint8_t HandleJoinAccept(const uint8_t* buffer, uint8_t size);
+
+            /**
+             * Callback to for rx parameter setup ServerCommand
+             * @param payload packet data
+             * @param index of start of command buffer
+             * @param size number of bytes in command buffer
+             * @param[out] status to be returned in MoteCommand answer
+             * @return LORA_OK
+             */
+            virtual uint8_t HandleRxParamSetup(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
+
+            /**
+             * Callback to for new channel ServerCommand
+             * @param payload packet data
+             * @param index of start of command buffer
+             * @param size number of bytes in command buffer
+             * @param[out] status to be returned in MoteCommand answer
+             * @return LORA_OK
+             */
+            virtual uint8_t HandleNewChannel(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
+
+            /**
+             * Callback to for ping slot channel request ServerCommand
+             * @param payload packet data
+             * @param index of start of command buffer
+             * @param size number of bytes in command buffer
+             * @param[out] status to be returned in MoteCommand answer
+             * @return LORA_OK
+             */
+            virtual uint8_t HandlePingSlotChannelReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
+
+            /**
+             * Callback to for beacon frequency request ServerCommand
+             * @param payload packet data
+             * @param index of start of command buffer
+             * @param size number of bytes in command buffer
+             * @param[out] status to be returned in MoteCommand answer
+             * @return LORA_OK
+             */
+            virtual uint8_t HandleBeaconFrequencyReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
+
+            /**
+             * Callback to for adaptive datarate ServerCommand
+             * @param payload packet data
+             * @param index of start of command buffer
+             * @param size number of bytes in command buffer
+             * @param[out] status to be returned in MoteCommand answer
+             * @return LORA_OK
+             */
+            virtual uint8_t HandleAdrCommand(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
+
+            /**
+             * Validate the configuration after multiple ADR commands have been applied
+             * @return status to be returned in MoteCommand answer
+             */
+            virtual uint8_t ValidateAdrConfiguration();
+
+            /**
+             * Update duty cycle with at given frequency and time on air
+             * @param freq frequency
+             * @param time_on_air_ms tx time on air
+             */
+            virtual void UpdateDutyCycle(uint32_t freq, uint32_t time_on_air_ms);
+
+            /**
+             * Get the time the radio must be off air to comply with regulations
+             * Time to wait may be dependent on duty-cycle restrictions per channel
+             * Or duty-cycle of join requests if OTAA is being attempted
+             * @return ms of time to wait for next tx opportunity
+             */
+            virtual uint32_t GetTimeOffAir();
+
+            /**
+             * Get the channels in use by current channel plan
+             * @return channel frequencies
+             */
+            virtual std::vector<uint32_t> GetChannels();
+
+            /**
+             * Get the channel datarate ranges in use by current channel plan
+             * @return channel datarate ranges
+             */
+            virtual std::vector<uint8_t> GetChannelRanges();
+
+            /**
+             * Print log message for given rx window
+             * @param wnd 1 or 2
+             */
+            virtual void LogRxWindow(uint8_t wnd);
+
+            /**
+             * Enable the default channels of the channel plan
+             */
+            virtual void EnableDefaultChannels();
+
+            /**
+             * Check if this packet is a beacon and if so extract parameters needed
+             * @param payload of potential beacon
+             * @param size of the packet
+             * @param [out] data extracted from the beacon if this packet was indeed a beacon
+             * @return true if this packet is beacon, false if not
+             */
+            virtual bool DecodeBeacon(const uint8_t* payload,
+                                      size_t size,
+                                      BeaconData_t& data);
+
+        protected:
+
+            static const uint8_t RU864_TX_POWERS[8];                    //!< List of available tx powers
+            static const uint8_t RU864_RADIO_POWERS[21];                 //!< List of calibrated tx powers
+            static const uint8_t RU864_MAX_PAYLOAD_SIZE[];              //!< List of max payload sizes for each datarate
+            static const uint8_t RU864_MAX_PAYLOAD_SIZE_REPEATER[];     //!< List of repeater compatible max payload sizes for each datarate
+
+            typedef struct __attribute__((packed)) {
+                uint8_t RFU[2];
+                uint8_t Time[4];
+                uint8_t CRC1[2];
+                uint8_t GwSpecific[7];
+                uint8_t CRC2[2];
+            } BCNPayload;
+    };
+}
+
+#endif //__CHANNEL_PLAN_RU864_H__
--- a/plans/ChannelPlan_US915.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/plans/ChannelPlan_US915.h	Tue Apr 23 08:51:44 2019 -0500
@@ -23,6 +23,32 @@
 
 namespace lora {
 
+    const uint8_t US915_125K_NUM_CHANS = 64;                    //!< Number of 125k channels in US915 channel plan
+    const uint8_t US915_500K_NUM_CHANS = 8;                     //!< Number of 500k channels in US915 channel plan
+
+    const uint32_t US915_125K_FREQ_BASE = 902300000;            //!< Frequency base for 125k US915 uplink channels
+    const uint32_t US915_125K_FREQ_STEP = 200000;               //!< Frequency step for 125k US915 uplink channels
+
+    const uint32_t US915_500K_FREQ_BASE = 903000000;            //!< Frequency base for 500k US915 uplink channels
+    const uint32_t US915_500K_FREQ_STEP = 1600000;              //!< Frequency step for 500k US915 uplink channels
+
+    const uint32_t US915_500K_DBASE = 923300000;                //!< Frequency base for 500k US915 downlink channels
+    const uint32_t US915_500K_DSTEP = 600000;                   //!< Frequency step for 500k US915 downlink channels
+
+    const uint32_t US915_FREQ_MIN = 902000000;
+    const uint32_t US915_FREQ_MAX = 928000000;
+
+    const uint8_t US915_MIN_DATARATE = (uint8_t) DR_0;          //!< Minimum transmit datarate for US915
+    const uint8_t US915_MAX_DATARATE = (uint8_t) DR_4;          //!< Maximum transmit datarate for US915
+
+    const uint8_t US915_MIN_DATARATE_OFFSET = (uint8_t) 0;      //!< Minimum transmit datarate for US915
+    const uint8_t US915_MAX_DATARATE_OFFSET = (uint8_t) 3;      //!< Maximum transmit datarate for US915
+
+    const uint8_t  US915_BEACON_DR = DR_8;                      //!< Default beacon datarate
+    const uint32_t US915_BEACON_FREQ_BASE = 923300000U;         //!< Base beacon broadcast frequency
+    const uint32_t US915_BEACON_FREQ_STEP = 600000U;            //!< Step size for beacon frequencies
+    const uint8_t  US915_BEACON_CHANNELS = 8U;                  //!< Number of beacon channels
+
     class ChannelPlan_US915 : public lora::ChannelPlan {
         public:
 
@@ -129,9 +155,14 @@
              * Set the SxRadio rx config provided window
              * @param window to be opened
              * @param continuous keep window open
+             * @param wnd_growth factor to increase the rx window by
+             * @param pad_ms time in milliseconds to add to computed window size
              * @return LORA_OK
              */
-            virtual uint8_t SetRxConfig(uint8_t window, bool continuous);
+            virtual uint8_t SetRxConfig(uint8_t window,
+                                        bool continuous,
+                                        uint16_t wnd_growth,
+                                        uint16_t pad_ms);
 
             /**
              * Set frequency sub band if supported by plan
@@ -248,6 +279,24 @@
 
             virtual uint8_t GetMaxDatarate();
 
+            /**
+             * Check if this packet is a beacon and if so extract parameters needed
+             * @param payload of potential beacon
+             * @param size of the packet
+             * @param [out] data extracted from the beacon if this packet was indeed a beacon
+             * @return true if this packet is beacon, false if not
+             */
+            virtual bool DecodeBeacon(const uint8_t* payload,
+                                      size_t size,
+                                      BeaconData_t& data);
+            /**
+             * Update class B beacon and ping slot settings if frequency hopping enabled
+             * @param time received in the last beacon
+             * @param period of the beacon
+             * @param devAddr of this end device
+             */
+            virtual void FrequencyHop(uint32_t time, uint32_t period, uint32_t devAddr);
+
         protected:
 
             static const uint8_t US915_TX_POWERS[11];                   //!< List of available tx powers
@@ -255,6 +304,14 @@
             static const uint8_t US915_MAX_PAYLOAD_SIZE[];              //!< List of max payload sizes for each datarate
             static const uint8_t US915_MAX_PAYLOAD_SIZE_REPEATER[];     //!< List of repeater compatible max payload sizes for each datarate
 
+            typedef struct __attribute__((packed)) {
+                uint8_t RFU1[5];
+                uint8_t Time[4];
+                uint8_t CRC1[2];
+                uint8_t GwSpecific[7];
+                uint8_t RFU2[3];
+                uint8_t CRC2[2];
+            } BCNPayload;
     };
 }
 
--- a/plans/ChannelPlans.h	Fri Aug 24 10:59:18 2018 -0500
+++ b/plans/ChannelPlans.h	Tue Apr 23 08:51:44 2019 -0500
@@ -5,6 +5,7 @@
 #include "ChannelPlan_KR920.h"
 #include "ChannelPlan_IN865.h"
 #include "ChannelPlan_AS923_Japan.h"
+#include "ChannelPlan_RU864.h"
 
 
 #define CP_AS923 1
@@ -14,3 +15,4 @@
 #define CP_KR920 5
 #define CP_IN865 6
 #define CP_AS923_JAPAN 7
+#define CP_RU864 8