Bleeding edge development version of the mDot library for mbed 5. This version of the library is not guaranteed to be stable or well tested and should not be used in production or deployment scenarios.

Dependents:   mDot-IKS01A1 mDot-IKS01A1 mDot-Examples mDot-IKS01A1-Explora ... more

Fork of libmDot-dev-mbed2-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.

Dot Library Version 3 Updates

Dot Library versions 3.x.x require a channel plan to be injected into the stack. Channel plans are included with the 3.x.x Dot Library releases. The following code snippet demonstrates how to create a channel plan and inject it into the stack.

#include "mDot.h"
#include "channel_plans.h"

int main() {
    ChannelPlan* plan = new lora::ChannelPlan_US915();
    assert(plan);
    mDot* dot = mDot::getInstance(plan);
    assert(dot);

    // ...
}

Dot devices must not be deployed with software using a different channel plan than the Dot's default plan! This functionality is for development and testing only!

Multicast Sessions

Multicast sessions and packet rx events in library. When in Class C mode Multicast downlinks can be received. Recieved packets should be filtered on address, counter value will be maintained in the session or can be set explicitly depending on Application support to share Multicast Address, Keys and Counters.

mDot.h

        /**
         * Add a multicast session address and keys
         * Downlink counter is set to 0
         * Up to 3 MULTICAST_SESSIONS can be set
         */
        int32_t setMulticastSession(uint8_t index, uint32_t addr, const uint8_t* nsk, const uint8_t* dsk);
 
        /**
         * Set a multicast session counter
         * Up to 3 MULTICAST_SESSIONS can be set
         */
        int32_t setMulticastDownlinkCounter(uint8_t index, uint32_t count);

mDotEvent.h

The address field was added to PacketRx event.

        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);

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.

Committer:
Jenkins@KEILDM1.dc.multitech.prv
Date:
Tue Aug 08 07:09:10 2017 -0500
Revision:
90:79a8c8660a4e
Parent:
81:d8f2c4e664f5
Child:
103:06bafd42c324
mdot-library revision 3.0.0-9-gb9fedc4 and mbed-os revision mbed-os-5.5.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jreiss 9:ec2fffe31793 1 // TODO: add license header
mfiore 0:c62615f15125 2
mfiore 0:c62615f15125 3 #ifndef MDOT_H
mfiore 0:c62615f15125 4 #define MDOT_H
mfiore 0:c62615f15125 5
mfiore 0:c62615f15125 6 #include "mbed.h"
mfiore 0:c62615f15125 7 #include "rtos.h"
Mike Fiore 16:b630e18103e5 8 #include "Mote.h"
mfiore 0:c62615f15125 9 #include <vector>
mfiore 0:c62615f15125 10 #include <map>
mfiore 0:c62615f15125 11 #include <string>
mfiore 0:c62615f15125 12
Mike Fiore 12:54f9cac9d690 13 class mDotEvent;
mfiore 0:c62615f15125 14 class LoRaConfig;
mfiore 0:c62615f15125 15
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 16
mfiore 0:c62615f15125 17 class mDot {
Mike Fiore 16:b630e18103e5 18 friend class mDotEvent;
mfiore 0:c62615f15125 19
mfiore 0:c62615f15125 20 private:
mfiore 0:c62615f15125 21
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 22 mDot(lora::ChannelPlan* plan);
mfiore 0:c62615f15125 23 ~mDot();
mfiore 0:c62615f15125 24
Mike Fiore 16:b630e18103e5 25 void initLora();
Mike Fiore 16:b630e18103e5 26
mfiore 0:c62615f15125 27 void setLastError(const std::string& str);
mfiore 0:c62615f15125 28
mfiore 0:c62615f15125 29 static bool validateBaudRate(const uint32_t& baud);
mfiore 0:c62615f15125 30 static bool validateFrequencySubBand(const uint8_t& band);
mfiore 0:c62615f15125 31 bool validateDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 32
mfiore 0:c62615f15125 33 int32_t joinBase(const uint32_t& retries);
mfiore 0:c62615f15125 34 int32_t sendBase(const std::vector<uint8_t>& data, const bool& confirmed = false, const bool& blocking = true, const bool& highBw = false);
mfiore 0:c62615f15125 35 void waitForPacket();
mfiore 0:c62615f15125 36 void waitForLinkCheck();
mfiore 0:c62615f15125 37
mfiore 0:c62615f15125 38 void setActivityLedState(const uint8_t& state);
mfiore 0:c62615f15125 39 uint8_t getActivityLedState();
mfiore 0:c62615f15125 40
mfiore 0:c62615f15125 41 void blinkActivityLed(void) {
Mike Fiore 6:390fc83d588d 42 if (_activity_led) {
Mike Fiore 6:390fc83d588d 43 int val = _activity_led->read();
Mike Fiore 6:390fc83d588d 44 _activity_led->write(!val);
Mike Fiore 6:390fc83d588d 45 }
mfiore 0:c62615f15125 46 }
mfiore 0:c62615f15125 47
mfiore 0:c62615f15125 48 mDot(const mDot&);
mfiore 0:c62615f15125 49 mDot& operator=(const mDot&);
mfiore 0:c62615f15125 50
Mike Fiore 7:683dba5d576f 51 uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);
Mike Fiore 7:683dba5d576f 52 void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);
Mike Fiore 7:683dba5d576f 53
Mike Fiore 7:683dba5d576f 54 void wakeup();
Mike Fiore 7:683dba5d576f 55
Mike Fiore 12:54f9cac9d690 56 void enterStopMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM);
Mike Fiore 12:54f9cac9d690 57 void enterStandbyMode(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM);
Mike Fiore 12:54f9cac9d690 58
mfiore 0:c62615f15125 59 static mDot* _instance;
mfiore 0:c62615f15125 60
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 61 lora::Mote* _mote;
mfiore 0:c62615f15125 62 LoRaConfig* _config;
Mike Fiore 16:b630e18103e5 63 lora::Settings _settings;
Mike Fiore 16:b630e18103e5 64 mDotEvent* _events;
Mike Fiore 16:b630e18103e5 65
mfiore 0:c62615f15125 66 std::string _last_error;
mfiore 0:c62615f15125 67 static const uint32_t _baud_rates[];
mfiore 0:c62615f15125 68 uint8_t _activity_led_state;
mfiore 0:c62615f15125 69 Ticker _tick;
Mike Fiore 6:390fc83d588d 70 DigitalOut* _activity_led;
Mike Fiore 6:390fc83d588d 71 bool _activity_led_enable;
Mike Fiore 6:390fc83d588d 72 PinName _activity_led_pin;
Mike Fiore 5:0bfe6a650513 73 bool _activity_led_external;
jreiss 9:ec2fffe31793 74 uint8_t _linkFailCount;
Mike Fiore 7:683dba5d576f 75 uint8_t _class;
Mike Fiore 7:683dba5d576f 76 InterruptIn* _wakeup;
Mike Fiore 7:683dba5d576f 77 PinName _wakeup_pin;
mfiore 0:c62615f15125 78
mfiore 0:c62615f15125 79 typedef enum {
Jason Reiss 10:27dafba9fe19 80 OFF,
Jason Reiss 10:27dafba9fe19 81 ON,
Jason Reiss 10:27dafba9fe19 82 BLINK,
mfiore 0:c62615f15125 83 } state;
mfiore 0:c62615f15125 84
mfiore 0:c62615f15125 85 public:
mfiore 0:c62615f15125 86
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 87 #if defined(TARGET_MTS_MDOT_F411RE)
mfiore 0:c62615f15125 88 typedef enum {
Mike Fiore 7:683dba5d576f 89 FM_APPEND = (1 << 0),
Mike Fiore 7:683dba5d576f 90 FM_TRUNC = (1 << 1),
Mike Fiore 7:683dba5d576f 91 FM_CREAT = (1 << 2),
Mike Fiore 7:683dba5d576f 92 FM_RDONLY = (1 << 3),
Mike Fiore 7:683dba5d576f 93 FM_WRONLY = (1 << 4),
Mike Fiore 7:683dba5d576f 94 FM_RDWR = (FM_RDONLY | FM_WRONLY),
Mike Fiore 7:683dba5d576f 95 FM_DIRECT = (1 << 5)
Mike Fiore 7:683dba5d576f 96 } FileMode;
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 97 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 7:683dba5d576f 98
Mike Fiore 7:683dba5d576f 99 typedef enum {
mfiore 0:c62615f15125 100 MDOT_OK = 0,
mfiore 0:c62615f15125 101 MDOT_INVALID_PARAM = -1,
mfiore 0:c62615f15125 102 MDOT_TX_ERROR = -2,
mfiore 0:c62615f15125 103 MDOT_RX_ERROR = -3,
mfiore 0:c62615f15125 104 MDOT_JOIN_ERROR = -4,
mfiore 0:c62615f15125 105 MDOT_TIMEOUT = -5,
mfiore 0:c62615f15125 106 MDOT_NOT_JOINED = -6,
mfiore 0:c62615f15125 107 MDOT_ENCRYPTION_DISABLED = -7,
mfiore 0:c62615f15125 108 MDOT_NO_FREE_CHAN = -8,
Mike Fiore 12:54f9cac9d690 109 MDOT_TEST_MODE = -9,
Mike Fiore 12:54f9cac9d690 110 MDOT_NO_ENABLED_CHAN = -10,
Mike Fiore 12:54f9cac9d690 111 MDOT_AGGREGATED_DUTY_CYCLE = -11,
Jenkins@KEILDM1.dc.multitech.prv 43:ba29a595814e 112 MDOT_MAX_PAYLOAD_EXCEEDED = -12,
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 113 MDOT_LBT_CHANNEL_BUSY = -13,
mfiore 0:c62615f15125 114 MDOT_ERROR = -1024,
mfiore 0:c62615f15125 115 } mdot_ret_code;
mfiore 0:c62615f15125 116
mfiore 0:c62615f15125 117 enum JoinMode {
Mike Fiore 16:b630e18103e5 118 MANUAL = 0,
Jason Reiss 10:27dafba9fe19 119 OTA,
Mike Fiore 12:54f9cac9d690 120 AUTO_OTA,
Mike Fiore 12:54f9cac9d690 121 PEER_TO_PEER
mfiore 0:c62615f15125 122 };
mfiore 0:c62615f15125 123
mfiore 0:c62615f15125 124 enum Mode {
Jason Reiss 10:27dafba9fe19 125 COMMAND_MODE,
Jason Reiss 10:27dafba9fe19 126 SERIAL_MODE
mfiore 0:c62615f15125 127 };
mfiore 0:c62615f15125 128
mfiore 0:c62615f15125 129 enum RX_Output {
Jason Reiss 10:27dafba9fe19 130 HEXADECIMAL,
Jason Reiss 10:27dafba9fe19 131 BINARY
mfiore 0:c62615f15125 132 };
mfiore 0:c62615f15125 133
mfiore 0:c62615f15125 134 enum DataRates {
Mike Fiore 12:54f9cac9d690 135 DR0,
Mike Fiore 12:54f9cac9d690 136 DR1,
Mike Fiore 12:54f9cac9d690 137 DR2,
Mike Fiore 12:54f9cac9d690 138 DR3,
Mike Fiore 12:54f9cac9d690 139 DR4,
Mike Fiore 12:54f9cac9d690 140 DR5,
Mike Fiore 12:54f9cac9d690 141 DR6,
Mike Fiore 12:54f9cac9d690 142 DR7,
Mike Fiore 12:54f9cac9d690 143 DR8,
Mike Fiore 12:54f9cac9d690 144 DR9,
Mike Fiore 12:54f9cac9d690 145 DR10,
Mike Fiore 12:54f9cac9d690 146 DR11,
Mike Fiore 12:54f9cac9d690 147 DR12,
Mike Fiore 12:54f9cac9d690 148 DR13,
Mike Fiore 12:54f9cac9d690 149 DR14,
Mike Fiore 12:54f9cac9d690 150 DR15,
Mike Fiore 12:54f9cac9d690 151 SF_12 = 16,
Jason Reiss 10:27dafba9fe19 152 SF_11,
Jason Reiss 10:27dafba9fe19 153 SF_10,
Jason Reiss 10:27dafba9fe19 154 SF_9,
Jason Reiss 10:27dafba9fe19 155 SF_8,
Jason Reiss 10:27dafba9fe19 156 SF_7,
Jason Reiss 10:27dafba9fe19 157 SF_7H,
Mike Fiore 12:54f9cac9d690 158 SF_FSK
mfiore 0:c62615f15125 159 };
mfiore 0:c62615f15125 160
mfiore 0:c62615f15125 161 enum FrequencySubBands {
Jason Reiss 10:27dafba9fe19 162 FSB_ALL,
Jason Reiss 10:27dafba9fe19 163 FSB_1,
Jason Reiss 10:27dafba9fe19 164 FSB_2,
Jason Reiss 10:27dafba9fe19 165 FSB_3,
Jason Reiss 10:27dafba9fe19 166 FSB_4,
Jason Reiss 10:27dafba9fe19 167 FSB_5,
Jason Reiss 10:27dafba9fe19 168 FSB_6,
Jason Reiss 10:27dafba9fe19 169 FSB_7,
Jason Reiss 10:27dafba9fe19 170 FSB_8
mfiore 0:c62615f15125 171 };
mfiore 0:c62615f15125 172
Mike Fiore 6:390fc83d588d 173 enum JoinByteOrder {
Jason Reiss 10:27dafba9fe19 174 LSB,
Jason Reiss 10:27dafba9fe19 175 MSB
Mike Fiore 6:390fc83d588d 176 };
Mike Fiore 6:390fc83d588d 177
Mike Fiore 7:683dba5d576f 178 enum wakeup_mode {
Jason Reiss 10:27dafba9fe19 179 RTC_ALARM,
Jason Reiss 10:27dafba9fe19 180 INTERRUPT,
Jason Reiss 10:27dafba9fe19 181 RTC_ALARM_OR_INTERRUPT
Mike Fiore 7:683dba5d576f 182 };
Mike Fiore 7:683dba5d576f 183
jreiss 9:ec2fffe31793 184 enum UserBackupRegs {
Jason Reiss 10:27dafba9fe19 185 UBR0,
Jason Reiss 10:27dafba9fe19 186 UBR1,
Jason Reiss 10:27dafba9fe19 187 UBR2,
Jason Reiss 10:27dafba9fe19 188 UBR3,
Jason Reiss 10:27dafba9fe19 189 UBR4,
Jason Reiss 10:27dafba9fe19 190 UBR5,
Jason Reiss 10:27dafba9fe19 191 UBR6,
Jason Reiss 10:27dafba9fe19 192 UBR7,
Jason Reiss 10:27dafba9fe19 193 UBR8,
Jason Reiss 10:27dafba9fe19 194 UBR9
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 195 #if defined (TARGET_XDOT_L151CC)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 196 ,UBR10,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 197 UBR11,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 198 UBR12,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 199 UBR13,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 200 UBR14,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 201 UBR15,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 202 UBR16,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 203 UBR17,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 204 UBR18,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 205 UBR19,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 206 UBR20,
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 207 UBR21
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 208 #endif /* TARGET_XDOT_L151CC */
jreiss 9:ec2fffe31793 209 };
jreiss 9:ec2fffe31793 210
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 211 #if defined(TARGET_MTS_MDOT_F411RE)
Mike Fiore 7:683dba5d576f 212 typedef struct {
Mike Fiore 7:683dba5d576f 213 int16_t fd;
Mike Fiore 16:b630e18103e5 214 char name[33];
Mike Fiore 7:683dba5d576f 215 uint32_t size;
Mike Fiore 7:683dba5d576f 216 } mdot_file;
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 217 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 7:683dba5d576f 218
mfiore 0:c62615f15125 219 typedef struct {
mfiore 0:c62615f15125 220 uint32_t Up;
mfiore 0:c62615f15125 221 uint32_t Down;
mfiore 0:c62615f15125 222 uint32_t Joins;
mfiore 0:c62615f15125 223 uint32_t JoinFails;
mfiore 0:c62615f15125 224 uint32_t MissedAcks;
Mike Fiore 16:b630e18103e5 225 uint32_t CRCErrors;
mfiore 0:c62615f15125 226 } mdot_stats;
mfiore 0:c62615f15125 227
mfiore 0:c62615f15125 228 typedef struct {
mfiore 0:c62615f15125 229 int16_t last;
mfiore 0:c62615f15125 230 int16_t min;
mfiore 0:c62615f15125 231 int16_t max;
mfiore 0:c62615f15125 232 int16_t avg;
mfiore 0:c62615f15125 233 } rssi_stats;
mfiore 0:c62615f15125 234
mfiore 0:c62615f15125 235 typedef struct {
Mike Fiore 11:d8464345e1f1 236 int16_t last;
Mike Fiore 11:d8464345e1f1 237 int16_t min;
Mike Fiore 11:d8464345e1f1 238 int16_t max;
Mike Fiore 11:d8464345e1f1 239 int16_t avg;
mfiore 0:c62615f15125 240 } snr_stats;
mfiore 0:c62615f15125 241
mfiore 0:c62615f15125 242 typedef struct {
mfiore 0:c62615f15125 243 bool status;
mfiore 0:c62615f15125 244 int32_t dBm;
mfiore 0:c62615f15125 245 uint32_t gateways;
mfiore 0:c62615f15125 246 std::vector<uint8_t> payload;
mfiore 0:c62615f15125 247 } link_check;
mfiore 0:c62615f15125 248
mfiore 0:c62615f15125 249 typedef struct {
mfiore 0:c62615f15125 250 int32_t status;
mfiore 0:c62615f15125 251 int16_t rssi;
mfiore 0:c62615f15125 252 int16_t snr;
mfiore 0:c62615f15125 253 } ping_response;
mfiore 0:c62615f15125 254
mfiore 0:c62615f15125 255 static const uint8_t MaxLengths_915[];
mfiore 0:c62615f15125 256 static const uint8_t MaxLengths_868[];
mfiore 0:c62615f15125 257
mfiore 0:c62615f15125 258 static std::string JoinModeStr(uint8_t mode);
mfiore 0:c62615f15125 259 static std::string ModeStr(uint8_t mode);
mfiore 0:c62615f15125 260 static std::string RxOutputStr(uint8_t format);
mfiore 0:c62615f15125 261 static std::string DataRateStr(uint8_t rate);
mfiore 0:c62615f15125 262 static std::string FrequencyBandStr(uint8_t band);
mfiore 0:c62615f15125 263 static std::string FrequencySubBandStr(uint8_t band);
mfiore 0:c62615f15125 264
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 265 #if defined(TARGET_MTS_MDOT_F411RE)
jreiss 9:ec2fffe31793 266 uint32_t UserRegisters[10];
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 267 #else
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 268 uint32_t UserRegisters[22];
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 269 #endif /* TARGET_MTS_MDOT_F411RE */
jreiss 9:ec2fffe31793 270
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 271 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 272 * Get a handle to the singleton object
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 273 * @param plan the channel plan to use
mfiore 0:c62615f15125 274 * @returns pointer to mDot object
mfiore 0:c62615f15125 275 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 276 static mDot* getInstance(lora::ChannelPlan* plan);
mfiore 0:c62615f15125 277
Mike Fiore 12:54f9cac9d690 278 void setEvents(mDotEvent* events);
Mike Fiore 12:54f9cac9d690 279
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 280 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 281 *
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 282 * Get library version information
mfiore 0:c62615f15125 283 * @returns string containing library version information
mfiore 0:c62615f15125 284 */
mfiore 0:c62615f15125 285 std::string getId();
mfiore 0:c62615f15125 286
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 287 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 288 * Get MTS LoRa version information
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 289 * @returns string containing MTS LoRa version information
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 290 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 291 std::string getMtsLoraId();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 292
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 293 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 294 * Perform a soft reset of the system
mfiore 0:c62615f15125 295 */
mfiore 0:c62615f15125 296 void resetCpu();
mfiore 0:c62615f15125 297
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 298 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 299 * Reset config to factory default
mfiore 0:c62615f15125 300 */
mfiore 0:c62615f15125 301 void resetConfig();
mfiore 0:c62615f15125 302
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 303 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 304 * Save config data to non volatile memory
mfiore 0:c62615f15125 305 * @returns true if success, false if failure
mfiore 0:c62615f15125 306 */
mfiore 0:c62615f15125 307 bool saveConfig();
mfiore 0:c62615f15125 308
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 309 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 310 * Set the log level for the library
mfiore 0:c62615f15125 311 * options are:
mfiore 0:c62615f15125 312 * NONE_LEVEL - logging is off at this level
mfiore 0:c62615f15125 313 * FATAL_LEVEL - only critical errors will be reported
mfiore 0:c62615f15125 314 * ERROR_LEVEL
mfiore 0:c62615f15125 315 * WARNING_LEVEL
mfiore 0:c62615f15125 316 * INFO_LEVEL
mfiore 0:c62615f15125 317 * DEBUG_LEVEL
mfiore 0:c62615f15125 318 * TRACE_LEVEL - every detail will be reported
mfiore 0:c62615f15125 319 * @param level the level to log at
mfiore 0:c62615f15125 320 * @returns MDOT_OK if success
mfiore 0:c62615f15125 321 */
mfiore 0:c62615f15125 322 int32_t setLogLevel(const uint8_t& level);
mfiore 0:c62615f15125 323
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 324 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 325 * Get the current log level for the library
mfiore 0:c62615f15125 326 * @returns current log level
mfiore 0:c62615f15125 327 */
Mike Fiore 6:390fc83d588d 328 uint8_t getLogLevel();
Mike Fiore 6:390fc83d588d 329
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 330 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 331 * Seed pseudo RNG in LoRaMac layer, uses random value from radio RSSI reading by default
Mike Fiore 12:54f9cac9d690 332 * @param seed for RNG
Mike Fiore 12:54f9cac9d690 333 */
Mike Fiore 12:54f9cac9d690 334 void seedRandom(uint32_t seed);
Mike Fiore 12:54f9cac9d690 335
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 336
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 337 uint8_t setChannelPlan(lora::ChannelPlan* plan);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 338
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 339 lora::Settings* getSettings();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 340
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 341 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 342 * Enable or disable the activity LED.
Mike Fiore 6:390fc83d588d 343 * @param enable true to enable the LED, false to disable
Mike Fiore 6:390fc83d588d 344 */
Mike Fiore 6:390fc83d588d 345 void setActivityLedEnable(const bool& enable);
Mike Fiore 4:94969e981dcc 346
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 347 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 348 * Find out if the activity LED is enabled
Mike Fiore 6:390fc83d588d 349 * @returns true if activity LED is enabled, false if disabled
Mike Fiore 6:390fc83d588d 350 */
Mike Fiore 6:390fc83d588d 351 bool getActivityLedEnable();
Mike Fiore 6:390fc83d588d 352
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 353 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 354 * Use a different pin for the activity LED.
Mike Fiore 6:390fc83d588d 355 * The default is XBEE_RSSI.
Mike Fiore 6:390fc83d588d 356 * @param pin the new pin to use
Mike Fiore 6:390fc83d588d 357 */
Mike Fiore 6:390fc83d588d 358 void setActivityLedPin(const PinName& pin);
Mike Fiore 6:390fc83d588d 359
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 360 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 361 * Use an external DigitalOut object for the activity LED.
Mike Fiore 5:0bfe6a650513 362 * The pointer must stay valid!
Mike Fiore 5:0bfe6a650513 363 * @param pin the DigitalOut object to use
Mike Fiore 5:0bfe6a650513 364 */
Mike Fiore 5:0bfe6a650513 365 void setActivityLedPin(DigitalOut* pin);
Mike Fiore 6:390fc83d588d 366
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 367 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 368 * Find out what pin the activity LED is on
Mike Fiore 6:390fc83d588d 369 * @returns the pin the activity LED is using
Mike Fiore 6:390fc83d588d 370 */
Mike Fiore 6:390fc83d588d 371 PinName getActivityLedPin();
mfiore 0:c62615f15125 372
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 373 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 374 * Returns boolean indicative of start-up from standby mode
Mike Fiore 12:54f9cac9d690 375 * @returns true if dot woke from standby
Mike Fiore 12:54f9cac9d690 376 */
Mike Fiore 12:54f9cac9d690 377 bool getStandbyFlag();
Mike Fiore 12:54f9cac9d690 378
Mike Fiore 16:b630e18103e5 379 std::vector<uint16_t> getChannelMask();
Mike Fiore 16:b630e18103e5 380
Mike Fiore 16:b630e18103e5 381 int32_t setChannelMask(uint8_t offset, uint16_t mask);
Mike Fiore 16:b630e18103e5 382
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 383 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 384 * Add a channel
Mike Fiore 12:54f9cac9d690 385 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 386 */
Mike Fiore 12:54f9cac9d690 387 int32_t addChannel(uint8_t index, uint32_t frequency, uint8_t datarateRange);
Mike Fiore 12:54f9cac9d690 388
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 389 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 390 * Add a downlink channel
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 391 * @returns MDOT_OK
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 392 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 393 int32_t addDownlinkChannel(uint8_t index, uint32_t frequency);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 394
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 395 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 396 * Get list of channel frequencies currently in use
mfiore 0:c62615f15125 397 * @returns vector of channels currently in use
mfiore 0:c62615f15125 398 */
mfiore 0:c62615f15125 399 std::vector<uint32_t> getChannels();
mfiore 0:c62615f15125 400
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 401 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 402 * Get list of downlink channel frequencies currently in use
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 403 * @returns vector of channels currently in use
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 404 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 405 std::vector<uint32_t> getDownlinkChannels();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 406
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 407 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 408 * Get list of channel datarate ranges currently in use
Mike Fiore 12:54f9cac9d690 409 * @returns vector of datarate ranges currently in use
Mike Fiore 12:54f9cac9d690 410 */
Mike Fiore 12:54f9cac9d690 411 std::vector<uint8_t> getChannelRanges();
Mike Fiore 12:54f9cac9d690 412
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 413 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 414 * Get list of channel frequencies in config file to be used as session defaults
Mike Fiore 12:54f9cac9d690 415 * @returns vector of channels in config file
Mike Fiore 12:54f9cac9d690 416 */
Mike Fiore 12:54f9cac9d690 417 std::vector<uint32_t> getConfigChannels();
Mike Fiore 12:54f9cac9d690 418
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 419 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 420 * Get list of channel datarate ranges in config file to be used as session defaults
Mike Fiore 12:54f9cac9d690 421 * @returns vector of datarate ranges in config file
Mike Fiore 12:54f9cac9d690 422 */
Mike Fiore 12:54f9cac9d690 423 std::vector<uint8_t> getConfigChannelRanges();
Mike Fiore 12:54f9cac9d690 424
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 425 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 426 * Get default frequency band
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 427 * @returns frequency band the device was manufactured for
mfiore 0:c62615f15125 428 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 429 uint8_t getDefaultFrequencyBand();
mfiore 0:c62615f15125 430
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 431 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 432 * Set frequency sub band
mfiore 0:c62615f15125 433 * only applicable if frequency band is set for United States (FB_915)
Jason Reiss 10:27dafba9fe19 434 * sub band 0 will allow the radio to use all 64 channels
mfiore 0:c62615f15125 435 * sub band 1 - 8 will allow the radio to use the 8 channels in that sub band
mfiore 0:c62615f15125 436 * for use with Conduit gateway and MTAC_LORA, use sub bands 1 - 8, not sub band 0
mfiore 0:c62615f15125 437 * @param band the sub band to use (0 - 8)
mfiore 0:c62615f15125 438 * @returns MDOT_OK if success
mfiore 0:c62615f15125 439 */
mfiore 0:c62615f15125 440 int32_t setFrequencySubBand(const uint8_t& band);
mfiore 0:c62615f15125 441
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 442 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 443 * Get frequency sub band
mfiore 0:c62615f15125 444 * @returns frequency sub band currently in use
mfiore 0:c62615f15125 445 */
mfiore 0:c62615f15125 446 uint8_t getFrequencySubBand();
mfiore 0:c62615f15125 447
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 448 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 449 * Get frequency band
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 450 * @returns frequency band (channel plan) currently in use
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 451 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 452 uint8_t getFrequencyBand();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 453
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 454 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 455 * Get channel plan name
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 456 * @returns name of channel plan currently in use
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 457 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 458 std::string getChannelPlanName();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 459
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 460 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 461 * Get the datarate currently in use within the MAC layer
Mike Fiore 12:54f9cac9d690 462 * returns 0-15
Mike Fiore 12:54f9cac9d690 463 */
Mike Fiore 12:54f9cac9d690 464 uint8_t getSessionDataRate();
Mike Fiore 12:54f9cac9d690 465
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 466
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 467 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 468 * Get the current max EIRP used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 469 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 470 * returns 0-36
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 471 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 472 uint8_t getSessionMaxEIRP();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 473
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 474 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 475 * Set the current max EIRP used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 476 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 477 * accepts 0-36
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 478 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 479 void setSessionMaxEIRP(uint8_t max);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 480
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 481 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 482 * Get the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 483 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 484 * returns 0-1
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 485 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 486 uint8_t getSessionDownlinkDwelltime();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 487
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 488 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 489 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 490 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 491 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 492 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 493 void setSessionDownlinkDwelltime(uint8_t dwell);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 494
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 495 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 496 * Get the current uplink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 497 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 498 * returns 0-1
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 499 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 500 uint8_t getSessionUplinkDwelltime();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 501
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 502 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 503 * Set the current uplink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 504 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 505 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 506 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 507 void setSessionUplinkDwelltime(uint8_t dwell);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 508
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 509 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 510 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 511 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 512 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 513 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 514 uint32_t getListenBeforeTalkTime(uint8_t ms);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 515
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 516 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 517 * Set the current downlink dwell time used in the channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 518 * May be changed by the network server
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 519 * accepts 0-1
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 520 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 521 void setListenBeforeTalkTime(uint32_t ms);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 522
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 523 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 524 * Enable/disable public network mode
Jason Reiss 10:27dafba9fe19 525 * JoinDelay will be set to (public: 5s, private: 1s) and
Jason Reiss 10:27dafba9fe19 526 * RxDelay will be set to 1s both can be adjusted afterwards
mfiore 0:c62615f15125 527 * @param on should be true to enable public network mode
mfiore 0:c62615f15125 528 * @returns MDOT_OK if success
mfiore 0:c62615f15125 529 */
mfiore 0:c62615f15125 530 int32_t setPublicNetwork(const bool& on);
mfiore 0:c62615f15125 531
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 532 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 533 * Get public network mode
mfiore 0:c62615f15125 534 * @returns true if public network mode is enabled
mfiore 0:c62615f15125 535 */
mfiore 0:c62615f15125 536 bool getPublicNetwork();
mfiore 0:c62615f15125 537
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 538 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 544 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 550 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 556 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 562 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 568 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 574 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 582 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 588 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 596 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 602 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 610 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 616 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 625 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 631 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 640 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 646 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 655 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 661 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 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 81:d8f2c4e664f5 670 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 671 * Get network key
mfiore 0:c62615f15125 672 * @returns a vector containing network key (size 16)
mfiore 0:c62615f15125 673 */
mfiore 0:c62615f15125 674 std::vector<uint8_t> getNetworkKey();
mfiore 0:c62615f15125 675
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 676 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 677 * Set lorawan application EUI
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 678 * equivalent to setNetworkId
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 679 * @param eui application EUI (size 8)
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 680 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 681 int32_t setAppEUI(const uint8_t* eui);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 682
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 683 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 684 * Get lorawan application EUI
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 685 * equivalent to getNetworkId
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 686 * @returns vector containing application EUI (size 8)
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 687 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 688 const uint8_t* getAppEUI();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 689
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 690 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 691 * Set lorawan application key
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 692 * equivalent to setNetworkKey
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 693 * @param eui application key (size 16)
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 694 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 695 int32_t setAppKey(const uint8_t* key);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 696
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 697 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 698 * Set lorawan application key
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 699 * equivalent to getNetworkKey
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 700 * @returns eui application key (size 16)
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 701 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 702 const uint8_t* getAppKey();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 703
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 704 /**
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 705 * Add a multicast session address and keys
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 706 * Downlink counter is set to 0
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 707 * Up to 3 MULTICAST_SESSIONS can be set
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 708 */
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 709 int32_t setMulticastSession(uint8_t index, uint32_t addr, const uint8_t* nsk, const uint8_t* dsk);
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 710
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 711 /**
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 712 * Set a multicast session counter
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 713 * Up to 3 MULTICAST_SESSIONS can be set
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 714 */
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 715 int32_t setMulticastDownlinkCounter(uint8_t index, uint32_t count);
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 716
Jenkins@KEILDM1.dc.multitech.prv 90:79a8c8660a4e 717 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 718 * Set join byte order
Mike Fiore 6:390fc83d588d 719 * @param order 0:LSB 1:MSB
Mike Fiore 6:390fc83d588d 720 */
Mike Fiore 6:390fc83d588d 721 uint32_t setJoinByteOrder(uint8_t order);
Mike Fiore 6:390fc83d588d 722
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 723 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 724 * Get join byte order
Mike Fiore 6:390fc83d588d 725 * @returns byte order to use in joins 0:LSB 1:MSB
Mike Fiore 6:390fc83d588d 726 */
Mike Fiore 6:390fc83d588d 727 uint8_t getJoinByteOrder();
Mike Fiore 6:390fc83d588d 728
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 729 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 730 * Attempt to join network
Mike Fiore 12:54f9cac9d690 731 * each attempt will be made with a random datarate up to the configured datarate
Mike Fiore 12:54f9cac9d690 732 * 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 733 * Check getNextTxMs() for time until next join attempt can be made
mfiore 0:c62615f15125 734 * @returns MDOT_OK if success
mfiore 0:c62615f15125 735 */
mfiore 0:c62615f15125 736 int32_t joinNetwork();
mfiore 0:c62615f15125 737
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 738 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 739 * Attempts to join network once
mfiore 0:c62615f15125 740 * @returns MDOT_OK if success
mfiore 0:c62615f15125 741 */
mfiore 0:c62615f15125 742 int32_t joinNetworkOnce();
mfiore 0:c62615f15125 743
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 744 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 745 * Resets current network session, essentially disconnecting from the network
mfiore 0:c62615f15125 746 * has no effect for MANUAL network join mode
mfiore 0:c62615f15125 747 */
mfiore 0:c62615f15125 748 void resetNetworkSession();
mfiore 0:c62615f15125 749
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 750 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 751 * Restore saved network session from flash
Mike Fiore 12:54f9cac9d690 752 * has no effect for MANUAL network join mode
Mike Fiore 12:54f9cac9d690 753 */
Mike Fiore 12:54f9cac9d690 754 void restoreNetworkSession();
Mike Fiore 12:54f9cac9d690 755
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 756 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 757 * Save current network session to flash
Mike Fiore 12:54f9cac9d690 758 * has no effect for MANUAL network join mode
Mike Fiore 12:54f9cac9d690 759 */
Mike Fiore 12:54f9cac9d690 760 void saveNetworkSession();
Mike Fiore 12:54f9cac9d690 761
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 762 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 763 * Set number of times joining will retry each sub-band before changing
jreiss 17:306ffaa5d79b 764 * to the next subband in US915 and AU915
mfiore 0:c62615f15125 765 * @param retries must be between 0 - 255
mfiore 0:c62615f15125 766 * @returns MDOT_OK if success
mfiore 0:c62615f15125 767 */
mfiore 0:c62615f15125 768 int32_t setJoinRetries(const uint8_t& retries);
mfiore 0:c62615f15125 769
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 770 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 771 * Get number of times joining will retry each sub-band
mfiore 0:c62615f15125 772 * @returns join retries (0 - 255)
mfiore 0:c62615f15125 773 */
mfiore 0:c62615f15125 774 uint8_t getJoinRetries();
mfiore 0:c62615f15125 775
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 776 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 777 * Set network join mode
mfiore 0:c62615f15125 778 * MANUAL: set network address and session keys manually
mfiore 0:c62615f15125 779 * OTA: User sets network name and passphrase, then attempts to join
mfiore 0:c62615f15125 780 * AUTO_OTA: same as OTA, but network sessions can be saved and restored
mfiore 0:c62615f15125 781 * @param mode MANUAL, OTA, or AUTO_OTA
mfiore 0:c62615f15125 782 * @returns MDOT_OK if success
mfiore 0:c62615f15125 783 */
mfiore 0:c62615f15125 784 int32_t setJoinMode(const uint8_t& mode);
mfiore 0:c62615f15125 785
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 786 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 787 * Get network join mode
mfiore 0:c62615f15125 788 * @returns MANUAL, OTA, or AUTO_OTA
mfiore 0:c62615f15125 789 */
mfiore 0:c62615f15125 790 uint8_t getJoinMode();
mfiore 0:c62615f15125 791
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 792 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 793 * Get network join status
mfiore 0:c62615f15125 794 * @returns true if currently joined to network
mfiore 0:c62615f15125 795 */
mfiore 0:c62615f15125 796 bool getNetworkJoinStatus();
mfiore 0:c62615f15125 797
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 798 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 799 * Do a network link check
mfiore 0:c62615f15125 800 * application data may be returned in response to a network link check command
mfiore 0:c62615f15125 801 * @returns link_check structure containing success, dBm above noise floor, gateways in range, and packet payload
mfiore 0:c62615f15125 802 */
mfiore 0:c62615f15125 803 link_check networkLinkCheck();
mfiore 0:c62615f15125 804
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 805 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 806 * Set network link check count to perform automatic link checks every count packets
mfiore 0:c62615f15125 807 * only applicable if ACKs are disabled
mfiore 0:c62615f15125 808 * @param count must be between 0 - 255
mfiore 0:c62615f15125 809 * @returns MDOT_OK if success
mfiore 0:c62615f15125 810 */
mfiore 0:c62615f15125 811 int32_t setLinkCheckCount(const uint8_t& count);
mfiore 0:c62615f15125 812
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 813 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 814 * Get network link check count
mfiore 0:c62615f15125 815 * @returns count (0 - 255)
mfiore 0:c62615f15125 816 */
mfiore 0:c62615f15125 817 uint8_t getLinkCheckCount();
mfiore 0:c62615f15125 818
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 819 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 820 * Set network link check threshold, number of link check failures or missed acks to tolerate
mfiore 0:c62615f15125 821 * before considering network connection lost
mfiore 0:c62615f15125 822 * @pararm count must be between 0 - 255
mfiore 0:c62615f15125 823 * @returns MDOT_OK if success
mfiore 0:c62615f15125 824 */
mfiore 0:c62615f15125 825 int32_t setLinkCheckThreshold(const uint8_t& count);
mfiore 0:c62615f15125 826
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 827 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 828 * Get network link check threshold
mfiore 0:c62615f15125 829 * @returns threshold (0 - 255)
mfiore 0:c62615f15125 830 */
mfiore 0:c62615f15125 831 uint8_t getLinkCheckThreshold();
mfiore 0:c62615f15125 832
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 833 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 834 * Get/set number of failed link checks in the current session
Mike Fiore 12:54f9cac9d690 835 * @returns count (0 - 255)
Mike Fiore 12:54f9cac9d690 836 */
Mike Fiore 12:54f9cac9d690 837 uint8_t getLinkFailCount();
Mike Fiore 12:54f9cac9d690 838 int32_t setLinkFailCount(uint8_t count);
Mike Fiore 12:54f9cac9d690 839
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 840 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 841 * Set UpLinkCounter number of packets sent to the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 842 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 843 */
Mike Fiore 12:54f9cac9d690 844 int32_t setUpLinkCounter(uint32_t count);
Mike Fiore 12:54f9cac9d690 845
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 846 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 847 * Get UpLinkCounter
mfiore 0:c62615f15125 848 * @returns number of packets sent to the gateway during this network session (sequence number)
mfiore 0:c62615f15125 849 */
mfiore 0:c62615f15125 850 uint32_t getUpLinkCounter();
mfiore 0:c62615f15125 851
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 852 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 853 * Set UpLinkCounter number of packets sent by the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 854 * @returns MDOT_OK
Mike Fiore 12:54f9cac9d690 855 */
Mike Fiore 12:54f9cac9d690 856 int32_t setDownLinkCounter(uint32_t count);
Mike Fiore 12:54f9cac9d690 857
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 858 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 859 * Get DownLinkCounter
Mike Fiore 12:54f9cac9d690 860 * @returns number of packets sent by the gateway during this network session (sequence number)
Mike Fiore 12:54f9cac9d690 861 */
Mike Fiore 12:54f9cac9d690 862 uint32_t getDownLinkCounter();
Mike Fiore 12:54f9cac9d690 863
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 864 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 865 * Enable/disable AES encryption
mfiore 0:c62615f15125 866 * AES encryption must be enabled for use with Conduit gateway and MTAC_LORA card
mfiore 0:c62615f15125 867 * @param on true for AES encryption to be enabled
mfiore 0:c62615f15125 868 * @returns MDOT_OK if success
mfiore 0:c62615f15125 869 */
mfiore 0:c62615f15125 870 int32_t setAesEncryption(const bool& on);
mfiore 0:c62615f15125 871
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 872 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 873 * Get AES encryption
mfiore 0:c62615f15125 874 * @returns true if AES encryption is enabled
mfiore 0:c62615f15125 875 */
mfiore 0:c62615f15125 876 bool getAesEncryption();
mfiore 0:c62615f15125 877
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 878 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 879 * Get RSSI stats
Mike Fiore 11:d8464345e1f1 880 * @returns rssi_stats struct containing last, min, max, and avg RSSI in dB
mfiore 0:c62615f15125 881 */
mfiore 0:c62615f15125 882 rssi_stats getRssiStats();
mfiore 0:c62615f15125 883
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 884 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 885 * Get SNR stats
Mike Fiore 11:d8464345e1f1 886 * @returns snr_stats struct containing last, min, max, and avg SNR in cB
mfiore 0:c62615f15125 887 */
mfiore 0:c62615f15125 888 snr_stats getSnrStats();
mfiore 0:c62615f15125 889
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 890 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 891 * Get ms until next free channel
mfiore 0:c62615f15125 892 * only applicable for European models, US models return 0
mfiore 0:c62615f15125 893 * @returns time (ms) until a channel is free to use for transmitting
mfiore 0:c62615f15125 894 */
mfiore 0:c62615f15125 895 uint32_t getNextTxMs();
mfiore 0:c62615f15125 896
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 897 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 898 * Get join delay in seconds
Jason Reiss 10:27dafba9fe19 899 * Public network defaults to 5 seconds
Jason Reiss 10:27dafba9fe19 900 * Private network defaults to 1 second
Jason Reiss 10:27dafba9fe19 901 * @returns number of seconds before join accept message is expected
Jason Reiss 10:27dafba9fe19 902 */
Jason Reiss 10:27dafba9fe19 903 uint8_t getJoinDelay();
Jason Reiss 10:27dafba9fe19 904
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 905 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 906 * Set join delay in seconds
Jason Reiss 10:27dafba9fe19 907 * Public network defaults to 5 seconds
Jason Reiss 10:27dafba9fe19 908 * Private network defaults to 1 second
Jason Reiss 10:27dafba9fe19 909 * @param delay number of seconds before join accept message is expected
Jason Reiss 10:27dafba9fe19 910 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 911 */
Jason Reiss 10:27dafba9fe19 912 uint32_t setJoinDelay(uint8_t delay);
Jason Reiss 10:27dafba9fe19 913
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 914 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 915 * Get join Rx1 datarate offset
Mike Fiore 16:b630e18103e5 916 * defaults to 0
Mike Fiore 16:b630e18103e5 917 * @returns offset
Mike Fiore 16:b630e18103e5 918 */
Mike Fiore 16:b630e18103e5 919 uint8_t getJoinRx1DataRateOffset();
Mike Fiore 16:b630e18103e5 920
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 921 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 922 * Set join Rx1 datarate offset
Mike Fiore 16:b630e18103e5 923 * @param offset for datarate
Mike Fiore 16:b630e18103e5 924 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 925 */
Mike Fiore 16:b630e18103e5 926 uint32_t setJoinRx1DataRateOffset(uint8_t offset);
Mike Fiore 16:b630e18103e5 927
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 928 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 929 * Get join Rx2 datarate
Mike Fiore 16:b630e18103e5 930 * defaults to US:DR8, AU:DR8, EU:DR0
Mike Fiore 16:b630e18103e5 931 * @returns datarate
Mike Fiore 16:b630e18103e5 932 */
Mike Fiore 16:b630e18103e5 933 uint8_t getJoinRx2DataRate();
Mike Fiore 16:b630e18103e5 934
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 935 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 936 * Set join Rx2 datarate
Mike Fiore 16:b630e18103e5 937 * @param datarate
Mike Fiore 16:b630e18103e5 938 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 939 */
Mike Fiore 16:b630e18103e5 940 uint32_t setJoinRx2DataRate(uint8_t datarate);
Mike Fiore 16:b630e18103e5 941
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 942 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 943 * Get join Rx2 frequency
Mike Fiore 16:b630e18103e5 944 * defaults US:923.3, AU:923.3, EU:869.525
Mike Fiore 16:b630e18103e5 945 * @returns frequency
Mike Fiore 16:b630e18103e5 946 */
Mike Fiore 16:b630e18103e5 947 uint32_t getJoinRx2Frequency();
Mike Fiore 16:b630e18103e5 948
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 949 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 950 * Set join Rx2 frequency
Mike Fiore 16:b630e18103e5 951 * @param frequency
Mike Fiore 16:b630e18103e5 952 * @return MDOT_OK if success
Mike Fiore 16:b630e18103e5 953 */
Mike Fiore 16:b630e18103e5 954 uint32_t setJoinRx2Frequency(uint32_t frequency);
Mike Fiore 16:b630e18103e5 955
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 956 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 957 * Get rx delay in seconds
Jason Reiss 10:27dafba9fe19 958 * Defaults to 1 second
Jason Reiss 10:27dafba9fe19 959 * @returns number of seconds before response message is expected
Jason Reiss 10:27dafba9fe19 960 */
Jason Reiss 10:27dafba9fe19 961 uint8_t getRxDelay();
Jason Reiss 10:27dafba9fe19 962
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 963 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 964 * Set rx delay in seconds
Jason Reiss 10:27dafba9fe19 965 * Defaults to 1 second
Jason Reiss 10:27dafba9fe19 966 * @param delay number of seconds before response message is expected
Jason Reiss 10:27dafba9fe19 967 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 968 */
Jason Reiss 10:27dafba9fe19 969 uint32_t setRxDelay(uint8_t delay);
Jason Reiss 10:27dafba9fe19 970
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 971 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 972 * Get preserve session to save network session info through reset or power down in AUTO_OTA mode
Jason Reiss 10:27dafba9fe19 973 * Defaults to off
Jason Reiss 10:27dafba9fe19 974 * @returns true if enabled
Jason Reiss 10:27dafba9fe19 975 */
Jason Reiss 10:27dafba9fe19 976 bool getPreserveSession();
Jason Reiss 10:27dafba9fe19 977
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 978 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 979 * Set preserve session to save network session info through reset or power down in AUTO_OTA mode
Jason Reiss 10:27dafba9fe19 980 * Defaults to off
Jason Reiss 10:27dafba9fe19 981 * @param enable
Jason Reiss 10:27dafba9fe19 982 * @return MDOT_OK if success
Jason Reiss 10:27dafba9fe19 983 */
Jason Reiss 10:27dafba9fe19 984 uint32_t setPreserveSession(bool enable);
Jason Reiss 10:27dafba9fe19 985
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 986 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 987 * Get data pending
mfiore 0:c62615f15125 988 * only valid after sending data to the gateway
mfiore 0:c62615f15125 989 * @returns true if server has available packet(s)
mfiore 0:c62615f15125 990 */
mfiore 0:c62615f15125 991 bool getDataPending();
mfiore 0:c62615f15125 992
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 993 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 994 * Get ack requested
Mike Fiore 16:b630e18103e5 995 * only valid after sending data to the gateway
Mike Fiore 16:b630e18103e5 996 * @returns true if server has requested ack
Mike Fiore 16:b630e18103e5 997 */
Mike Fiore 16:b630e18103e5 998 bool getAckRequested();
Mike Fiore 16:b630e18103e5 999
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1000 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1001 * Get is transmitting indicator
mfiore 0:c62615f15125 1002 * @returns true if currently transmitting
mfiore 0:c62615f15125 1003 */
mfiore 0:c62615f15125 1004 bool getIsTransmitting();
mfiore 0:c62615f15125 1005
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1006 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1007 * Get is idle indicator
Mike Fiore 16:b630e18103e5 1008 * @returns true if not currently transmitting, waiting or receiving
Mike Fiore 16:b630e18103e5 1009 */
Mike Fiore 16:b630e18103e5 1010 bool getIsIdle();
Mike Fiore 16:b630e18103e5 1011
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1012 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1013 * Set TX data rate
mfiore 0:c62615f15125 1014 * data rates affect maximum payload size
Mike Fiore 11:d8464345e1f1 1015 * @param dr SF_7 - SF_12|DR0-DR7 for Europe, SF_7 - SF_10 | DR0-DR4 for United States
mfiore 0:c62615f15125 1016 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1017 */
mfiore 0:c62615f15125 1018 int32_t setTxDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 1019
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1020 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1021 * Get TX data rate
Mike Fiore 11:d8464345e1f1 1022 * @returns current TX data rate (DR0-DR15)
mfiore 0:c62615f15125 1023 */
mfiore 0:c62615f15125 1024 uint8_t getTxDataRate();
mfiore 0:c62615f15125 1025
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1026 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1027 * Get a random value from the radio based on RSSI
Mike Fiore 12:54f9cac9d690 1028 * @returns randome value
Mike Fiore 12:54f9cac9d690 1029 */
Mike Fiore 12:54f9cac9d690 1030 uint32_t getRadioRandom();
Mike Fiore 12:54f9cac9d690 1031
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1032 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1033 * Get data rate spreading factor and bandwidth
Mike Fiore 11:d8464345e1f1 1034 * EU868 Datarates
Mike Fiore 11:d8464345e1f1 1035 * ---------------
Mike Fiore 11:d8464345e1f1 1036 * DR0 - SF12BW125
Mike Fiore 11:d8464345e1f1 1037 * DR1 - SF11BW125
Mike Fiore 11:d8464345e1f1 1038 * DR2 - SF10BW125
Mike Fiore 11:d8464345e1f1 1039 * DR3 - SF9BW125
Mike Fiore 11:d8464345e1f1 1040 * DR4 - SF8BW125
Mike Fiore 11:d8464345e1f1 1041 * DR5 - SF7BW125
Mike Fiore 11:d8464345e1f1 1042 * DR6 - SF7BW250
Mike Fiore 11:d8464345e1f1 1043 * DR7 - FSK
Mike Fiore 11:d8464345e1f1 1044 *
Mike Fiore 11:d8464345e1f1 1045 * US915 Datarates
Mike Fiore 11:d8464345e1f1 1046 * ---------------
Mike Fiore 11:d8464345e1f1 1047 * DR0 - SF10BW125
Mike Fiore 11:d8464345e1f1 1048 * DR1 - SF9BW125
Mike Fiore 11:d8464345e1f1 1049 * DR2 - SF8BW125
Mike Fiore 11:d8464345e1f1 1050 * DR3 - SF7BW125
Mike Fiore 11:d8464345e1f1 1051 * DR4 - SF8BW500
Mike Fiore 11:d8464345e1f1 1052 *
jreiss 17:306ffaa5d79b 1053 * AU915 Datarates
jreiss 17:306ffaa5d79b 1054 * ---------------
jreiss 17:306ffaa5d79b 1055 * DR0 - SF10BW125
jreiss 17:306ffaa5d79b 1056 * DR1 - SF9BW125
jreiss 17:306ffaa5d79b 1057 * DR2 - SF8BW125
jreiss 17:306ffaa5d79b 1058 * DR3 - SF7BW125
jreiss 17:306ffaa5d79b 1059 * DR4 - SF8BW500
jreiss 17:306ffaa5d79b 1060 *
Mike Fiore 11:d8464345e1f1 1061 * @returns spreading factor and bandwidth
Mike Fiore 11:d8464345e1f1 1062 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1063 std::string getDataRateDetails(uint8_t rate);
Mike Fiore 11:d8464345e1f1 1064 std::string getDateRateDetails(uint8_t rate);
Mike Fiore 11:d8464345e1f1 1065
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1066
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1067 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1068 * Set TX power output of radio before antenna gain, default: 14 dBm
Mike Fiore 12:54f9cac9d690 1069 * actual output power may be limited by local regulations for the chosen frequency
mfiore 0:c62615f15125 1070 * power affects maximum range
mfiore 0:c62615f15125 1071 * @param power 2 dBm - 20 dBm
mfiore 0:c62615f15125 1072 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1073 */
mfiore 0:c62615f15125 1074 int32_t setTxPower(const uint32_t& power);
mfiore 0:c62615f15125 1075
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1076 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1077 * Get TX power
mfiore 0:c62615f15125 1078 * @returns TX power (2 dBm - 20 dBm)
mfiore 0:c62615f15125 1079 */
mfiore 0:c62615f15125 1080 uint32_t getTxPower();
mfiore 0:c62615f15125 1081
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1082 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1083 * Get configured gain of installed antenna, default: +3 dBi
Mike Fiore 11:d8464345e1f1 1084 * @returns gain of antenna in dBi
Mike Fiore 11:d8464345e1f1 1085 */
Mike Fiore 11:d8464345e1f1 1086 int8_t getAntennaGain();
Mike Fiore 11:d8464345e1f1 1087
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1088 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1089 * Set configured gain of installed antenna, default: +3 dBi
Mike Fiore 11:d8464345e1f1 1090 * @param gain -127 dBi - 128 dBi
Mike Fiore 11:d8464345e1f1 1091 * @returns MDOT_OK if success
Mike Fiore 11:d8464345e1f1 1092 */
Mike Fiore 11:d8464345e1f1 1093 int32_t setAntennaGain(int8_t gain);
Mike Fiore 11:d8464345e1f1 1094
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1095 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1096 * Enable/disable TX waiting for rx windows
mfiore 0:c62615f15125 1097 * when enabled, send calls will block until a packet is received or RX timeout
mfiore 0:c62615f15125 1098 * @param enable set to true if expecting responses to transmitted packets
mfiore 0:c62615f15125 1099 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1100 */
mfiore 0:c62615f15125 1101 int32_t setTxWait(const bool& enable);
mfiore 0:c62615f15125 1102
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1103 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1104 * Get TX wait
mfiore 0:c62615f15125 1105 * @returns true if TX wait is enabled
mfiore 0:c62615f15125 1106 */
mfiore 0:c62615f15125 1107 bool getTxWait();
mfiore 0:c62615f15125 1108
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1109 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1110 * Cancel pending rx windows
Mike Fiore 16:b630e18103e5 1111 */
Mike Fiore 16:b630e18103e5 1112 void cancelRxWindow();
Mike Fiore 16:b630e18103e5 1113
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1114 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1115 * Get time on air
mfiore 0:c62615f15125 1116 * @returns the amount of time (in ms) it would take to send bytes bytes based on current configuration
mfiore 0:c62615f15125 1117 */
mfiore 0:c62615f15125 1118 uint32_t getTimeOnAir(uint8_t bytes);
mfiore 0:c62615f15125 1119
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1120 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1121 * Get min frequency
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1122 * @returns minimum frequency based on current channel plan
mfiore 0:c62615f15125 1123 */
mfiore 0:c62615f15125 1124 uint32_t getMinFrequency();
mfiore 0:c62615f15125 1125
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1126 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1127 * Get max frequency
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1128 * @returns maximum frequency based on current channel plan
mfiore 0:c62615f15125 1129 */
mfiore 0:c62615f15125 1130 uint32_t getMaxFrequency();
mfiore 0:c62615f15125 1131
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1132 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1133 * Get min datarate
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1134 * @returns minimum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1135 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1136 uint8_t getMinDatarate();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1137
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1138 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1139 * Get max datarate
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1140 * @returns maximum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1141 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1142 uint8_t getMaxDatarate();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1143
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1144 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1145 * Get min datarate offset
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1146 * @returns minimum datarate offset based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1147 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1148 uint8_t getMinDatarateOffset();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1149
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1150 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1151 * Get max datarate offset
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1152 * @returns maximum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1153 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1154 uint8_t getMaxDatarateOffset();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1155
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1156 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1157 * Get min datarate
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1158 * @returns minimum datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1159 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1160 uint8_t getMinRx2Datarate();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1161
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1162 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1163 * Get max rx2 datarate
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1164 * @returns maximum rx2 datarate based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1165 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1166 uint8_t getMaxRx2Datarate();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1167
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1168 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1169 * Get max tx power
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1170 * @returns maximum tx power based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1171 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1172 uint8_t getMaxTxPower();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1173
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1174 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1175 * Get min tx power
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1176 * @returns minimum tx power based on current channel plan
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1177 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1178 uint8_t getMinTxPower();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1179
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1180 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1181 *
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1182 * get/set adaptive data rate
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1183 * configure data rates and power levels based on signal to noise of packets received at gateway
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1184 * true == adaptive data rate is on
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1185 * set function returns MDOT_OK if success
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1186 */
Mike Fiore 12:54f9cac9d690 1187 int32_t setAdr(const bool& on);
Mike Fiore 12:54f9cac9d690 1188 bool getAdr();
Mike Fiore 12:54f9cac9d690 1189
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1190 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1191 * Set forward error correction bytes
mfiore 0:c62615f15125 1192 * @param bytes 1 - 4 bytes
mfiore 0:c62615f15125 1193 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1194 */
mfiore 0:c62615f15125 1195 int32_t setFec(const uint8_t& bytes);
mfiore 0:c62615f15125 1196
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1197 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1198 * Get forward error correction bytes
mfiore 0:c62615f15125 1199 * @returns bytes (1 - 4)
mfiore 0:c62615f15125 1200 */
mfiore 0:c62615f15125 1201 uint8_t getFec();
mfiore 0:c62615f15125 1202
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1203 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1204 * Enable/disable CRC checking of packets
mfiore 0:c62615f15125 1205 * CRC checking must be enabled for use with Conduit gateway and MTAC_LORA card
mfiore 0:c62615f15125 1206 * @param on set to true to enable CRC checking
mfiore 0:c62615f15125 1207 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1208 */
mfiore 0:c62615f15125 1209 int32_t setCrc(const bool& on);
mfiore 0:c62615f15125 1210
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1211 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1212 * Get CRC checking
mfiore 0:c62615f15125 1213 * @returns true if CRC checking is enabled
mfiore 0:c62615f15125 1214 */
mfiore 0:c62615f15125 1215 bool getCrc();
mfiore 0:c62615f15125 1216
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1217 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1218 * Set ack
mfiore 0:c62615f15125 1219 * @param retries 0 to disable acks, otherwise 1 - 8
mfiore 0:c62615f15125 1220 * @returns MDOT_OK if success
mfiore 0:c62615f15125 1221 */
mfiore 0:c62615f15125 1222 int32_t setAck(const uint8_t& retries);
mfiore 0:c62615f15125 1223
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1224 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1225 * Get ack
mfiore 0:c62615f15125 1226 * @returns 0 if acks are disabled, otherwise retries (1 - 8)
mfiore 0:c62615f15125 1227 */
mfiore 0:c62615f15125 1228 uint8_t getAck();
mfiore 0:c62615f15125 1229
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1230 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1231 * Set number of packet repeats for unconfirmed frames
Mike Fiore 12:54f9cac9d690 1232 * @param repeat 0 or 1 for no repeats, otherwise 2-15
Mike Fiore 12:54f9cac9d690 1233 * @returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1234 */
Mike Fiore 12:54f9cac9d690 1235 int32_t setRepeat(const uint8_t& repeat);
Mike Fiore 12:54f9cac9d690 1236
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1237 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1238 * Get number of packet repeats for unconfirmed frames
Mike Fiore 12:54f9cac9d690 1239 * @returns 0 or 1 if no repeats, otherwise 2-15
Mike Fiore 12:54f9cac9d690 1240 */
Mike Fiore 12:54f9cac9d690 1241 uint8_t getRepeat();
Mike Fiore 12:54f9cac9d690 1242
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1243 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1244 * Send data to the gateway
mfiore 0:c62615f15125 1245 * validates data size (based on spreading factor)
mfiore 0:c62615f15125 1246 * @param data a vector of up to 242 bytes (may be less based on spreading factor)
mfiore 0:c62615f15125 1247 * @returns MDOT_OK if packet was sent successfully (ACKs disabled), or if an ACK was received (ACKs enabled)
mfiore 0:c62615f15125 1248 */
mfiore 0:c62615f15125 1249 int32_t send(const std::vector<uint8_t>& data, const bool& blocking = true, const bool& highBw = false);
mfiore 0:c62615f15125 1250
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1251 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1252 * Inject mac command
Mike Fiore 16:b630e18103e5 1253 * @param data a vector containing mac commands
Mike Fiore 16:b630e18103e5 1254 * @returns MDOT_OK
Mike Fiore 16:b630e18103e5 1255 */
Mike Fiore 16:b630e18103e5 1256 int32_t injectMacCommand(const std::vector<uint8_t>& data);
Mike Fiore 16:b630e18103e5 1257
Mike Fiore 16:b630e18103e5 1258 /**
Mike Fiore 16:b630e18103e5 1259 * Clear MAC command buffer to be sent in next uplink
Mike Fiore 16:b630e18103e5 1260 * @returns MDOT_OK
Mike Fiore 16:b630e18103e5 1261 */
Mike Fiore 16:b630e18103e5 1262 int32_t clearMacCommands();
Mike Fiore 16:b630e18103e5 1263
Mike Fiore 16:b630e18103e5 1264 /**
Mike Fiore 16:b630e18103e5 1265 * Get MAC command buffer to be sent in next uplink
Mike Fiore 16:b630e18103e5 1266 * @returns command bytes
Mike Fiore 16:b630e18103e5 1267 */
Mike Fiore 16:b630e18103e5 1268 std::vector<uint8_t> getMacCommands();
Mike Fiore 16:b630e18103e5 1269
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1270 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1271 * Fetch data received from the gateway
mfiore 0:c62615f15125 1272 * this function only checks to see if a packet has been received - it does not open a receive window
mfiore 0:c62615f15125 1273 * send() must be called before recv()
mfiore 0:c62615f15125 1274 * @param data a vector to put the received data into
mfiore 0:c62615f15125 1275 * @returns MDOT_OK if packet was successfully received
mfiore 0:c62615f15125 1276 */
mfiore 0:c62615f15125 1277 int32_t recv(std::vector<uint8_t>& data);
mfiore 0:c62615f15125 1278
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1279 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1280 * Ping
mfiore 0:c62615f15125 1281 * status will be MDOT_OK if ping succeeded
mfiore 0:c62615f15125 1282 * @returns ping_response struct containing status, RSSI, and SNR
mfiore 0:c62615f15125 1283 */
mfiore 0:c62615f15125 1284 ping_response ping();
mfiore 0:c62615f15125 1285
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1286 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1287 * Get return code string
mfiore 0:c62615f15125 1288 * @returns string containing a description of the given error code
mfiore 0:c62615f15125 1289 */
mfiore 0:c62615f15125 1290 static std::string getReturnCodeString(const int32_t& code);
mfiore 0:c62615f15125 1291
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1292 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1293 * Get last error
mfiore 0:c62615f15125 1294 * @returns string explaining the last error that occured
mfiore 0:c62615f15125 1295 */
mfiore 0:c62615f15125 1296 std::string getLastError();
mfiore 0:c62615f15125 1297
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1298 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1299 * Go to sleep
Jason Reiss 10:27dafba9fe19 1300 * @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 1301 * @param wakeup_mode RTC_ALARM, INTERRUPT, RTC_ALARM_OR_INTERRUPT
Mike Fiore 7:683dba5d576f 1302 * if RTC_ALARM the real time clock is configured to wake the device up after the specified interval
Mike Fiore 7:683dba5d576f 1303 * if INTERRUPT the device will wake up on the rising edge of the interrupt pin
Jason Reiss 10:27dafba9fe19 1304 * if RTC_ALARM_OR_INTERRUPT the device will wake on the first event to occur
Mike Fiore 7:683dba5d576f 1305 * @param deepsleep if true go into deep sleep mode (lowest power, all memory and registers are lost, peripherals turned off)
Mike Fiore 7:683dba5d576f 1306 * else go into sleep mode (low power, memory and registers are maintained, peripherals stay on)
Mike Fiore 7:683dba5d576f 1307 *
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1308 * For the MDOT
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1309 * 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 1310 * 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 1311 * For the XDOT
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1312 * 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 1313 * in deepsleep mode, the device can only be woken up using the WKUP pin (PA0, WAKE) or by the RTC alarm
Mike Fiore 7:683dba5d576f 1314 */
Mike Fiore 7:683dba5d576f 1315 void sleep(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM, const bool& deepsleep = true);
Mike Fiore 7:683dba5d576f 1316
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1317 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1318 * Set wake pin
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1319 * @param pin the pin to use to wake the device from sleep mode
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1320 * For MDOT, XBEE_DI (2-8)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1321 * For XDOT, GPIO (0-3), UART1_RX, or WAKE
Mike Fiore 7:683dba5d576f 1322 */
Mike Fiore 7:683dba5d576f 1323 void setWakePin(const PinName& pin);
Mike Fiore 7:683dba5d576f 1324
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1325 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1326 * Get wake pin
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1327 * @returns the pin to use to wake the device from sleep mode
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1328 * For MDOT, XBEE_DI (2-8)
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1329 * For XDOT, GPIO (0-3), UART1_RX, or WAKE
Mike Fiore 7:683dba5d576f 1330 */
Mike Fiore 7:683dba5d576f 1331 PinName getWakePin();
Mike Fiore 7:683dba5d576f 1332
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1333 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1334 * Write data in a user backup register
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1335 * @param register one of UBR0 through UBR9 for MDOT, one of UBR0 through UBR21 for XDOT
jreiss 9:ec2fffe31793 1336 * @param data user data to back up
jreiss 9:ec2fffe31793 1337 * @returns true if success
jreiss 9:ec2fffe31793 1338 */
jreiss 9:ec2fffe31793 1339 bool writeUserBackupRegister(uint32_t reg, uint32_t data);
jreiss 9:ec2fffe31793 1340
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1341 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1342 * Read data in a user backup register
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1343 * @param register one of UBR0 through UBR9 for MDOT, one of UBR0 through UBR21 for XDOT
jreiss 9:ec2fffe31793 1344 * @param data gets set to content of register
jreiss 9:ec2fffe31793 1345 * @returns true if success
jreiss 9:ec2fffe31793 1346 */
jreiss 9:ec2fffe31793 1347 bool readUserBackupRegister(uint32_t reg, uint32_t& data);
jreiss 9:ec2fffe31793 1348
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1349 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1350 * Set LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1351 * @param ms time in us
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1352 * @returns true if success
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1353 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1354 bool setLbtTimeUs(uint16_t us);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1355
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1356 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1357 * Get LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1358 * @returns LBT time in us
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1359 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1360 uint16_t getLbtTimeUs();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1361
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1362 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1363 * Set LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1364 * @param rssi threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1365 * @returns true if success
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1366 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1367 bool setLbtThreshold(int8_t rssi);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1368
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1369 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1370 * Get LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1371 * @returns LBT threshold in dBm
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1372 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1373 int8_t getLbtThreshold();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1374
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1375 #if defined(TARGET_MTS_MDOT_F411RE)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1376 ///////////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1377 // Filesystem (Non Volatile Memory) Operation Functions for mDot //
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1378 ///////////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1379
Mike Fiore 11:d8464345e1f1 1380 // Save user file data to flash
Mike Fiore 11:d8464345e1f1 1381 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1382 // data - data of file
Mike Fiore 11:d8464345e1f1 1383 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1384 // returns true if successful
Mike Fiore 11:d8464345e1f1 1385 bool saveUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1386
Mike Fiore 11:d8464345e1f1 1387 // Append user file data to flash
Mike Fiore 11:d8464345e1f1 1388 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1389 // data - data of file
Mike Fiore 11:d8464345e1f1 1390 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1391 // returns true if successful
Mike Fiore 11:d8464345e1f1 1392 bool appendUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1393
Mike Fiore 11:d8464345e1f1 1394 // Read user file data from flash
Mike Fiore 11:d8464345e1f1 1395 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1396 // data - data of file
Mike Fiore 11:d8464345e1f1 1397 // size - size of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1398 // returns true if successful
Mike Fiore 11:d8464345e1f1 1399 bool readUserFile(const char* file, void* data, uint32_t size);
Mike Fiore 11:d8464345e1f1 1400
Mike Fiore 11:d8464345e1f1 1401 // Move a user file in flash
Mike Fiore 11:d8464345e1f1 1402 // file - name of file
Mike Fiore 11:d8464345e1f1 1403 // new_name - new name of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1404 // returns true if successful
Mike Fiore 11:d8464345e1f1 1405 bool moveUserFile(const char* file, const char* new_name);
Mike Fiore 11:d8464345e1f1 1406
Mike Fiore 11:d8464345e1f1 1407 // Delete user file data from flash
Mike Fiore 11:d8464345e1f1 1408 // file - name of file max 30 chars
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1409 // returns true if successful
Mike Fiore 11:d8464345e1f1 1410 bool deleteUserFile(const char* file);
Mike Fiore 11:d8464345e1f1 1411
Mike Fiore 11:d8464345e1f1 1412 // Open user file in flash, max of 4 files open concurrently
Mike Fiore 11:d8464345e1f1 1413 // file - name of file max 30 chars
Mike Fiore 11:d8464345e1f1 1414 // mode - combination of FM_APPEND | FM_TRUNC | FM_CREAT |
Mike Fiore 11:d8464345e1f1 1415 // FM_RDONLY | FM_WRONLY | FM_RDWR | FM_DIRECT
Mike Fiore 11:d8464345e1f1 1416 // returns - mdot_file struct, fd field will be a negative value if file could not be opened
Mike Fiore 11:d8464345e1f1 1417 mDot::mdot_file openUserFile(const char* file, int mode);
Mike Fiore 11:d8464345e1f1 1418
Mike Fiore 11:d8464345e1f1 1419 // Seek an open file
Mike Fiore 11:d8464345e1f1 1420 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1421 // offset - offset in bytes
Mike Fiore 11:d8464345e1f1 1422 // whence - where offset is based SEEK_SET, SEEK_CUR, SEEK_END
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1423 // returns true if successful
Mike Fiore 11:d8464345e1f1 1424 bool seekUserFile(mDot::mdot_file& file, size_t offset, int whence);
Mike Fiore 11:d8464345e1f1 1425
Mike Fiore 11:d8464345e1f1 1426 // Read bytes from open file
Mike Fiore 11:d8464345e1f1 1427 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1428 // data - mem location to store data
Mike Fiore 11:d8464345e1f1 1429 // length - number of bytes to read
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1430 // returns - number of bytes read, negative if error
Mike Fiore 11:d8464345e1f1 1431 int readUserFile(mDot::mdot_file& file, void* data, size_t length);
Mike Fiore 11:d8464345e1f1 1432
Mike Fiore 11:d8464345e1f1 1433 // Write bytes to open file
Mike Fiore 11:d8464345e1f1 1434 // file - mdot file struct
Mike Fiore 11:d8464345e1f1 1435 // data - data to write
Mike Fiore 11:d8464345e1f1 1436 // length - number of bytes to write
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1437 // returns - number of bytes written, negative if error
Mike Fiore 11:d8464345e1f1 1438 int writeUserFile(mDot::mdot_file& file, void* data, size_t length);
Mike Fiore 11:d8464345e1f1 1439
Mike Fiore 11:d8464345e1f1 1440 // Close open file
Mike Fiore 11:d8464345e1f1 1441 // file - mdot file struct
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1442 // returns true if successful
Mike Fiore 11:d8464345e1f1 1443 bool closeUserFile(mDot::mdot_file& file);
Mike Fiore 11:d8464345e1f1 1444
Mike Fiore 11:d8464345e1f1 1445 // List user files stored in flash
Mike Fiore 11:d8464345e1f1 1446 std::vector<mDot::mdot_file> listUserFiles();
Mike Fiore 11:d8464345e1f1 1447
Mike Fiore 11:d8464345e1f1 1448 // Move file into the firmware upgrade path to be flashed on next boot
Mike Fiore 11:d8464345e1f1 1449 // file - name of file
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1450 // returns true if successful
Mike Fiore 11:d8464345e1f1 1451 bool moveUserFileToFirmwareUpgrade(const char* file);
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1452 #else
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1453 ///////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1454 // EEPROM (Non Volatile Memory) Operation Functions for xDot //
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1455 ///////////////////////////////////////////////////////////////
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1456
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1457 // Write to EEPROM
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1458 // addr - address to write to (0 - 0x17FF)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1459 // data - data to write
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1460 // size - size of data
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1461 // returns true if successful
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1462 bool nvmWrite(uint16_t addr, void* data, uint16_t size);
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1463
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1464 // Read from EEPROM
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1465 // addr - address to read from (0 - 0x17FF)
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1466 // data - buffer for data
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1467 // size - size of buffer
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1468 // returns true if successful
Jenkins@KEILDM1.dc.multitech.prv 31:7fdee197d415 1469 bool nvmRead(uint16_t addr, void* data, uint16_t size);
Jenkins@KEILDM1.dc.multitech.prv 19:f3a46d2bb9b3 1470 #endif /* TARGET_MTS_MDOT_F411RE */
Mike Fiore 11:d8464345e1f1 1471
Mike Fiore 11:d8464345e1f1 1472 // get current statistics
Mike Fiore 11:d8464345e1f1 1473 // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
Mike Fiore 11:d8464345e1f1 1474 mdot_stats getStats();
Mike Fiore 11:d8464345e1f1 1475
Mike Fiore 11:d8464345e1f1 1476 // reset statistics
Mike Fiore 11:d8464345e1f1 1477 // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
Mike Fiore 11:d8464345e1f1 1478 void resetStats();
Mike Fiore 11:d8464345e1f1 1479
Mike Fiore 11:d8464345e1f1 1480 // Convert pin number 2-8 to pin name DIO2-DI8
Mike Fiore 11:d8464345e1f1 1481 static PinName pinNum2Name(uint8_t num);
Mike Fiore 11:d8464345e1f1 1482
Mike Fiore 11:d8464345e1f1 1483 // Convert pin name DIO2-DI8 to pin number 2-8
Mike Fiore 11:d8464345e1f1 1484 static uint8_t pinName2Num(PinName name);
Mike Fiore 11:d8464345e1f1 1485
Mike Fiore 11:d8464345e1f1 1486 // Convert pin name DIO2-DI8 to string
Mike Fiore 11:d8464345e1f1 1487 static std::string pinName2Str(PinName name);
Mike Fiore 11:d8464345e1f1 1488
Mike Fiore 11:d8464345e1f1 1489 uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l);
mfiore 0:c62615f15125 1490
mfiore 0:c62615f15125 1491 /*************************************************************************
mfiore 0:c62615f15125 1492 * The following functions are only used by the AT command application and
mfiore 0:c62615f15125 1493 * should not be used by standard applications consuming the mDot library
mfiore 0:c62615f15125 1494 ************************************************************************/
Mike Fiore 7:683dba5d576f 1495
mfiore 0:c62615f15125 1496 // set/get configured baud rate for command port
mfiore 0:c62615f15125 1497 // only for use in conjunction with AT interface
mfiore 0:c62615f15125 1498 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1499 int32_t setBaud(const uint32_t& baud);
mfiore 0:c62615f15125 1500 uint32_t getBaud();
mfiore 0:c62615f15125 1501
mfiore 0:c62615f15125 1502 // set/get baud rate for debug port
mfiore 0:c62615f15125 1503 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1504 int32_t setDebugBaud(const uint32_t& baud);
mfiore 0:c62615f15125 1505 uint32_t getDebugBaud();
mfiore 0:c62615f15125 1506
mfiore 0:c62615f15125 1507 // set/get command terminal echo
mfiore 0:c62615f15125 1508 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1509 int32_t setEcho(const bool& on);
mfiore 0:c62615f15125 1510 bool getEcho();
mfiore 0:c62615f15125 1511
mfiore 0:c62615f15125 1512 // set/get command terminal verbose mode
mfiore 0:c62615f15125 1513 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1514 int32_t setVerbose(const bool& on);
mfiore 0:c62615f15125 1515 bool getVerbose();
mfiore 0:c62615f15125 1516
mfiore 0:c62615f15125 1517 // set/get startup mode
mfiore 0:c62615f15125 1518 // COMMAND_MODE (default), starts up ready to accept AT commands
mfiore 0:c62615f15125 1519 // SERIAL_MODE, read serial data and send it as LoRa packets
mfiore 0:c62615f15125 1520 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1521 int32_t setStartUpMode(const uint8_t& mode);
mfiore 0:c62615f15125 1522 uint8_t getStartUpMode();
mfiore 0:c62615f15125 1523
mfiore 0:c62615f15125 1524 int32_t setRxDataRate(const uint8_t& dr);
mfiore 0:c62615f15125 1525 uint8_t getRxDataRate();
mfiore 0:c62615f15125 1526
mfiore 0:c62615f15125 1527 // get/set TX/RX frequency
mfiore 0:c62615f15125 1528 // if frequency band == FB_868 (Europe), must be between 863000000 - 870000000
mfiore 0:c62615f15125 1529 // if frequency band == FB_915 (United States), must be between 902000000-928000000
mfiore 0:c62615f15125 1530 // if set to 0, device will hop frequencies
mfiore 0:c62615f15125 1531 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1532 int32_t setTxFrequency(const uint32_t& freq);
mfiore 0:c62615f15125 1533 uint32_t getTxFrequency();
mfiore 0:c62615f15125 1534 int32_t setRxFrequency(const uint32_t& freq);
mfiore 0:c62615f15125 1535 uint32_t getRxFrequency();
mfiore 0:c62615f15125 1536
mfiore 0:c62615f15125 1537 // get/set TX/RX inverted
mfiore 0:c62615f15125 1538 // true == signal is inverted
mfiore 0:c62615f15125 1539 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1540 int32_t setTxInverted(const bool& on);
mfiore 0:c62615f15125 1541 bool getTxInverted();
mfiore 0:c62615f15125 1542 int32_t setRxInverted(const bool& on);
mfiore 0:c62615f15125 1543 bool getRxInverted();
mfiore 0:c62615f15125 1544
mfiore 0:c62615f15125 1545 // get/set RX output mode
mfiore 0:c62615f15125 1546 // valid options are HEXADECIMAL and BINARY
mfiore 0:c62615f15125 1547 // set function returns MDOT_OK if success
mfiore 0:c62615f15125 1548 int32_t setRxOutput(const uint8_t& mode);
mfiore 0:c62615f15125 1549 uint8_t getRxOutput();
mfiore 0:c62615f15125 1550
mfiore 0:c62615f15125 1551 // get/set serial wake interval
mfiore 0:c62615f15125 1552 // valid values are 2 s - INT_MAX (2147483647) s
mfiore 0:c62615f15125 1553 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1554 int32_t setWakeInterval(const uint32_t& interval);
Mike Fiore 7:683dba5d576f 1555 uint32_t getWakeInterval();
mfiore 0:c62615f15125 1556
mfiore 0:c62615f15125 1557 // get/set serial wake delay
mfiore 0:c62615f15125 1558 // valid values are 2 ms - INT_MAX (2147483647) ms
mfiore 0:c62615f15125 1559 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1560 int32_t setWakeDelay(const uint32_t& delay);
Mike Fiore 7:683dba5d576f 1561 uint32_t getWakeDelay();
mfiore 0:c62615f15125 1562
mfiore 0:c62615f15125 1563 // get/set serial receive timeout
mfiore 0:c62615f15125 1564 // valid values are 0 ms - 65000 ms
mfiore 0:c62615f15125 1565 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1566 int32_t setWakeTimeout(const uint16_t& timeout);
Mike Fiore 7:683dba5d576f 1567 uint16_t getWakeTimeout();
Mike Fiore 7:683dba5d576f 1568
Mike Fiore 7:683dba5d576f 1569 // get/set serial wake mode
Mike Fiore 7:683dba5d576f 1570 // valid values are INTERRUPT or RTC_ALARM
Mike Fiore 7:683dba5d576f 1571 // set function returns MDOT_OK if success
Mike Fiore 7:683dba5d576f 1572 int32_t setWakeMode(const uint8_t& delay);
Mike Fiore 7:683dba5d576f 1573 uint8_t getWakeMode();
Mike Fiore 7:683dba5d576f 1574
Mike Fiore 12:54f9cac9d690 1575 // get/set serial flow control enabled
Mike Fiore 12:54f9cac9d690 1576 // set function returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1577 int32_t setFlowControl(const bool& on);
Mike Fiore 12:54f9cac9d690 1578 bool getFlowControl();
Mike Fiore 12:54f9cac9d690 1579
Mike Fiore 12:54f9cac9d690 1580 // get/set serial clear on error
Mike Fiore 12:54f9cac9d690 1581 // 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 1582 // set function returns MDOT_OK if success
Mike Fiore 12:54f9cac9d690 1583 int32_t setSerialClearOnError(const bool& on);
Mike Fiore 12:54f9cac9d690 1584 bool getSerialClearOnError();
mfiore 0:c62615f15125 1585
mfiore 0:c62615f15125 1586 // MTS_RADIO_DEBUG_COMMANDS
Mike Fiore 7:683dba5d576f 1587
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1588 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1589 * Disable Duty cycle
Mike Fiore 16:b630e18103e5 1590 * enables or disables the duty cycle limitations
Mike Fiore 16:b630e18103e5 1591 * **** ONLY TO BE USED FOR TESTINGS PURPOSES ****
Mike Fiore 16:b630e18103e5 1592 * **** ALL DEPLOYABLE CODE MUST ADHERE TO LOCAL REGULATIONS ****
Mike Fiore 16:b630e18103e5 1593 * **** THIS SETTING WILL NOT BE SAVED TO CONFIGURATION *****
Mike Fiore 16:b630e18103e5 1594 * @param val true to disable duty-cycle (default:false)
Mike Fiore 16:b630e18103e5 1595 */
Mike Fiore 16:b630e18103e5 1596 int32_t setDisableDutyCycle(bool val);
Mike Fiore 16:b630e18103e5 1597
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1598 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1599 * Disable Duty cycle
Mike Fiore 16:b630e18103e5 1600 * **** ONLY TO BE USED FOR TESTINGS PURPOSES ****
Mike Fiore 16:b630e18103e5 1601 * **** ALL DEPLOYABLE CODE MUST ADHERE TO LOCAL REGULATIONS ****
Mike Fiore 16:b630e18103e5 1602 * **** THIS SETTING WILL NOT BE SAVED TO CONFIGURATION *****
Mike Fiore 16:b630e18103e5 1603 * @return true if duty-cycle is disabled (default:false)
Mike Fiore 16:b630e18103e5 1604 */
Mike Fiore 16:b630e18103e5 1605 uint8_t getDisableDutyCycle();
Mike Fiore 16:b630e18103e5 1606
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1607 /**
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1608 * LBT RSSI
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1609 * @return the current RSSI on the configured frequency (SetTxFrequency) using configured LBT Time
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1610 */
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1611 int16_t lbtRssi();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1612
Mike Fiore 7:683dba5d576f 1613 void openRxWindow(uint32_t timeout, uint8_t bandwidth = 0);
Mike Fiore 16:b630e18103e5 1614 void closeRxWindow();
Mike Fiore 16:b630e18103e5 1615 void sendContinuous(bool enable=true);
mfiore 0:c62615f15125 1616 int32_t setDeviceId(const std::vector<uint8_t>& id);
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1617 int32_t setDefaultFrequencyBand(const uint8_t& band);
mfiore 0:c62615f15125 1618 bool saveProtectedConfig();
mfiore 0:c62615f15125 1619 void resetRadio();
mfiore 0:c62615f15125 1620 int32_t setRadioMode(const uint8_t& mode);
mfiore 0:c62615f15125 1621 std::map<uint8_t, uint8_t> dumpRegisters();
mfiore 0:c62615f15125 1622 void eraseFlash();
mfiore 0:c62615f15125 1623
Mike Fiore 7:683dba5d576f 1624 // deprecated - use setWakeInterval
Mike Fiore 7:683dba5d576f 1625 int32_t setSerialWakeInterval(const uint32_t& interval);
Mike Fiore 7:683dba5d576f 1626 // deprecated - use getWakeInterval
Mike Fiore 7:683dba5d576f 1627 uint32_t getSerialWakeInterval();
Mike Fiore 6:390fc83d588d 1628
Mike Fiore 7:683dba5d576f 1629 // deprecated - use setWakeDelay
Mike Fiore 7:683dba5d576f 1630 int32_t setSerialWakeDelay(const uint32_t& delay);
Mike Fiore 7:683dba5d576f 1631 // deprecated - use setWakeDelay
Mike Fiore 7:683dba5d576f 1632 uint32_t getSerialWakeDelay();
Mike Fiore 7:683dba5d576f 1633
Mike Fiore 7:683dba5d576f 1634 // deprecated - use setWakeTimeout
Mike Fiore 7:683dba5d576f 1635 int32_t setSerialReceiveTimeout(const uint16_t& timeout);
Mike Fiore 7:683dba5d576f 1636 // deprecated - use getWakeTimeout
Mike Fiore 7:683dba5d576f 1637 uint16_t getSerialReceiveTimeout();
mfiore 0:c62615f15125 1638
Mike Fiore 11:d8464345e1f1 1639 void setWakeupCallback(void (*function)(void));
Mike Fiore 11:d8464345e1f1 1640
Mike Fiore 11:d8464345e1f1 1641 template<typename T>
Mike Fiore 11:d8464345e1f1 1642 void setWakeupCallback(T *object, void (T::*member)(void)) {
Mike Fiore 11:d8464345e1f1 1643 _wakeup_callback.attach(object, member);
Mike Fiore 11:d8464345e1f1 1644 }
Mike Fiore 11:d8464345e1f1 1645
mfiore 0:c62615f15125 1646 private:
mfiore 0:c62615f15125 1647 mdot_stats _stats;
mfiore 0:c62615f15125 1648
Mike Fiore 11:d8464345e1f1 1649 FunctionPointer _wakeup_callback;
Mike Fiore 11:d8464345e1f1 1650
Mike Fiore 12:54f9cac9d690 1651 bool _standbyFlag;
Mike Fiore 12:54f9cac9d690 1652 bool _testMode;
Mike Fiore 12:54f9cac9d690 1653 uint8_t _savedPort;
Mike Fiore 12:54f9cac9d690 1654 void handleTestModePacket();
Jenkins@KEILDM1.dc.multitech.prv 81:d8f2c4e664f5 1655 lora::ChannelPlan* _plan;
mfiore 0:c62615f15125 1656 };
mfiore 0:c62615f15125 1657
mfiore 0:c62615f15125 1658 #endif