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

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

Fork of libmDot-dev-mbed2-deprecated by MultiTech

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

Dot Library Version 3 Updates

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

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

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

    // ...
}

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

Multicast Sessions

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

mDot.h

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

mDotEvent.h

The address field was added to PacketRx event.

        virtual void PacketRx(uint8_t port, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot, uint8_t retries, uint32_t address);

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

A changelog for the Dot library can be found here.

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

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

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

Revision:
10:27dafba9fe19
Parent:
9:ec2fffe31793
Child:
11:d8464345e1f1
--- a/mDot.h	Tue Nov 10 14:44:36 2015 -0600
+++ b/mDot.h	Wed Dec 02 15:19:12 2015 -0600
@@ -76,7 +76,9 @@
         PinName _wakeup_pin;
 
         typedef enum {
-            OFF, ON, BLINK,
+            OFF,
+            ON,
+            BLINK,
         } state;
 
     public:
@@ -105,39 +107,71 @@
         } mdot_ret_code;
 
         enum JoinMode {
-            MANUAL, OTA, AUTO_OTA
+            MANUAL,
+            OTA,
+            AUTO_OTA
         };
 
         enum Mode {
-            COMMAND_MODE, SERIAL_MODE
+            COMMAND_MODE,
+            SERIAL_MODE
         };
 
         enum RX_Output {
-            HEXADECIMAL, BINARY
+            HEXADECIMAL,
+            BINARY
         };
 
         enum DataRates {
-            SF_12, SF_11, SF_10, SF_9, SF_8, SF_7, SF_7H, SF_50
+            SF_12,
+            SF_11,
+            SF_10,
+            SF_9,
+            SF_8,
+            SF_7,
+            SF_7H,
+            SF_50
         };
 
         enum FrequencyBands {
-            FB_868, FB_915
+            FB_868,
+            FB_915
         };
 
         enum FrequencySubBands {
-            FSB_ALL, FSB_1, FSB_2, FSB_3, FSB_4, FSB_5, FSB_6, FSB_7, FSB_8
+            FSB_ALL,
+            FSB_1,
+            FSB_2,
+            FSB_3,
+            FSB_4,
+            FSB_5,
+            FSB_6,
+            FSB_7,
+            FSB_8
         };
 
         enum JoinByteOrder {
-            LSB, MSB
+            LSB,
+            MSB
         };
 
         enum wakeup_mode {
-            RTC_ALARM, INTERRUPT
+            RTC_ALARM,
+            INTERRUPT,
+            RTC_ALARM_OR_INTERRUPT
         };
 
         enum UserBackupRegs {
-            UBR0, UBR1, UBR2, UBR3, UBR4, UBR5, UBR6, UBR7, UBR8, UBR9
+            UBR0,
+            UBR1,
+            UBR2,
+            UBR3,
+            UBR4,
+            UBR5,
+            UBR6,
+            UBR7,
+            UBR8,
+            UBR9
         };
 
         typedef struct {
@@ -274,7 +308,7 @@
 
         /** Set frequency sub band
          * only applicable if frequency band is set for United States (FB_915)
-         * sub band 0 will allow the radio to use all 64 channels 
+         * sub band 0 will allow the radio to use all 64 channels
          * sub band 1 - 8 will allow the radio to use the 8 channels in that sub band
          * for use with Conduit gateway and MTAC_LORA, use sub bands 1 - 8, not sub band 0
          * @param band the sub band to use (0 - 8)
@@ -288,6 +322,8 @@
         uint8_t getFrequencySubBand();
 
         /** Enable/disable public network mode
+         * JoinDelay will be set to (public: 5s, private: 1s) and
+         * RxDelay will be set to 1s both can be adjusted afterwards
          * @param on should be true to enable public network mode
          * @returns MDOT_OK if success
          */
@@ -303,6 +339,31 @@
          */
         std::vector<uint8_t> getDeviceId();
 
+        /** Get the device port to be used for lora application data (1-223)
+         *  @returns port
+         */
+        uint8_t getAppPort();
+
+        /** Set the device port to be used for lora application data (1-223)
+         *  @returns MDOT_OK if success
+         */
+        int32_t setAppPort(uint8_t port);
+
+        /** Set the device class A, B or C
+         *  @returns MDOT_OK if success
+         */
+        int32_t setClass(std::string newClass);
+
+        /** Get the device class A, B or C
+         *  @returns MDOT_OK if success
+         */
+        std::string getClass();
+
+        /** Get the max packet length with current settings
+         * @returns max packet length
+         */
+        uint8_t getMaxPacketLength();
+
         /** Set network address
          * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes
          * @param addr a vector of 4 bytes
@@ -510,13 +571,54 @@
          */
         uint32_t getNextTxMs();
 
+        /** Get join delay in seconds
+         *  Public network defaults to 5 seconds
+         *  Private network defaults to 1 second
+         *  @returns number of seconds before join accept message is expected
+         */
+        uint8_t getJoinDelay();
+
+        /** Set join delay in seconds
+         *  Public network defaults to 5 seconds
+         *  Private network defaults to 1 second
+         *  @param delay number of seconds before join accept message is expected
+         *  @return MDOT_OK if success
+         */
+        uint32_t setJoinDelay(uint8_t delay);
+
+        /** Get rx delay in seconds
+         *  Defaults to 1 second
+         *  @returns number of seconds before response message is expected
+         */
+        uint8_t getRxDelay();
+
+        /** Set rx delay in seconds
+         *  Defaults to 1 second
+         *  @param delay number of seconds before response message is expected
+         *  @return MDOT_OK if success
+         */
+        uint32_t setRxDelay(uint8_t delay);
+
+        /** Get  preserve session to save network session info through reset or power down in AUTO_OTA mode
+         *  Defaults to off
+         *  @returns true if enabled
+         */
+        bool getPreserveSession();
+
+        /** Set preserve session to save network session info through reset or power down in AUTO_OTA mode
+         *  Defaults to off
+         *  @param enable
+         *  @return MDOT_OK if success
+         */
+        uint32_t setPreserveSession(bool enable);
+
         /** Get data pending
          * only valid after sending data to the gateway
          * @returns true if server has available packet(s)
          */
         bool getDataPending();
 
-        /** Get transmitting 
+        /** Get transmitting
          * @returns true if currently transmitting
          */
         bool getIsTransmitting();
@@ -621,7 +723,6 @@
          */
         int32_t recv(std::vector<uint8_t>& data);
 
-
         /** Ping
          * status will be MDOT_OK if ping succeeded
          * @returns ping_response struct containing status, RSSI, and SNR
@@ -639,15 +740,14 @@
         std::string getLastError();
 
         /** Go to sleep
-         * @param interval the number of seconds to sleep before waking up if wakeup_mode == RTC_ALARM, else ignored
-         * @param wakeup_mode RTC_ALARM, INTERRUPT
+         * @param interval the number of seconds to sleep before waking up if wakeup_mode == RTC_ALARM or RTC_ALARM_OR_INTERRUPT, else ignored
+         * @param wakeup_mode RTC_ALARM, INTERRUPT, RTC_ALARM_OR_INTERRUPT
          *      if RTC_ALARM the real time clock is configured to wake the device up after the specified interval
          *      if INTERRUPT the device will wake up on the rising edge of the interrupt pin
+         *      if RTC_ALARM_OR_INTERRUPT the device will wake on the first event to occur
          * @param deepsleep if true go into deep sleep mode (lowest power, all memory and registers are lost, peripherals turned off)
          *                  else go into sleep mode (low power, memory and registers are maintained, peripherals stay on)
          *
-         * ** CURRENTLY ONLY DEEPSLEEP MODE IS AVAILABLE **
-         *
          * in sleep mode, the device can be woken up on any of the XBEE pins or by the RTC alarm
          * in deepsleep mode, the device can only be woken up using the WKUP pin (PA0, XBEE_DIO7) or by the RTC alarm
          */
@@ -853,7 +953,6 @@
         // Convert pin name DIO2-DI8 to string
         static std::string pinName2Str(PinName name);
 
-
         uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l);
 
         // MTS_RADIO_DEBUG_COMMANDS
@@ -868,7 +967,6 @@
         std::map<uint8_t, uint8_t> dumpRegisters();
         void eraseFlash();
 
-
         // deprecated - use setWakeInterval
         int32_t setSerialWakeInterval(const uint32_t& interval);
         // deprecated - use getWakeInterval