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
Committer:
jreiss
Date:
Wed Mar 25 17:06:41 2020 +0000
Revision:
74:8b02b1a9a1b6
Parent:
72:b1e07ec1c30d
Remove old ARMCC archive, only ARMC6 is available.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1 /**********************************************************************
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 2 * COPYRIGHT 2015 MULTI-TECH SYSTEMS, INC.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 3 *
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 4 * Redistribution and use in source and binary forms, with or without modification,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 5 * are permitted provided that the following conditions are met:
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 6 * 1. Redistributions of source code must retain the above copyright notice,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 7 * this list of conditions and the following disclaimer.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 8 * 2. Redistributions in binary form must reproduce the above copyright notice,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 9 * this list of conditions and the following disclaimer in the documentation
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 10 * and/or other materials provided with the distribution.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 11 * 3. Neither the name of MULTI-TECH SYSTEMS, INC. nor the names of its contributors
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 12 * may be used to endorse or promote products derived from this software
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 13 * without specific prior written permission.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 14 *
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 25 *
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 26 ******************************************************************************
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 27 */
mfiore 0:c62615f15125 28
mfiore 0:c62615f15125 29 #ifndef MDOT_H
mfiore 0:c62615f15125 30 #define MDOT_H
mfiore 0:c62615f15125 31
mfiore 0:c62615f15125 32 #include "mbed.h"
mfiore 0:c62615f15125 33 #include "rtos.h"
Mike Fiore 16:b630e18103e5 34 #include "Mote.h"
mfiore 0:c62615f15125 35 #include <vector>
mfiore 0:c62615f15125 36 #include <map>
mfiore 0:c62615f15125 37 #include <string>
mfiore 0:c62615f15125 38
Mike Fiore 12:54f9cac9d690 39 class mDotEvent;
mfiore 0:c62615f15125 40 class LoRaConfig;
mfiore 0:c62615f15125 41
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 42
mfiore 0:c62615f15125 43 class mDot {
Mike Fiore 16:b630e18103e5 44 friend class mDotEvent;
mfiore 0:c62615f15125 45
mfiore 0:c62615f15125 46 private:
mfiore 0:c62615f15125 47
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 48 mDot(lora::ChannelPlan* plan);
mfiore 0:c62615f15125 49 ~mDot();
mfiore 0:c62615f15125 50
Mike Fiore 16:b630e18103e5 51 void initLora();
Mike Fiore 16:b630e18103e5 52
mfiore 0:c62615f15125 53 void setLastError(const std::string& str);
mfiore 0:c62615f15125 54
mfiore 0:c62615f15125 55 static bool validateBaudRate(const uint32_t& baud);
mfiore 0:c62615f15125 56 static bool validateFrequencySubBand(const uint8_t& band);
mfiore 0:c62615f15125 57 bool validateDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 58
mfiore 0:c62615f15125 59 int32_t joinBase(const uint32_t& retries);
mfiore 0:c62615f15125 60 int32_t sendBase(const std::vector<uint8_t>& data, const bool& confirmed = false, const bool& blocking = true, const bool& highBw = false);
mfiore 0:c62615f15125 61 void waitForPacket();
mfiore 0:c62615f15125 62 void waitForLinkCheck();
mfiore 0:c62615f15125 63
mfiore 0:c62615f15125 64 mDot(const mDot&);
mfiore 0:c62615f15125 65 mDot& operator=(const mDot&);
mfiore 0:c62615f15125 66
Mike Fiore 7:683dba5d576f 67 uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);
Mike Fiore 7:683dba5d576f 68 void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);
Mike Fiore 7:683dba5d576f 69
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 70 void RTC_DisableWakeupTimer();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 71 void RTC_EnableWakeupTimer();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 72
Mike Fiore 12:54f9cac9d690 73 void enterStopMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM);
Mike Fiore 12:54f9cac9d690 74 void enterStandbyMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM);
Mike Fiore 12:54f9cac9d690 75
mfiore 0:c62615f15125 76 static mDot* _instance;
mfiore 0:c62615f15125 77
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 78 lora::Mote* _mote;
mfiore 0:c62615f15125 79 LoRaConfig* _config;
Mike Fiore 16:b630e18103e5 80 lora::Settings _settings;
Mike Fiore 16:b630e18103e5 81 mDotEvent* _events;
Mike Fiore 16:b630e18103e5 82
mfiore 0:c62615f15125 83 std::string _last_error;
mfiore 0:c62615f15125 84 static const uint32_t _baud_rates[];
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 85
jreiss 9:ec2fffe31793 86 uint8_t _linkFailCount;
Mike Fiore 7:683dba5d576f 87 uint8_t _class;
Mike Fiore 7:683dba5d576f 88 InterruptIn* _wakeup;
Mike Fiore 7:683dba5d576f 89 PinName _wakeup_pin;
mfiore 0:c62615f15125 90
mfiore 0:c62615f15125 91 typedef enum {
Jason Reiss 10:27dafba9fe19 92 OFF,
Jason Reiss 10:27dafba9fe19 93 ON,
Jason Reiss 10:27dafba9fe19 94 BLINK,
mfiore 0:c62615f15125 95 } state;
mfiore 0:c62615f15125 96
mfiore 0:c62615f15125 97 public:
mfiore 0:c62615f15125 98
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 99 #if defined(TARGET_MTS_MDOT_F411RE)
mfiore 0:c62615f15125 100 typedef enum {
Mike Fiore 7:683dba5d576f 101 FM_APPEND = (1 << 0),
Mike Fiore 7:683dba5d576f 102 FM_TRUNC = (1 << 1),
Mike Fiore 7:683dba5d576f 103 FM_CREAT = (1 << 2),
Mike Fiore 7:683dba5d576f 104 FM_RDONLY = (1 << 3),
Mike Fiore 7:683dba5d576f 105 FM_WRONLY = (1 << 4),
Mike Fiore 7:683dba5d576f 106 FM_RDWR = (FM_RDONLY | FM_WRONLY),
Mike Fiore 7:683dba5d576f 107 FM_DIRECT = (1 << 5)
Mike Fiore 7:683dba5d576f 108 } FileMode;
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 109 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 7:683dba5d576f 110
Mike Fiore 7:683dba5d576f 111 typedef enum {
mfiore 0:c62615f15125 112 MDOT_OK = 0,
mfiore 0:c62615f15125 113 MDOT_INVALID_PARAM = -1,
mfiore 0:c62615f15125 114 MDOT_TX_ERROR = -2,
mfiore 0:c62615f15125 115 MDOT_RX_ERROR = -3,
mfiore 0:c62615f15125 116 MDOT_JOIN_ERROR = -4,
mfiore 0:c62615f15125 117 MDOT_TIMEOUT = -5,
mfiore 0:c62615f15125 118 MDOT_NOT_JOINED = -6,
mfiore 0:c62615f15125 119 MDOT_ENCRYPTION_DISABLED = -7,
mfiore 0:c62615f15125 120 MDOT_NO_FREE_CHAN = -8,
Mike Fiore 12:54f9cac9d690 121 MDOT_TEST_MODE = -9,
Mike Fiore 12:54f9cac9d690 122 MDOT_NO_ENABLED_CHAN = -10,
Mike Fiore 12:54f9cac9d690 123 MDOT_AGGREGATED_DUTY_CYCLE = -11,
Jenkins@KEILDM1.dc.multitech.prv 43:ba29a595814e 124 MDOT_MAX_PAYLOAD_EXCEEDED = -12,
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 125 MDOT_LBT_CHANNEL_BUSY = -13,
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 126 MDOT_NOT_IDLE = -14,
mfiore 0:c62615f15125 127 MDOT_ERROR = -1024,
mfiore 0:c62615f15125 128 } mdot_ret_code;
mfiore 0:c62615f15125 129
mfiore 0:c62615f15125 130 enum JoinMode {
Mike Fiore 16:b630e18103e5 131 MANUAL = 0,
Jason Reiss 10:27dafba9fe19 132 OTA,
Mike Fiore 12:54f9cac9d690 133 AUTO_OTA,
Mike Fiore 12:54f9cac9d690 134 PEER_TO_PEER
mfiore 0:c62615f15125 135 };
mfiore 0:c62615f15125 136
mfiore 0:c62615f15125 137 enum Mode {
Jason Reiss 10:27dafba9fe19 138 COMMAND_MODE,
Jason Reiss 10:27dafba9fe19 139 SERIAL_MODE
mfiore 0:c62615f15125 140 };
mfiore 0:c62615f15125 141
mfiore 0:c62615f15125 142 enum RX_Output {
Jason Reiss 10:27dafba9fe19 143 HEXADECIMAL,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 144 BINARY,
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 145 EXTENDED,
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 146 EXTENDED_HEX
mfiore 0:c62615f15125 147 };
mfiore 0:c62615f15125 148
mfiore 0:c62615f15125 149 enum DataRates {
Mike Fiore 12:54f9cac9d690 150 DR0,
Mike Fiore 12:54f9cac9d690 151 DR1,
Mike Fiore 12:54f9cac9d690 152 DR2,
Mike Fiore 12:54f9cac9d690 153 DR3,
Mike Fiore 12:54f9cac9d690 154 DR4,
Mike Fiore 12:54f9cac9d690 155 DR5,
Mike Fiore 12:54f9cac9d690 156 DR6,
Mike Fiore 12:54f9cac9d690 157 DR7,
Mike Fiore 12:54f9cac9d690 158 DR8,
Mike Fiore 12:54f9cac9d690 159 DR9,
Mike Fiore 12:54f9cac9d690 160 DR10,
Mike Fiore 12:54f9cac9d690 161 DR11,
Mike Fiore 12:54f9cac9d690 162 DR12,
Mike Fiore 12:54f9cac9d690 163 DR13,
Mike Fiore 12:54f9cac9d690 164 DR14,
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 165 DR15
mfiore 0:c62615f15125 166 };
mfiore 0:c62615f15125 167
mfiore 0:c62615f15125 168 enum FrequencySubBands {
Jason Reiss 10:27dafba9fe19 169 FSB_ALL,
Jason Reiss 10:27dafba9fe19 170 FSB_1,
Jason Reiss 10:27dafba9fe19 171 FSB_2,
Jason Reiss 10:27dafba9fe19 172 FSB_3,
Jason Reiss 10:27dafba9fe19 173 FSB_4,
Jason Reiss 10:27dafba9fe19 174 FSB_5,
Jason Reiss 10:27dafba9fe19 175 FSB_6,
Jason Reiss 10:27dafba9fe19 176 FSB_7,
Jason Reiss 10:27dafba9fe19 177 FSB_8
mfiore 0:c62615f15125 178 };
mfiore 0:c62615f15125 179
Mike Fiore 7:683dba5d576f 180 enum wakeup_mode {
Jason Reiss 10:27dafba9fe19 181 RTC_ALARM,
Jason Reiss 10:27dafba9fe19 182 INTERRUPT,
Jason Reiss 10:27dafba9fe19 183 RTC_ALARM_OR_INTERRUPT
Mike Fiore 7:683dba5d576f 184 };
Mike Fiore 7:683dba5d576f 185
jreiss 9:ec2fffe31793 186 enum UserBackupRegs {
Jason Reiss 10:27dafba9fe19 187 UBR0,
Jason Reiss 10:27dafba9fe19 188 UBR1,
Jason Reiss 10:27dafba9fe19 189 UBR2,
Jason Reiss 10:27dafba9fe19 190 UBR3,
Jason Reiss 10:27dafba9fe19 191 UBR4,
Jason Reiss 10:27dafba9fe19 192 UBR5,
Jason Reiss 10:27dafba9fe19 193 UBR6,
Jason Reiss 10:27dafba9fe19 194 UBR7,
Jason Reiss 10:27dafba9fe19 195 UBR8,
Jason Reiss 10:27dafba9fe19 196 UBR9
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 197 #if defined (TARGET_XDOT_L151CC)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 198 ,UBR10,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 199 UBR11,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 200 UBR12,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 201 UBR13,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 202 UBR14,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 203 UBR15,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 204 UBR16,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 205 UBR17,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 206 UBR18,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 207 UBR19,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 208 UBR20,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 209 UBR21
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 210 #endif /* TARGET_XDOT_L151CC */
jreiss 9:ec2fffe31793 211 };
jreiss 9:ec2fffe31793 212
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 213 #if defined(TARGET_MTS_MDOT_F411RE)
Mike Fiore 7:683dba5d576f 214 typedef struct {
Mike Fiore 7:683dba5d576f 215 int16_t fd;
Mike Fiore 16:b630e18103e5 216 char name[33];
Mike Fiore 7:683dba5d576f 217 uint32_t size;
Mike Fiore 7:683dba5d576f 218 } mdot_file;
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 219 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 7:683dba5d576f 220
mfiore 0:c62615f15125 221 typedef struct {
mfiore 0:c62615f15125 222 uint32_t Up;
mfiore 0:c62615f15125 223 uint32_t Down;
mfiore 0:c62615f15125 224 uint32_t Joins;
mfiore 0:c62615f15125 225 uint32_t JoinFails;
mfiore 0:c62615f15125 226 uint32_t MissedAcks;
Mike Fiore 16:b630e18103e5 227 uint32_t CRCErrors;
mfiore 0:c62615f15125 228 } mdot_stats;
mfiore 0:c62615f15125 229
mfiore 0:c62615f15125 230 typedef struct {
mfiore 0:c62615f15125 231 int16_t last;
mfiore 0:c62615f15125 232 int16_t min;
mfiore 0:c62615f15125 233 int16_t max;
mfiore 0:c62615f15125 234 int16_t avg;
mfiore 0:c62615f15125 235 } rssi_stats;
mfiore 0:c62615f15125 236
mfiore 0:c62615f15125 237 typedef struct {
Mike Fiore 11:d8464345e1f1 238 int16_t last;
Mike Fiore 11:d8464345e1f1 239 int16_t min;
Mike Fiore 11:d8464345e1f1 240 int16_t max;
Mike Fiore 11:d8464345e1f1 241 int16_t avg;
mfiore 0:c62615f15125 242 } snr_stats;
mfiore 0:c62615f15125 243
mfiore 0:c62615f15125 244 typedef struct {
mfiore 0:c62615f15125 245 bool status;
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 246 uint8_t dBm;
mfiore 0:c62615f15125 247 uint32_t gateways;
mfiore 0:c62615f15125 248 std::vector<uint8_t> payload;
mfiore 0:c62615f15125 249 } link_check;
mfiore 0:c62615f15125 250
mfiore 0:c62615f15125 251 typedef struct {
mfiore 0:c62615f15125 252 int32_t status;
mfiore 0:c62615f15125 253 int16_t rssi;
mfiore 0:c62615f15125 254 int16_t snr;
mfiore 0:c62615f15125 255 } ping_response;
mfiore 0:c62615f15125 256
mfiore 0:c62615f15125 257 static std::string JoinModeStr(uint8_t mode);
mfiore 0:c62615f15125 258 static std::string ModeStr(uint8_t mode);
mfiore 0:c62615f15125 259 static std::string RxOutputStr(uint8_t format);
mfiore 0:c62615f15125 260 static std::string DataRateStr(uint8_t rate);
mfiore 0:c62615f15125 261 static std::string FrequencyBandStr(uint8_t band);
mfiore 0:c62615f15125 262 static std::string FrequencySubBandStr(uint8_t band);
mfiore 0:c62615f15125 263
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 264 #if defined(TARGET_MTS_MDOT_F411RE)
jreiss 9:ec2fffe31793 265 uint32_t UserRegisters[10];
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 266 #else
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 267 uint32_t UserRegisters[22];
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 268 #endif /* TARGET_MTS_MDOT_F411RE */
jreiss 9:ec2fffe31793 269
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 270 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 271 * Get a handle to the singleton object
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 272 * @param plan the channel plan to use
mfiore 0:c62615f15125 273 * @returns pointer to mDot object
mfiore 0:c62615f15125 274 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 275 static mDot* getInstance(lora::ChannelPlan* plan);
mfiore 0:c62615f15125 276
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 277 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 278 * Can only be used after a dot has
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 279 * configured with a plan
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 280 * @returns pointer to mDot object
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 281 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 282 static mDot* getInstance();
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 283
Mike Fiore 12:54f9cac9d690 284 void setEvents(mDotEvent* events);
Mike Fiore 12:54f9cac9d690 285
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 286 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 287 *
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 288 * Get library version information
mfiore 0:c62615f15125 289 * @returns string containing library version information
mfiore 0:c62615f15125 290 */
mfiore 0:c62615f15125 291 std::string getId();
mfiore 0:c62615f15125 292
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 293 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 294 * Get MTS LoRa version information
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 295 * @returns string containing MTS LoRa version information
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 296 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 297 std::string getMtsLoraId();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 298
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 299
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 300 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 301 * MAC version
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 302 *
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 303 * @return string containing version information of supported LoRaWAN MAC Version
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 304 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 305 const char* getMACVersion();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 306
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 307 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 308 * Perform a soft reset of the system
mfiore 0:c62615f15125 309 */
mfiore 0:c62615f15125 310 void resetCpu();
mfiore 0:c62615f15125 311
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 312 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 313 * Reset config to factory default
mfiore 0:c62615f15125 314 */
mfiore 0:c62615f15125 315 void resetConfig();
mfiore 0:c62615f15125 316
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 317 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 318 * Save config data to non volatile memory
mfiore 0:c62615f15125 319 * @returns true if success, false if failure
mfiore 0:c62615f15125 320 */
mfiore 0:c62615f15125 321 bool saveConfig();
mfiore 0:c62615f15125 322
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 323 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 324 * Set the log level for the library
mfiore 0:c62615f15125 325 * options are:
mfiore 0:c62615f15125 326 * NONE_LEVEL - logging is off at this level
mfiore 0:c62615f15125 327 * FATAL_LEVEL - only critical errors will be reported
mfiore 0:c62615f15125 328 * ERROR_LEVEL
mfiore 0:c62615f15125 329 * WARNING_LEVEL
mfiore 0:c62615f15125 330 * INFO_LEVEL
mfiore 0:c62615f15125 331 * DEBUG_LEVEL
mfiore 0:c62615f15125 332 * TRACE_LEVEL - every detail will be reported
mfiore 0:c62615f15125 333 * @param level the level to log at
mfiore 0:c62615f15125 334 * @returns MDOT_OK if success
mfiore 0:c62615f15125 335 */
mfiore 0:c62615f15125 336 int32_t setLogLevel(const uint8_t& level);
mfiore 0:c62615f15125 337
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 338 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 339 * Get the current log level for the library
mfiore 0:c62615f15125 340 * @returns current log level
mfiore 0:c62615f15125 341 */
Mike Fiore 6:390fc83d588d 342 uint8_t getLogLevel();
Mike Fiore 6:390fc83d588d 343
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 344 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 345 * Seed pseudo RNG in LoRaMac layer, uses random value from radio RSSI reading by default
Mike Fiore 12:54f9cac9d690 346 * @param seed for RNG
Mike Fiore 12:54f9cac9d690 347 */
Mike Fiore 12:54f9cac9d690 348 void seedRandom(uint32_t seed);
Mike Fiore 12:54f9cac9d690 349
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 350 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 351 * @returns true if MAC command answers are ready to be sent
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 352 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 353 bool hasMacCommands();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 354
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 355
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 356 uint8_t setChannelPlan(lora::ChannelPlan* plan);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 357
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 358 lora::Settings* getSettings();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 359
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 360 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 361 * Returns boolean indicative of start-up from standby mode
Mike Fiore 12:54f9cac9d690 362 * @returns true if dot woke from standby
Mike Fiore 12:54f9cac9d690 363 */
Mike Fiore 12:54f9cac9d690 364 bool getStandbyFlag();
Mike Fiore 12:54f9cac9d690 365
Mike Fiore 16:b630e18103e5 366 std::vector<uint16_t> getChannelMask();
Mike Fiore 16:b630e18103e5 367
Mike Fiore 16:b630e18103e5 368 int32_t setChannelMask(uint8_t offset, uint16_t mask);
Mike Fiore 16:b630e18103e5 369
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 370 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 371 * Add a channel
Mike Fiore 12:54f9cac9d690 372 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 373 */
Mike Fiore 12:54f9cac9d690 374 int32_t addChannel(uint8_t index, uint32_t frequency, uint8_t datarateRange);
Mike Fiore 12:54f9cac9d690 375
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 376 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 377 * Add a downlink channel
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 378 * @returns MDOT_OK
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 379 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 380 int32_t addDownlinkChannel(uint8_t index, uint32_t frequency);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 381
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 382 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 383 * Get list of channel frequencies currently in use
mfiore 0:c62615f15125 384 * @returns vector of channels currently in use
mfiore 0:c62615f15125 385 */
mfiore 0:c62615f15125 386 std::vector<uint32_t> getChannels();
mfiore 0:c62615f15125 387
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 388 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 389 * Get list of downlink channel frequencies currently in use
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 390 * @returns vector of channels currently in use
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 391 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 392 std::vector<uint32_t> getDownlinkChannels();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 393
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 394 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 395 * Get list of channel datarate ranges currently in use
Mike Fiore 12:54f9cac9d690 396 * @returns vector of datarate ranges currently in use
Mike Fiore 12:54f9cac9d690 397 */
Mike Fiore 12:54f9cac9d690 398 std::vector<uint8_t> getChannelRanges();
Mike Fiore 12:54f9cac9d690 399
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 400 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 401 * Get list of channel frequencies in config file to be used as session defaults
Mike Fiore 12:54f9cac9d690 402 * @returns vector of channels in config file
Mike Fiore 12:54f9cac9d690 403 */
Mike Fiore 12:54f9cac9d690 404 std::vector<uint32_t> getConfigChannels();
Mike Fiore 12:54f9cac9d690 405
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 406 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 407 * Get list of channel datarate ranges in config file to be used as session defaults
Mike Fiore 12:54f9cac9d690 408 * @returns vector of datarate ranges in config file
Mike Fiore 12:54f9cac9d690 409 */
Mike Fiore 12:54f9cac9d690 410 std::vector<uint8_t> getConfigChannelRanges();
Mike Fiore 12:54f9cac9d690 411
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 412 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 413 * Get default frequency band
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 414 * @returns frequency band the device was manufactured for
mfiore 0:c62615f15125 415 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 416 uint8_t getDefaultFrequencyBand();
mfiore 0:c62615f15125 417
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 418 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 419 * Set frequency sub band
mfiore 0:c62615f15125 420 * only applicable if frequency band is set for United States (FB_915)
Jason Reiss 10:27dafba9fe19 421 * sub band 0 will allow the radio to use all 64 channels
mfiore 0:c62615f15125 422 * sub band 1 - 8 will allow the radio to use the 8 channels in that sub band
mfiore 0:c62615f15125 423 * for use with Conduit gateway and MTAC_LORA, use sub bands 1 - 8, not sub band 0
mfiore 0:c62615f15125 424 * @param band the sub band to use (0 - 8)
mfiore 0:c62615f15125 425 * @returns MDOT_OK if success
mfiore 0:c62615f15125 426 */
mfiore 0:c62615f15125 427 int32_t setFrequencySubBand(const uint8_t& band);
mfiore 0:c62615f15125 428
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 429 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 430 * Get frequency sub band
mfiore 0:c62615f15125 431 * @returns frequency sub band currently in use
mfiore 0:c62615f15125 432 */
mfiore 0:c62615f15125 433 uint8_t getFrequencySubBand();
mfiore 0:c62615f15125 434
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 435 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 436 * Get frequency band
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 437 * @returns frequency band (channel plan) currently in use
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 438 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 439 uint8_t getFrequencyBand();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 440
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 441 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 442 * Get channel plan name
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 443 * @returns name of channel plan currently in use
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 444 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 445 std::string getChannelPlanName();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 446
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 447 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 448 * Get the datarate currently in use within the MAC layer
Mike Fiore 12:54f9cac9d690 449 * returns 0-15
Mike Fiore 12:54f9cac9d690 450 */
Mike Fiore 12:54f9cac9d690 451 uint8_t getSessionDataRate();
Mike Fiore 12:54f9cac9d690 452
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 453
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 454 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 455 * Get the current max EIRP used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 456 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 457 * returns 0-36
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 458 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 459 uint8_t getSessionMaxEIRP();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 460
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 461 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 462 * Set the current max EIRP used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 463 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 464 * accepts 0-36
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 465 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 466 void setSessionMaxEIRP(uint8_t max);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 467
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 468 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 469 * Get the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 470 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 471 * returns 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 472 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 473 uint8_t getSessionDownlinkDwelltime();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 474
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 475 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 476 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 477 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 478 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 479 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 480 void setSessionDownlinkDwelltime(uint8_t dwell);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 481
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 482 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 483 * Get the current uplink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 484 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 485 * returns 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 486 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 487 uint8_t getSessionUplinkDwelltime();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 488
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 489 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 490 * Set the current uplink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 491 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 492 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 493 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 494 void setSessionUplinkDwelltime(uint8_t dwell);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 495
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 496 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 497 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 498 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 499 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 500 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 501 uint32_t getListenBeforeTalkTime(uint8_t ms);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 502
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 503 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 504 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 505 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 506 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 507 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 508 void setListenBeforeTalkTime(uint32_t ms);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 509
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 510 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 511 * Set public network mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 512 * 0:PRIVATE_MTS, 1:PUBLIC_LORAWAN, 2:PRIVATE_LORAWAN
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 513 * PRIVATE_MTS - Sync Word 0x12, US/AU Downlink frequencies per Frequency Sub Band
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 514 * PUBLIC_LORAWAN - Sync Word 0x34
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 515 * PRIVATE_LORAWAN - Sync Word 0x12
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 516 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 517 * The default Join Delay is 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 518 * The default Join Delay for PRIVATE_MTS was 1 second in the previous release
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 519 * The Join Delay must be changed independently of Public Network setting
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 520 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 521 * @see lora::NetworkType
mfiore 0:c62615f15125 522 * @returns MDOT_OK if success
mfiore 0:c62615f15125 523 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 524 int32_t setPublicNetwork(const uint8_t& val);
mfiore 0:c62615f15125 525
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 526 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 527 * Get public network mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 528 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 529 * The default Join Delay is 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 530 * The default Join Delay for PRIVATE_MTS was 1 second in the previous release
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 531 * The Join Delay must be changed independently of Public Network setting
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 532 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 533 * @see lora:NetworkType
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 534 * @returns 0:PRIVATE_MTS, 1:PUBLIC_LORAWAN, 2:PRIVATE_LORAWAN
mfiore 0:c62615f15125 535 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 536 uint8_t getPublicNetwork();
mfiore 0:c62615f15125 537
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 538 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 539 * Get the device ID
mfiore 0:c62615f15125 540 * @returns vector containing the device ID (size 8)
mfiore 0:c62615f15125 541 */
mfiore 0:c62615f15125 542 std::vector<uint8_t> getDeviceId();
mfiore 0:c62615f15125 543
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 544 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 545 * Get the device port to be used for lora application data (1-223)
Jason Reiss 10:27dafba9fe19 546 * @returns port
Jason Reiss 10:27dafba9fe19 547 */
Jason Reiss 10:27dafba9fe19 548 uint8_t getAppPort();
Jason Reiss 10:27dafba9fe19 549
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 550 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 551 * Set the device port to be used for lora application data (1-223)
Jason Reiss 10:27dafba9fe19 552 * @returns MDOT_OK if success
Jason Reiss 10:27dafba9fe19 553 */
Jason Reiss 10:27dafba9fe19 554 int32_t setAppPort(uint8_t port);
Jason Reiss 10:27dafba9fe19 555
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 556 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 557 * Set the device class A, B or C
Jason Reiss 10:27dafba9fe19 558 * @returns MDOT_OK if success
Jason Reiss 10:27dafba9fe19 559 */
Jason Reiss 10:27dafba9fe19 560 int32_t setClass(std::string newClass);
Jason Reiss 10:27dafba9fe19 561
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 562 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 563 * Get the device class A, B or C
Jason Reiss 10:27dafba9fe19 564 * @returns MDOT_OK if success
Jason Reiss 10:27dafba9fe19 565 */
Jason Reiss 10:27dafba9fe19 566 std::string getClass();
Jason Reiss 10:27dafba9fe19 567
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 568 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 569 * Get the max packet length with current settings
Jason Reiss 10:27dafba9fe19 570 * @returns max packet length
Jason Reiss 10:27dafba9fe19 571 */
Jason Reiss 10:27dafba9fe19 572 uint8_t getMaxPacketLength();
Jason Reiss 10:27dafba9fe19 573
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 574 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 575 * Set network address
mfiore 0:c62615f15125 576 * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes
mfiore 0:c62615f15125 577 * @param addr a vector of 4 bytes
mfiore 0:c62615f15125 578 * @returns MDOT_OK if success
mfiore 0:c62615f15125 579 */
mfiore 0:c62615f15125 580 int32_t setNetworkAddress(const std::vector<uint8_t>& addr);
mfiore 0:c62615f15125 581
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 582 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 583 * Get network address
mfiore 0:c62615f15125 584 * @returns vector containing network address (size 4)
mfiore 0:c62615f15125 585 */
mfiore 0:c62615f15125 586 std::vector<uint8_t> getNetworkAddress();
mfiore 0:c62615f15125 587
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 588 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 589 * Set network session key
mfiore 0:c62615f15125 590 * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes
mfiore 0:c62615f15125 591 * @param key a vector of 16 bytes
mfiore 0:c62615f15125 592 * @returns MDOT_OK if success
mfiore 0:c62615f15125 593 */
mfiore 0:c62615f15125 594 int32_t setNetworkSessionKey(const std::vector<uint8_t>& key);
mfiore 0:c62615f15125 595
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 596 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 597 * Get network session key
mfiore 0:c62615f15125 598 * @returns vector containing network session key (size 16)
mfiore 0:c62615f15125 599 */
mfiore 0:c62615f15125 600 std::vector<uint8_t> getNetworkSessionKey();
mfiore 0:c62615f15125 601
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 602 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 603 * Set data session key
mfiore 0:c62615f15125 604 * for use with MANUAL network join mode, will be assigned in OTA & AUTO_OTA modes
mfiore 0:c62615f15125 605 * @param key a vector of 16 bytes
mfiore 0:c62615f15125 606 * @returns MDOT_OK if success
mfiore 0:c62615f15125 607 */
mfiore 0:c62615f15125 608 int32_t setDataSessionKey(const std::vector<uint8_t>& key);
mfiore 0:c62615f15125 609
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 610 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 611 * Get data session key
mfiore 0:c62615f15125 612 * @returns vector containing data session key (size 16)
mfiore 0:c62615f15125 613 */
mfiore 0:c62615f15125 614 std::vector<uint8_t> getDataSessionKey();
mfiore 0:c62615f15125 615
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 616 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 617 * Set network name
mfiore 0:c62615f15125 618 * for use with OTA & AUTO_OTA network join modes
mfiore 0:c62615f15125 619 * generates network ID (crc64 of name) automatically
mfiore 0:c62615f15125 620 * @param name a string of of at least 8 bytes and no more than 128 bytes
mfiore 0:c62615f15125 621 * @return MDOT_OK if success
mfiore 0:c62615f15125 622 */
mfiore 0:c62615f15125 623 int32_t setNetworkName(const std::string& name);
mfiore 0:c62615f15125 624
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 625 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 626 * Get network name
mfiore 0:c62615f15125 627 * @return string containing network name (size 8 to 128)
mfiore 0:c62615f15125 628 */
mfiore 0:c62615f15125 629 std::string getNetworkName();
mfiore 0:c62615f15125 630
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 631 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 632 * Set network ID
mfiore 0:c62615f15125 633 * for use with OTA & AUTO_OTA network join modes
mfiore 0:c62615f15125 634 * setting network ID via this function sets network name to empty
mfiore 0:c62615f15125 635 * @param id a vector of 8 bytes
mfiore 0:c62615f15125 636 * @returns MDOT_OK if success
mfiore 0:c62615f15125 637 */
mfiore 0:c62615f15125 638 int32_t setNetworkId(const std::vector<uint8_t>& id);
mfiore 0:c62615f15125 639
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 640 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 641 * Get network ID
mfiore 0:c62615f15125 642 * @returns vector containing network ID (size 8)
mfiore 0:c62615f15125 643 */
mfiore 0:c62615f15125 644 std::vector<uint8_t> getNetworkId();
mfiore 0:c62615f15125 645
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 646 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 647 * Set network passphrase
mfiore 0:c62615f15125 648 * for use with OTA & AUTO_OTA network join modes
mfiore 0:c62615f15125 649 * generates network key (cmac of passphrase) automatically
mfiore 0:c62615f15125 650 * @param name a string of of at least 8 bytes and no more than 128 bytes
mfiore 0:c62615f15125 651 * @return MDOT_OK if success
mfiore 0:c62615f15125 652 */
mfiore 0:c62615f15125 653 int32_t setNetworkPassphrase(const std::string& passphrase);
mfiore 0:c62615f15125 654
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 655 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 656 * Get network passphrase
mfiore 0:c62615f15125 657 * @return string containing network passphrase (size 8 to 128)
mfiore 0:c62615f15125 658 */
mfiore 0:c62615f15125 659 std::string getNetworkPassphrase();
mfiore 0:c62615f15125 660
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 661 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 662 * Set network key
mfiore 0:c62615f15125 663 * for use with OTA & AUTO_OTA network join modes
mfiore 0:c62615f15125 664 * setting network key via this function sets network passphrase to empty
mfiore 0:c62615f15125 665 * @param id a vector of 16 bytes
mfiore 0:c62615f15125 666 * @returns MDOT_OK if success
mfiore 0:c62615f15125 667 */
mfiore 0:c62615f15125 668 int32_t setNetworkKey(const std::vector<uint8_t>& id);
mfiore 0:c62615f15125 669
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 670 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 671 * Get generic app key
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 672 * @returns a vector containing key (size 16)
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 673 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 674 std::vector<uint8_t> getGenAppKey();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 675
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 676 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 677 * Set generic app key
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 678 * for use with Multicast key exchange
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 679 * @param id a vector of 16 bytes
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 680 * @returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 681 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 682 int32_t setGenAppKey(const std::vector<uint8_t>& id);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 683
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 684 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 685 * Get network key
mfiore 0:c62615f15125 686 * @returns a vector containing network key (size 16)
mfiore 0:c62615f15125 687 */
mfiore 0:c62615f15125 688 std::vector<uint8_t> getNetworkKey();
mfiore 0:c62615f15125 689
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 690 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 691 * Set lorawan application EUI
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 692 * equivalent to setNetworkId
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 693 * @param eui application EUI (size 8)
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 694 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 695 int32_t setAppEUI(const uint8_t* eui);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 696
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 697 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 698 * Get lorawan application EUI
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 699 * equivalent to getNetworkId
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 700 * @returns vector containing application EUI (size 8)
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 701 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 702 const uint8_t* getAppEUI();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 703
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 704 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 705 * Set lorawan application key
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 706 * equivalent to setNetworkKey
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 707 * @param eui application key (size 16)
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 708 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 709 int32_t setAppKey(const uint8_t* key);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 710
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 711 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 712 * Set lorawan application key
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 713 * equivalent to getNetworkKey
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 714 * @returns eui application key (size 16)
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 715 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 716 const uint8_t* getAppKey();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 717
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 718 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 719 * Set device nonce counter incremented with each Join Request
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 720 * @returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 721 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 722 int32_t setDevNonce(const uint16_t& nonce);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 723
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 724 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 725 * Get device nonce counter incremented with each Join Request
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 726 * @returns join nonce
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 727 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 728 uint16_t getDevNonce();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 729
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 730 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 731 * Set app nonce counter incremented with each Join Accept
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 732 * @returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 733 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 734 int32_t setAppNonce(const uint32_t& nonce);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 735
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 736 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 737 * Get app nonce counter incremented with each Join Accept
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 738 * @returns app nonce
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 739 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 740 uint32_t getAppNonce();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 741
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 742 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 743 * Enable/disable Join Nonce validation for App Nonce in Join Accept
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 744 * Default is enabled
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 745 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 746 int32_t setJoinNonceValidation(bool enable);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 747 bool getJoinNonceValidation();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 748
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 749 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 750 * Add a multicast session address and keys
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 751 * Downlink counter is set to 0
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 752 * Up to 8 MULTICAST_SESSIONS can be set
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 753 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 754 int32_t setMulticastSession(uint8_t index, uint32_t addr, const uint8_t* nsk, const uint8_t* ask);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 755
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 756 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 757 * Set multicast session info
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 758 * Up to 8 MULTICAST_SESSIONS
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 759 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 760 int32_t setMulticastAddress(uint8_t index, uint32_t addr);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 761 int32_t setMulticastNetworkSessionKey(uint8_t index, const uint8_t* nsk);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 762 int32_t setMulticastApplicationSessionKey(uint8_t index, const uint8_t* ask);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 763
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 764 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 765 * Set a multicast session counter
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 766 * Up to 8 MULTICAST_SESSIONS
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 767 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 768 int32_t setMulticastDownlinkCounter(uint8_t index, uint32_t count);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 769 int32_t setMulticastPeriodicity(uint8_t index, int8_t period);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 770 int32_t setMulticastFrequency(uint8_t index, uint32_t freq);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 771 int32_t setMulticastDatarate(uint8_t index, uint8_t dr);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 772
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 773 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 774 * Get multicast session info
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 775 * Up to 8 MULTICAST_SESSIONS
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 776 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 777 uint32_t getMulticastAddress(uint8_t index);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 778 int32_t getMulticastNetworkSessionKey(uint8_t index, uint8_t* nsk);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 779 int32_t getMulticastApplicationSessionKey(uint8_t index, uint8_t* ask);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 780 uint32_t getMulticastDownlinkCounter(uint8_t index);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 781 int8_t getMulticastPeriodicity(uint8_t index);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 782 uint32_t getMulticastFrequency(uint8_t index);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 783 uint8_t getMulticastDatarate(uint8_t index);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 784
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 785 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 786 * Attempt to join network
Mike Fiore 12:54f9cac9d690 787 * each attempt will be made with a random datarate up to the configured datarate
Mike Fiore 12:54f9cac9d690 788 * JoinRequest backoff between tries is enforced to 1% for 1st hour, 0.1% for 1-10 hours and 0.01% after 10 hours
Mike Fiore 12:54f9cac9d690 789 * Check getNextTxMs() for time until next join attempt can be made
mfiore 0:c62615f15125 790 * @returns MDOT_OK if success
mfiore 0:c62615f15125 791 */
mfiore 0:c62615f15125 792 int32_t joinNetwork();
mfiore 0:c62615f15125 793
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 794 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 795 * Attempts to join network once
mfiore 0:c62615f15125 796 * @returns MDOT_OK if success
mfiore 0:c62615f15125 797 */
mfiore 0:c62615f15125 798 int32_t joinNetworkOnce();
mfiore 0:c62615f15125 799
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 800 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 801 * Resets current network session, essentially disconnecting from the network
mfiore 0:c62615f15125 802 * has no effect for MANUAL network join mode
mfiore 0:c62615f15125 803 */
mfiore 0:c62615f15125 804 void resetNetworkSession();
mfiore 0:c62615f15125 805
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 806 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 807 * Restore saved network session from flash
Mike Fiore 12:54f9cac9d690 808 * has no effect for MANUAL network join mode
Mike Fiore 12:54f9cac9d690 809 */
Mike Fiore 12:54f9cac9d690 810 void restoreNetworkSession();
Mike Fiore 12:54f9cac9d690 811
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 812 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 813 * Save current network session to flash
Mike Fiore 12:54f9cac9d690 814 * has no effect for MANUAL network join mode
Mike Fiore 12:54f9cac9d690 815 */
Mike Fiore 12:54f9cac9d690 816 void saveNetworkSession();
Mike Fiore 12:54f9cac9d690 817
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 818 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 819 * Set number of times joining will retry each sub-band before changing
jreiss 17:306ffaa5d79b 820 * to the next subband in US915 and AU915
mfiore 0:c62615f15125 821 * @param retries must be between 0 - 255
mfiore 0:c62615f15125 822 * @returns MDOT_OK if success
mfiore 0:c62615f15125 823 */
mfiore 0:c62615f15125 824 int32_t setJoinRetries(const uint8_t& retries);
mfiore 0:c62615f15125 825
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 826 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 827 * Get number of times joining will retry each sub-band
mfiore 0:c62615f15125 828 * @returns join retries (0 - 255)
mfiore 0:c62615f15125 829 */
mfiore 0:c62615f15125 830 uint8_t getJoinRetries();
mfiore 0:c62615f15125 831
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 832 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 833 * Set network join mode
mfiore 0:c62615f15125 834 * MANUAL: set network address and session keys manually
mfiore 0:c62615f15125 835 * OTA: User sets network name and passphrase, then attempts to join
mfiore 0:c62615f15125 836 * AUTO_OTA: same as OTA, but network sessions can be saved and restored
mfiore 0:c62615f15125 837 * @param mode MANUAL, OTA, or AUTO_OTA
mfiore 0:c62615f15125 838 * @returns MDOT_OK if success
mfiore 0:c62615f15125 839 */
mfiore 0:c62615f15125 840 int32_t setJoinMode(const uint8_t& mode);
mfiore 0:c62615f15125 841
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 842 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 843 * Get network join mode
mfiore 0:c62615f15125 844 * @returns MANUAL, OTA, or AUTO_OTA
mfiore 0:c62615f15125 845 */
mfiore 0:c62615f15125 846 uint8_t getJoinMode();
mfiore 0:c62615f15125 847
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 848 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 849 * Get network join status
mfiore 0:c62615f15125 850 * @returns true if currently joined to network
mfiore 0:c62615f15125 851 */
mfiore 0:c62615f15125 852 bool getNetworkJoinStatus();
mfiore 0:c62615f15125 853
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 854 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 855 * Do a network link check
mfiore 0:c62615f15125 856 * application data may be returned in response to a network link check command
mfiore 0:c62615f15125 857 * @returns link_check structure containing success, dBm above noise floor, gateways in range, and packet payload
mfiore 0:c62615f15125 858 */
mfiore 0:c62615f15125 859 link_check networkLinkCheck();
mfiore 0:c62615f15125 860
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 861 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 862 * Set network link check count to perform automatic link checks every count packets
mfiore 0:c62615f15125 863 * only applicable if ACKs are disabled
mfiore 0:c62615f15125 864 * @param count must be between 0 - 255
mfiore 0:c62615f15125 865 * @returns MDOT_OK if success
mfiore 0:c62615f15125 866 */
mfiore 0:c62615f15125 867 int32_t setLinkCheckCount(const uint8_t& count);
mfiore 0:c62615f15125 868
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 869 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 870 * Get network link check count
mfiore 0:c62615f15125 871 * @returns count (0 - 255)
mfiore 0:c62615f15125 872 */
mfiore 0:c62615f15125 873 uint8_t getLinkCheckCount();
mfiore 0:c62615f15125 874
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 875 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 876 * Set network link check threshold, number of link check failures or missed acks to tolerate
mfiore 0:c62615f15125 877 * before considering network connection lost
mfiore 0:c62615f15125 878 * @pararm count must be between 0 - 255
mfiore 0:c62615f15125 879 * @returns MDOT_OK if success
mfiore 0:c62615f15125 880 */
mfiore 0:c62615f15125 881 int32_t setLinkCheckThreshold(const uint8_t& count);
mfiore 0:c62615f15125 882
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 883 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 884 * Get network link check threshold
mfiore 0:c62615f15125 885 * @returns threshold (0 - 255)
mfiore 0:c62615f15125 886 */
mfiore 0:c62615f15125 887 uint8_t getLinkCheckThreshold();
mfiore 0:c62615f15125 888
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 889 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 890 * Get/set number of failed link checks in the current session
Mike Fiore 12:54f9cac9d690 891 * @returns count (0 - 255)
Mike Fiore 12:54f9cac9d690 892 */
Mike Fiore 12:54f9cac9d690 893 uint8_t getLinkFailCount();
Mike Fiore 12:54f9cac9d690 894 int32_t setLinkFailCount(uint8_t count);
Mike Fiore 12:54f9cac9d690 895
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 896 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 897 * Set UpLinkCounter number of packets sent to the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 898 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 899 */
Mike Fiore 12:54f9cac9d690 900 int32_t setUpLinkCounter(uint32_t count);
Mike Fiore 12:54f9cac9d690 901
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 902 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 903 * Get UpLinkCounter
mfiore 0:c62615f15125 904 * @returns number of packets sent to the gateway during this network session (sequence number)
mfiore 0:c62615f15125 905 */
mfiore 0:c62615f15125 906 uint32_t getUpLinkCounter();
mfiore 0:c62615f15125 907
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 908 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 909 * Set UpLinkCounter number of packets sent by the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 910 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 911 */
Mike Fiore 12:54f9cac9d690 912 int32_t setDownLinkCounter(uint32_t count);
Mike Fiore 12:54f9cac9d690 913
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 914 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 915 * Get DownLinkCounter
Mike Fiore 12:54f9cac9d690 916 * @returns number of packets sent by the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 917 */
Mike Fiore 12:54f9cac9d690 918 uint32_t getDownLinkCounter();
Mike Fiore 12:54f9cac9d690 919
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 920 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 921 * Enable/disable AES encryption
mfiore 0:c62615f15125 922 * AES encryption must be enabled for use with Conduit gateway and MTAC_LORA card
mfiore 0:c62615f15125 923 * @param on true for AES encryption to be enabled
mfiore 0:c62615f15125 924 * @returns MDOT_OK if success
mfiore 0:c62615f15125 925 */
mfiore 0:c62615f15125 926 int32_t setAesEncryption(const bool& on);
mfiore 0:c62615f15125 927
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 928 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 929 * Get AES encryption
mfiore 0:c62615f15125 930 * @returns true if AES encryption is enabled
mfiore 0:c62615f15125 931 */
mfiore 0:c62615f15125 932 bool getAesEncryption();
mfiore 0:c62615f15125 933
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 934 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 935 * Get RSSI stats
Mike Fiore 11:d8464345e1f1 936 * @returns rssi_stats struct containing last, min, max, and avg RSSI in dB
mfiore 0:c62615f15125 937 */
mfiore 0:c62615f15125 938 rssi_stats getRssiStats();
mfiore 0:c62615f15125 939
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 940 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 941 * Get SNR stats
Mike Fiore 11:d8464345e1f1 942 * @returns snr_stats struct containing last, min, max, and avg SNR in cB
mfiore 0:c62615f15125 943 */
mfiore 0:c62615f15125 944 snr_stats getSnrStats();
mfiore 0:c62615f15125 945
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 946 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 947 * Get ms until next free channel
mfiore 0:c62615f15125 948 * only applicable for European models, US models return 0
mfiore 0:c62615f15125 949 * @returns time (ms) until a channel is free to use for transmitting
mfiore 0:c62615f15125 950 */
mfiore 0:c62615f15125 951 uint32_t getNextTxMs();
mfiore 0:c62615f15125 952
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 953 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 954 * Get available bytes for payload
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 955 * @returns bytes
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 956 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 957 uint8_t getNextTxMaxSize();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 958
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 959 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 960 * Get join delay in seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 961 * Defaults to 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 962 * Must match join delay setting of the network server
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 963 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 964 * The default Join Delay is 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 965 * The default Join Delay for PRIVATE_MTS was 1 second in the previous release
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 966 *
Jason Reiss 10:27dafba9fe19 967 * @returns number of seconds before join accept message is expected
Jason Reiss 10:27dafba9fe19 968 */
Jason Reiss 10:27dafba9fe19 969 uint8_t getJoinDelay();
Jason Reiss 10:27dafba9fe19 970
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 971 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 972 * Set join delay in seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 973 * Defaults to 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 974 * Must match join delay setting of the network server
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 975 *
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 976 * The default Join Delay is 5 seconds
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 977 * The default Join Delay for PRIVATE_MTS was 1 second in the previous release
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 978 *
Jason Reiss 10:27dafba9fe19 979 * @param delay number of seconds before join accept message is expected
Jason Reiss 10:27dafba9fe19 980 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 981 */
Jason Reiss 10:27dafba9fe19 982 uint32_t setJoinDelay(uint8_t delay);
Jason Reiss 10:27dafba9fe19 983
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 984 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 985 * Get join Rx1 datarate offset
Mike Fiore 16:b630e18103e5 986 * defaults to 0
Mike Fiore 16:b630e18103e5 987 * @returns offset
Mike Fiore 16:b630e18103e5 988 */
Mike Fiore 16:b630e18103e5 989 uint8_t getJoinRx1DataRateOffset();
Mike Fiore 16:b630e18103e5 990
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 991 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 992 * Set join Rx1 datarate offset
Mike Fiore 16:b630e18103e5 993 * @param offset for datarate
Mike Fiore 16:b630e18103e5 994 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 995 */
Mike Fiore 16:b630e18103e5 996 uint32_t setJoinRx1DataRateOffset(uint8_t offset);
Mike Fiore 16:b630e18103e5 997
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 998 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 999 * Get join Rx2 datarate
Mike Fiore 16:b630e18103e5 1000 * defaults to US:DR8, AU:DR8, EU:DR0
Mike Fiore 16:b630e18103e5 1001 * @returns datarate
Mike Fiore 16:b630e18103e5 1002 */
Mike Fiore 16:b630e18103e5 1003 uint8_t getJoinRx2DataRate();
Mike Fiore 16:b630e18103e5 1004
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1005 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1006 * Set join Rx2 datarate
Mike Fiore 16:b630e18103e5 1007 * @param datarate
Mike Fiore 16:b630e18103e5 1008 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 1009 */
Mike Fiore 16:b630e18103e5 1010 uint32_t setJoinRx2DataRate(uint8_t datarate);
Mike Fiore 16:b630e18103e5 1011
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1012 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1013 * Get join Rx2 frequency
Mike Fiore 16:b630e18103e5 1014 * defaults US:923.3, AU:923.3, EU:869.525
Mike Fiore 16:b630e18103e5 1015 * @returns frequency
Mike Fiore 16:b630e18103e5 1016 */
Mike Fiore 16:b630e18103e5 1017 uint32_t getJoinRx2Frequency();
Mike Fiore 16:b630e18103e5 1018
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1019 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1020 * Set join Rx2 frequency
Mike Fiore 16:b630e18103e5 1021 * @param frequency
Mike Fiore 16:b630e18103e5 1022 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 1023 */
Mike Fiore 16:b630e18103e5 1024 uint32_t setJoinRx2Frequency(uint32_t frequency);
Mike Fiore 16:b630e18103e5 1025
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1026 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1027 * Get rx delay in seconds
Jason Reiss 10:27dafba9fe19 1028 * Defaults to 1 second
Jason Reiss 10:27dafba9fe19 1029 * @returns number of seconds before response message is expected
Jason Reiss 10:27dafba9fe19 1030 */
Jason Reiss 10:27dafba9fe19 1031 uint8_t getRxDelay();
Jason Reiss 10:27dafba9fe19 1032
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1033 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1034 * Set rx delay in seconds
Jason Reiss 10:27dafba9fe19 1035 * Defaults to 1 second
Jason Reiss 10:27dafba9fe19 1036 * @param delay number of seconds before response message is expected
Jason Reiss 10:27dafba9fe19 1037 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 1038 */
Jason Reiss 10:27dafba9fe19 1039 uint32_t setRxDelay(uint8_t delay);
Jason Reiss 10:27dafba9fe19 1040
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1041 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1042 * Get preserve session to save network session info through reset or power down in AUTO_OTA mode
Jason Reiss 10:27dafba9fe19 1043 * Defaults to off
Jason Reiss 10:27dafba9fe19 1044 * @returns true if enabled
Jason Reiss 10:27dafba9fe19 1045 */
Jason Reiss 10:27dafba9fe19 1046 bool getPreserveSession();
Jason Reiss 10:27dafba9fe19 1047
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1048 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1049 * Set preserve session to save network session info through reset or power down in AUTO_OTA mode
Jason Reiss 10:27dafba9fe19 1050 * Defaults to off
Jason Reiss 10:27dafba9fe19 1051 * @param enable
Jason Reiss 10:27dafba9fe19 1052 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 1053 */
Jason Reiss 10:27dafba9fe19 1054 uint32_t setPreserveSession(bool enable);
Jason Reiss 10:27dafba9fe19 1055
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1056 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1057 * Get data pending
mfiore 0:c62615f15125 1058 * only valid after sending data to the gateway
mfiore 0:c62615f15125 1059 * @returns true if server has available packet(s)
mfiore 0:c62615f15125 1060 */
mfiore 0:c62615f15125 1061 bool getDataPending();
mfiore 0:c62615f15125 1062
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1063 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1064 * Get ack requested
Mike Fiore 16:b630e18103e5 1065 * only valid after sending data to the gateway
Mike Fiore 16:b630e18103e5 1066 * @returns true if server has requested ack
Mike Fiore 16:b630e18103e5 1067 */
Mike Fiore 16:b630e18103e5 1068 bool getAckRequested();
Mike Fiore 16:b630e18103e5 1069
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1070 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1071 * Get is transmitting indicator
mfiore 0:c62615f15125 1072 * @returns true if currently transmitting
mfiore 0:c62615f15125 1073 */
mfiore 0:c62615f15125 1074 bool getIsTransmitting();
mfiore 0:c62615f15125 1075
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1076 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1077 * Get is idle indicator
Mike Fiore 16:b630e18103e5 1078 * @returns true if not currently transmitting, waiting or receiving
Mike Fiore 16:b630e18103e5 1079 */
Mike Fiore 16:b630e18103e5 1080 bool getIsIdle();
Mike Fiore 16:b630e18103e5 1081
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1082 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1083 * Set TX data rate
mfiore 0:c62615f15125 1084 * data rates affect maximum payload size
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1085 * @param dr DR0-DR7 for Europe, DR0-DR4 for United States
mfiore 0:c62615f15125 1086 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1087 */
mfiore 0:c62615f15125 1088 int32_t setTxDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 1089
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1090 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1091 * Get TX data rate
Mike Fiore 11:d8464345e1f1 1092 * @returns current TX data rate (DR0-DR15)
mfiore 0:c62615f15125 1093 */
mfiore 0:c62615f15125 1094 uint8_t getTxDataRate();
mfiore 0:c62615f15125 1095
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1096 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1097 * Get a random value from the radio based on RSSI
Mike Fiore 12:54f9cac9d690 1098 * @returns randome value
Mike Fiore 12:54f9cac9d690 1099 */
Mike Fiore 12:54f9cac9d690 1100 uint32_t getRadioRandom();
Mike Fiore 12:54f9cac9d690 1101
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1102 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1103 * Get data rate spreading factor and bandwidth
Mike Fiore 11:d8464345e1f1 1104 * EU868 Datarates
Mike Fiore 11:d8464345e1f1 1105 * ---------------
Mike Fiore 11:d8464345e1f1 1106 * DR0 - SF12BW125
Mike Fiore 11:d8464345e1f1 1107 * DR1 - SF11BW125
Mike Fiore 11:d8464345e1f1 1108 * DR2 - SF10BW125
Mike Fiore 11:d8464345e1f1 1109 * DR3 - SF9BW125
Mike Fiore 11:d8464345e1f1 1110 * DR4 - SF8BW125
Mike Fiore 11:d8464345e1f1 1111 * DR5 - SF7BW125
Mike Fiore 11:d8464345e1f1 1112 * DR6 - SF7BW250
Mike Fiore 11:d8464345e1f1 1113 * DR7 - FSK
Mike Fiore 11:d8464345e1f1 1114 *
Mike Fiore 11:d8464345e1f1 1115 * US915 Datarates
Mike Fiore 11:d8464345e1f1 1116 * ---------------
Mike Fiore 11:d8464345e1f1 1117 * DR0 - SF10BW125
Mike Fiore 11:d8464345e1f1 1118 * DR1 - SF9BW125
Mike Fiore 11:d8464345e1f1 1119 * DR2 - SF8BW125
Mike Fiore 11:d8464345e1f1 1120 * DR3 - SF7BW125
Mike Fiore 11:d8464345e1f1 1121 * DR4 - SF8BW500
Mike Fiore 11:d8464345e1f1 1122 *
jreiss 17:306ffaa5d79b 1123 * AU915 Datarates
jreiss 17:306ffaa5d79b 1124 * ---------------
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1125 * DR0 - SF12BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1126 * DR1 - SF11BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1127 * DR2 - SF10BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1128 * DR3 - SF9BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1129 * DR4 - SF8BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1130 * DR5 - SF7BW125
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1131 * DR6 - SF8BW500
jreiss 17:306ffaa5d79b 1132 *
Mike Fiore 11:d8464345e1f1 1133 * @returns spreading factor and bandwidth
Mike Fiore 11:d8464345e1f1 1134 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1135 std::string getDataRateDetails(uint8_t rate);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1136
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1137 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1138 * Set TX power output of radio before antenna gain, default: 14 dBm
Mike Fiore 12:54f9cac9d690 1139 * actual output power may be limited by local regulations for the chosen frequency
mfiore 0:c62615f15125 1140 * power affects maximum range
mfiore 0:c62615f15125 1141 * @param power 2 dBm - 20 dBm
mfiore 0:c62615f15125 1142 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1143 */
mfiore 0:c62615f15125 1144 int32_t setTxPower(const uint32_t& power);
mfiore 0:c62615f15125 1145
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1146 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1147 * Get TX power
mfiore 0:c62615f15125 1148 * @returns TX power (2 dBm - 20 dBm)
mfiore 0:c62615f15125 1149 */
mfiore 0:c62615f15125 1150 uint32_t getTxPower();
mfiore 0:c62615f15125 1151
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1152 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1153 * Get configured gain of installed antenna, default: +3 dBi
Mike Fiore 11:d8464345e1f1 1154 * @returns gain of antenna in dBi
Mike Fiore 11:d8464345e1f1 1155 */
Mike Fiore 11:d8464345e1f1 1156 int8_t getAntennaGain();
Mike Fiore 11:d8464345e1f1 1157
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1158 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1159 * Set configured gain of installed antenna, default: +3 dBi
Mike Fiore 11:d8464345e1f1 1160 * @param gain -127 dBi - 128 dBi
Mike Fiore 11:d8464345e1f1 1161 * @returns MDOT_OK if success
Mike Fiore 11:d8464345e1f1 1162 */
Mike Fiore 11:d8464345e1f1 1163 int32_t setAntennaGain(int8_t gain);
Mike Fiore 11:d8464345e1f1 1164
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1165 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1166 * Enable/disable TX waiting for rx windows
mfiore 0:c62615f15125 1167 * when enabled, send calls will block until a packet is received or RX timeout
mfiore 0:c62615f15125 1168 * @param enable set to true if expecting responses to transmitted packets
mfiore 0:c62615f15125 1169 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1170 */
mfiore 0:c62615f15125 1171 int32_t setTxWait(const bool& enable);
mfiore 0:c62615f15125 1172
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1173 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1174 * Get TX wait
mfiore 0:c62615f15125 1175 * @returns true if TX wait is enabled
mfiore 0:c62615f15125 1176 */
mfiore 0:c62615f15125 1177 bool getTxWait();
mfiore 0:c62615f15125 1178
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1179 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1180 * Cancel pending rx windows
Mike Fiore 16:b630e18103e5 1181 */
Mike Fiore 16:b630e18103e5 1182 void cancelRxWindow();
Mike Fiore 16:b630e18103e5 1183
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1184 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1185 * Get time on air
mfiore 0:c62615f15125 1186 * @returns the amount of time (in ms) it would take to send bytes bytes based on current configuration
mfiore 0:c62615f15125 1187 */
mfiore 0:c62615f15125 1188 uint32_t getTimeOnAir(uint8_t bytes);
mfiore 0:c62615f15125 1189
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1190 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1191 * Get min frequency
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1192 * @returns minimum frequency based on current channel plan
mfiore 0:c62615f15125 1193 */
mfiore 0:c62615f15125 1194 uint32_t getMinFrequency();
mfiore 0:c62615f15125 1195
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1196 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1197 * Get max frequency
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1198 * @returns maximum frequency based on current channel plan
mfiore 0:c62615f15125 1199 */
mfiore 0:c62615f15125 1200 uint32_t getMaxFrequency();
mfiore 0:c62615f15125 1201
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1202 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1203 * Get min datarate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1204 * @returns minimum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1205 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1206 uint8_t getMinDatarate();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1207
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1208 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1209 * Get max datarate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1210 * @returns maximum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1211 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1212 uint8_t getMaxDatarate();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1213
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1214 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1215 * Get min datarate offset
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1216 * @returns minimum datarate offset based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1217 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1218 uint8_t getMinDatarateOffset();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1219
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1220 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1221 * Get max datarate offset
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1222 * @returns maximum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1223 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1224 uint8_t getMaxDatarateOffset();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1225
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1226 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1227 * Get min datarate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1228 * @returns minimum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1229 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1230 uint8_t getMinRx2Datarate();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1231
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1232 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1233 * Get max rx2 datarate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1234 * @returns maximum rx2 datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1235 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1236 uint8_t getMaxRx2Datarate();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1237
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1238 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1239 * Get max tx power
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1240 * @returns maximum tx power based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1241 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1242 uint8_t getMaxTxPower();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1243
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1244 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1245 * Get min tx power
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1246 * @returns minimum tx power based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1247 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1248 uint8_t getMinTxPower();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1249
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1250 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1251 * Set ping slot periodicity
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1252 * Specify the the number of ping slots in a given beacon interval
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1253 * Note: Must switch back to class A for the change to take effect
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1254 * @param exp - number_of_pings = 2^(7 - exp) where 0 <= exp <= 7
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1255 * @returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1256 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1257 uint32_t setPingPeriodicity(uint8_t exp);
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1258
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1259 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1260 * Get ping slot periodicity
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1261 * @returns exp = 7 - log2(number_of_pings)
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1262 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1263 uint8_t getPingPeriodicity();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1264
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1265 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1266 *
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1267 * get/set adaptive data rate
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1268 * configure data rates and power levels based on signal to noise of packets received at gateway
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1269 * true == adaptive data rate is on
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1270 * set function returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1271 */
Mike Fiore 12:54f9cac9d690 1272 int32_t setAdr(const bool& on);
Mike Fiore 12:54f9cac9d690 1273 bool getAdr();
Mike Fiore 12:54f9cac9d690 1274
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1275 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1276 * Set the ADR ACK Limit
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1277 * @param limit - ADR ACK limit
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1278 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1279 */
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1280 int32_t setAdrAckLimit(uint8_t limit);
mfiore 0:c62615f15125 1281
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1282 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1283 * Get the ADR ACK Limit
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1284 * @returns ADR ACK limit
mfiore 0:c62615f15125 1285 */
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1286 uint8_t getAdrAckLimit();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1287
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1288 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1289 * Set the ADR ACK Delay
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1290 * @param delay - ADR ACK delay
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1291 * @returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1292 */
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1293 int32_t setAdrAckDelay(uint8_t delay);
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1294
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1295 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1296 * Get the ADR ACK Delay
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1297 * @returns ADR ACK delay
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1298 */
Jenkins@KEILDM1.dc.multitech.prv 70:0c5b5b02d17b 1299 uint8_t getAdrAckDelay();
mfiore 0:c62615f15125 1300
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1301 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1302 * Enable/disable CRC checking of packets
mfiore 0:c62615f15125 1303 * CRC checking must be enabled for use with Conduit gateway and MTAC_LORA card
mfiore 0:c62615f15125 1304 * @param on set to true to enable CRC checking
mfiore 0:c62615f15125 1305 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1306 */
mfiore 0:c62615f15125 1307 int32_t setCrc(const bool& on);
mfiore 0:c62615f15125 1308
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1309 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1310 * Get CRC checking
mfiore 0:c62615f15125 1311 * @returns true if CRC checking is enabled
mfiore 0:c62615f15125 1312 */
mfiore 0:c62615f15125 1313 bool getCrc();
mfiore 0:c62615f15125 1314
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1315 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1316 * Set ack
mfiore 0:c62615f15125 1317 * @param retries 0 to disable acks, otherwise 1 - 8
mfiore 0:c62615f15125 1318 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1319 */
mfiore 0:c62615f15125 1320 int32_t setAck(const uint8_t& retries);
mfiore 0:c62615f15125 1321
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1322 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1323 * Get ack
mfiore 0:c62615f15125 1324 * @returns 0 if acks are disabled, otherwise retries (1 - 8)
mfiore 0:c62615f15125 1325 */
mfiore 0:c62615f15125 1326 uint8_t getAck();
mfiore 0:c62615f15125 1327
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1328 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1329 * Set number of packet repeats for unconfirmed frames
Mike Fiore 12:54f9cac9d690 1330 * @param repeat 0 or 1 for no repeats, otherwise 2-15
Mike Fiore 12:54f9cac9d690 1331 * @returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1332 */
Mike Fiore 12:54f9cac9d690 1333 int32_t setRepeat(const uint8_t& repeat);
Mike Fiore 12:54f9cac9d690 1334
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1335 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1336 * Get number of packet repeats for unconfirmed frames
Mike Fiore 12:54f9cac9d690 1337 * @returns 0 or 1 if no repeats, otherwise 2-15
Mike Fiore 12:54f9cac9d690 1338 */
Mike Fiore 12:54f9cac9d690 1339 uint8_t getRepeat();
Mike Fiore 12:54f9cac9d690 1340
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1341 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1342 * Send data to the gateway
mfiore 0:c62615f15125 1343 * validates data size (based on spreading factor)
mfiore 0:c62615f15125 1344 * @param data a vector of up to 242 bytes (may be less based on spreading factor)
mfiore 0:c62615f15125 1345 * @returns MDOT_OK if packet was sent successfully (ACKs disabled), or if an ACK was received (ACKs enabled)
mfiore 0:c62615f15125 1346 */
mfiore 0:c62615f15125 1347 int32_t send(const std::vector<uint8_t>& data, const bool& blocking = true, const bool& highBw = false);
mfiore 0:c62615f15125 1348
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1349 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1350 * Inject mac command
Mike Fiore 16:b630e18103e5 1351 * @param data a vector containing mac commands
Mike Fiore 16:b630e18103e5 1352 * @returns MDOT_OK
Mike Fiore 16:b630e18103e5 1353 */
Mike Fiore 16:b630e18103e5 1354 int32_t injectMacCommand(const std::vector<uint8_t>& data);
Mike Fiore 16:b630e18103e5 1355
Mike Fiore 16:b630e18103e5 1356 /**
Mike Fiore 16:b630e18103e5 1357 * Clear MAC command buffer to be sent in next uplink
Mike Fiore 16:b630e18103e5 1358 * @returns MDOT_OK
Mike Fiore 16:b630e18103e5 1359 */
Mike Fiore 16:b630e18103e5 1360 int32_t clearMacCommands();
Mike Fiore 16:b630e18103e5 1361
Mike Fiore 16:b630e18103e5 1362 /**
Mike Fiore 16:b630e18103e5 1363 * Get MAC command buffer to be sent in next uplink
Mike Fiore 16:b630e18103e5 1364 * @returns command bytes
Mike Fiore 16:b630e18103e5 1365 */
Mike Fiore 16:b630e18103e5 1366 std::vector<uint8_t> getMacCommands();
Mike Fiore 16:b630e18103e5 1367
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1368 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1369 * Fetch data received from the gateway
mfiore 0:c62615f15125 1370 * this function only checks to see if a packet has been received - it does not open a receive window
mfiore 0:c62615f15125 1371 * send() must be called before recv()
mfiore 0:c62615f15125 1372 * @param data a vector to put the received data into
mfiore 0:c62615f15125 1373 * @returns MDOT_OK if packet was successfully received
mfiore 0:c62615f15125 1374 */
mfiore 0:c62615f15125 1375 int32_t recv(std::vector<uint8_t>& data);
mfiore 0:c62615f15125 1376
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1377 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1378 * Ping
mfiore 0:c62615f15125 1379 * status will be MDOT_OK if ping succeeded
mfiore 0:c62615f15125 1380 * @returns ping_response struct containing status, RSSI, and SNR
mfiore 0:c62615f15125 1381 */
mfiore 0:c62615f15125 1382 ping_response ping();
mfiore 0:c62615f15125 1383
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1384 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1385 * Get return code string
mfiore 0:c62615f15125 1386 * @returns string containing a description of the given error code
mfiore 0:c62615f15125 1387 */
mfiore 0:c62615f15125 1388 static std::string getReturnCodeString(const int32_t& code);
mfiore 0:c62615f15125 1389
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1390 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1391 * Get last error
mfiore 0:c62615f15125 1392 * @returns string explaining the last error that occured
mfiore 0:c62615f15125 1393 */
mfiore 0:c62615f15125 1394 std::string getLastError();
mfiore 0:c62615f15125 1395
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1396 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1397 * Go to sleep
Jason Reiss 10:27dafba9fe19 1398 * @param interval the number of seconds to sleep before waking up if wakeup_mode == RTC_ALARM or RTC_ALARM_OR_INTERRUPT, else ignored
Jason Reiss 10:27dafba9fe19 1399 * @param wakeup_mode RTC_ALARM, INTERRUPT, RTC_ALARM_OR_INTERRUPT
Mike Fiore 7:683dba5d576f 1400 * if RTC_ALARM the real time clock is configured to wake the device up after the specified interval
Mike Fiore 7:683dba5d576f 1401 * if INTERRUPT the device will wake up on the rising edge of the interrupt pin
Jason Reiss 10:27dafba9fe19 1402 * if RTC_ALARM_OR_INTERRUPT the device will wake on the first event to occur
Mike Fiore 7:683dba5d576f 1403 * @param deepsleep if true go into deep sleep mode (lowest power, all memory and registers are lost, peripherals turned off)
Mike Fiore 7:683dba5d576f 1404 * else go into sleep mode (low power, memory and registers are maintained, peripherals stay on)
Mike Fiore 7:683dba5d576f 1405 *
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1406 * For the MDOT
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1407 * in sleep mode, the device can be woken up on an XBEE_DI (2-8) pin or by the RTC alarm
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1408 * in deepsleep mode, the device can only be woken up using the WKUP pin (PA0, XBEE_DIO7) or by the RTC alarm
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1409 * For the XDOT
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1410 * in sleep mode, the device can be woken up on GPIO (0-3), UART1_RX, WAKE or by the RTC alarm
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1411 * in deepsleep mode, the device can only be woken up using the WKUP pin (PA0, WAKE) or by the RTC alarm
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1412 * @returns MDOT_OK on success
Mike Fiore 7:683dba5d576f 1413 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1414 int32_t sleep(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM, const bool& deepsleep = true);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1415
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1416 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1417 * Set auto sleep mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1418 * Auto sleep mode will automatically put the MCU to sleep after tx and in between receive windows
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1419 * Note: The MCU will go into a stop mode sleep in between rx windows. This means that
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1420 * peripherals such as timers will not function during the sleep intervals.
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1421 * @param enable - Flag to enable auto sleep mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1422 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1423 void setAutoSleep(bool enable);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1424
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1425 /**
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1426 * Get auto sleep mode
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1427 * @returns 0 if sleep mode is disabled, 1 if it is enabled
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1428 */
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1429 uint8_t getAutoSleep();
Mike Fiore 7:683dba5d576f 1430
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1431 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1432 * Set wake pin
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1433 * @param pin the pin to use to wake the device from sleep mode
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1434 * For MDOT, XBEE_DI (2-8)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1435 * For XDOT, GPIO (0-3), UART1_RX, or WAKE
Mike Fiore 7:683dba5d576f 1436 */
Mike Fiore 7:683dba5d576f 1437 void setWakePin(const PinName& pin);
Mike Fiore 7:683dba5d576f 1438
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1439 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1440 * Get wake pin
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1441 * @returns the pin to use to wake the device from sleep mode
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1442 * For MDOT, XBEE_DI (2-8)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1443 * For XDOT, GPIO (0-3), UART1_RX, or WAKE
Mike Fiore 7:683dba5d576f 1444 */
Mike Fiore 7:683dba5d576f 1445 PinName getWakePin();
Mike Fiore 7:683dba5d576f 1446
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1447 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1448 * Write data in a user backup register
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1449 * @param register one of UBR0 through UBR9 for MDOT, one of UBR0 through UBR21 for XDOT
jreiss 9:ec2fffe31793 1450 * @param data user data to back up
jreiss 9:ec2fffe31793 1451 * @returns true if success
jreiss 9:ec2fffe31793 1452 */
jreiss 9:ec2fffe31793 1453 bool writeUserBackupRegister(uint32_t reg, uint32_t data);
jreiss 9:ec2fffe31793 1454
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1455 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1456 * Read data in a user backup register
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1457 * @param register one of UBR0 through UBR9 for MDOT, one of UBR0 through UBR21 for XDOT
jreiss 9:ec2fffe31793 1458 * @param data gets set to content of register
jreiss 9:ec2fffe31793 1459 * @returns true if success
jreiss 9:ec2fffe31793 1460 */
jreiss 9:ec2fffe31793 1461 bool readUserBackupRegister(uint32_t reg, uint32_t& data);
jreiss 9:ec2fffe31793 1462
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1463 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1464 * Set LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1465 * @param ms time in us
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1466 * @returns true if success
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1467 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1468 bool setLbtTimeUs(uint16_t us);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1469
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1470 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1471 * Get LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1472 * @returns LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1473 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1474 uint16_t getLbtTimeUs();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1475
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1476 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1477 * Set LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1478 * @param rssi threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1479 * @returns true if success
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1480 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1481 bool setLbtThreshold(int8_t rssi);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1482
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1483 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1484 * Get LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1485 * @returns LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1486 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1487 int8_t getLbtThreshold();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1488
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1489 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1490 * Get Radio Frequency Offset
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1491 * Used for fine calibration of radio frequencies
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1492 * @returns frequency offset in MHz
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1493 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1494 int32_t getFrequencyOffset();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1495 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1496 * Get Radio Frequency Offset
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1497 * Used for fine calibration of radio frequencies
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1498 * @param offset frequency offset in MHz
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1499 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1500 void setFrequencyOffset(int32_t offset);
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1501
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1502 /**
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1503 * Get GPS time from network server
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1504 * Sends a DeviceTimeReq command to the network server
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1505 * @returns time since GPS epoch, 0 on failure
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1506 */
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1507 uint64_t getGPSTime();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1508
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1509 /**
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1510 * Add a device time request to the MacCommand buffer
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1511 */
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1512 void addDeviceTimeRequest();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1513
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1514 #if defined(TARGET_MTS_MDOT_F411RE)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1515 ///////////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1516 // Filesystem (Non Volatile Memory) Operation Functions for mDot //
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1517 ///////////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1518
Mike Fiore 11:d8464345e1f1 1519 // Save user file data to flash
Mike Fiore 11:d8464345e1f1 1520 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1521 // data - data of file
Mike Fiore 11:d8464345e1f1 1522 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1523 // returns true if successful
Mike Fiore 11:d8464345e1f1 1524 bool saveUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1525
Mike Fiore 11:d8464345e1f1 1526 // Append user file data to flash
Mike Fiore 11:d8464345e1f1 1527 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1528 // data - data of file
Mike Fiore 11:d8464345e1f1 1529 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1530 // returns true if successful
Mike Fiore 11:d8464345e1f1 1531 bool appendUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1532
Mike Fiore 11:d8464345e1f1 1533 // Read user file data from flash
Mike Fiore 11:d8464345e1f1 1534 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1535 // data - data of file
Mike Fiore 11:d8464345e1f1 1536 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1537 // returns true if successful
Mike Fiore 11:d8464345e1f1 1538 bool readUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1539
Mike Fiore 11:d8464345e1f1 1540 // Move a user file in flash
Mike Fiore 11:d8464345e1f1 1541 // file - name of file
Mike Fiore 11:d8464345e1f1 1542 // new_name - new name of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1543 // returns true if successful
Mike Fiore 11:d8464345e1f1 1544 bool moveUserFile(const char* file, const char* new_name);
Mike Fiore 11:d8464345e1f1 1545
Mike Fiore 11:d8464345e1f1 1546 // Delete user file data from flash
Mike Fiore 11:d8464345e1f1 1547 // file - name of file max 30 chars
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1548 // returns true if successful
Mike Fiore 11:d8464345e1f1 1549 bool deleteUserFile(const char* file);
Mike Fiore 11:d8464345e1f1 1550
Mike Fiore 11:d8464345e1f1 1551 // Open user file in flash, max of 4 files open concurrently
Mike Fiore 11:d8464345e1f1 1552 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1553 // mode - combination of FM_APPEND | FM_TRUNC | FM_CREAT |
Mike Fiore 11:d8464345e1f1 1554 // FM_RDONLY | FM_WRONLY | FM_RDWR | FM_DIRECT
Mike Fiore 11:d8464345e1f1 1555 // returns - mdot_file struct, fd field will be a negative value if file could not be opened
Mike Fiore 11:d8464345e1f1 1556 mDot::mdot_file openUserFile(const char* file, int mode);
Mike Fiore 11:d8464345e1f1 1557
Mike Fiore 11:d8464345e1f1 1558 // Seek an open file
Mike Fiore 11:d8464345e1f1 1559 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1560 // offset - offset in bytes
Mike Fiore 11:d8464345e1f1 1561 // whence - where offset is based SEEK_SET, SEEK_CUR, SEEK_END
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1562 // returns true if successful
Mike Fiore 11:d8464345e1f1 1563 bool seekUserFile(mDot::mdot_file& file, size_t offset, int whence);
Mike Fiore 11:d8464345e1f1 1564
Mike Fiore 11:d8464345e1f1 1565 // Read bytes from open file
Mike Fiore 11:d8464345e1f1 1566 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1567 // data - mem location to store data
Mike Fiore 11:d8464345e1f1 1568 // length - number of bytes to read
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1569 // returns - number of bytes read, negative if error
Mike Fiore 11:d8464345e1f1 1570 int readUserFile(mDot::mdot_file& file, void* data, size_t length);
Mike Fiore 11:d8464345e1f1 1571
Mike Fiore 11:d8464345e1f1 1572 // Write bytes to open file
Mike Fiore 11:d8464345e1f1 1573 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1574 // data - data to write
Mike Fiore 11:d8464345e1f1 1575 // length - number of bytes to write
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1576 // returns - number of bytes written, negative if error
Mike Fiore 11:d8464345e1f1 1577 int writeUserFile(mDot::mdot_file& file, void* data, size_t length);
Mike Fiore 11:d8464345e1f1 1578
Mike Fiore 11:d8464345e1f1 1579 // Close open file
Mike Fiore 11:d8464345e1f1 1580 // file - mdot file struct
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1581 // returns true if successful
Mike Fiore 11:d8464345e1f1 1582 bool closeUserFile(mDot::mdot_file& file);
Mike Fiore 11:d8464345e1f1 1583
Mike Fiore 11:d8464345e1f1 1584 // List user files stored in flash
Mike Fiore 11:d8464345e1f1 1585 std::vector<mDot::mdot_file> listUserFiles();
Mike Fiore 11:d8464345e1f1 1586
Mike Fiore 11:d8464345e1f1 1587 // Move file into the firmware upgrade path to be flashed on next boot
Mike Fiore 11:d8464345e1f1 1588 // file - name of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1589 // returns true if successful
Mike Fiore 11:d8464345e1f1 1590 bool moveUserFileToFirmwareUpgrade(const char* file);
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1591
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1592 // Return total size of all files saved in FLASH
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1593 // Does not include SPIFFS overhead
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1594 uint32_t getUsedSpace();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1595
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1596 bool repairFlashFileSystem();
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1597 #else
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1598 ///////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1599 // EEPROM (Non Volatile Memory) Operation Functions for xDot //
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1600 ///////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1601
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1602 // Write to EEPROM
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1603 // addr - address to write to (0 - 0x17FF)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1604 // data - data to write
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1605 // size - size of data
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1606 // returns true if successful
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1607 bool nvmWrite(uint16_t addr, void* data, uint16_t size);
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1608
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1609 // Read from EEPROM
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1610 // addr - address to read from (0 - 0x17FF)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1611 // data - buffer for data
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1612 // size - size of buffer
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1613 // returns true if successful
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1614 bool nvmRead(uint16_t addr, void* data, uint16_t size);
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1615 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 11:d8464345e1f1 1616
Mike Fiore 11:d8464345e1f1 1617 // get current statistics
Mike Fiore 11:d8464345e1f1 1618 // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
Mike Fiore 11:d8464345e1f1 1619 mdot_stats getStats();
Mike Fiore 11:d8464345e1f1 1620
Mike Fiore 11:d8464345e1f1 1621 // reset statistics
Mike Fiore 11:d8464345e1f1 1622 // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
Mike Fiore 11:d8464345e1f1 1623 void resetStats();
Mike Fiore 11:d8464345e1f1 1624
Mike Fiore 11:d8464345e1f1 1625 // Convert pin number 2-8 to pin name DIO2-DI8
Mike Fiore 11:d8464345e1f1 1626 static PinName pinNum2Name(uint8_t num);
Mike Fiore 11:d8464345e1f1 1627
Mike Fiore 11:d8464345e1f1 1628 // Convert pin name DIO2-DI8 to pin number 2-8
Mike Fiore 11:d8464345e1f1 1629 static uint8_t pinName2Num(PinName name);
Mike Fiore 11:d8464345e1f1 1630
Mike Fiore 11:d8464345e1f1 1631 // Convert pin name DIO2-DI8 to string
Mike Fiore 11:d8464345e1f1 1632 static std::string pinName2Str(PinName name);
Mike Fiore 11:d8464345e1f1 1633
Mike Fiore 11:d8464345e1f1 1634 uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l);
mfiore 0:c62615f15125 1635
mfiore 0:c62615f15125 1636 /*************************************************************************
mfiore 0:c62615f15125 1637 * The following functions are only used by the AT command application and
mfiore 0:c62615f15125 1638 * should not be used by standard applications consuming the mDot library
mfiore 0:c62615f15125 1639 ************************************************************************/
Mike Fiore 7:683dba5d576f 1640
mfiore 0:c62615f15125 1641 // set/get configured baud rate for command port
mfiore 0:c62615f15125 1642 // only for use in conjunction with AT interface
mfiore 0:c62615f15125 1643 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1644 int32_t setBaud(const uint32_t& baud);
mfiore 0:c62615f15125 1645 uint32_t getBaud();
mfiore 0:c62615f15125 1646
mfiore 0:c62615f15125 1647 // set/get baud rate for debug port
mfiore 0:c62615f15125 1648 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1649 int32_t setDebugBaud(const uint32_t& baud);
mfiore 0:c62615f15125 1650 uint32_t getDebugBaud();
mfiore 0:c62615f15125 1651
mfiore 0:c62615f15125 1652 // set/get command terminal echo
mfiore 0:c62615f15125 1653 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1654 int32_t setEcho(const bool& on);
mfiore 0:c62615f15125 1655 bool getEcho();
mfiore 0:c62615f15125 1656
mfiore 0:c62615f15125 1657 // set/get command terminal verbose mode
mfiore 0:c62615f15125 1658 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1659 int32_t setVerbose(const bool& on);
mfiore 0:c62615f15125 1660 bool getVerbose();
mfiore 0:c62615f15125 1661
mfiore 0:c62615f15125 1662 // set/get startup mode
mfiore 0:c62615f15125 1663 // COMMAND_MODE (default), starts up ready to accept AT commands
mfiore 0:c62615f15125 1664 // SERIAL_MODE, read serial data and send it as LoRa packets
mfiore 0:c62615f15125 1665 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1666 int32_t setStartUpMode(const uint8_t& mode);
mfiore 0:c62615f15125 1667 uint8_t getStartUpMode();
mfiore 0:c62615f15125 1668
mfiore 0:c62615f15125 1669 int32_t setRxDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 1670 uint8_t getRxDataRate();
mfiore 0:c62615f15125 1671
mfiore 0:c62615f15125 1672 // get/set TX/RX frequency
mfiore 0:c62615f15125 1673 // if set to 0, device will hop frequencies
mfiore 0:c62615f15125 1674 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1675 int32_t setTxFrequency(const uint32_t& freq);
mfiore 0:c62615f15125 1676 uint32_t getTxFrequency();
mfiore 0:c62615f15125 1677 int32_t setRxFrequency(const uint32_t& freq);
mfiore 0:c62615f15125 1678 uint32_t getRxFrequency();
mfiore 0:c62615f15125 1679
mfiore 0:c62615f15125 1680 // get/set RX output mode
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1681 // valid options are HEXADECIMAL, BINARY, and EXTENDED
mfiore 0:c62615f15125 1682 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1683 int32_t setRxOutput(const uint8_t& mode);
mfiore 0:c62615f15125 1684 uint8_t getRxOutput();
mfiore 0:c62615f15125 1685
mfiore 0:c62615f15125 1686 // get/set serial wake interval
mfiore 0:c62615f15125 1687 // valid values are 2 s - INT_MAX (2147483647) s
mfiore 0:c62615f15125 1688 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1689 int32_t setWakeInterval(const uint32_t& interval);
Mike Fiore 7:683dba5d576f 1690 uint32_t getWakeInterval();
mfiore 0:c62615f15125 1691
mfiore 0:c62615f15125 1692 // get/set serial wake delay
mfiore 0:c62615f15125 1693 // valid values are 2 ms - INT_MAX (2147483647) ms
mfiore 0:c62615f15125 1694 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1695 int32_t setWakeDelay(const uint32_t& delay);
Mike Fiore 7:683dba5d576f 1696 uint32_t getWakeDelay();
mfiore 0:c62615f15125 1697
mfiore 0:c62615f15125 1698 // get/set serial receive timeout
mfiore 0:c62615f15125 1699 // valid values are 0 ms - 65000 ms
mfiore 0:c62615f15125 1700 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1701 int32_t setWakeTimeout(const uint16_t& timeout);
Mike Fiore 7:683dba5d576f 1702 uint16_t getWakeTimeout();
Mike Fiore 7:683dba5d576f 1703
Mike Fiore 7:683dba5d576f 1704 // get/set serial wake mode
Mike Fiore 7:683dba5d576f 1705 // valid values are INTERRUPT or RTC_ALARM
Mike Fiore 7:683dba5d576f 1706 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1707 int32_t setWakeMode(const uint8_t& delay);
Mike Fiore 7:683dba5d576f 1708 uint8_t getWakeMode();
Mike Fiore 7:683dba5d576f 1709
Mike Fiore 12:54f9cac9d690 1710 // get/set serial flow control enabled
Mike Fiore 12:54f9cac9d690 1711 // set function returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1712 int32_t setFlowControl(const bool& on);
Mike Fiore 12:54f9cac9d690 1713 bool getFlowControl();
Mike Fiore 12:54f9cac9d690 1714
Mike Fiore 12:54f9cac9d690 1715 // get/set serial clear on error
Mike Fiore 12:54f9cac9d690 1716 // if enabled the data read from the serial port will be discarded if it cannot be sent or if the send fails
Mike Fiore 11:d8464345e1f1 1717 // set function returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1718 int32_t setSerialClearOnError(const bool& on);
Mike Fiore 12:54f9cac9d690 1719 bool getSerialClearOnError();
mfiore 0:c62615f15125 1720
mfiore 0:c62615f15125 1721 // MTS_RADIO_DEBUG_COMMANDS
Mike Fiore 7:683dba5d576f 1722
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1723 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1724 * Disable Duty cycle
Mike Fiore 16:b630e18103e5 1725 * enables or disables the duty cycle limitations
Mike Fiore 16:b630e18103e5 1726 * **** ONLY TO BE USED FOR TESTINGS PURPOSES ****
Mike Fiore 16:b630e18103e5 1727 * **** ALL DEPLOYABLE CODE MUST ADHERE TO LOCAL REGULATIONS ****
Mike Fiore 16:b630e18103e5 1728 * **** THIS SETTING WILL NOT BE SAVED TO CONFIGURATION *****
Mike Fiore 16:b630e18103e5 1729 * @param val true to disable duty-cycle (default:false)
Mike Fiore 16:b630e18103e5 1730 */
Mike Fiore 16:b630e18103e5 1731 int32_t setDisableDutyCycle(bool val);
Mike Fiore 16:b630e18103e5 1732
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1733 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1734 * Disable Duty cycle
Mike Fiore 16:b630e18103e5 1735 * **** ONLY TO BE USED FOR TESTINGS PURPOSES ****
Mike Fiore 16:b630e18103e5 1736 * **** ALL DEPLOYABLE CODE MUST ADHERE TO LOCAL REGULATIONS ****
Mike Fiore 16:b630e18103e5 1737 * **** THIS SETTING WILL NOT BE SAVED TO CONFIGURATION *****
Mike Fiore 16:b630e18103e5 1738 * @return true if duty-cycle is disabled (default:false)
Mike Fiore 16:b630e18103e5 1739 */
Mike Fiore 16:b630e18103e5 1740 uint8_t getDisableDutyCycle();
Mike Fiore 16:b630e18103e5 1741
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1742 /**
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1743 * LBT RSSI
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1744 * @return the current RSSI on the configured frequency (SetTxFrequency) using configured LBT Time
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1745 */
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1746 int16_t lbtRssi();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1747
Mike Fiore 7:683dba5d576f 1748 void openRxWindow(uint32_t timeout, uint8_t bandwidth = 0);
Mike Fiore 16:b630e18103e5 1749 void closeRxWindow();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1750 void sendContinuous(bool enable=true, uint32_t timeout=0, uint32_t frequency=0, int8_t txpower=-1);
mfiore 0:c62615f15125 1751 int32_t setDeviceId(const std::vector<uint8_t>& id);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1752 int32_t setProtectedAppEUI(const std::vector<uint8_t>& appEUI);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1753 int32_t setProtectedAppKey(const std::vector<uint8_t>& appKey);
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1754 std::vector<uint8_t> getProtectedAppEUI();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1755 std::vector<uint8_t> getProtectedAppKey();
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1756 int32_t setProtectedGenAppKey(const std::vector<uint8_t>& appKey);
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1757 int32_t setDefaultFrequencyBand(const uint8_t& band);
mfiore 0:c62615f15125 1758 bool saveProtectedConfig();
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1759 // resets the radio/mac/link
mfiore 0:c62615f15125 1760 void resetRadio();
mfiore 0:c62615f15125 1761 int32_t setRadioMode(const uint8_t& mode);
mfiore 0:c62615f15125 1762 std::map<uint8_t, uint8_t> dumpRegisters();
mfiore 0:c62615f15125 1763 void eraseFlash();
mfiore 0:c62615f15125 1764
Mike Fiore 11:d8464345e1f1 1765 void setWakeupCallback(void (*function)(void));
Mike Fiore 11:d8464345e1f1 1766
Mike Fiore 11:d8464345e1f1 1767 template<typename T>
Mike Fiore 11:d8464345e1f1 1768 void setWakeupCallback(T *object, void (T::*member)(void)) {
Mike Fiore 11:d8464345e1f1 1769 _wakeup_callback.attach(object, member);
Mike Fiore 11:d8464345e1f1 1770 }
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1771
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1772 lora::ChannelPlan* getChannelPlan(void);
Mike Fiore 11:d8464345e1f1 1773
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1774 uint32_t setRx2DataRate(uint8_t dr);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1775 uint8_t getRx2DataRate();
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1776
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1777 void mcGroupKeys(uint8_t *mcKeyEncrypt, uint32_t addr, uint8_t groupId, uint32_t frame_count);
mfiore 0:c62615f15125 1778 private:
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1779
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1780 void sleep_ms(uint32_t interval,
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1781 uint8_t wakeup_mode = RTC_ALARM,
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1782 bool deepsleep = true);
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1783
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1784
Jenkins@KEILDM1.dc.multitech.prv 65:acc0468b9aec 1785 void wakeup();
Jenkins@KEILDM1.dc.multitech.prv 64:64982192a2af 1786
mfiore 0:c62615f15125 1787 mdot_stats _stats;
mfiore 0:c62615f15125 1788
Jenkins@KEILDM1.dc.multitech.prv 72:b1e07ec1c30d 1789 Callback<void()> _wakeup_callback;
Mike Fiore 11:d8464345e1f1 1790
Mike Fiore 12:54f9cac9d690 1791 bool _standbyFlag;
Mike Fiore 12:54f9cac9d690 1792 bool _testMode;
Mike Fiore 12:54f9cac9d690 1793 uint8_t _savedPort;
Mike Fiore 12:54f9cac9d690 1794 void handleTestModePacket();
Jenkins@KEILDM1.dc.multitech.prv 60:7985b4783af9 1795 lora::ChannelPlan* _plan;
mfiore 0:c62615f15125 1796 };
mfiore 0:c62615f15125 1797
mfiore 0:c62615f15125 1798 #endif