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

README.txt

Committer:
jreiss
Date:
2020-03-25
Revision:
74:8b02b1a9a1b6
Parent:
13:5ac2300dc06a

File content as of revision 74:8b02b1a9a1b6:

---------------------------------------
Getting Started with the mDot Library
---------------------------------------

This README should get you started using the mDot library with your MultiTech mDot.

License information can be found in the accompanying LICENSE file.

The mDot header has documentation for all the public functions that will be useful to consumers of the library.

The following source code provides an example application which configures the mDot, connects to a MultiTech Conduit gateway with matching configuration, and sends data packets to the gateway.

/**************
  SAMPLE CODE
**************/

#include "mbed.h"
#include "mDot.h"
#include <string>
#include <vector>

// these options must match the settings on your Conduit in
// /var/config/lora/lora-network-server.conf
static std::string config_network_name = "my_lora_network";
static std::string config_network_pass = "my_network_password";
static uint8_t config_frequency_sub_band = 1;

void log_error(mDot* dot, const char* msg, int32_t retval);

int main() {
    int32_t ret;
    mDot* dot;
    std::vector<uint8_t> data;
    std::string data_str = "hello world!";

    // get a mDot handle
    dot = mDot::getInstance();

    // reset to default config so we know what state we're in
    dot->resetConfig();

    // print library version information
    printf("version: %s\r\n", dot->getId().c_str());

    // set up the mDot with our network information
    printf("setting frequency sub band\r\n");
    if ((ret = dot->setFrequencySubBand(config_frequency_sub_band)) != mDot::MDOT_OK) {
        log_error(dot, "failed to set frequency sub band", ret);
    }
    printf("setting network name\r\n");
    if ((ret = dot->setNetworkName(config_network_name)) != mDot::MDOT_OK) {
        log_error(dot, "failed to set network name", ret);
    }
    printf("setting network password\r\n");
    if ((ret = dot->setNetworkPassphrase(config_network_pass)) != mDot::MDOT_OK) {
        log_error(dot, "failed to set network password", ret);
    }

    // attempt to join the network
    printf("joining network\r\n");
    while ((ret = dot->joinNetwork()) != mDot::MDOT_OK) {
        log_error(dot, "failed to join network", ret);
        wait(2);
    }

    // format data for sending to the gateway
    for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
        data.push_back((uint8_t) *it);

    while (true) {
        // send the data
        // ACKs are enabled by default, so we're expecting to get one back
        if ((ret = dot->send(data)) != mDot::MDOT_OK) {
            log_error(dot, "failed to send", ret);
        } else {
            printf("successfully sent data to gateway\r\n");
        }

        wait(5);
    }

    return 0;
}

void log_error(mDot* dot, const char* msg, int32_t retval) {
    printf("%s - %ld:%s, %s\r\n", msg, retval, mDot::getReturnCodeString(retval).c_str(), dot->getLastError().c_str());
}