MultiTech / libmDot-Custom

Fork of libmDot-custom by Jason Reiss

Information

Library has been updated to mbed 5.x

The LoRaWAN Certification test mode implementation is built-in to libmDot code. When a start test mode packet is received the library will not return until test mode has ended.

Warning

This library is currently in BETA release. Unresolved issues may be experienced. Software is provided as is with no expectation of support of bug fixes in the future. Please report issues found through the mbed website or directly to support.multitech.com.

Changing of channel plan parameters may cause the device to no longer respect local RF regulations. Please use caution and respect your local regulations.

In AT Command Firmware remove line 803.

CommandTerminal/CommandTerminal.cpp

        delete[] info->RxBuffer;

Likewise, if your application is handling events from the library asynchronously.

Creating new channel plans

Copy EU868 or US915 custom channel plan as a starting point

Import programmDot_AT_firmware_CUSTOM

AT Firmware with custom channel plan support

EU868 provides a framework for a DYNAMIC channel plan with duty-cycle limitations

US915 provides a framework for a FIXED channel plan

RADIO_POWERS are measured output in dBm for each radio tx power setting.

Additional MAC Commands can be implemented by overriding the HandleMacCommand function.

Steps

  1. Setup datarates, duty-cycle bands and channels in ChannelPlan_* constructor
  2. Modify GetJoinDatarate and CalculateJoinBackoff to change join datarates and backoff
  3. Customize HandleJoinAccept datarates
  4. Use GetRxWindow(int) to define how the device open Rx window 1 and 2
  5. GetNextChannel will pick a channel from the enabled channel at the current datarate before each TX

README.txt

Committer:
Mike Fiore
Date:
2015-06-24
Revision:
3:5e805b567124
Parent:
2:6385bf37bfe7
Child:
9:ebf682e616d0

File content as of revision 3:5e805b567124:

---------------------------------------
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.

NOTE: All applications built using the mDot library must include mbed-src instead of mbed and must
have the "newboards" beta token enabled.  This is to resolve a stack size issue that may be
encountered otherwise.  A fix is on its way to the regular mbed library, but these extra steps are
required until then.  To enable the "newboards" beta token, go to the page listed below, click
enable, and completely refresh your online compiler.

https://developer.mbed.org/betamode/?pre=newboards

/**************
  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());
}