Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Dot-Examples Dot-AT-Firmware Dot-Examples TEST_FF1705 ... more
ChannelPlan_EU868.h
00001 /** __ ___ ____ _ ______ __ ____ __ ____ 00002 * / |/ /_ __/ / /_(_)__/_ __/__ ____/ / / __/_ _____ / /____ __ _ ___ / _/__ ____ 00003 * / /|_/ / // / / __/ /___// / / -_) __/ _ \ _\ \/ // (_-</ __/ -_) ' \(_-< _/ // _ \/ __/ __ 00004 * /_/ /_/\_,_/_/\__/_/ /_/ \__/\__/_//_/ /___/\_, /___/\__/\__/_/_/_/___/ /___/_//_/\__/ /_/ 00005 * Copyright (C) 2015 by Multi-Tech Systems /___/ 00006 * 00007 * 00008 * @author Jason Reiss 00009 * @date 10-31-2015 00010 * @brief lora::ChannelPlan provides an interface for LoRaWAN channel schemes 00011 * 00012 * @details 00013 * 00014 */ 00015 00016 #ifndef __CHANNEL_PLAN_EU868_H__ 00017 #define __CHANNEL_PLAN_EU868_H__ 00018 00019 #include "Lora.h" 00020 #include "SxRadio.h" 00021 #include <vector> 00022 #include "ChannelPlan.h" 00023 00024 namespace lora { 00025 00026 const uint8_t EU868_125K_NUM_CHANS = 16; //!< Number of 125k channels in EU868 channel plan 00027 const uint8_t EU868_DEFAULT_NUM_CHANS = 3; //!< Number of defualt channels in EU868 channel plan 00028 const uint32_t EU868_125K_FREQ_BASE = 868100000; //!< Frequency base for 125k EU868 uplink channels 00029 const uint32_t EU868_125K_FREQ_STEP = 200000; //!< Frequency step for 125k EU868 uplink channels 00030 const uint32_t EU868_RX2_FREQ = 869525000; //!< Frequency default for second rx window in EU868 00031 00032 const uint8_t EU868_TX_POWER_MAX = 14; //!< Max power for EU868 channel plan 00033 00034 // 0.1% duty cycle 863-868 00035 // Limiting to 865-868 allows for 1% duty cycle 00036 const uint32_t EU868_MILLI_FREQ_MIN = 865000000; 00037 const uint32_t EU868_MILLI_FREQ_MAX = 868000000; 00038 00039 const uint32_t EU868_MILLI_1_FREQ_MIN = 868700000; 00040 const uint32_t EU868_MILLI_1_FREQ_MAX = 869200000; 00041 00042 // 1% duty cycle 00043 const uint32_t EU868_CENTI_FREQ_MIN = 868000000; 00044 const uint32_t EU868_CENTI_FREQ_MAX = 868600000; 00045 00046 // 10% duty cycle 00047 const uint32_t EU868_DECI_FREQ_MIN = 869400000; 00048 const uint32_t EU868_DECI_FREQ_MAX = 869650000; 00049 00050 // Below 7dBm there is no duty cycle for these frequencies 00051 // Up to 14dBm there is 1% duty cycle 00052 const uint32_t EU868_VAR_FREQ_MIN = 869700000; 00053 const uint32_t EU868_VAR_FREQ_MAX = 870000000; 00054 00055 const uint32_t EU868_FREQ_MIN = 863000000; 00056 const uint32_t EU868_FREQ_MAX = 870000000; 00057 00058 const uint8_t EU868_MIN_DATARATE = (uint8_t) DR_0; //!< Minimum transmit datarate for EU868 00059 const uint8_t EU868_MAX_DATARATE = (uint8_t) DR_7; //!< Maximum transmit datarate for EU868 00060 00061 const uint8_t EU868_MIN_DATARATE_OFFSET = (uint8_t) 0; //!< Minimum transmit datarate for US915 00062 const uint8_t EU868_MAX_DATARATE_OFFSET = (uint8_t) 5; //!< Maximum transmit datarate for US915 00063 00064 const uint8_t EU868_BEACON_DR = DR_3; //!< Default beacon datarate 00065 const uint32_t EU868_BEACON_FREQ = 869525000U; //!< Default beacon broadcast frequency 00066 00067 class ChannelPlan_EU868 : public lora::ChannelPlan { 00068 public: 00069 /** 00070 * ChannelPlan constructor 00071 * @param radio SxRadio object used to set Tx/Rx config 00072 * @param settings Settings object 00073 */ 00074 ChannelPlan_EU868(); 00075 ChannelPlan_EU868(Settings* settings); 00076 ChannelPlan_EU868(SxRadio* radio, Settings* settings); 00077 00078 /** 00079 * ChannelPlan destructor 00080 */ 00081 virtual ~ChannelPlan_EU868(); 00082 00083 /** 00084 * Initialize channels, datarates and duty cycle bands according to current channel plan in settings 00085 */ 00086 virtual void Init(); 00087 00088 /** 00089 * Get the next channel to use to transmit 00090 * @return LORA_OK if channel was found 00091 * @return LORA_NO_CHANS_ENABLED 00092 */ 00093 virtual uint8_t GetNextChannel(); 00094 00095 /** 00096 * Add a channel to the ChannelPlan 00097 * @param index of channel, use -1 to add to end 00098 * @param channel settings to add 00099 */ 00100 virtual uint8_t AddChannel(int8_t index, Channel channel); 00101 00102 /** 00103 * Get channel at index 00104 * @return Channel 00105 */ 00106 virtual Channel GetChannel(int8_t index); 00107 00108 /** 00109 * Get rx window settings for requested window 00110 * RX_1, RX_2, RX_BEACON, RX_SLOT 00111 * @param window 00112 * @return RxWindow 00113 */ 00114 virtual RxWindow GetRxWindow(uint8_t window); 00115 00116 /** 00117 * Get datarate to use on the join request 00118 * @return datarate index 00119 */ 00120 virtual uint8_t GetJoinDatarate(); 00121 00122 /** 00123 * Calculate the next time a join request is possible 00124 * @param size of join frame 00125 * @returns LORA_OK 00126 */ 00127 virtual uint8_t CalculateJoinBackoff(uint8_t size); 00128 00129 /** 00130 * Get next channel and set the SxRadio tx config with current settings 00131 * @return LORA_OK 00132 */ 00133 virtual uint8_t SetTxConfig(); 00134 00135 /** 00136 * Set the SxRadio rx config provided window 00137 * @param window to be opened 00138 * @param continuous keep window open 00139 * @param wnd_growth factor to increase the rx window by 00140 * @return LORA_OK 00141 */ 00142 virtual uint8_t SetRxConfig(uint8_t window, bool continuous, uint16_t wnd_growth); 00143 00144 /** 00145 * Set frequency sub band if supported by plan 00146 * @param sub_band 00147 * @return LORA_OK 00148 */ 00149 virtual uint8_t SetFrequencySubBand(uint8_t sub_band); 00150 00151 /** 00152 * Callback for ACK timeout event 00153 * @return LORA_OK 00154 */ 00155 virtual uint8_t HandleAckTimeout(); 00156 00157 /** 00158 * Callback for Join Accept packet to load optional channels 00159 * @return LORA_OK 00160 */ 00161 virtual uint8_t HandleJoinAccept(const uint8_t* buffer, uint8_t size); 00162 00163 /** 00164 * Callback to for rx parameter setup ServerCommand 00165 * @param payload packet data 00166 * @param index of start of command buffer 00167 * @param size number of bytes in command buffer 00168 * @param[out] status to be returned in MoteCommand answer 00169 * @return LORA_OK 00170 */ 00171 virtual uint8_t HandleRxParamSetup(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00172 00173 /** 00174 * Callback to for new channel ServerCommand 00175 * @param payload packet data 00176 * @param index of start of command buffer 00177 * @param size number of bytes in command buffer 00178 * @param[out] status to be returned in MoteCommand answer 00179 * @return LORA_OK 00180 */ 00181 virtual uint8_t HandleNewChannel(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00182 00183 /** 00184 * Callback to for ping slot channel request ServerCommand 00185 * @param payload packet data 00186 * @param index of start of command buffer 00187 * @param size number of bytes in command buffer 00188 * @param[out] status to be returned in MoteCommand answer 00189 * @return LORA_OK 00190 */ 00191 virtual uint8_t HandlePingSlotChannelReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00192 00193 /** 00194 * Callback to for beacon frequency request ServerCommand 00195 * @param payload packet data 00196 * @param index of start of command buffer 00197 * @param size number of bytes in command buffer 00198 * @param[out] status to be returned in MoteCommand answer 00199 * @return LORA_OK 00200 */ 00201 virtual uint8_t HandleBeaconFrequencyReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00202 00203 /** 00204 * Callback to for adaptive datarate ServerCommand 00205 * @param payload packet data 00206 * @param index of start of command buffer 00207 * @param size number of bytes in command buffer 00208 * @param[out] status to be returned in MoteCommand answer 00209 * @return LORA_OK 00210 */ 00211 virtual uint8_t HandleAdrCommand(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00212 00213 /** 00214 * Validate the configuration after multiple ADR commands have been applied 00215 * @return status to be returned in MoteCommand answer 00216 */ 00217 virtual uint8_t ValidateAdrConfiguration(); 00218 00219 /** 00220 * Update duty cycle with at given frequency and time on air 00221 * @param freq frequency 00222 * @param time_on_air_ms tx time on air 00223 */ 00224 virtual void UpdateDutyCycle(uint32_t freq, uint32_t time_on_air_ms); 00225 00226 /** 00227 * Get the time the radio must be off air to comply with regulations 00228 * Time to wait may be dependent on duty-cycle restrictions per channel 00229 * Or duty-cycle of join requests if OTAA is being attempted 00230 * @return ms of time to wait for next tx opportunity 00231 */ 00232 virtual uint32_t GetTimeOffAir(); 00233 00234 /** 00235 * Get the channels in use by current channel plan 00236 * @return channel frequencies 00237 */ 00238 virtual std::vector<uint32_t> GetChannels(); 00239 00240 /** 00241 * Get the channel datarate ranges in use by current channel plan 00242 * @return channel datarate ranges 00243 */ 00244 virtual std::vector<uint8_t> GetChannelRanges(); 00245 00246 /** 00247 * Print log message for given rx window 00248 * @param wnd 1 or 2 00249 */ 00250 virtual void LogRxWindow(uint8_t wnd); 00251 00252 /** 00253 * Enable the default channels of the channel plan 00254 */ 00255 virtual void EnableDefaultChannels(); 00256 00257 /** 00258 * Check if this packet is a beacon and if so extract parameters needed 00259 * @param payload of potential beacon 00260 * @param size of the packet 00261 * @param [out] data extracted from the beacon if this packet was indeed a beacon 00262 * @return true if this packet is beacon, false if not 00263 */ 00264 virtual bool DecodeBeacon(const uint8_t* payload, 00265 size_t size, 00266 BeaconData_t& data); 00267 00268 protected: 00269 00270 static const uint8_t EU868_TX_POWERS[8]; //!< List of available tx powers 00271 static const uint8_t EU868_RADIO_POWERS[21]; //!< List of calibrated tx powers 00272 static const uint8_t EU868_MAX_PAYLOAD_SIZE[]; //!< List of max payload sizes for each datarate 00273 static const uint8_t EU868_MAX_PAYLOAD_SIZE_REPEATER[]; //!< List of repeater compatible max payload sizes for each datarate 00274 00275 typedef struct __attribute__((packed)) { 00276 uint8_t RFU[2]; 00277 uint8_t Time[4]; 00278 uint8_t CRC1[2]; 00279 uint8_t GwSpecific[7]; 00280 uint8_t CRC2[2]; 00281 } BCNPayload; 00282 }; 00283 } 00284 00285 #endif //__CHANNEL_PLAN_EU868_H__
Generated on Tue Jul 12 2022 18:19:47 by
1.7.2


L-Tek FF1705