34 #ifndef MBED_OS_LORAPHY_BASE_ 35 #define MBED_OS_LORAPHY_BASE_ 37 #include "platform/NonCopyable.h" 39 #include "system/LoRaWANTimer.h" 40 #include "LoRaRadio.h" 124 void calculate_backoff(
bool joined,
bool last_tx_was_join_req,
bool dc_enabled, uint8_t channel,
180 virtual void apply_cf_list(
const uint8_t *payload, uint8_t size);
195 bool get_next_ADR(
bool restore_channel_mask, int8_t &dr_out,
196 int8_t &tx_power_out, uint32_t &adr_ack_counter);
315 int8_t *dr_out, int8_t *tx_power_out,
317 uint8_t *nb_bytes_parsed);
407 uint32_t frequency = 0);
583 bool val_in_range(int8_t value, int8_t min, int8_t max);
593 bool disable_channel(uint16_t *channel_mask, uint8_t
id, uint8_t max_channels);
598 uint8_t
count_bits(uint16_t mask, uint8_t nb_bits);
628 int8_t *tx_pow, uint8_t *nb_rep);
634 float rx_error,
float wakeup_time,
635 uint32_t *window_length, uint32_t *window_length_ms,
636 int32_t *window_offset,
642 int8_t
compute_tx_power(int8_t txPowerIndex,
float maxEirp,
float antennaGain);
659 uint8_t enabled_channel_count(uint8_t datarate,
660 const uint16_t *mask, uint8_t *enabledChannels,
663 bool is_datarate_supported(
const int8_t datarate)
const;
670 float compute_symb_timeout_lora(uint8_t phy_dr, uint32_t bandwidth);
675 float compute_symb_timeout_fsk(uint8_t phy_dr);
bool val_in_range(int8_t value, int8_t min, int8_t max)
Verifies, if a value is in a given range.
uint8_t get_default_rx2_datarate()
get_default_rx2_datarate Gets default RX2 datarate
bool verify_tx_power(uint8_t tx_power)
verify_tx_power Verifies that given TX power is valid
TX configuration parameters.
void handle_send(uint8_t *buf, uint8_t size)
Delegates MAC layer request to transmit packet.
uint8_t get_minimum_rx_datarate()
get_minimum_rx_datarate Gets the minimum RX datarate supported by a device
uint8_t num_active_channels(uint16_t *channel_mask, uint8_t start_idx, uint8_t stop_idx)
Counts the number of active channels in a given channels mask.
uint8_t get_default_tx_datarate()
get_default_tx_datarate Gets the default TX datarate
uint8_t get_max_payload(uint8_t datarate, bool use_repeater=false)
get_max_payload Gets maximum amount in bytes which device can send
virtual void apply_cf_list(const uint8_t *payload, uint8_t size)
Processes the incoming CF-list.
virtual void set_tx_cont_mode(cw_mode_params_t *continuous_wave, uint32_t frequency=0)
Puts the radio into continuous wave mode.
virtual int8_t get_alternate_DR(uint8_t nb_trials)
Alternates the datarate of the channel for the join request.
bool verify_channel_DR(uint16_t *channelsMask, int8_t dr)
Verifies, if a datarate is available on an active channel.
void setup_public_network_mode(bool set)
Enables/Disables public network mode.
virtual bool remove_channel(uint8_t channel_id)
Removes a channel from the channel list.
virtual void set_last_tx_done(uint8_t channel, bool joined, lorawan_time_t last_tx_done_time)
Process PHY layer state after a successful transmission.
bool verify_tx_datarate(uint8_t datarate, bool use_default=false)
verify_tx_datarate Verifies that given TX datarate is valid
virtual bool tx_config(tx_config_params_t *tx_config, int8_t *tx_power, lorawan_time_t *tx_toa)
Configure radio transmission.
virtual uint8_t link_ADR_request(adr_req_params_t *params, int8_t *dr_out, int8_t *tx_power_out, uint8_t *nb_rep_out, uint8_t *nb_bytes_parsed)
Processes a Link ADR Request.
uint8_t verify_link_ADR_req(verify_adr_params_t *verify_params, int8_t *dr, int8_t *tx_pow, uint8_t *nb_rep)
Verifies and updates the datarate, the TX power and the number of repetitions of a LinkAdrRequest...
uint8_t count_bits(uint16_t mask, uint8_t nb_bits)
Counts number of bits on in a given mask.
Prevents generation of copy constructor and copy assignment operator in derived classes.
uint32_t lorawan_time_t
Timer time variable definition.
virtual lorawan_status_t set_next_channel(channel_selection_params_t *nextChanParams, uint8_t *channel, lorawan_time_t *time, lorawan_time_t *aggregatedTimeOff)
Searches and sets the next available channel.
void mask_bit_clear(uint16_t *mask, unsigned bit)
Tests if a channel is on or off in the channel mask.
Structure used to store ADR values received from network for verification (legality) purposes...
uint32_t get_rx_time_on_air(uint8_t modem, uint16_t pkt_len)
get_rx_time_on_air(...) calculates the time the received spent on air
LoRaPHY Class Parent class for LoRa regional PHY implementations.
Structure containing data for local ADR settings.
/ _____) _ | | ( (____ _____ ____ _| |_ _____ ____| |__ ____ | ___ | (_ _) ___ |/ ___) _ \ _____) ) _...
uint32_t get_default_rx2_frequency()
get_default_rx2_frequency Gets default RX2 frequency
virtual lorawan_status_t add_channel(const channel_params_t *new_channel, uint8_t id)
Adds a channel to the channel list.
void put_radio_to_sleep(void)
Puts radio in sleep mode.
virtual bool verify_frequency_for_band(uint32_t freq, uint8_t band) const
Verifies, if a frequency is within a given band.
uint8_t get_default_max_tx_datarate()
get_default_max_tx_datarate Gets the maximum achievable data rate for LoRa modulation.
enum lorawan_status lorawan_status_t
lorawan_status_t contains status codes in response to stack operations
void mask_bit_set(uint16_t *mask, unsigned bit)
Tests if a channel is on or off in the channel mask.
void copy_channel_mask(uint16_t *dest_mask, uint16_t *src_mask, uint8_t len)
Copy channel masks.
virtual void restore_default_channels()
Enables default channels only.
void initialize(LoRaWANTimeHandler *lora_time)
Initialize LoRaPHY.
int8_t compute_tx_power(int8_t txPowerIndex, float maxEirp, float antennaGain)
Computes the txPower, based on the max EIRP and the antenna gain.
uint16_t * get_channel_mask(bool get_default=false)
get_channel_mask Gets the channel mask
bool is_custom_channel_plan_supported()
is_custom_channel_plan_supported Checks if custom channel plan is supported
uint8_t get_minimum_tx_datarate()
get_minimum_tx_datarate Gets the minimum TX datarate supported by a device
virtual uint8_t dl_channel_request(uint8_t channel_id, uint32_t rx1_frequency)
Processes a DlChannelReq MAC command.
The parameter structure for the function RegionNextChannel.
uint8_t parse_link_ADR_req(const uint8_t *payload, uint8_t payload_size, link_adr_params_t *adr_params)
Parses the parameter of an LinkAdrRequest.
virtual uint8_t request_new_channel(int8_t channel_id, channel_params_t *new_channel)
Entertain a new channel request MAC command.
int32_t get_random(int32_t min, int32_t max)
Provides a random number in the range provided.
uint32_t get_ack_timeout()
get_ack_timeout Gets timeout value for ACK to be received
void calculate_backoff(bool joined, bool last_tx_was_join_req, bool dc_enabled, uint8_t channel, lorawan_time_t elapsed_time, lorawan_time_t tx_toa)
calculate_backoff Calculates and applies duty cycle back-off time.
Contains rx parameter setup request coming from network server.
void get_rx_window_params(float t_symbol, uint8_t min_rx_symbols, float rx_error, float wakeup_time, uint32_t *window_length, uint32_t *window_length_ms, int32_t *window_offset, uint8_t phy_dr)
Computes the RX window timeout and the RX window offset.
bool get_next_ADR(bool restore_channel_mask, int8_t &dr_out, int8_t &tx_power_out, uint32_t &adr_ack_counter)
Calculates the next datarate to set, when ADR is on or off.
virtual bool rx_config(rx_config_params_t *config)
Configure radio reception.
bool disable_channel(uint16_t *channel_mask, uint8_t id, uint8_t max_channels)
Disables a channel in a given channels mask.
uint8_t get_max_nb_channels()
get_max_nb_channels Gets maximum number of channels supported
channel_params_t * get_phy_channels()
get_phy_channels Gets PHY channels
int8_t get_next_lower_tx_datarate(int8_t datarate)
get_next_lower_tx_datarate Gets the next lower datarate
int8_t get_next_lower_dr(int8_t dr, int8_t min_dr)
Get next lower data rate.
Data structures relating to PHY layer.
bool verify_nb_join_trials(uint8_t nb_join_trials)
verify_nb_join_trials Verifies that given number of trials is valid
int lookup_band_for_frequency(uint32_t freq) const
Looks up corresponding band for a frequency.
virtual uint8_t apply_DR_offset(int8_t dr, int8_t dr_offset)
Computes new data rate according to the given offset.
virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t *params)
Accept or rejects RxParamSetupReq MAC command.
void handle_receive(void)
Puts radio in receive mode.
This structure contains parameters for ADR request coming from network server.
void set_radio_instance(LoRaRadio &radio)
Stores a reference to Radio object.
uint32_t get_radio_rng()
Provides a random number from radio.
virtual bool accept_tx_param_setup_req(uint8_t ul_dwell_time, uint8_t dl_dwell_time)
accept_tx_param_setup_req Makes decision whether to accept or reject TxParamSetupReq MAC command...
bool verify_rx_datarate(uint8_t datarate)
verify_rx_datarate Verifies that given RX datarate is valid
void put_radio_to_standby(void)
Puts radio in standby mode.
Interface for the radios, containing the main functions that a radio needs, and five callback functio...
DO NOT MODIFY, WILL BREAK THE API!
bool mask_bit_test(const uint16_t *mask, unsigned bit)
Tests if a channel is on or off in the channel mask.
uint8_t get_bandwidth(uint8_t dr_index)
Get channel bandwidth depending upon data rate table index.
Default user application maximum data size for transmission.
lorawan_time_t update_band_timeoff(bool joined, bool dutyCycle, band_t *bands, uint8_t nb_bands)
Updates the time-offs of the bands.
virtual void compute_rx_win_params(int8_t datarate, uint8_t min_rx_symbols, uint32_t rx_error, rx_config_params_t *rx_conf_params)
Computing Receive Windows.
uint16_t get_maximum_frame_counter_gap()
get_maximum_frame_counter_gap Gets maximum frame counter gap
void reset_to_default_values(loramac_protocol_params *params, bool init=false)
reset_to_default_values resets some parameters to default values
bool verify_duty_cycle(bool cycle)
verify_duty_cycle Verifies that given cycle is valid
uint8_t get_default_tx_power()
get_default_tx_power Gets the default TX power