Stable version of the mDot library for mbed 5. This version of the library is suitable for deployment scenarios. See lastest commit message for version of mbed-os library that has been tested against.

Dependents:   mdot_two_way unh-hackathon-example unh-hackathon-example-raw TelitSensorToCloud ... more

Fork of libmDot-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

main.cpp

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

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
    }

A definition is needed to enable Fragmentation support on mDot and save fragments to flash. This should not be defined for xDot and will result in a compiler error.

mbed_app.json

{
    "macros": [
        "FOTA=1"
    ]
}

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:
31:7fdee197d415
Parent:
30:c3150500b324
Child:
43:ba29a595814e
--- a/mDot.h	Wed Sep 07 15:40:13 2016 -0500
+++ b/mDot.h	Thu Sep 08 11:15:32 2016 -0500
@@ -1043,31 +1043,40 @@
         bool readUserBackupRegister(uint32_t reg, uint32_t& data);
 
 #if defined(TARGET_MTS_MDOT_F411RE)
+        ///////////////////////////////////////////////////////////////////
+        // Filesystem (Non Volatile Memory) Operation Functions for mDot //
+        ///////////////////////////////////////////////////////////////////
+
         // Save user file data to flash
         // file - name of file max 30 chars
         // data - data of file
         // size - size of file
+        // returns true if successful
         bool saveUserFile(const char* file, void* data, uint32_t size);
 
         // Append user file data to flash
         // file - name of file max 30 chars
         // data - data of file
         // size - size of file
+        // returns true if successful
         bool appendUserFile(const char* file, void* data, uint32_t size);
 
         // Read user file data from flash
         // file - name of file max 30 chars
         // data - data of file
         // size - size of file
+        // returns true if successful
         bool readUserFile(const char* file, void* data, uint32_t size);
 
         // Move a user file in flash
         // file     - name of file
         // new_name - new name of file
+        // returns true if successful
         bool moveUserFile(const char* file, const char* new_name);
 
         // Delete user file data from flash
         // file - name of file max 30 chars
+        // returns true if successful
         bool deleteUserFile(const char* file);
 
         // Open user file in flash, max of 4 files open concurrently
@@ -1081,24 +1090,26 @@
         // file - mdot file struct
         // offset - offset in bytes
         // whence - where offset is based SEEK_SET, SEEK_CUR, SEEK_END
+        // returns true if successful
         bool seekUserFile(mDot::mdot_file& file, size_t offset, int whence);
 
         // Read bytes from open file
         // file - mdot file struct
         // data - mem location to store data
         // length - number of bytes to read
-        // returns - number of bytes written
+        // returns - number of bytes read, negative if error
         int readUserFile(mDot::mdot_file& file, void* data, size_t length);
 
         // Write bytes to open file
         // file - mdot file struct
         // data - data to write
         // length - number of bytes to write
-        // returns - number of bytes written
+        // returns - number of bytes written, negative if error
         int writeUserFile(mDot::mdot_file& file, void* data, size_t length);
 
         // Close open file
         // file - mdot file struct
+        // returns true if successful
         bool closeUserFile(mDot::mdot_file& file);
 
         // List user files stored in flash
@@ -1106,7 +1117,26 @@
 
         // Move file into the firmware upgrade path to be flashed on next boot
         // file - name of file
+        // returns true if successful
         bool moveUserFileToFirmwareUpgrade(const char* file);
+#else
+        ///////////////////////////////////////////////////////////////
+        // EEPROM (Non Volatile Memory) Operation Functions for xDot //
+        ///////////////////////////////////////////////////////////////
+        
+        // Write to EEPROM
+        // addr - address to write to (0 - 0x17FF)
+        // data - data to write
+        // size - size of data
+        // returns true if successful
+        bool nvmWrite(uint16_t addr, void* data, uint16_t size);
+
+        // Read from EEPROM
+        // addr - address to read from (0 - 0x17FF)
+        // data - buffer for data
+        // size - size of buffer
+        // returns true if successful
+        bool nvmRead(uint16_t addr, void* data, uint16_t size);
 #endif /* TARGET_MTS_MDOT_F411RE */
 
         // get current statistics