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
Revision:
25:3101c522ae11
Parent:
20:bc12c888e7dc
--- a/mDot.h	Tue Dec 17 06:57:48 2019 -0600
+++ b/mDot.h	Mon Feb 17 14:42:01 2020 -0600
@@ -61,21 +61,6 @@
         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();
-                _activity_led->write(!val);
-            }
-        }
-
         mDot(const mDot&);
         mDot& operator=(const mDot&);
 
@@ -97,12 +82,7 @@
 
         std::string _last_error;
         static const uint32_t _baud_rates[];
-        uint8_t _activity_led_state; //deprecated will be removed
-        Ticker _tick;
-        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;
@@ -162,7 +142,8 @@
         enum RX_Output {
             HEXADECIMAL,
             BINARY,
-            EXTENDED
+            EXTENDED,
+            EXTENDED_HEX
         };
 
         enum DataRates {
@@ -315,6 +296,14 @@
          */
         std::string getMtsLoraId();
 
+
+        /**
+         * MAC version
+         *
+         * @return string containing version information of supported LoRaWAN MAC Version
+         */
+        const char* getMACVersion();
+
         /**
          * Perform a soft reset of the system
          */
@@ -368,21 +357,6 @@
 
         lora::Settings* getSettings();
 
-        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
-        void setActivityLedEnable(const bool& enable);
-
-        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
-        bool getActivityLedEnable();
-
-        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
-        void setActivityLedPin(const PinName& pin);
-
-        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
-        void setActivityLedPin(DigitalOut* pin);
-
-        MBED_DEPRECATED("Will be removed in dotlib 3.3.0")
-        PinName getActivityLedPin();
-
         /**
          * Returns boolean indicative of start-up from standby mode
          * @returns true if dot woke from standby
@@ -694,6 +668,20 @@
         int32_t setNetworkKey(const std::vector<uint8_t>& id);
 
         /**
+         * Get generic app key
+         * @returns a vector containing key (size 16)
+         */
+        std::vector<uint8_t> getGenAppKey();
+
+        /**
+         * Set generic app key
+         * for use with Multicast key exchange
+         * @param id a vector of 16 bytes
+         * @returns MDOT_OK if success
+         */
+        int32_t setGenAppKey(const std::vector<uint8_t>& id);
+
+        /**
          * Get network key
          * @returns a vector containing network key (size 16)
          */
@@ -728,17 +716,71 @@
         const uint8_t* getAppKey();
 
         /**
+         * Set device nonce counter incremented with each Join Request
+         * @returns MDOT_OK if success
+         */
+        int32_t setDevNonce(const uint16_t& nonce);
+
+        /**
+         * Get device nonce counter incremented with each Join Request
+         * @returns join nonce
+         */
+        uint16_t getDevNonce();
+
+        /**
+         * Set app nonce counter incremented with each Join Accept
+         * @returns MDOT_OK if success
+         */
+        int32_t setAppNonce(const uint32_t& nonce);
+
+        /**
+         * Get app nonce counter incremented with each Join Accept
+         * @returns app nonce
+         */
+        uint32_t getAppNonce();
+
+        /**
+         * Enable/disable Join Nonce validation for App Nonce in Join Accept
+         * Default is enabled
+         */
+        int32_t setJoinNonceValidation(bool enable);
+        bool getJoinNonceValidation();
+
+        /**
          * Add a multicast session address and keys
          * Downlink counter is set to 0
-         * Up to 3 MULTICAST_SESSIONS can be set
+         * Up to 8 MULTICAST_SESSIONS can be set
          */
-        int32_t setMulticastSession(uint8_t index, uint32_t addr, const uint8_t* nsk, const uint8_t* dsk);
+        int32_t setMulticastSession(uint8_t index, uint32_t addr, const uint8_t* nsk, const uint8_t* ask);
+
+        /**
+         * Set multicast session info
+         * Up to 8 MULTICAST_SESSIONS
+         */
+        int32_t setMulticastAddress(uint8_t index, uint32_t addr);
+        int32_t setMulticastNetworkSessionKey(uint8_t index, const uint8_t* nsk);
+        int32_t setMulticastApplicationSessionKey(uint8_t index, const uint8_t* ask);
 
         /**
          * Set a multicast session counter
-         * Up to 3 MULTICAST_SESSIONS can be set
+         * Up to 8 MULTICAST_SESSIONS
          */
         int32_t setMulticastDownlinkCounter(uint8_t index, uint32_t count);
+        int32_t setMulticastPeriodicity(uint8_t index, int8_t period);
+        int32_t setMulticastFrequency(uint8_t index, uint32_t freq);
+        int32_t setMulticastDatarate(uint8_t index, uint8_t dr);
+
+        /**
+         * Get multicast session info
+         * Up to 8 MULTICAST_SESSIONS
+         */
+        uint32_t getMulticastAddress(uint8_t index);
+        int32_t getMulticastNetworkSessionKey(uint8_t index, uint8_t* nsk);
+        int32_t getMulticastApplicationSessionKey(uint8_t index, uint8_t* ask);
+        uint32_t getMulticastDownlinkCounter(uint8_t index);
+        int8_t getMulticastPeriodicity(uint8_t index);
+        uint32_t getMulticastFrequency(uint8_t index);
+        uint8_t getMulticastDatarate(uint8_t index);
 
         /**
          * Attempt to join network
@@ -1464,6 +1506,11 @@
          */
         uint64_t getGPSTime();
 
+        /**
+         * Add a device time request to the MacCommand buffer
+         */
+        void addDeviceTimeRequest();
+
 #if defined(TARGET_MTS_MDOT_F411RE)
         ///////////////////////////////////////////////////////////////////
         // Filesystem (Non Volatile Memory) Operation Functions for mDot //
@@ -1545,6 +1592,8 @@
         // Return total size of all files saved in FLASH
         // Does not include SPIFFS overhead
         uint32_t getUsedSpace();
+
+        bool repairFlashFileSystem();
 #else
         ///////////////////////////////////////////////////////////////
         // EEPROM (Non Volatile Memory) Operation Functions for xDot //
@@ -1702,6 +1751,9 @@
         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);
+        std::vector<uint8_t> getProtectedAppEUI();
+        std::vector<uint8_t> getProtectedAppKey();
+        int32_t setProtectedGenAppKey(const std::vector<uint8_t>& appKey);
         int32_t setDefaultFrequencyBand(const uint8_t& band);
         bool saveProtectedConfig();
         // resets the radio/mac/link
@@ -1734,7 +1786,7 @@
 
         mdot_stats _stats;
 
-        FunctionPointer _wakeup_callback;
+        Callback<void()> _wakeup_callback;
 
         bool _standbyFlag;
         bool _testMode;