fota lib for mdot
Embed:
(wiki syntax)
Show/hide line numbers
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 class ChannelPlan_EU868 : public lora::ChannelPlan { 00027 public: 00028 /** 00029 * ChannelPlan constructor 00030 * @param radio SxRadio object used to set Tx/Rx config 00031 * @param settings Settings object 00032 */ 00033 ChannelPlan_EU868(); 00034 ChannelPlan_EU868(Settings* settings); 00035 ChannelPlan_EU868(SxRadio* radio, Settings* settings); 00036 00037 /** 00038 * ChannelPlan destructor 00039 */ 00040 virtual ~ChannelPlan_EU868(); 00041 00042 /** 00043 * Initialize channels, datarates and duty cycle bands according to current channel plan in settings 00044 */ 00045 virtual void Init(); 00046 00047 /** 00048 * Get the next channel to use to transmit 00049 * @return LORA_OK if channel was found 00050 * @return LORA_NO_CHANS_ENABLED 00051 */ 00052 virtual uint8_t GetNextChannel(); 00053 00054 /** 00055 * Add a channel to the ChannelPlan 00056 * @param index of channel, use -1 to add to end 00057 * @param channel settings to add 00058 */ 00059 virtual uint8_t AddChannel(int8_t index, Channel channel); 00060 00061 /** 00062 * Get channel at index 00063 * @return Channel 00064 */ 00065 virtual Channel GetChannel(int8_t index); 00066 00067 /** 00068 * Get rx window settings for requested window 00069 * RX_1, RX_2, RX_BEACON, RX_SLOT 00070 * @param window 00071 * @return RxWindow 00072 */ 00073 virtual RxWindow GetRxWindow(uint8_t window); 00074 00075 /** 00076 * Get datarate to use on the join request 00077 * @return datarate index 00078 */ 00079 virtual uint8_t GetJoinDatarate(); 00080 00081 /** 00082 * Calculate the next time a join request is possible 00083 * @param size of join frame 00084 * @returns LORA_OK 00085 */ 00086 virtual uint8_t CalculateJoinBackoff(uint8_t size); 00087 00088 /** 00089 * Get next channel and set the SxRadio tx config with current settings 00090 * @return LORA_OK 00091 */ 00092 virtual uint8_t SetTxConfig(); 00093 00094 /** 00095 * Set the SxRadio rx config provided window 00096 * @param window to be opened 00097 * @param continuous keep window open 00098 * @return LORA_OK 00099 */ 00100 virtual uint8_t SetRxConfig(uint8_t window, bool continuous); 00101 00102 /** 00103 * Set frequency sub band if supported by plan 00104 * @param sub_band 00105 * @return LORA_OK 00106 */ 00107 virtual uint8_t SetFrequencySubBand(uint8_t sub_band); 00108 00109 /** 00110 * Get time on air with current settings 00111 * @param bytes number of bytes to be sent 00112 */ 00113 virtual uint32_t GetTimeOnAir(uint8_t bytes); 00114 00115 /** 00116 * Callback for ACK timeout event 00117 * @return LORA_OK 00118 */ 00119 virtual uint8_t HandleAckTimeout(); 00120 00121 /** 00122 * Callback for Join Accept packet to load optional channels 00123 * @return LORA_OK 00124 */ 00125 virtual uint8_t HandleJoinAccept(const uint8_t* buffer, uint8_t size); 00126 00127 /** 00128 * Callback to for rx parameter setup ServerCommand 00129 * @param payload packet data 00130 * @param index of start of command buffer 00131 * @param size number of bytes in command buffer 00132 * @param[out] status to be returned in MoteCommand answer 00133 * @return LORA_OK 00134 */ 00135 virtual uint8_t HandleRxParamSetup(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00136 00137 /** 00138 * Callback to for new channel ServerCommand 00139 * @param payload packet data 00140 * @param index of start of command buffer 00141 * @param size number of bytes in command buffer 00142 * @param[out] status to be returned in MoteCommand answer 00143 * @return LORA_OK 00144 */ 00145 virtual uint8_t HandleNewChannel(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00146 00147 /** 00148 * Callback to for ping slot channel request ServerCommand 00149 * @param payload packet data 00150 * @param index of start of command buffer 00151 * @param size number of bytes in command buffer 00152 * @param[out] status to be returned in MoteCommand answer 00153 * @return LORA_OK 00154 */ 00155 virtual uint8_t HandlePingSlotChannelReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00156 00157 /** 00158 * Callback to for beacon frequency request ServerCommand 00159 * @param payload packet data 00160 * @param index of start of command buffer 00161 * @param size number of bytes in command buffer 00162 * @param[out] status to be returned in MoteCommand answer 00163 * @return LORA_OK 00164 */ 00165 virtual uint8_t HandleBeaconFrequencyReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00166 00167 /** 00168 * Callback to for adaptive datarate ServerCommand 00169 * @param payload packet data 00170 * @param index of start of command buffer 00171 * @param size number of bytes in command buffer 00172 * @param[out] status to be returned in MoteCommand answer 00173 * @return LORA_OK 00174 */ 00175 virtual uint8_t HandleAdrCommand(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status); 00176 00177 /** 00178 * Validate the configuration after multiple ADR commands have been applied 00179 * @return status to be returned in MoteCommand answer 00180 */ 00181 virtual uint8_t ValidateAdrConfiguration(); 00182 00183 /** 00184 * Update duty cycle with at given frequency and time on air 00185 * @param freq frequency 00186 * @param time_on_air_ms tx time on air 00187 */ 00188 virtual void UpdateDutyCycle(uint32_t freq, uint32_t time_on_air_ms); 00189 00190 /** 00191 * Get the time the radio must be off air to comply with regulations 00192 * Time to wait may be dependent on duty-cycle restrictions per channel 00193 * Or duty-cycle of join requests if OTAA is being attempted 00194 * @return ms of time to wait for next tx opportunity 00195 */ 00196 virtual uint32_t GetTimeOffAir(); 00197 00198 /** 00199 * Get the channels in use by current channel plan 00200 * @return channel frequencies 00201 */ 00202 virtual std::vector<uint32_t> GetChannels(); 00203 00204 /** 00205 * Get the channel datarate ranges in use by current channel plan 00206 * @return channel datarate ranges 00207 */ 00208 virtual std::vector<uint8_t> GetChannelRanges(); 00209 00210 /** 00211 * Print log message for given rx window 00212 * @param wnd 1 or 2 00213 */ 00214 virtual void LogRxWindow(uint8_t wnd); 00215 00216 /** 00217 * Enable the default channels of the channel plan 00218 */ 00219 virtual void EnableDefaultChannels(); 00220 00221 protected: 00222 00223 static const uint8_t EU868_TX_POWERS[8]; //!< List of available tx powers 00224 static const uint8_t EU868_RADIO_POWERS[21]; //!< List of calibrated tx powers 00225 static const uint8_t EU868_MAX_PAYLOAD_SIZE[]; //!< List of max payload sizes for each datarate 00226 static const uint8_t EU868_MAX_PAYLOAD_SIZE_REPEATER[]; //!< List of repeater compatible max payload sizes for each datarate 00227 }; 00228 } 00229 00230 #endif //__CHANNEL_PLAN_EU868_H__
Generated on Tue Jul 12 2022 12:07:34 by 1.7.2