Stable version of the xDot library for mbed 5. This version of the library is suitable for deployment scenarios.

Dependents:   Dot-Examples XDOT-Devicewise Dot-Examples-delujoc Dot-Examples_receive ... more

Fork of libxDot-dev-mbed5-deprecated by MultiTech

The Dot library provides a LoRaWan certified stack for LoRa communication using MultiTech mDot and xDot devices. The stack is compatible with mbed 5.

The name of the repository can be used to determine which device the stack was compiled for and if it's a development or production-ready build:

A changelog for the Dot library can be found here.

The Dot library version and the version of mbed-os it was compiled against can both be found in the commit message for that revision of the Dot library. Building your application with the same version of mbed-os as what was used to build the Dot library is highly recommended!

The Dot-Examples repository demonstrates how to use the Dot library in a custom application.

The mDot and xDot platform pages have lots of platform specific information and document potential issues, gotchas, etc, and provide instructions for getting started with development. Please take a look at the platform page before starting development as they should answer many questions you will have.

FOTA

Full FOTA support is only available with mDot, xDot does not have the required external flash. xDot can use the FOTA example to dynamically join a multicast session only. After joining the multicast session the received Fragmentation packets could be handed to a host MCU for processing and at completion the firmware can be loaded into the xDot using the bootloader and y-modem. See xDot Developer Guide.

  • Add the following code to allow Fota to use the Dot instance

examples/src/fota_example.cpp

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

examples/inc/RadioEvent.h

    virtual void PacketRx(uint8_t port, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot, uint8_t retries, uint32_t address, bool dupRx) {
        mDotEvent::PacketRx(port, payload, size, rssi, snr, ctrl, slot, retries, address, dupRx);

#if ACTIVE_EXAMPLE == FOTA_EXAMPLE
        if(port == 200 || port == 201 || port == 202) {
            Fota::getInstance()->processCmd(payload, port, size);
        }
#endif
    }

The FOTA implementation has a few differences from the LoRaWAN Protocol

  • Fragmentation Indexing starts at 0
  • McKEKey is 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
  • Start Time is a count-down in seconds to start of session
Committer:
Jenkins@KEILDM1.dc.multitech.prv
Date:
Thu Aug 23 14:21:20 2018 -0500
Revision:
14:f0c24ce93427
Parent:
10:1e831990a669
Child:
16:4a382fe8f51b
mdot-library revision 3.1.0 and mbed-os revision mbed-os-5.7.7

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 1 /** __ ___ ____ _ ______ __ ____ __ ____
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 2 * / |/ /_ __/ / /_(_)__/_ __/__ ____/ / / __/_ _____ / /____ __ _ ___ / _/__ ____
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 3 * / /|_/ / // / / __/ /___// / / -_) __/ _ \ _\ \/ // (_-</ __/ -_) ' \(_-< _/ // _ \/ __/ __
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 4 * /_/ /_/\_,_/_/\__/_/ /_/ \__/\__/_//_/ /___/\_, /___/\__/\__/_/_/_/___/ /___/_//_/\__/ /_/
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 5 * Copyright (C) 2015 by Multi-Tech Systems /___/
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 6 *
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 7 *
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 8 * @author Jason Reiss
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 9 * @date 10-31-2015
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 10 * @brief lora namespace defines global settings, structures and enums for the lora library
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 11 *
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 12 * @details
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 13 *
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 14 *
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 15 *
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 16 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 17
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 18 #ifndef __LORA_H__
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 19 #define __LORA_H__
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 20
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 21 #include "mbed.h"
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 22 #include <assert.h>
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 23 #include "MTSLog.h"
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 24 //#include <cstring>
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 25 #include <inttypes.h>
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 26
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 27 namespace lora {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 28
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 29 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 30 * Frequency bandwidth of a Datarate, higher bandwidth gives higher datarate
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 31 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 32 enum Bandwidth {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 33 BW_125,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 34 BW_250,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 35 BW_500,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 36 BW_FSK = 50
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 37 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 38
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 39 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 40 * Spreading factor of a Datarate, lower spreading factor gives higher datarate
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 41 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 42 enum SpreadingFactors {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 43 SF_6 = 6,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 44 SF_7,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 45 SF_8,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 46 SF_9,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 47 SF_10,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 48 SF_11,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 49 SF_12,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 50 SF_FSK,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 51 SF_INVALID
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 52 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 53
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 54 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 55 * Datarates for use with ChannelPlan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 56 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 57 enum Datarates {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 58 DR_0 = 0,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 59 DR_1,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 60 DR_2,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 61 DR_3,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 62 DR_4,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 63 DR_5,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 64 DR_6,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 65 DR_7,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 66 DR_8,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 67 DR_9,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 68 DR_10,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 69 DR_11,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 70 DR_12,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 71 DR_13,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 72 DR_14,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 73 DR_15
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 74 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 75
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 76 const uint8_t MIN_DATARATE = (uint8_t) DR_0; //!< Minimum datarate
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 77
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 78
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 79 const uint8_t MAX_PHY_PACKET_SIZE = 255; //!< Maximum size for a packet
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 80 const uint8_t MAX_APPS = 8; //!< Maximum number of apps sessions to save
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 81 const uint8_t MAX_MULTICAST_SESSIONS = 8; //!< Maximum number of multicast sessions to save
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 82 const uint8_t EUI_SIZE = 8; //!< Number of bytes in an EUI
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 83 const uint8_t KEY_SIZE = 16; //!< Number of bytes in an AES key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 84
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 85 const uint8_t DEFAULT_NUM_CHANNELS = 16; //!< Default number of channels in a plan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 86 const uint8_t DEFAULT_RX1_DR_OFFSET = 0; //!< Default datarate offset for first rx window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 87 const uint8_t DEFAULT_RX2_DATARATE = 0; //!< Default datarate for second rx window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 88 const uint8_t DEFAULT_TX_POWER = 14; //!< Default transmit power
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 89 const uint8_t DEFAULT_CODE_RATE = 1; //!< Default coding rate 1:4/5, 2:4/6, 3:4/7, 4:4/8
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 90 const uint8_t DEFAULT_PREAMBLE_LEN = 8; //!< Default preamble length
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 91
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 92 const int32_t MAX_FCNT_GAP = 16384; //!< Maximum allowed gap in sequence numbers before roll-over
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 93
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 94 const uint16_t PRIVATE_JOIN_DELAY = 1000; //!< Default join delay used for private network
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 95 const uint16_t PUBLIC_JOIN_DELAY = 5000; //!< Default join delay used for public network
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 96 const uint16_t DEFAULT_JOIN_DELAY = PRIVATE_JOIN_DELAY; //!< Default join delay1
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 97 const uint16_t DEFAULT_RX_DELAY = 1000; //!< Default delay for first receive window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 98 const uint16_t DEFAULT_RX_TIMEOUT = 3000; //!< Default timeout for receive windows
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 99
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 100 const uint8_t HI_DR_SYMBOL_TIMEOUT = 12; //!< Symbol timeout for receive at datarate with SF < 11
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 101 const uint8_t LO_DR_SYMBOL_TIMEOUT = 8; //!< Symbol timeout for receive at datarate with SF > 10
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 102
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 103 const uint16_t RX2_DELAY_OFFSET = 1000; //!< Delay between first and second window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 104 const uint16_t RXC_OFFSET = 50; //!< Time between end of RXC after TX and RX1
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 105
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 106 const uint8_t US915_125K_NUM_CHANS = 64; //!< Number of 125k channels in US915 channel plan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 107 const uint8_t US915_500K_NUM_CHANS = 8; //!< Number of 500k channels in US915 channel plan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 108
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 109 const uint32_t US915_125K_FREQ_BASE = 902300000; //!< Frequency base for 125k US915 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 110 const uint32_t US915_125K_FREQ_STEP = 200000; //!< Frequency step for 125k US915 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 111
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 112 const uint32_t US915_500K_FREQ_BASE = 903000000; //!< Frequency base for 500k US915 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 113 const uint32_t US915_500K_FREQ_STEP = 1600000; //!< Frequency step for 500k US915 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 114
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 115 const uint32_t US915_500K_DBASE = 923300000; //!< Frequency base for 500k US915 downlink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 116 const uint32_t US915_500K_DSTEP = 600000; //!< Frequency step for 500k US915 downlink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 117
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 118 const uint32_t US915_FREQ_MIN = 902000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 119 const uint32_t US915_FREQ_MAX = 928000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 120
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 121 const uint8_t US915_MIN_DATARATE = (uint8_t) DR_0; //!< Minimum transmit datarate for US915
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 122 const uint8_t US915_MAX_DATARATE = (uint8_t) DR_4; //!< Maximum transmit datarate for US915
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 123
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 124 const uint8_t US915_MIN_DATARATE_OFFSET = (uint8_t) 0; //!< Minimum transmit datarate for US915
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 125 const uint8_t US915_MAX_DATARATE_OFFSET = (uint8_t) 3; //!< Maximum transmit datarate for US915
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 126
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 127 const uint8_t AU915_125K_NUM_CHANS = 64; //!< Number of 125k channels in AU915 channel plan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 128 const uint8_t AU915_500K_NUM_CHANS = 8; //!< Number of 500k channels in AU915 channel plan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 129
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 130 const uint32_t AU915_125K_FREQ_BASE = 915200000; //!< Frequency base for 125k AU915 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 131 const uint32_t AU915_125K_FREQ_STEP = 200000; //!< Frequency step for 125k AU915 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 132
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 133 const uint32_t AU915_500K_FREQ_BASE = 915900000; //!< Frequency base for 500k AU915 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 134 const uint32_t AU915_500K_FREQ_STEP = 1600000; //!< Frequency step for 500k AU915 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 135
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 136 const uint32_t AU915_500K_DBASE = 923300000; //!< Frequency base for 500k AU915 downlink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 137 const uint32_t AU915_500K_DSTEP = 600000; //!< Frequency step for 500k AU915 downlink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 138
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 139 const uint32_t AU915_FREQ_MIN = 915000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 140 const uint32_t AU915_FREQ_MAX = 928000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 141
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 142 const uint8_t AU915_MIN_DATARATE = (uint8_t) DR_0; //!< Minimum transmit datarate for AU915
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 143 const uint8_t AU915_MAX_DATARATE = (uint8_t) DR_6; //!< Maximum transmit datarate for AU915
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 144
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 145 const uint8_t AU915_MIN_DATARATE_OFFSET = (uint8_t) 0; //!< Minimum transmit datarate for AU915
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 146 const uint8_t AU915_MAX_DATARATE_OFFSET = (uint8_t) 5; //!< Maximum transmit datarate for AU915
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 147
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 148 const uint8_t EU868_125K_NUM_CHANS = 16; //!< Number of 125k channels in EU868 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 149 const uint8_t EU868_DEFAULT_NUM_CHANS = 3; //!< Number of default channels in EU868 channel plan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 150 const uint32_t EU868_125K_FREQ_BASE = 868100000; //!< Frequency base for 125k EU868 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 151 const uint32_t EU868_125K_FREQ_STEP = 200000; //!< Frequency step for 125k EU868 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 152 const uint32_t EU868_RX2_FREQ = 869525000; //!< Frequency default for second rx window in EU868
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 153
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 154 const uint8_t EU868_TX_POWER_MAX = 14; //!< Max power for EU868 channel plan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 155
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 156 const uint8_t KR920_125K_NUM_CHANS = 16; //!< Number of 125k channels in KR920 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 157 const uint8_t KR920_DEFAULT_NUM_CHANS = 3; //!< Number of default channels in KR920 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 158 const uint32_t KR920_125K_FREQ_BASE = 868100000; //!< Frequency base for 125k KR920 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 159 const uint32_t KR920_125K_FREQ_STEP = 200000; //!< Frequency step for 125k KR920 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 160 const uint32_t KR920_RX2_FREQ = 869525000; //!< Frequency default for second rx window in KR920
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 161
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 162 const uint8_t KR920_TX_POWER_MAX = 14; //!< Max power for KR920 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 163
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 164 const uint8_t AS923_125K_NUM_CHANS = 16; //!< Number of 125k channels in AS923 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 165 const uint8_t AS923_DEFAULT_NUM_CHANS = 2; //!< Number of default channels in AS923 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 166 const uint32_t AS923_125K_FREQ_BASE = 868100000; //!< Frequency base for 125k AS923 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 167 const uint32_t AS923_125K_FREQ_STEP = 200000; //!< Frequency step for 125k AS923 uplink channels
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 168 const uint32_t AS923_RX2_FREQ = 869525000; //!< Frequency default for second rx window in AS923
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 169
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 170 const uint8_t AS923_TX_POWER_MAX = 14; //!< Max power for AS923 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 171
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 172 const uint8_t IN865_125K_NUM_CHANS = 16; //!< Number of 125k channels in IN865 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 173 const uint8_t IN865_DEFAULT_NUM_CHANS = 3; //!< Number of default channels in IN865 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 174 const uint32_t IN865_125K_DEF_FREQ_1 = 865062500;
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 175 const uint32_t IN865_125K_DEF_FREQ_2 = 865402500;
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 176 const uint32_t IN865_125K_DEF_FREQ_3 = 865985000;
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 177 const uint32_t IN865_RX2_FREQ = 866550000; //!< Frequency default for second rx window in IN865
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 178
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 179 const uint8_t IN865_TX_POWER_MAX = 30; //!< Max power for IN865 channel plan
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 180
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 181 // 0.1% duty cycle 863-868
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 182 // Limiting to 865-868 allows for 1% duty cycle
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 183 const uint32_t EU868_MILLI_FREQ_MIN = 865000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 184 const uint32_t EU868_MILLI_FREQ_MAX = 868000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 185
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 186 const uint32_t EU868_MILLI_1_FREQ_MIN = 868700000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 187 const uint32_t EU868_MILLI_1_FREQ_MAX = 869200000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 188
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 189 // 1% duty cycle
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 190 const uint32_t EU868_CENTI_FREQ_MIN = 868000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 191 const uint32_t EU868_CENTI_FREQ_MAX = 868600000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 192
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 193 // 10% duty cycle
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 194 const uint32_t EU868_DECI_FREQ_MIN = 869400000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 195 const uint32_t EU868_DECI_FREQ_MAX = 869650000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 196
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 197 // Below 7dBm there is no duty cycle for these frequencies
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 198 // Up to 14dBm there is 1% duty cycle
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 199 const uint32_t EU868_VAR_FREQ_MIN = 869700000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 200 const uint32_t EU868_VAR_FREQ_MAX = 870000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 201
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 202 const uint32_t EU868_FREQ_MIN = 863000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 203 const uint32_t EU868_FREQ_MAX = 870000000;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 204
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 205 const uint8_t EU868_MIN_DATARATE = (uint8_t) DR_0; //!< Minimum transmit datarate for EU868
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 206 const uint8_t EU868_MAX_DATARATE = (uint8_t) DR_7; //!< Maximum transmit datarate for EU868
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 207
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 208 const uint8_t EU868_MIN_DATARATE_OFFSET = (uint8_t) 0; //!< Minimum transmit datarate for US915
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 209 const uint8_t EU868_MAX_DATARATE_OFFSET = (uint8_t) 5; //!< Maximum transmit datarate for US915
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 210
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 211 const int16_t DEFAULT_FREE_CHAN_RSSI_THRESHOLD = -90; //!< Threshold for channel activity detection (CAD) dBm
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 212
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 213 const uint8_t CHAN_MASK_SIZE = 16; //!< Number of bits in a channel mask
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 214 const uint8_t COMMANDS_BUFFER_SIZE = 15; //!< Size of Mac Command buffer
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 215
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 216 const uint8_t PKT_HEADER = 0; //!< Index to packet mHdr field
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 217 const uint8_t PKT_ADDRESS = 1; //!< Index to first byte of packet address field
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 218 const uint8_t PKT_FRAME_CONTROL = PKT_ADDRESS + 4; //!< Index to packet fCtrl field @see UplinkControl
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 219 const uint8_t PKT_FRAME_COUNTER = PKT_FRAME_CONTROL + 1; //!< Index to packet frame counter field
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 220 const uint8_t PKT_OPTIONS_START = PKT_FRAME_COUNTER + 2; //!< Index to start of optional mac commands
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 221
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 222 const uint8_t PKT_JOIN_APP_NONCE = 1; //!< Index to application nonce in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 223 const uint8_t PKT_JOIN_NETWORK_ID = 4; //!< Index to network id in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 224 const uint8_t PKT_JOIN_NETWORK_ADDRESS = 7; //!< Index to network address in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 225 const uint8_t PKT_JOIN_DL_SETTINGS = 11; //!< Index to downlink settings in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 226 const uint8_t PKT_JOIN_RX_DELAY = 12; //!< Index to rx delay in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 227
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 228 const uint8_t ADR_ACK_LIMIT = 64; //!< Number of packets without ADR ACK Request
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 229 const uint8_t ADR_ACK_DELAY = 32; //!< Number of packets to expect ADR ACK Response within
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 230
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 231 const uint16_t ACK_TIMEOUT = 2000; //!< Base millisecond timeout to resend after missed ACK
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 232 const uint16_t ACK_TIMEOUT_RND = 1000; //!< Random millisecond adjustment to resend after missed ACK
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 233
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 234 const uint8_t FRAME_OVERHEAD = 13; //!< Bytes of network info overhead in a frame
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 235
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 236 const uint16_t MAX_OFF_AIR_WAIT = 5000U; //!< Max time in ms to block for a duty cycle restriction to expire before erroring out
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 237 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 238 * Settings for type of network
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 239 *
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 240 * PRIVATE_MTS - Sync Word 0x12, US/AU Downlink frequencies per Frequency Sub Band
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 241 * PUBLIC_LORAWAN - Sync Word 0x34
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 242 * PRIVATE_LORAWAN - Sync Word 0x12
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 243 * PEER_TO_PEER - Sync Word 0x56 used for Dot to Dot communication
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 244 *
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 245 * Join Delay window settings are independent of Network Type setting
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 246 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 247 enum NetworkType {
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 248 PRIVATE_MTS = 0,
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 249 PUBLIC_LORAWAN = 1,
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 250 PRIVATE_LORAWAN = 2,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 251 PEER_TO_PEER = 4
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 252 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 253
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 254 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 255 * Enum for on/off settings
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 256 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 257 enum Enabled {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 258 OFF = 0,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 259 ON = 1
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 260 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 261
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 262 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 263 * Return status of mac functions
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 264 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 265 enum MacStatus {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 266 LORA_OK = 0,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 267 LORA_ERROR = 1,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 268 LORA_JOIN_ERROR = 2,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 269 LORA_SEND_ERROR = 3,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 270 LORA_MIC_ERROR = 4,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 271 LORA_ADDRESS_ERROR = 5,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 272 LORA_NO_CHANS_ENABLED = 6,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 273 LORA_COMMAND_BUFFER_FULL = 7,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 274 LORA_UNKNOWN_MAC_COMMAND = 8,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 275 LORA_ADR_OFF = 9,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 276 LORA_BUSY = 10,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 277 LORA_LINK_BUSY = 11,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 278 LORA_RADIO_BUSY = 12,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 279 LORA_BUFFER_FULL = 13,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 280 LORA_JOIN_BACKOFF = 14,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 281 LORA_NO_FREE_CHAN = 15,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 282 LORA_AGGREGATED_DUTY_CYCLE = 16,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 283 LORA_MAC_COMMAND_ERROR = 17,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 284 LORA_MAX_PAYLOAD_EXCEEDED = 18,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 285 LORA_LBT_CHANNEL_BUSY = 19
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 286 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 287
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 288 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 289 * State for Link
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 290 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 291 enum LinkState {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 292 LINK_IDLE = 0, //!< Link ready to send or receive
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 293 LINK_TX, //!< Link is busy sending
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 294 LINK_ACK_TX, //!< Link is busy resending after missed ACK
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 295 LINK_REP_TX, //!< Link is busy repeating
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 296 LINK_RX, //!< Link has receive window open
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 297 LINK_RX1, //!< Link has first received window open
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 298 LINK_RX2, //!< Link has second received window open
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 299 LINK_RXC, //!< Link has class C received window open
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 300 LINK_P2P, //!< Link is busy sending
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 301 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 302
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 303 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 304 * State for MAC
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 305 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 306 enum MacState {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 307 MAC_IDLE,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 308 MAC_RX1,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 309 MAC_RX2,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 310 MAC_RXC,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 311 MAC_TX,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 312 MAC_JOIN
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 313 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 314
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 315 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 316 * Operation class for device
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 317 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 318 enum MoteClass {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 319 CLASS_A = 0x00, //!< Device can only receive in windows opened after a transmit
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 320 CLASS_B = 0x01, //!< Device can receive in windows sychronized with gateway beacon
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 321 CLASS_C = 0x02 //!< Device can receive any time when not transmitting
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 322 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 323
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 324 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 325 * Direction of a packet
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 326 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 327 enum Direction {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 328 DIR_UP = 0, //!< Packet is sent from mote to gateway
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 329 DIR_DOWN = 1, //!< Packet was received from gateway
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 330 DIR_PEER = 2 //!< Packet was received from peer
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 331 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 332
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 333
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 334 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 335 * Received window used by Link
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 336 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 337 enum ReceiveWindows {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 338 RX_1 = 1, //!< First receive window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 339 RX_2, //!< Second receive window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 340 RX_BEACON, //!< Beacon receive window
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 341 RX_SLOT, //!< Ping Slot receive window
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 342 RXC, //!< Class C continuous window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 343 RX_TEST
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 344 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 345
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 346 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 347 * Datarate range for a Channel
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 348 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 349 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 350 int8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 351 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 352 int8_t Min :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 353 int8_t Max :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 354 } Fields;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 355 } DatarateRange;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 356
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 357 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 358 * Datarate used for transmitting and receiving
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 359 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 360 typedef struct Datarate {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 361 uint8_t Index;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 362 uint8_t Bandwidth;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 363 uint8_t Coderate;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 364 uint8_t PreambleLength;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 365 uint8_t SpreadingFactor;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 366 uint8_t Crc;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 367 uint8_t TxIQ;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 368 uint8_t RxIQ;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 369 uint8_t SymbolTimeout();
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 370 Datarate();
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 371 } Datarate;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 372
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 373 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 374 * Channel used for transmitting
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 375 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 376 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 377 uint8_t Index;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 378 uint32_t Frequency;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 379 DatarateRange DrRange;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 380 } Channel;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 381
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 382 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 383 * Receive window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 384 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 385 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 386 uint8_t Index;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 387 uint32_t Frequency;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 388 uint8_t DatarateIndex;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 389 } RxWindow;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 390
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 391 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 392 * Duty band for limiting time-on-air for regional regulations
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 393 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 394 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 395 uint8_t Index;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 396 uint32_t FrequencyMin;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 397 uint32_t FrequencyMax;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 398 uint8_t PowerMax;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 399 uint16_t DutyCycle; //!< Multiplier of time on air, 0:100%, 1:50%, 2:33%, 10:10%, 100:1%, 1000,0.1%
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 400 uint32_t TimeOffEnd; //!< Timestamp when this band will be available
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 401 } DutyBand;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 402
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 403 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 404 * Device configuration
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 405 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 406 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 407 uint8_t FrequencyBand; //!< Used to choose ChannelPlan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 408 uint8_t EUI[8]; //!< Unique identifier assigned to device
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 409 } DeviceConfig;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 410
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 411 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 412 * Network configuration
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 413 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 414 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 415 uint8_t Mode; //!< PUBLIC, PRIVATE or PEER_TO_PEER network mode
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 416 uint8_t Class; //!< Operating class of device
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 417 uint8_t EUI[8]; //!< Network ID or AppEUI
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 418 uint8_t Key[16]; //!< Network Key or AppKey
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 419 uint8_t JoinDelay; //!< Number of seconds to wait before 1st RX Window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 420 uint8_t RxDelay; //!< Number of seconds to wait before 1st RX Window
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 421 uint8_t FrequencySubBand; //!< FrequencySubBand used for US915 hybrid operation 0:72 channels, 1:1-8 channels ...
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 422 uint8_t AckAttempts; //!< Number of attempts to send packet and receive an ACK from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 423 uint8_t Retries; //!< Number of times to resend a packet without receiving an ACK, redundancy
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 424 uint8_t ADREnabled; //!< Enable adaptive datarate
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 425 uint8_t CADEnabled; //!< Enable listen before talk/channel activity detection
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 426 uint8_t RepeaterMode; //!< Limit payloads to repeater compatible sizes
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 427 uint8_t TxPower; //!< Default radio output power in dBm
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 428 uint8_t TxPowerMax; //!< Max transmit power
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 429 uint8_t TxDatarate; //!< Datarate for P2P transmit
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 430 uint32_t TxFrequency; //!< Frequency for P2P transmit
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 431 int8_t AntennaGain; //!< Antenna Gain
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 432 uint8_t DisableEncryption; //!< Disable Encryption
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 433 uint8_t DisableCRC; //!< Disable CRC on uplink packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 434 uint16_t P2PACKTimeout;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 435 uint16_t P2PACKBackoff;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 436 uint8_t JoinRx1DatarateOffset; //!< Offset for datarate for first window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 437 uint32_t JoinRx2Frequency; //!< Frequency used in second window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 438 uint8_t JoinRx2DatarateIndex; //!< Datarate for second window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 439 } NetworkConfig;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 440
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 441 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 442 * Network session info
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 443 * Some settings are acquired in join message and others may be changed through Mac Commands from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 444 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 445 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 446 uint8_t Joined; //!< State of session
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 447 uint8_t Rx1DatarateOffset; //!< Offset for datarate for first window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 448 uint32_t Rx2Frequency; //!< Frequency used in second window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 449 uint8_t Rx2DatarateIndex; //!< Datarate for second window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 450 uint8_t TxPower; //!< Current total radiated output power in dBm
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 451 uint8_t TxDatarate; //!< Current datarate can be changed when ADR is enabled
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 452 uint32_t Address; //!< Network address
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 453 uint32_t NetworkID; //!< Network ID 24-bits
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 454 uint8_t NetworkSessionKey[16]; //!< Network session key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 455 uint8_t ApplicationSessionKey[16]; //!< Data session key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 456 uint16_t ChannelMask[4]; //!< Current channel mask
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 457 uint16_t ChannelMask500k; //!< Current channel mask for 500k channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 458 uint32_t DownlinkCounter; //!< Downlink counter of last packet received from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 459 uint32_t UplinkCounter; //!< Uplink counter of last packet received from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 460 uint8_t Redundancy; //!< Number of time to repeat an uplink
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 461 uint8_t MaxDutyCycle; //!< Current Max Duty Cycle value
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 462 uint32_t JoinTimeOnAir; //!< Balance of time on air used during join attempts
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 463 uint32_t JoinTimeOffEnd; //!< RTC time of next join attempt
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 464 uint32_t JoinFirstAttempt; //!< RTC time of first failed join attempt
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 465 uint32_t AggregatedTimeOffEnd; //!< Time off air expiration for aggregate duty cycle
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 466 uint16_t AggregateDutyCycle; //!< Used for enforcing time-on-air
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 467 uint8_t AckCounter; //!< Current number of packets sent without ACK from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 468 uint8_t AdrCounter; //!< Current number of packets received without downlink from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 469 uint8_t RxDelay; //!< Number of seconds to wait before 1st RX Window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 470 uint8_t CommandBuffer[COMMANDS_BUFFER_SIZE]; //!< Buffer to hold Mac Commands and parameters to be sent in next packet
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 471 uint8_t CommandBufferIndex; //!< Index to place next Mac Command, also current size of Command Buffer
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 472 bool SrvRequestedAck; //!< Indicator of ACK requested by server in last packet received
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 473 bool DataPending; //!< Indicator of data pending at server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 474 uint8_t RxTimingSetupReqReceived; //!< Indicator that RxTimingSetupAns should be included in uplink
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 475 uint8_t RxParamSetupReqAnswer; //!< Indicator that RxParamSetupAns should be included in uplink
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 476 uint8_t DlChannelReqAnswer; //!< Indicator that DlChannelAns should be included in uplink
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 477 uint8_t DownlinkDwelltime; //!< On air dwell time for downlink packets 0:NONE,1:400ms
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 478 uint8_t UplinkDwelltime; //!< On air dwell time for uplink packets 0:NONE,1:400ms
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 479 uint8_t Max_EIRP; //!< Maximum allowed EIRP for uplink
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 480 } NetworkSession;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 481
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 482 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 483 * Multicast session info
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 484 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 485 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 486 uint32_t Address; //!< Network address
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 487 uint8_t NetworkSessionKey[16]; //!< Network session key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 488 uint8_t DataSessionKey[16]; //!< Data session key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 489 uint32_t DownlinkCounter; //!< Downlink counter of last packet received from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 490 } MulticastSession;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 491
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 492 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 493 * Application configuration
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 494 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 495 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 496 uint8_t Port; //!< Port used by application
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 497 uint8_t AppEUI; //!< Application ID
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 498 uint8_t AppKey[16]; //!< Application Key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 499 } ApplicationConfig;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 500
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 501 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 502 * Statistics of current network session
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 503 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 504 typedef struct Statistics {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 505 uint32_t Up; //!< Number of uplink packets sent
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 506 uint32_t Down; //!< Number of downlink packets received
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 507 uint32_t Joins; //!< Number of join requests sent
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 508 uint32_t JoinFails; //!< Number of join requests without response or invalid response
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 509 uint32_t MissedAcks; //!< Number of missed acknowledgement attempts of confirmed packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 510 uint32_t CRCErrors; //!< Number of CRC errors in received packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 511 int32_t AvgCount; //!< Number of packets used to compute rolling average of RSSI and SNR
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 512 int16_t Rssi; //!< RSSI of last packet received
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 513 int16_t RssiMin; //!< Minimum RSSI of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 514 int16_t RssiMax; //!< Maximum RSSI of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 515 int16_t RssiAvg; //!< Rolling average RSSI of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 516 int16_t Snr; //!< SNR of last packet received
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 517 int16_t SnrMin; //!< Minimum SNR of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 518 int16_t SnrMax; //!< Maximum SNR of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 519 int16_t SnrAvg; //!< Rolling average SNR of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 520 } Statistics;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 521
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 522 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 523 * Testing settings
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 524 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 525 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 526 uint8_t TestMode;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 527 uint8_t SkipMICCheck;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 528 uint8_t DisableDutyCycle;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 529 uint8_t DisableRx1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 530 uint8_t DisableRx2;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 531 uint8_t FixedUplinkCounter;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 532 uint8_t DisableRandomJoinDatarate;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 533 } Testing;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 534
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 535 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 536 * Combination of device, network, testing settings and statistics
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 537 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 538 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 539 DeviceConfig Device;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 540 NetworkConfig Network;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 541 NetworkSession Session;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 542 ApplicationConfig Applications[MAX_APPS];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 543 MulticastSession Multicast[MAX_MULTICAST_SESSIONS];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 544 Statistics Stats;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 545 Testing Test;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 546 } Settings;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 547
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 548 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 549 * Downlink settings sent in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 550 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 551 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 552 uint8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 553 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 554 uint8_t Rx2Datarate :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 555 uint8_t Rx1Offset :3;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 556 uint8_t RFU :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 557 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 558 } DownlinkSettings;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 559
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 560 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 561 * Frame structure for Join Request
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 562 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 563 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 564 uint8_t Type;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 565 uint8_t AppEUI[8];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 566 uint8_t DevEUI[8];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 567 uint8_t Nonce[2];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 568 uint8_t MIC[4];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 569 } JoinRequestFrame;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 570
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 571 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 572 * Mac header of uplink and downlink packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 573 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 574 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 575 uint8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 576 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 577 uint8_t Major :2;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 578 uint8_t RFU :3;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 579 uint8_t MType :3;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 580 } Bits;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 581 } MacHeader;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 582
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 583 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 584 * Frame control field of uplink packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 585 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 586 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 587 uint8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 588 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 589 uint8_t OptionsLength :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 590 uint8_t ClassB :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 591 uint8_t Ack :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 592 uint8_t AdrAckReq :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 593 uint8_t Adr :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 594 } Bits;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 595 } UplinkControl;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 596
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 597 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 598 * Frame control field of downlink packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 599 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 600 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 601 uint8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 602 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 603 uint8_t OptionsLength :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 604 uint8_t FPending :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 605 uint8_t Ack :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 606 uint8_t RFU :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 607 uint8_t Adr :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 608 } Bits;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 609 } DownlinkControl;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 610
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 611 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 612 * Frame type of packet
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 613 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 614 typedef enum {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 615 FRAME_TYPE_JOIN_REQ = 0x00,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 616 FRAME_TYPE_JOIN_ACCEPT = 0x01,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 617 FRAME_TYPE_DATA_UNCONFIRMED_UP = 0x02,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 618 FRAME_TYPE_DATA_UNCONFIRMED_DOWN = 0x03,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 619 FRAME_TYPE_DATA_CONFIRMED_UP = 0x04,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 620 FRAME_TYPE_DATA_CONFIRMED_DOWN = 0x05,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 621 FRAME_TYPE_RFU = 0x06,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 622 FRAME_TYPE_PROPRIETARY = 0x07,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 623 } FrameType;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 624
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 625 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 626 * LoRaWAN mote MAC commands
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 627 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 628 typedef enum {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 629 /* Class A */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 630 MOTE_MAC_LINK_CHECK_REQ = 0x02,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 631 MOTE_MAC_LINK_ADR_ANS = 0x03,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 632 MOTE_MAC_DUTY_CYCLE_ANS = 0x04,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 633 MOTE_MAC_RX_PARAM_SETUP_ANS = 0x05,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 634 MOTE_MAC_DEV_STATUS_ANS = 0x06,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 635 MOTE_MAC_NEW_CHANNEL_ANS = 0x07,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 636 MOTE_MAC_RX_TIMING_SETUP_ANS = 0x08,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 637 MOTE_MAC_TX_PARAM_SETUP_ANS = 0x09,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 638 MOTE_MAC_DL_CHANNEL_ANS = 0x0A,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 639
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 640 /* Class B */
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 641 MOTE_MAC_PING_SLOT_INFO_REQ = 0x0B,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 642 MOTE_MAC_PING_SLOT_FREQ_ANS = 0x0C,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 643 MOTE_MAC_PING_SLOT_CHANNEL_ANS = 0x0D,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 644 MOTE_MAC_BEACON_TIMING_REQ = 0x0E,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 645 MOTE_MAC_BEACON_FREQ_ANS = 0x0F,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 646
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 647 /* Multitech */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 648 MOTE_MAC_PING_REQ = 0x80,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 649 MOTE_MAC_CHANGE_CLASS = 0x81,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 650 MOTE_MAC_MULTIPART_START_REQ = 0x82,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 651 MOTE_MAC_MULTIPART_START_ANS = 0x83,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 652 MOTE_MAC_MULTIPART_CHUNK = 0x84,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 653 MOTE_MAC_MULTIPART_END_REQ = 0x85,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 654 MOTE_MAC_MULTIPART_END_ANS = 0x86
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 655 } MoteCommand;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 656
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 657 /*!
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 658 * LoRaWAN server MAC commands
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 659 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 660 typedef enum {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 661 /* Class A */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 662 SRV_MAC_LINK_CHECK_ANS = 0x02,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 663 SRV_MAC_LINK_ADR_REQ = 0x03,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 664 SRV_MAC_DUTY_CYCLE_REQ = 0x04,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 665 SRV_MAC_RX_PARAM_SETUP_REQ = 0x05,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 666 SRV_MAC_DEV_STATUS_REQ = 0x06,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 667 SRV_MAC_NEW_CHANNEL_REQ = 0x07,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 668 SRV_MAC_RX_TIMING_SETUP_REQ = 0x08,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 669 SRV_MAC_TX_PARAM_SETUP_REQ = 0x09,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 670 SRV_MAC_DL_CHANNEL_REQ = 0x0A,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 671
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 672 /* Class B */
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 673 SRV_MAC_PING_SLOT_INFO_ANS = 0x0B,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 674 SRV_MAC_PING_SLOT_FREQ_REQ = 0x0C,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 675 SRV_MAC_PING_SLOT_CHANNEL_REQ = 0x0D,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 676 SRV_MAC_BEACON_TIMING_ANS = 0x0E,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 677 SRV_MAC_BEACON_FREQ_REQ = 0x0F,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 678
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 679 /* Multitech */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 680 SRV_MAC_PING_ANS = 0x80,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 681 SRV_MAC_CHANGE_CLASS = 0x81,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 682 SRV_MAC_MULTIPART_START_REQ = 0x82,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 683 SRV_MAC_MULTIPART_START_ANS = 0x83,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 684 SRV_MAC_MULTIPART_CHUNK = 0x84,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 685 SRV_MAC_MULTIPART_END_REQ = 0x85,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 686 SRV_MAC_MULTIPART_END_ANS = 0x86
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 687 } ServerCommand;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 688
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 689 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 690 * Random seed for software RNG
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 691 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 692 void srand(uint32_t seed);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 693
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 694 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 695 * Software RNG for consistent results across differing hardware
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 696 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 697 int rand(void);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 698
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 699 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 700 * Generate random number bounded by min and max
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 701 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 702 int32_t rand_r(int32_t min, int32_t max);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 703
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 704 uint8_t CountBits(uint16_t mask);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 705
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 706 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 707 * Copy 3-bytes network order from array into LSB of integer value
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 708 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 709 void CopyNetIDtoInt(const uint8_t* arr, uint32_t& val);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 710
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 711 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 712 * Copy LSB 3-bytes from integer value into array network order
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 713 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 714 void CopyNetIDtoArray(uint32_t val, uint8_t* arr);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 715
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 716 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 717 * Copy 4-bytes network order from array in to integer value
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 718 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 719 void CopyAddrtoInt(const uint8_t* arr, uint32_t& val);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 720
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 721 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 722 * Copy 4-bytes from integer in to array network order
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 723 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 724 void CopyAddrtoArray(uint32_t val, uint8_t* arr);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 725
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 726 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 727 * Copy 3-bytes network order from array into integer value and multiply by 100
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 728 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 729 void CopyFreqtoInt(const uint8_t* arr, uint32_t& freq);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 730
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 731 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 732 * Reverse memory copy
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 733 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 734 void memcpy_r(uint8_t *dst, const uint8_t *src, size_t n);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 735
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 736 }
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 737
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 738 #endif
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 739