this is the working code for the xdot to read in serial from the pi and send it over LoRa

Committer:
Jenkins@KEILDM1.dc.multitech.prv
Date:
Fri Nov 08 09:35:40 2019 -0600
Revision:
22:f062567a28ae
Parent:
21:bc12c888e7dc
xdot-library revision 3.2.5 and mbed-os revision mbed-os-5.13.4

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 16:4a382fe8f51b 106 const uint16_t BEACON_PREAMBLE_LENGTH = 10U; //!< Beacon preamble length
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 107 const uint16_t DEFAULT_BEACON_PERIOD = 128U; //!< Default period of the beacon (in seconds)
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 108 const uint16_t PING_SLOT_LENGTH = 30U; //!< Duration of each class B ping slot (in milliseconds)
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 109 const uint16_t BEACON_RESERVED_TIME = 2120U; //!< Time reserved for beacon broadcast (in milliseconds)
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 110 const uint16_t BEACON_GUARD_TIME = 3000U; //!< Guard time before beacon transmission where no ping slots can be scheduled (in milliseconds)
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 111 const uint32_t MAX_BEACONLESS_OP_TIME = 7200U; //!< Maximum time to operate in class B since last beacon received (in seconds)
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 112 const uint16_t MAX_CLASS_B_WINDOW_GROWTH = 3U; //!< Maximum window growth factor for beacons and ping slots in beacon-less operation
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 113 const uint16_t DEFAULT_PING_NB = 1U; //!< Default number of ping slots per beacon interval
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 114 const uint16_t CLS_B_PAD = 15U; //!< Pad added to the beginning of ping slot rx windows (in milliseconds)
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 115
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 116 const int16_t DEFAULT_FREE_CHAN_RSSI_THRESHOLD = -90; //!< Threshold for channel activity detection (CAD) dBm
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 117
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 118 const uint8_t CHAN_MASK_SIZE = 16; //!< Number of bits in a channel mask
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 119 const uint8_t COMMANDS_BUFFER_SIZE = 15; //!< Size of Mac Command buffer
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 120
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 121 const uint8_t PKT_HEADER = 0; //!< Index to packet mHdr field
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 122 const uint8_t PKT_ADDRESS = 1; //!< Index to first byte of packet address field
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 123 const uint8_t PKT_FRAME_CONTROL = PKT_ADDRESS + 4; //!< Index to packet fCtrl field @see UplinkControl
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 124 const uint8_t PKT_FRAME_COUNTER = PKT_FRAME_CONTROL + 1; //!< Index to packet frame counter field
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 125 const uint8_t PKT_OPTIONS_START = PKT_FRAME_COUNTER + 2; //!< Index to start of optional mac commands
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 126
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 127 const uint8_t PKT_JOIN_APP_NONCE = 1; //!< Index to application nonce in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 128 const uint8_t PKT_JOIN_NETWORK_ID = 4; //!< Index to network id in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 129 const uint8_t PKT_JOIN_NETWORK_ADDRESS = 7; //!< Index to network address in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 130 const uint8_t PKT_JOIN_DL_SETTINGS = 11; //!< Index to downlink settings in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 131 const uint8_t PKT_JOIN_RX_DELAY = 12; //!< Index to rx delay in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 132
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 133 const uint8_t DEFAULT_ADR_ACK_LIMIT = 64; //!< Number of packets without ADR ACK Request
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 134 const uint8_t DEFAULT_ADR_ACK_DELAY = 32; //!< Number of packets to expect ADR ACK Response within
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 135
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 136 const uint16_t ACK_TIMEOUT = 2000; //!< Base millisecond timeout to resend after missed ACK
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 137 const uint16_t ACK_TIMEOUT_RND = 1000; //!< Random millisecond adjustment to resend after missed ACK
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 138
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 139 const uint8_t FRAME_OVERHEAD = 13; //!< Bytes of network info overhead in a frame
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 140
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 141 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 142 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 143 * Settings for type of network
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 144 *
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 145 * PRIVATE_MTS - Sync Word 0x12, US/AU Downlink frequencies per Frequency Sub Band
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 146 * PUBLIC_LORAWAN - Sync Word 0x34
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 147 * PRIVATE_LORAWAN - Sync Word 0x12
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 148 * PEER_TO_PEER - Sync Word 0x56 used for Dot to Dot communication
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 149 *
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 150 * Join Delay window settings are independent of Network Type setting
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 151 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 152 enum NetworkType {
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 153 PRIVATE_MTS = 0,
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 154 PUBLIC_LORAWAN = 1,
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 155 PRIVATE_LORAWAN = 2,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 156 PEER_TO_PEER = 4
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 157 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 158
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 159 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 160 * Enum for on/off settings
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 161 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 162 enum Enabled {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 163 OFF = 0,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 164 ON = 1
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 165 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 166
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 167 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 168 * Return status of mac functions
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 169 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 170 enum MacStatus {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 171 LORA_OK = 0,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 172 LORA_ERROR = 1,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 173 LORA_JOIN_ERROR = 2,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 174 LORA_SEND_ERROR = 3,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 175 LORA_MIC_ERROR = 4,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 176 LORA_ADDRESS_ERROR = 5,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 177 LORA_NO_CHANS_ENABLED = 6,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 178 LORA_COMMAND_BUFFER_FULL = 7,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 179 LORA_UNKNOWN_MAC_COMMAND = 8,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 180 LORA_ADR_OFF = 9,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 181 LORA_BUSY = 10,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 182 LORA_LINK_BUSY = 11,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 183 LORA_RADIO_BUSY = 12,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 184 LORA_BUFFER_FULL = 13,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 185 LORA_JOIN_BACKOFF = 14,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 186 LORA_NO_FREE_CHAN = 15,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 187 LORA_AGGREGATED_DUTY_CYCLE = 16,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 188 LORA_MAC_COMMAND_ERROR = 17,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 189 LORA_MAX_PAYLOAD_EXCEEDED = 18,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 190 LORA_LBT_CHANNEL_BUSY = 19
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 191 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 192
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 193 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 194 * State for Link
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 195 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 196 enum LinkState {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 197 LINK_IDLE = 0, //!< Link ready to send or receive
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 198 LINK_TX, //!< Link is busy sending
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 199 LINK_ACK_TX, //!< Link is busy resending after missed ACK
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 200 LINK_REP_TX, //!< Link is busy repeating
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 201 LINK_RX, //!< Link has receive window open
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 202 LINK_RX1, //!< Link has first received window open
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 203 LINK_RX2, //!< Link has second received window open
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 204 LINK_RXC, //!< Link has class C received window open
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 205 LINK_RX_BEACON, //!< Link has a beacon receive window open
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 206 LINK_RX_PING, //!< Link has a ping slot receive window open
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 207 LINK_P2P //!< Link is busy sending
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 208 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 209
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 210 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 211 * State for MAC
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 212 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 213 enum MacState {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 214 MAC_IDLE,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 215 MAC_RX1,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 216 MAC_RX2,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 217 MAC_RXC,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 218 MAC_TX,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 219 MAC_JOIN
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 220 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 221
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 222 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 223 * Operation class for device
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 224 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 225 enum MoteClass {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 226 CLASS_A = 0x00, //!< Device can only receive in windows opened after a transmit
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 227 CLASS_B = 0x01, //!< Device can receive in windows sychronized with gateway beacon
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 228 CLASS_C = 0x02 //!< Device can receive any time when not transmitting
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 229 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 230
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 231 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 232 * Direction of a packet
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 233 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 234 enum Direction {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 235 DIR_UP = 0, //!< Packet is sent from mote to gateway
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 236 DIR_DOWN = 1, //!< Packet was received from gateway
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 237 DIR_PEER = 2 //!< Packet was received from peer
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 238 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 239
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 240
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 241 /**
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 242 * Receive window used by Link
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 243 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 244 enum ReceiveWindows {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 245 RX_1 = 1, //!< First receive window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 246 RX_2, //!< Second receive window
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 247 RX_SLOT, //!< Ping slot receive window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 248 RX_BEACON, //!< Beacon receive window
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 249 RXC, //!< Class C continuous window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 250 RX_TEST
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 251 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 252
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 253 /**
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 254 * Beacon info descriptors for the GwSpecific Info field
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 255 */
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 256 enum BeaconInfoDesc {
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 257 GPS_FIRST_ANTENNA = 0, //!< GPS coordinates of the gateway's first antenna
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 258 GPS_SECOND_ANTENNA, //!< GPS coordinates of the gateway's second antenna
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 259 GPS_THIRD_ANTENNA, //!< GPS coordinates of the gateway's third antenna
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 260 };
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 261
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 262 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 263 * Datarate range for a Channel
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 264 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 265 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 266 int8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 267 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 268 int8_t Min :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 269 int8_t Max :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 270 } Fields;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 271 } DatarateRange;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 272
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 273 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 274 * Datarate used for transmitting and receiving
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 275 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 276 typedef struct Datarate {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 277 uint8_t Index;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 278 uint8_t Bandwidth;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 279 uint8_t Coderate;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 280 uint8_t PreambleLength;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 281 uint8_t SpreadingFactor;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 282 uint8_t Crc;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 283 uint8_t TxIQ;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 284 uint8_t RxIQ;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 285 uint8_t SymbolTimeout(uint16_t pad_ms = 0);
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 286 float Timeout();
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 287 Datarate();
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 288 } Datarate;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 289
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 290 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 291 * Channel used for transmitting
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 292 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 293 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 294 uint8_t Index;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 295 uint32_t Frequency;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 296 DatarateRange DrRange;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 297 } Channel;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 298
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 299 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 300 * Receive window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 301 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 302 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 303 uint8_t Index;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 304 uint32_t Frequency;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 305 uint8_t DatarateIndex;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 306 } RxWindow;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 307
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 308 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 309 * Duty band for limiting time-on-air for regional regulations
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 310 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 311 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 312 uint8_t Index;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 313 uint32_t FrequencyMin;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 314 uint32_t FrequencyMax;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 315 uint8_t PowerMax;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 316 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 317 uint32_t TimeOffEnd; //!< Timestamp when this band will be available
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 318 } DutyBand;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 319
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 320 /**
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 321 * Beacon data content (w/o CRCs and RFUs)
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 322 */
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 323 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 324 uint32_t Time;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 325 uint8_t InfoDesc;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 326 uint32_t Latitude;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 327 uint32_t Longitude;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 328 } BeaconData_t;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 329
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 330 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 331 * Device configuration
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 332 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 333 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 334 uint8_t FrequencyBand; //!< Used to choose ChannelPlan
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 335 uint8_t EUI[8]; //!< Unique identifier assigned to device
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 336 } DeviceConfig;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 337
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 338 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 339 * Network configuration
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 340 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 341 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 342 uint8_t Mode; //!< PUBLIC, PRIVATE or PEER_TO_PEER network mode
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 343 uint8_t Class; //!< Operating class of device
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 344 uint8_t EUI[8]; //!< Network ID or AppEUI
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 345 uint8_t Key[16]; //!< Network Key or AppKey
Jenkins@KEILDM1.dc.multitech.prv 21:bc12c888e7dc 346 uint8_t GenAppKey[16]; //!< Generic App Key, will be AppKey for LW 1.1.x
Jenkins@KEILDM1.dc.multitech.prv 21:bc12c888e7dc 347 uint8_t McKEKey[16]; //!< Multicast Key Encryption Key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 348 uint8_t JoinDelay; //!< Number of seconds to wait before 1st RX Window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 349 uint8_t RxDelay; //!< Number of seconds to wait before 1st RX Window
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 350 uint8_t FrequencySubBand; //!< FrequencySubBand used for US915 hybrid operation 0:72 channels, 1:1-8 channels ...
Jenkins@KEILDM1.dc.multitech.prv 19:aa5b1fcd05be 351 uint8_t AckAttempts; //!< Number of attempts to send packet and receive an ACK from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 352 uint8_t Retries; //!< Number of times to resend a packet without receiving an ACK, redundancy
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 353 uint8_t ADREnabled; //!< Enable adaptive datarate
Jenkins@KEILDM1.dc.multitech.prv 21:bc12c888e7dc 354 uint8_t AdrAckLimit; //!< Number of uplinks without a downlink to allow before setting ADRACKReq
Jenkins@KEILDM1.dc.multitech.prv 21:bc12c888e7dc 355 uint8_t AdrAckDelay; //!< Number of downlinks to expect ADR ACK Response within
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 356 uint8_t CADEnabled; //!< Enable listen before talk/channel activity detection
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 357 uint8_t RepeaterMode; //!< Limit payloads to repeater compatible sizes
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 358 uint8_t TxPower; //!< Default radio output power in dBm
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 359 uint8_t TxPowerMax; //!< Max transmit power
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 360 uint8_t TxDatarate; //!< Datarate for P2P transmit
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 361 uint32_t TxFrequency; //!< Frequency for P2P transmit
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 362 int8_t AntennaGain; //!< Antenna Gain
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 363 uint8_t DisableEncryption; //!< Disable Encryption
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 364 uint8_t DisableCRC; //!< Disable CRC on uplink packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 365 uint16_t P2PACKTimeout;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 366 uint16_t P2PACKBackoff;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 367 uint8_t JoinRx1DatarateOffset; //!< Offset for datarate for first window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 368 uint32_t JoinRx2Frequency; //!< Frequency used in second window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 369 uint8_t JoinRx2DatarateIndex; //!< Datarate for second window
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 370 uint8_t PingPeriodicity; //!< Number of ping slots to open in a beacon interval (2^(7-PingPeriodicity))
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 371 } NetworkConfig;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 372
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 373 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 374 * Network session info
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 375 * Some settings are acquired in join message and others may be changed through Mac Commands from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 376 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 377 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 378 uint8_t Joined; //!< State of session
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 379 uint8_t Class; //!< Operating class of device
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 380 uint8_t Rx1DatarateOffset; //!< Offset for datarate for first window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 381 uint32_t Rx2Frequency; //!< Frequency used in second window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 382 uint8_t Rx2DatarateIndex; //!< Datarate for second window
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 383 uint32_t BeaconFrequency; //!< Frequency used for the beacon window
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 384 bool BeaconFreqHop; //!< Beacon frequency hopping enable
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 385 uint32_t PingSlotFrequency; //!< Frequency used for ping slot windows
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 386 uint8_t PingSlotDatarateIndex; //!< Datarate for the ping slots
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 387 bool PingSlotFreqHop; //!< Ping slot frequency hopping enable
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 388 uint8_t TxPower; //!< Current total radiated output power in dBm
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 389 uint8_t TxDatarate; //!< Current datarate can be changed when ADR is enabled
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 390 uint32_t Address; //!< Network address
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 391 uint32_t NetworkID; //!< Network ID 24-bits
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 392 uint8_t NetworkSessionKey[16]; //!< Network session key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 393 uint8_t ApplicationSessionKey[16]; //!< Data session key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 394 uint16_t ChannelMask[4]; //!< Current channel mask
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 395 uint16_t ChannelMask500k; //!< Current channel mask for 500k channels
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 396 uint32_t DownlinkCounter; //!< Downlink counter of last packet received from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 397 uint32_t UplinkCounter; //!< Uplink counter of last packet received from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 398 uint8_t Redundancy; //!< Number of time to repeat an uplink
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 399 uint8_t MaxDutyCycle; //!< Current Max Duty Cycle value
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 400 uint32_t JoinTimeOnAir; //!< Balance of time on air used during join attempts
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 401 uint32_t JoinTimeOffEnd; //!< RTC time of next join attempt
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 402 uint32_t JoinFirstAttempt; //!< RTC time of first failed join attempt
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 403 uint32_t AggregatedTimeOffEnd; //!< Time off air expiration for aggregate duty cycle
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 404 uint16_t AggregateDutyCycle; //!< Used for enforcing time-on-air
Jenkins@KEILDM1.dc.multitech.prv 19:aa5b1fcd05be 405 uint8_t AckCounter; //!< Current number of packets sent without ACK from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 406 uint8_t AdrCounter; //!< Current number of packets received without downlink from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 407 uint8_t RxDelay; //!< Number of seconds to wait before 1st RX Window
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 408 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 409 uint8_t CommandBufferIndex; //!< Index to place next Mac Command, also current size of Command Buffer
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 410 bool SrvRequestedAck; //!< Indicator of ACK requested by server in last packet received
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 411 bool DataPending; //!< Indicator of data pending at server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 412 uint8_t RxTimingSetupReqReceived; //!< Indicator that RxTimingSetupAns should be included in uplink
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 413 uint8_t RxParamSetupReqAnswer; //!< Indicator that RxParamSetupAns should be included in uplink
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 414 uint8_t DlChannelReqAnswer; //!< Indicator that DlChannelAns should be included in uplink
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 415 uint8_t DownlinkDwelltime; //!< On air dwell time for downlink packets 0:NONE,1:400ms
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 416 uint8_t UplinkDwelltime; //!< On air dwell time for uplink packets 0:NONE,1:400ms
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 417 uint8_t Max_EIRP; //!< Maximum allowed EIRP for uplink
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 418 } NetworkSession;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 419
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 420 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 421 * Multicast session info
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 422 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 423 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 424 uint32_t Address; //!< Network address
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 425 uint8_t NetworkSessionKey[16]; //!< Network session key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 426 uint8_t DataSessionKey[16]; //!< Data session key
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 427 uint32_t DownlinkCounter; //!< Downlink counter of last packet received from server
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 428 } MulticastSession;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 429
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 430 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 431 * Statistics of current network session
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 432 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 433 typedef struct Statistics {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 434 uint32_t Up; //!< Number of uplink packets sent
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 435 uint32_t Down; //!< Number of downlink packets received
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 436 uint32_t Joins; //!< Number of join requests sent
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 437 uint32_t JoinFails; //!< Number of join requests without response or invalid response
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 438 uint32_t MissedAcks; //!< Number of missed acknowledgement attempts of confirmed packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 439 uint32_t CRCErrors; //!< Number of CRC errors in received packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 440 int32_t AvgCount; //!< Number of packets used to compute rolling average of RSSI and SNR
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 441 int16_t Rssi; //!< RSSI of last packet received
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 442 int16_t RssiMin; //!< Minimum RSSI of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 443 int16_t RssiMax; //!< Maximum RSSI of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 444 int16_t RssiAvg; //!< Rolling average RSSI of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 445 int16_t Snr; //!< SNR of last packet received
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 446 int16_t SnrMin; //!< Minimum SNR of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 447 int16_t SnrMax; //!< Maximum SNR of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 448 int16_t SnrAvg; //!< Rolling average SNR of last AvgCount packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 449 } Statistics;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 450
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 451 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 452 * Testing settings
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 453 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 454 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 455 uint8_t TestMode;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 456 uint8_t SkipMICCheck;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 457 uint8_t DisableDutyCycle;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 458 uint8_t DisableRx1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 459 uint8_t DisableRx2;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 460 uint8_t FixedUplinkCounter;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 461 uint8_t DisableRandomJoinDatarate;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 462 } Testing;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 463
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 464 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 465 * Combination of device, network, testing settings and statistics
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 466 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 467 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 468 DeviceConfig Device;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 469 NetworkConfig Network;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 470 NetworkSession Session;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 471 MulticastSession Multicast[MAX_MULTICAST_SESSIONS];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 472 Statistics Stats;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 473 Testing Test;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 474 } Settings;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 475
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 476 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 477 * Downlink settings sent in Join Accept message
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 478 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 479 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 480 uint8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 481 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 482 uint8_t Rx2Datarate :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 483 uint8_t Rx1Offset :3;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 484 uint8_t RFU :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 485 };
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 486 } DownlinkSettings;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 487
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 488 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 489 * Frame structure for Join Request
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 490 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 491 typedef struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 492 uint8_t Type;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 493 uint8_t AppEUI[8];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 494 uint8_t DevEUI[8];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 495 uint8_t Nonce[2];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 496 uint8_t MIC[4];
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 497 } JoinRequestFrame;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 498
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 499 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 500 * Mac header of uplink and downlink packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 501 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 502 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 503 uint8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 504 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 505 uint8_t Major :2;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 506 uint8_t RFU :3;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 507 uint8_t MType :3;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 508 } Bits;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 509 } MacHeader;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 510
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 511 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 512 * Frame control field of uplink packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 513 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 514 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 515 uint8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 516 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 517 uint8_t OptionsLength :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 518 uint8_t ClassB :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 519 uint8_t Ack :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 520 uint8_t AdrAckReq :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 521 uint8_t Adr :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 522 } Bits;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 523 } UplinkControl;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 524
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 525 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 526 * Frame control field of downlink packets
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 527 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 528 typedef union {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 529 uint8_t Value;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 530 struct {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 531 uint8_t OptionsLength :4;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 532 uint8_t FPending :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 533 uint8_t Ack :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 534 uint8_t RFU :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 535 uint8_t Adr :1;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 536 } Bits;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 537 } DownlinkControl;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 538
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 539 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 540 * Frame type of packet
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 541 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 542 typedef enum {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 543 FRAME_TYPE_JOIN_REQ = 0x00,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 544 FRAME_TYPE_JOIN_ACCEPT = 0x01,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 545 FRAME_TYPE_DATA_UNCONFIRMED_UP = 0x02,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 546 FRAME_TYPE_DATA_UNCONFIRMED_DOWN = 0x03,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 547 FRAME_TYPE_DATA_CONFIRMED_UP = 0x04,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 548 FRAME_TYPE_DATA_CONFIRMED_DOWN = 0x05,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 549 FRAME_TYPE_RFU = 0x06,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 550 FRAME_TYPE_PROPRIETARY = 0x07,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 551 } FrameType;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 552
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 553 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 554 * LoRaWAN mote MAC commands
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 555 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 556 typedef enum {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 557 /* Class A */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 558 MOTE_MAC_LINK_CHECK_REQ = 0x02,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 559 MOTE_MAC_LINK_ADR_ANS = 0x03,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 560 MOTE_MAC_DUTY_CYCLE_ANS = 0x04,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 561 MOTE_MAC_RX_PARAM_SETUP_ANS = 0x05,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 562 MOTE_MAC_DEV_STATUS_ANS = 0x06,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 563 MOTE_MAC_NEW_CHANNEL_ANS = 0x07,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 564 MOTE_MAC_RX_TIMING_SETUP_ANS = 0x08,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 565 MOTE_MAC_TX_PARAM_SETUP_ANS = 0x09,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 566 MOTE_MAC_DL_CHANNEL_ANS = 0x0A,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 567 MOTE_MAC_REKEY_IND = 0x0B,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 568 MOTE_MAC_ADR_PARAM_SETUP_ANS = 0x0C,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 569 MOTE_MAC_DEVICE_TIME_REQ = 0x0D,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 570 MOTE_MAC_REJOIN_PARAM_SETUP_ANS = 0x0F,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 571
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 572 /* Class B */
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 573 MOTE_MAC_PING_SLOT_INFO_REQ = 0x10,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 574 MOTE_MAC_PING_SLOT_CHANNEL_ANS = 0x11,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 575 MOTE_MAC_BEACON_TIMING_REQ = 0x12,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 576 MOTE_MAC_BEACON_FREQ_ANS = 0x13,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 577
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 578 /* Multitech */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 579 MOTE_MAC_PING_REQ = 0x80,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 580 MOTE_MAC_CHANGE_CLASS = 0x81,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 581 MOTE_MAC_MULTIPART_START_REQ = 0x82,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 582 MOTE_MAC_MULTIPART_START_ANS = 0x83,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 583 MOTE_MAC_MULTIPART_CHUNK = 0x84,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 584 MOTE_MAC_MULTIPART_END_REQ = 0x85,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 585 MOTE_MAC_MULTIPART_END_ANS = 0x86
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 586 } MoteCommand;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 587
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 588 /*!
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 589 * LoRaWAN server MAC commands
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 590 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 591 typedef enum {
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 592 /* Class A */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 593 SRV_MAC_LINK_CHECK_ANS = 0x02,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 594 SRV_MAC_LINK_ADR_REQ = 0x03,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 595 SRV_MAC_DUTY_CYCLE_REQ = 0x04,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 596 SRV_MAC_RX_PARAM_SETUP_REQ = 0x05,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 597 SRV_MAC_DEV_STATUS_REQ = 0x06,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 598 SRV_MAC_NEW_CHANNEL_REQ = 0x07,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 599 SRV_MAC_RX_TIMING_SETUP_REQ = 0x08,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 600 SRV_MAC_TX_PARAM_SETUP_REQ = 0x09,
Jenkins@KEILDM1.dc.multitech.prv 10:1e831990a669 601 SRV_MAC_DL_CHANNEL_REQ = 0x0A,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 602 SRV_MAC_REKEY_CONF = 0x0B,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 603 SRV_MAC_ADR_PARAM_SETUP_REQ = 0x0C,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 604 SRV_MAC_DEVICE_TIME_ANS = 0x0D,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 605 SRV_MAC_FORCE_REJOIN_REQ = 0x0E,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 606 SRV_MAC_REJOIN_PARAM_SETUP_REQ = 0x0F,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 607
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 608 /* Class B */
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 609 SRV_MAC_PING_SLOT_INFO_ANS = 0x10,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 610 SRV_MAC_PING_SLOT_CHANNEL_REQ = 0x11,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 611 SRV_MAC_BEACON_TIMING_ANS = 0x12,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 612 SRV_MAC_BEACON_FREQ_REQ = 0x13,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 613
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 614 /* Multitech */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 615 SRV_MAC_PING_ANS = 0x80,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 616 SRV_MAC_CHANGE_CLASS = 0x81,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 617 SRV_MAC_MULTIPART_START_REQ = 0x82,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 618 SRV_MAC_MULTIPART_START_ANS = 0x83,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 619 SRV_MAC_MULTIPART_CHUNK = 0x84,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 620 SRV_MAC_MULTIPART_END_REQ = 0x85,
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 621 SRV_MAC_MULTIPART_END_ANS = 0x86
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 622 } ServerCommand;
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 623
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 624 /**
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 625 * Radio configuration options
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 626 */
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 627 typedef enum RadioCfg {
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 628 NO_RADIO_CFG,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 629 TX_RADIO_CFG,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 630 RX_RADIO_CFG
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 631 } RadioCfg_t;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 632
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 633 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 634 * Random seed for software RNG
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 635 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 636 void srand(uint32_t seed);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 637
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 638 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 639 * Software RNG for consistent results across differing hardware
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 640 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 641 int rand(void);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 642
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 643 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 644 * Generate random number bounded by min and max
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 645 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 646 int32_t rand_r(int32_t min, int32_t max);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 647
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 648 uint8_t CountBits(uint16_t mask);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 649
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 650 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 651 * Copy 3-bytes network order from array into LSB of integer value
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 652 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 653 void CopyNetIDtoInt(const uint8_t* arr, uint32_t& val);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 654
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 655 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 656 * Copy LSB 3-bytes from integer value into array network order
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 657 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 658 void CopyNetIDtoArray(uint32_t val, uint8_t* arr);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 659
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 660 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 661 * Copy 4-bytes network order from array in to integer value
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 662 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 663 void CopyAddrtoInt(const uint8_t* arr, uint32_t& val);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 664
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 665 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 666 * Copy 4-bytes from integer in to array network order
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 667 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 668 void CopyAddrtoArray(uint32_t val, uint8_t* arr);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 669
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 670 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 671 * Copy 3-bytes network order from array into integer value and multiply by 100
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 672 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 673 void CopyFreqtoInt(const uint8_t* arr, uint32_t& freq);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 674
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 675 /**
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 676 * Reverse memory copy
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 677 */
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 678 void memcpy_r(uint8_t *dst, const uint8_t *src, size_t n);
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 679
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 680 }
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 681
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 682 #endif
Jenkins@KEILDM1.dc.multitech.prv 2:4569491293d7 683