MultiTech / mDot_Channel_Plans

The channel plans in this library can be used as starting points for new channel plans and used as a reference for implementation.

Information

To use source version of a channel plan, first remove the Channel Plans folder from libmDot-Custom library.

Not all plans are complete to LoRaWAN specifications.

AS923 and KR920 have the default channels defined and can accept in channels in the Join Accept message or from New Channel MAC commands.

Channel Set must match those expected by the network server in order for ADR to work

AS923 regional settings can be adjusted by the network server using Tx Param Setup MAC command to set max EIRP and dwell time for uplinks.

Committer:
Jason Reiss
Date:
Tue Feb 07 09:00:25 2017 -0600
Revision:
13:996f1663d12e
Parent:
11:829f8c2ec1c3
Fix P2P in dynamic plans, channel 0 was being used instead of the set frequency

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jreiss 11:829f8c2ec1c3 1 /** __ ___ ____ _ ______ __ ____ __ ____
jreiss 11:829f8c2ec1c3 2 * / |/ /_ __/ / /_(_)__/_ __/__ ____/ / / __/_ _____ / /____ __ _ ___ / _/__ ____
jreiss 11:829f8c2ec1c3 3 * / /|_/ / // / / __/ /___// / / -_) __/ _ \ _\ \/ // (_-</ __/ -_) ' \(_-< _/ // _ \/ __/ __
jreiss 11:829f8c2ec1c3 4 * /_/ /_/\_,_/_/\__/_/ /_/ \__/\__/_//_/ /___/\_, /___/\__/\__/_/_/_/___/ /___/_//_/\__/ /_/
jreiss 11:829f8c2ec1c3 5 * Copyright (C) 2015 by Multi-Tech Systems /___/
jreiss 11:829f8c2ec1c3 6 *
jreiss 11:829f8c2ec1c3 7 *
jreiss 11:829f8c2ec1c3 8 * @author Jason Reiss
jreiss 11:829f8c2ec1c3 9 * @date 10-31-2015
jreiss 11:829f8c2ec1c3 10 * @brief lora::ChannelPlan provides an interface for LoRaWAN channel schemes
jreiss 11:829f8c2ec1c3 11 *
jreiss 11:829f8c2ec1c3 12 * @details
jreiss 11:829f8c2ec1c3 13 *
jreiss 11:829f8c2ec1c3 14 */
jreiss 11:829f8c2ec1c3 15
jreiss 11:829f8c2ec1c3 16 #ifndef __CUSTOM_CHANNEL_PLAN_EU868_H__
jreiss 11:829f8c2ec1c3 17 #define __CUSTOM_CHANNEL_PLAN_EU868_H__
jreiss 11:829f8c2ec1c3 18
jreiss 11:829f8c2ec1c3 19 #include "Lora.h"
jreiss 11:829f8c2ec1c3 20 #include "SxRadio.h"
jreiss 11:829f8c2ec1c3 21 #include <vector>
jreiss 11:829f8c2ec1c3 22 #include "ChannelPlan.h"
jreiss 11:829f8c2ec1c3 23
jreiss 11:829f8c2ec1c3 24 namespace lora {
jreiss 11:829f8c2ec1c3 25
jreiss 11:829f8c2ec1c3 26 class CustomChannelPlan_EU868 : public lora::ChannelPlan {
jreiss 11:829f8c2ec1c3 27 public:
jreiss 11:829f8c2ec1c3 28 /**
jreiss 11:829f8c2ec1c3 29 * ChannelPlan constructor
jreiss 11:829f8c2ec1c3 30 * @param radio SxRadio object used to set Tx/Rx config
jreiss 11:829f8c2ec1c3 31 * @param settings Settings object
jreiss 11:829f8c2ec1c3 32 */
jreiss 11:829f8c2ec1c3 33 CustomChannelPlan_EU868(SxRadio& radio, Settings& settings);
jreiss 11:829f8c2ec1c3 34
jreiss 11:829f8c2ec1c3 35 /**
jreiss 11:829f8c2ec1c3 36 * ChannelPlan destructor
jreiss 11:829f8c2ec1c3 37 */
jreiss 11:829f8c2ec1c3 38 virtual ~CustomChannelPlan_EU868();
jreiss 11:829f8c2ec1c3 39
jreiss 11:829f8c2ec1c3 40 /**
jreiss 11:829f8c2ec1c3 41 * Initialize channels, datarates and duty cycle bands according to current channel plan in settings
jreiss 11:829f8c2ec1c3 42 */
jreiss 11:829f8c2ec1c3 43 virtual void Init();
jreiss 11:829f8c2ec1c3 44
jreiss 11:829f8c2ec1c3 45 /**
jreiss 11:829f8c2ec1c3 46 * Get the next channel to use to transmit
jreiss 11:829f8c2ec1c3 47 * @return LORA_OK if channel was found
jreiss 11:829f8c2ec1c3 48 * @return LORA_NO_CHANS_ENABLED
jreiss 11:829f8c2ec1c3 49 */
jreiss 11:829f8c2ec1c3 50 virtual uint8_t GetNextChannel();
jreiss 11:829f8c2ec1c3 51
jreiss 11:829f8c2ec1c3 52 /**
jreiss 11:829f8c2ec1c3 53 * Add a channel to the ChannelPlan
jreiss 11:829f8c2ec1c3 54 * @param index of channel, use -1 to add to end
jreiss 11:829f8c2ec1c3 55 * @param channel settings to add
jreiss 11:829f8c2ec1c3 56 */
jreiss 11:829f8c2ec1c3 57 virtual uint8_t AddChannel(int8_t index, Channel channel);
jreiss 11:829f8c2ec1c3 58
jreiss 11:829f8c2ec1c3 59 /**
jreiss 11:829f8c2ec1c3 60 * Get channel at index
jreiss 11:829f8c2ec1c3 61 * @return Channel
jreiss 11:829f8c2ec1c3 62 */
jreiss 11:829f8c2ec1c3 63 virtual Channel GetChannel(int8_t index);
jreiss 11:829f8c2ec1c3 64
jreiss 11:829f8c2ec1c3 65 /**
jreiss 11:829f8c2ec1c3 66 * Get rx window settings for requested window
jreiss 11:829f8c2ec1c3 67 * RX_1, RX_2, RX_BEACON, RX_SLOT
jreiss 11:829f8c2ec1c3 68 * @param window
jreiss 11:829f8c2ec1c3 69 * @return RxWindow
jreiss 11:829f8c2ec1c3 70 */
jreiss 11:829f8c2ec1c3 71 virtual RxWindow GetRxWindow(uint8_t window);
jreiss 11:829f8c2ec1c3 72
jreiss 11:829f8c2ec1c3 73 /**
jreiss 11:829f8c2ec1c3 74 * Get datarate to use on the join request
jreiss 11:829f8c2ec1c3 75 * @return datarate index
jreiss 11:829f8c2ec1c3 76 */
jreiss 11:829f8c2ec1c3 77 virtual uint8_t GetJoinDatarate();
jreiss 11:829f8c2ec1c3 78
jreiss 11:829f8c2ec1c3 79 /**
jreiss 11:829f8c2ec1c3 80 * Calculate the next time a join request is possible
jreiss 11:829f8c2ec1c3 81 * @param size of join frame
jreiss 11:829f8c2ec1c3 82 * @returns LORA_OK
jreiss 11:829f8c2ec1c3 83 */
jreiss 11:829f8c2ec1c3 84 virtual uint8_t CalculateJoinBackoff(uint8_t size);
jreiss 11:829f8c2ec1c3 85
jreiss 11:829f8c2ec1c3 86 /**
jreiss 11:829f8c2ec1c3 87 * Get next channel and set the SxRadio tx config with current settings
jreiss 11:829f8c2ec1c3 88 * @return LORA_OK
jreiss 11:829f8c2ec1c3 89 */
jreiss 11:829f8c2ec1c3 90 virtual uint8_t SetTxConfig();
jreiss 11:829f8c2ec1c3 91
jreiss 11:829f8c2ec1c3 92 /**
jreiss 11:829f8c2ec1c3 93 * Set the SxRadio rx config provided window
jreiss 11:829f8c2ec1c3 94 * @param window to be opened
jreiss 11:829f8c2ec1c3 95 * @param continuous keep window open
jreiss 11:829f8c2ec1c3 96 * @return LORA_OK
jreiss 11:829f8c2ec1c3 97 */
jreiss 11:829f8c2ec1c3 98 virtual uint8_t SetRxConfig(uint8_t window, bool continuous);
jreiss 11:829f8c2ec1c3 99
jreiss 11:829f8c2ec1c3 100 /**
jreiss 11:829f8c2ec1c3 101 * Set channel group if supported by plan
jreiss 11:829f8c2ec1c3 102 * @param group
jreiss 11:829f8c2ec1c3 103 * @return LORA_OK
jreiss 11:829f8c2ec1c3 104 */
jreiss 11:829f8c2ec1c3 105 virtual uint8_t SetChannelGroup(uint8_t group);
jreiss 11:829f8c2ec1c3 106
jreiss 11:829f8c2ec1c3 107 /**
jreiss 11:829f8c2ec1c3 108 * Callback for ACK timeout event
jreiss 11:829f8c2ec1c3 109 * @return LORA_OK
jreiss 11:829f8c2ec1c3 110 */
jreiss 11:829f8c2ec1c3 111 virtual uint8_t HandleAckTimeout();
jreiss 11:829f8c2ec1c3 112
jreiss 11:829f8c2ec1c3 113 /**
jreiss 11:829f8c2ec1c3 114 * Callback for Join Accept packet to load optional channels
jreiss 11:829f8c2ec1c3 115 * @return LORA_OK
jreiss 11:829f8c2ec1c3 116 */
jreiss 11:829f8c2ec1c3 117 virtual uint8_t HandleJoinAccept(const uint8_t* buffer, uint8_t size);
jreiss 11:829f8c2ec1c3 118
jreiss 11:829f8c2ec1c3 119 /**
jreiss 11:829f8c2ec1c3 120 * Callback to for rx parameter setup ServerCommand
jreiss 11:829f8c2ec1c3 121 * @param payload packet data
jreiss 11:829f8c2ec1c3 122 * @param index of start of command buffer
jreiss 11:829f8c2ec1c3 123 * @param size number of bytes in command buffer
jreiss 11:829f8c2ec1c3 124 * @param[out] status to be returned in MoteCommand answer
jreiss 11:829f8c2ec1c3 125 * @return LORA_OK
jreiss 11:829f8c2ec1c3 126 */
jreiss 11:829f8c2ec1c3 127 virtual uint8_t HandleRxParamSetup(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
jreiss 11:829f8c2ec1c3 128
jreiss 11:829f8c2ec1c3 129 /**
jreiss 11:829f8c2ec1c3 130 * Callback to for new channel ServerCommand
jreiss 11:829f8c2ec1c3 131 * @param payload packet data
jreiss 11:829f8c2ec1c3 132 * @param index of start of command buffer
jreiss 11:829f8c2ec1c3 133 * @param size number of bytes in command buffer
jreiss 11:829f8c2ec1c3 134 * @param[out] status to be returned in MoteCommand answer
jreiss 11:829f8c2ec1c3 135 * @return LORA_OK
jreiss 11:829f8c2ec1c3 136 */
jreiss 11:829f8c2ec1c3 137 virtual uint8_t HandleNewChannel(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
jreiss 11:829f8c2ec1c3 138
jreiss 11:829f8c2ec1c3 139 /**
jreiss 11:829f8c2ec1c3 140 * Callback to for ping slot channel request ServerCommand
jreiss 11:829f8c2ec1c3 141 * @param payload packet data
jreiss 11:829f8c2ec1c3 142 * @param index of start of command buffer
jreiss 11:829f8c2ec1c3 143 * @param size number of bytes in command buffer
jreiss 11:829f8c2ec1c3 144 * @param[out] status to be returned in MoteCommand answer
jreiss 11:829f8c2ec1c3 145 * @return LORA_OK
jreiss 11:829f8c2ec1c3 146 */
jreiss 11:829f8c2ec1c3 147 virtual uint8_t HandlePingSlotChannelReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
jreiss 11:829f8c2ec1c3 148
jreiss 11:829f8c2ec1c3 149 /**
jreiss 11:829f8c2ec1c3 150 * Callback to for beacon frequency request ServerCommand
jreiss 11:829f8c2ec1c3 151 * @param payload packet data
jreiss 11:829f8c2ec1c3 152 * @param index of start of command buffer
jreiss 11:829f8c2ec1c3 153 * @param size number of bytes in command buffer
jreiss 11:829f8c2ec1c3 154 * @param[out] status to be returned in MoteCommand answer
jreiss 11:829f8c2ec1c3 155 * @return LORA_OK
jreiss 11:829f8c2ec1c3 156 */
jreiss 11:829f8c2ec1c3 157 virtual uint8_t HandleBeaconFrequencyReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
jreiss 11:829f8c2ec1c3 158
jreiss 11:829f8c2ec1c3 159 /**
jreiss 11:829f8c2ec1c3 160 * Callback to for adaptive datarate ServerCommand
jreiss 11:829f8c2ec1c3 161 * @param payload packet data
jreiss 11:829f8c2ec1c3 162 * @param index of start of command buffer
jreiss 11:829f8c2ec1c3 163 * @param size number of bytes in command buffer
jreiss 11:829f8c2ec1c3 164 * @param[out] status to be returned in MoteCommand answer
jreiss 11:829f8c2ec1c3 165 * @return LORA_OK
jreiss 11:829f8c2ec1c3 166 */
jreiss 11:829f8c2ec1c3 167 virtual uint8_t HandleAdrCommand(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status);
jreiss 11:829f8c2ec1c3 168
jreiss 11:829f8c2ec1c3 169 /**
jreiss 11:829f8c2ec1c3 170 * Flag if ADR ACK should be sent in next packet
jreiss 11:829f8c2ec1c3 171 * @return true when flag should be set
jreiss 11:829f8c2ec1c3 172 */
jreiss 11:829f8c2ec1c3 173 virtual bool AdrAckReq();
jreiss 11:829f8c2ec1c3 174
jreiss 11:829f8c2ec1c3 175 /**
jreiss 11:829f8c2ec1c3 176 * Update duty cycle with at given frequency and time on air
jreiss 11:829f8c2ec1c3 177 * @param freq frequency
jreiss 11:829f8c2ec1c3 178 * @param time_on_air_ms tx time on air
jreiss 11:829f8c2ec1c3 179 */
jreiss 11:829f8c2ec1c3 180 virtual void UpdateDutyCycle(uint32_t freq, uint32_t time_on_air_ms);
jreiss 11:829f8c2ec1c3 181
jreiss 11:829f8c2ec1c3 182 /**
jreiss 11:829f8c2ec1c3 183 * Get the time the radio must be off air to comply with regulations
jreiss 11:829f8c2ec1c3 184 * Time to wait may be dependent on duty-cycle restrictions per channel
jreiss 11:829f8c2ec1c3 185 * Or duty-cycle of join requests if OTAA is being attempted
jreiss 11:829f8c2ec1c3 186 * @return ms of time to wait for next tx opportunity
jreiss 11:829f8c2ec1c3 187 */
jreiss 11:829f8c2ec1c3 188 virtual uint32_t GetTimeOffAir();
jreiss 11:829f8c2ec1c3 189
jreiss 11:829f8c2ec1c3 190 /**
jreiss 11:829f8c2ec1c3 191 * Get the channels in use by current channel plan
jreiss 11:829f8c2ec1c3 192 * @return channel frequencies
jreiss 11:829f8c2ec1c3 193 */
jreiss 11:829f8c2ec1c3 194 virtual std::vector<uint32_t> GetChannels();
jreiss 11:829f8c2ec1c3 195
jreiss 11:829f8c2ec1c3 196 /**
jreiss 11:829f8c2ec1c3 197 * Get the channel datarate ranges in use by current channel plan
jreiss 11:829f8c2ec1c3 198 * @return channel datarate ranges
jreiss 11:829f8c2ec1c3 199 */
jreiss 11:829f8c2ec1c3 200 virtual std::vector<uint8_t> GetChannelRanges();
jreiss 11:829f8c2ec1c3 201
jreiss 11:829f8c2ec1c3 202 /**
jreiss 11:829f8c2ec1c3 203 * Print log message for given rx window
jreiss 11:829f8c2ec1c3 204 * @param wnd 1 or 2
jreiss 11:829f8c2ec1c3 205 */
jreiss 11:829f8c2ec1c3 206 virtual void LogRxWindow(uint8_t wnd);
jreiss 11:829f8c2ec1c3 207
jreiss 11:829f8c2ec1c3 208 /**
jreiss 11:829f8c2ec1c3 209 * Enable the default channels of the channel plan
jreiss 11:829f8c2ec1c3 210 */
jreiss 11:829f8c2ec1c3 211 virtual void EnableDefaultChannels();
jreiss 11:829f8c2ec1c3 212
jreiss 11:829f8c2ec1c3 213 protected:
jreiss 11:829f8c2ec1c3 214
jreiss 11:829f8c2ec1c3 215 static const uint8_t EU868_TX_POWERS[6]; //!< List of available tx powers
jreiss 11:829f8c2ec1c3 216 static const uint8_t EU868_RADIO_POWERS[21]; //!< List of calibrated tx powers
jreiss 11:829f8c2ec1c3 217 static const uint8_t EU868_MAX_PAYLOAD_SIZE[]; //!< List of max payload sizes for each datarate
jreiss 11:829f8c2ec1c3 218 static const uint8_t EU868_MAX_PAYLOAD_SIZE_REPEATER[]; //!< List of repeater compatible max payload sizes for each datarate
jreiss 11:829f8c2ec1c3 219 };
jreiss 11:829f8c2ec1c3 220 }
jreiss 11:829f8c2ec1c3 221
jreiss 11:829f8c2ec1c3 222 #endif //__CUSTOM_CHANNEL_PLAN_EU868_H__