Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

LoRaPHY Class Reference

LoRaPHY Class Parent class for LoRa regional PHY implementations. More...

#include <LoRaPHY.h>

Inherits NonCopyable< LoRaPHY >.

Inherited by LoRaPHYAS923, LoRaPHYAU915, LoRaPHYCN470, LoRaPHYCN779, LoRaPHYEU433, LoRaPHYEU868, LoRaPHYIN865, LoRaPHYKR920, and LoRaPHYUS915.

Public Member Functions

void initialize (LoRaWANTimeHandler *lora_time)
 Initialize LoRaPHY.
void set_radio_instance (LoRaRadio &radio)
 Stores a reference to Radio object.
void put_radio_to_sleep (void)
 Puts radio in sleep mode.
void put_radio_to_standby (void)
 Puts radio in standby mode.
void handle_receive (void)
 Puts radio in receive mode.
void handle_send (uint8_t *buf, uint8_t size)
 Delegates MAC layer request to transmit packet.
void setup_public_network_mode (bool set)
 Enables/Disables public network mode.
uint32_t get_radio_rng ()
 Provides a random number from radio.
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.
bool mask_bit_test (const uint16_t *mask, unsigned bit)
 Tests if a channel is on or off in the channel mask.
void mask_bit_set (uint16_t *mask, unsigned bit)
 Tests if a channel is on or off in the channel mask.
void mask_bit_clear (uint16_t *mask, unsigned bit)
 Tests if a channel is on or off in the channel mask.
virtual uint8_t request_new_channel (int8_t channel_id, channel_params_t *new_channel)
 Entertain a new channel request MAC command.
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.
virtual void restore_default_channels ()
 Enables default channels only.
virtual void apply_cf_list (const uint8_t *payload, uint8_t size)
 Processes the incoming CF-list.
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.
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.
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.
virtual uint8_t accept_rx_param_setup_req (rx_param_setup_req_t *params)
 Accept or rejects RxParamSetupReq MAC command.
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.
virtual uint8_t dl_channel_request (uint8_t channel_id, uint32_t rx1_frequency)
 Processes a DlChannelReq MAC command.
virtual int8_t get_alternate_DR (uint8_t nb_trials)
 Alternates the datarate of the channel for the join request.
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.
virtual lorawan_status_t add_channel (const channel_params_t *new_channel, uint8_t id)
 Adds a channel to the channel list.
virtual bool remove_channel (uint8_t channel_id)
 Removes a channel from the channel 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 uint8_t apply_DR_offset (int8_t dr, int8_t dr_offset)
 Computes new data rate according to the given offset.
void reset_to_default_values (loramac_protocol_params *params, bool init=false)
 reset_to_default_values resets some parameters to default values
int8_t get_next_lower_tx_datarate (int8_t datarate)
 get_next_lower_tx_datarate Gets the next lower datarate
uint8_t get_minimum_rx_datarate ()
 get_minimum_rx_datarate Gets the minimum RX datarate supported by a device
uint8_t get_minimum_tx_datarate ()
 get_minimum_tx_datarate Gets the minimum TX datarate supported by a device
uint8_t get_default_tx_datarate ()
 get_default_tx_datarate Gets the default TX datarate
uint8_t get_default_max_tx_datarate ()
 get_default_max_tx_datarate Gets the maximum achievable data rate for LoRa modulation.
uint8_t get_default_tx_power ()
 get_default_tx_power Gets the default TX power
uint8_t get_max_payload (uint8_t datarate, bool use_repeater=false)
 get_max_payload Gets maximum amount in bytes which device can send
uint16_t get_maximum_frame_counter_gap ()
 get_maximum_frame_counter_gap Gets maximum frame counter gap
uint32_t get_ack_timeout ()
 get_ack_timeout Gets timeout value for ACK to be received
uint32_t get_default_rx2_frequency ()
 get_default_rx2_frequency Gets default RX2 frequency
uint8_t get_default_rx2_datarate ()
 get_default_rx2_datarate Gets default RX2 datarate
uint16_t * get_channel_mask (bool get_default=false)
 get_channel_mask Gets the channel mask
uint8_t get_max_nb_channels ()
 get_max_nb_channels Gets maximum number of channels supported
channel_params_tget_phy_channels ()
 get_phy_channels Gets PHY channels
bool is_custom_channel_plan_supported ()
 is_custom_channel_plan_supported Checks if custom channel plan is supported
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
bool verify_rx_datarate (uint8_t datarate)
 verify_rx_datarate Verifies that given RX datarate is valid
bool verify_tx_datarate (uint8_t datarate, bool use_default=false)
 verify_tx_datarate Verifies that given TX datarate is valid
bool verify_tx_power (uint8_t tx_power)
 verify_tx_power Verifies that given TX power is valid
bool verify_duty_cycle (bool cycle)
 verify_duty_cycle Verifies that given cycle is valid
bool verify_nb_join_trials (uint8_t nb_join_trials)
 verify_nb_join_trials Verifies that given number of trials is valid

Protected Member Functions

int lookup_band_for_frequency (uint32_t freq) const
 Looks up corresponding band for a frequency.
virtual bool verify_frequency_for_band (uint32_t freq, uint8_t band) const
 Verifies, if a frequency is within a given band.
bool val_in_range (int8_t value, int8_t min, int8_t max)
 Verifies, if a value is in a given range.
bool verify_channel_DR (uint16_t *channelsMask, int8_t dr)
 Verifies, if a datarate is available on an active channel.
bool disable_channel (uint16_t *channel_mask, uint8_t id, uint8_t max_channels)
 Disables a channel in a given channels mask.
uint8_t count_bits (uint16_t mask, uint8_t nb_bits)
 Counts number of bits on in a given mask.
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.
void copy_channel_mask (uint16_t *dest_mask, uint16_t *src_mask, uint8_t len)
 Copy channel masks.
lorawan_time_t update_band_timeoff (bool joined, bool dutyCycle, band_t *bands, uint8_t nb_bands)
 Updates the time-offs of the bands.
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.
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.
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.
int8_t compute_tx_power (int8_t txPowerIndex, float maxEirp, float antennaGain)
 Computes the txPower, based on the max EIRP and the antenna gain.
int32_t get_random (int32_t min, int32_t max)
 Provides a random number in the range provided.
int8_t get_next_lower_dr (int8_t dr, int8_t min_dr)
 Get next lower data rate.
uint8_t get_bandwidth (uint8_t dr_index)
 Get channel bandwidth depending upon data rate table index.

Private Member Functions

 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.

Detailed Description

LoRaPHY Class Parent class for LoRa regional PHY implementations.

Definition at line 46 of file LoRaPHY.h.


Member Function Documentation

uint8_t accept_rx_param_setup_req ( rx_param_setup_req_t params ) [virtual]

Accept or rejects RxParamSetupReq MAC command.

The function processes a RX parameter setup request in response to server MAC command for RX setup.

Parameters:
[in]paramsA pointer to rx parameter setup request.
Returns:
The status of the operation, according to the LoRaWAN specification.

Definition at line 1081 of file LoRaPHY.cpp.

bool accept_tx_param_setup_req ( uint8_t  ul_dwell_time,
uint8_t  dl_dwell_time 
) [virtual]

accept_tx_param_setup_req Makes decision whether to accept or reject TxParamSetupReq MAC command.

Parameters:
ul_dwell_timeThe uplink dwell time.
dl_dwell_timeThe downlink dwell time.
Returns:
True to let the MAC know that the request is accepted and MAC can apply TX parameters received form Network Server. Otherwise false is returned.

Definition at line 1109 of file LoRaPHY.cpp.

lorawan_status_t add_channel ( const channel_params_t new_channel,
uint8_t  id 
) [virtual]

Adds a channel to the channel list.

Verifies the channel parameters and if everything is found legitimate, adds that particular channel to the channel list and updates the channel mask.

Parameters:
[in]new_channelA pointer to the parameters for the new channel.
[in]idChannel ID
Returns:
LORAWAN_STATUS_OK if everything goes fine, negative error code otherwise.

Definition at line 1326 of file LoRaPHY.cpp.

void apply_cf_list ( const uint8_t *  payload,
uint8_t  size 
) [virtual]

Processes the incoming CF-list.

Handles the payload containing CF-list and enables channels defined therein.

Parameters:
payloadPayload to process.
sizeSize of the payload.

Definition at line 734 of file LoRaPHY.cpp.

uint8_t apply_DR_offset ( int8_t  dr,
int8_t  dr_offset 
) [virtual]

Computes new data rate according to the given offset.

Parameters:
[in]drThe current datarate.
[in]dr_offsetThe offset to be applied.
Returns:
The computed datarate.

Definition at line 1453 of file LoRaPHY.cpp.

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.

Explicitly updates the band time-off.

Parameters:
joinedSet to true, if the node has already joined a network, otherwise false.
last_tx_was_join_reqSet to true, if the last uplink was a join request.
dc_enabledSet to true, if the duty cycle is enabled, otherwise false.
channelThe current channel index.
elapsed_timeElapsed time since the start of the node.
tx_toaTime-on-air of the last transmission.

Definition at line 1220 of file LoRaPHY.cpp.

void compute_rx_win_params ( int8_t  datarate,
uint8_t  min_rx_symbols,
uint32_t  rx_error,
rx_config_params_t rx_conf_params 
) [virtual]

Computing Receive Windows.

The algorithm tries to calculate the length of receive windows (i.e., the minimum time it should remain to acquire a lock on the Preamble for synchronization) and the error offset which compensates for the system timing errors. Basic idea behind the algorithm is to optimize for the reception of last 'min_rx_symbols' symbols out of transmitted Premable symbols. The algorithm compensates for the clock drifts, tick granularity and system wake up time (from sleep state) by opening the window early for the lower SFs. For higher SFs, the symbol time is large enough that we can afford to open late (hence the positive offset). The table below shows the calculated values for SF7 to SF12 with 125 kHz bandwidth.

+----+-----+----------+---------+-------------------------+----------------------+-------------------------+ | SF | BW (kHz) | rx_error (ms) | wake_up (ms) | min_rx_symbols | window_timeout(symb) | window_offset(ms) | +----+-----+----------+---------+-------------------------+----------------------+-------------------------+ | 7 | 125 | 5 | 5 | 5 | 18 | -7 | | 8 | 125 | 5 | 5 | 5 | 10 | -4 | | 9 | 125 | 5 | 5 | 5 | 6 | 2 | | 10 | 125 | 5 | 5 | 5 | 6 | 14 | | 11 | 125 | 5 | 5 | 5 | 6 | 39 | | 12 | 125 | 5 | 5 | 5 | 6 | 88 | +----+-----+----------+---------+-------------------------+----------------------+-------------------------+

For example for SF7, the receive window will open at downlink start time plus the offset calculated and will remain open for the length window_timeout.

Symbol time = 1.024 ms Downlink start: T = Tx + 1s (+/- 20 us) | | | | | +---+---+---+---+---+---+---+---+ | 8 Preamble Symbols | +---+---+---+---+---+---+---+---+ | RX Window start time = T +/- Offset +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Similarly for SF12:

Symbol time = 32.768 ms Downlink start: T = Tx + 1s (+/- 20 us) | | | | | +---+---+---+---+---+---+---+---+ | 8 Preamble Symbols | +---+---+---+---+---+---+---+---+ | RX Window start time = T +/- Offset +---+---+---+---+---+---+ | | | | | | | +---+---+---+---+---+---+

Computes the RX window timeout and offset.

Parameters:
[in]datarateThe RX window datarate index to be used.
[in]min_rx_symbolsThe minimum number of symbols required to detect an RX frame.
[in]rx_errorThe maximum timing error of the receiver in milliseconds. The receiver will turn on in a [-rxError : +rxError] ms interval around RxOffset.
[out]rx_conf_paramsPointer to the structure that needs to be filled with receive window parameters.

Definition at line 828 of file LoRaPHY.cpp.

int8_t compute_tx_power ( int8_t  txPowerIndex,
float  maxEirp,
float  antennaGain 
) [protected]

Computes the txPower, based on the max EIRP and the antenna gain.

Definition at line 449 of file LoRaPHY.cpp.

void copy_channel_mask ( uint16_t *  dest_mask,
uint16_t *  src_mask,
uint8_t  len 
) [protected]

Copy channel masks.

Definition at line 243 of file LoRaPHY.cpp.

uint8_t count_bits ( uint16_t  mask,
uint8_t  nb_bits 
) [protected]

Counts number of bits on in a given mask.

Definition at line 214 of file LoRaPHY.cpp.

bool disable_channel ( uint16_t *  channel_mask,
uint8_t  id,
uint8_t  max_channels 
) [protected]

Disables a channel in a given channels mask.

Definition at line 199 of file LoRaPHY.cpp.

uint8_t dl_channel_request ( uint8_t  channel_id,
uint32_t  rx1_frequency 
) [virtual]

Processes a DlChannelReq MAC command.

Parameters:
channel_idThe channel ID to add the frequency.
rx1_frequencyThe alternative frequency for the Rx1 window.
Returns:
The status of the operation, according to the LoRaWAN specification.

Definition at line 1145 of file LoRaPHY.cpp.

uint32_t get_ack_timeout (  )

get_ack_timeout Gets timeout value for ACK to be received

Returns:
ACK timeout

Definition at line 630 of file LoRaPHY.cpp.

int8_t get_alternate_DR ( uint8_t  nb_trials ) [virtual]

Alternates the datarate of the channel for the join request.

Alternate datarate algorithm for join requests.

Parameters:
nb_trialsNumber of trials to be made on one given data rate.
Returns:
The datarate to apply .
  • We check from the PHY and take note of total number of data rates available upto the default data rate for default channels.
  • Application sets a total number of re-trials for a Join Request, i.e., MBED_CONF_LORA_NB_TRIALS. So MAC layer will send us a counter nb_trials < MBED_CONF_LORA_NB_TRIALS which is the current number of trial.
  • We roll over total available datarates and pick one according to the number of trial sequentially.
  • We always start from the Default Data rate and and set the next lower data rate for every iteration.
  • MAC layer will stop when maximum number of re-trials, i.e., MBED_CONF_LORA_NB_TRIALS is achieved.

So essentially MBED_CONF_LORA_NB_TRIALS should be a multiple of range of data rates available. For example, in EU868 band, default max. data rate is DR_5 and min. data rate is DR_0, so total data rates available are 6.

Hence MBED_CONF_LORA_NB_TRIALS should be a multiple of 6. Setting, MBED_CONF_LORA_NB_TRIALS = 6 would mean that every data rate will be tried exactly once starting from the largest and finishing at the smallest.

PHY layers which do not have datarates scheme similar to EU band will ofcourse override this method.

Definition at line 1202 of file LoRaPHY.cpp.

uint8_t get_bandwidth ( uint8_t  dr_index ) [protected]

Get channel bandwidth depending upon data rate table index.

Definition at line 473 of file LoRaPHY.cpp.

uint16_t * get_channel_mask ( bool  get_default = false )

get_channel_mask Gets the channel mask

Parameters:
get_defaultIf true the default mask is returned, otherwise the current mask is returned
Returns:
A channel mask

Definition at line 646 of file LoRaPHY.cpp.

uint8_t get_default_max_tx_datarate (  )

get_default_max_tx_datarate Gets the maximum achievable data rate for LoRa modulation.

This will always be the highest data rate achievable with LoRa as defined in the regional specifications.

Returns:
Maximum achievable data rate with LoRa modulation.

Definition at line 599 of file LoRaPHY.cpp.

uint8_t get_default_rx2_datarate (  )

get_default_rx2_datarate Gets default RX2 datarate

Returns:
RX2 datarate

Definition at line 641 of file LoRaPHY.cpp.

uint32_t get_default_rx2_frequency (  )

get_default_rx2_frequency Gets default RX2 frequency

Returns:
RX2 frequency

Definition at line 636 of file LoRaPHY.cpp.

uint8_t get_default_tx_datarate (  )

get_default_tx_datarate Gets the default TX datarate

Returns:
default TX datarate

Definition at line 594 of file LoRaPHY.cpp.

uint8_t get_default_tx_power (  )

get_default_tx_power Gets the default TX power

Returns:
Default TX power

Definition at line 604 of file LoRaPHY.cpp.

uint8_t get_max_nb_channels (  )

get_max_nb_channels Gets maximum number of channels supported

Returns:
Number of channels

Definition at line 654 of file LoRaPHY.cpp.

uint8_t get_max_payload ( uint8_t  datarate,
bool  use_repeater = false 
)

get_max_payload Gets maximum amount in bytes which device can send

Parameters:
datarateA datarate to use
use_repeaterIf true repeater table is used, otherwise payloads table is used
Returns:
Maximum number of bytes for payload

Definition at line 609 of file LoRaPHY.cpp.

uint16_t get_maximum_frame_counter_gap (  )

get_maximum_frame_counter_gap Gets maximum frame counter gap

Returns:
Maximum frame counter gap

Definition at line 625 of file LoRaPHY.cpp.

uint8_t get_minimum_rx_datarate (  )

get_minimum_rx_datarate Gets the minimum RX datarate supported by a device

Returns:
Minimum RX datarate

Definition at line 578 of file LoRaPHY.cpp.

uint8_t get_minimum_tx_datarate (  )

get_minimum_tx_datarate Gets the minimum TX datarate supported by a device

Returns:
Minimum TX datarate

Definition at line 586 of file LoRaPHY.cpp.

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.

Parameters:
restore_channel_maskA boolean set restore channel mask in case of failure.
dr_outThe calculated datarate for the next TX.
tx_power_outThe TX power for the next TX.
adr_ack_counterThe calculated ADR acknowledgement counter.
Returns:
True, if an ADR request should be performed.

Definition at line 789 of file LoRaPHY.cpp.

int8_t get_next_lower_dr ( int8_t  dr,
int8_t  min_dr 
) [protected]

Get next lower data rate.

Definition at line 460 of file LoRaPHY.cpp.

int8_t get_next_lower_tx_datarate ( int8_t  datarate )

get_next_lower_tx_datarate Gets the next lower datarate

Parameters:
datarateCurrent TX datarate
Returns:
Lower datarate than given one or minimum if lower cannot be found anymore

Definition at line 568 of file LoRaPHY.cpp.

channel_params_t * get_phy_channels (  )

get_phy_channels Gets PHY channels

Returns:
PHY channels

Definition at line 659 of file LoRaPHY.cpp.

uint32_t get_radio_rng (  )

Provides a random number from radio.

Returns a 32-bit random unsigned integer value based upon RSSI measurements.

Returns:
a 32-bit long random number

Definition at line 105 of file LoRaPHY.cpp.

int32_t get_random ( int32_t  min,
int32_t  max 
) [protected]

Provides a random number in the range provided.

Definition at line 164 of file LoRaPHY.cpp.

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

Returns:
time spent on air in milliseconds

Definition at line 858 of file LoRaPHY.cpp.

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 
) [protected]

Computes the RX window timeout and the RX window offset.

Definition at line 407 of file LoRaPHY.cpp.

void handle_receive ( void   )

Puts radio in receive mode.

Requests the radio driver to enter receive mode.

Definition at line 97 of file LoRaPHY.cpp.

void handle_send ( uint8_t *  buf,
uint8_t  size 
)

Delegates MAC layer request to transmit packet.

Parameters:
bufa pointer to the data which needs to be transmitted
sizesize of the data in bytes

Definition at line 116 of file LoRaPHY.cpp.

void initialize ( LoRaWANTimeHandler *  lora_time )

Initialize LoRaPHY.

LoRaMac calls this to initialize LoRaPHY.

Parameters:
lora_timea pointer to LoRaWANTimeHandler object

Definition at line 51 of file LoRaPHY.cpp.

bool is_custom_channel_plan_supported (  )

is_custom_channel_plan_supported Checks if custom channel plan is supported

Returns:
True if custom channel plan is supported, false otherwise

Definition at line 664 of file LoRaPHY.cpp.

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 
) [virtual]

Processes a Link ADR Request.

Parameters:
[in]paramsA pointer ADR request parameters.
[out]dr_outThe datarate applied.
[out]tx_power_outThe TX power applied.
[out]nb_rep_outThe number of repetitions to apply.
[out]nb_bytes_parsedThe number of bytes parsed.
Returns:
The status of the operation, according to the LoRaMAC specification.

Definition at line 962 of file LoRaPHY.cpp.

int lookup_band_for_frequency ( uint32_t  freq ) const [protected]

Looks up corresponding band for a frequency.

Returns -1 if not in any band.

Definition at line 1119 of file LoRaPHY.cpp.

void mask_bit_clear ( uint16_t *  mask,
unsigned  bit 
)

Tests if a channel is on or off in the channel mask.

Definition at line 66 of file LoRaPHY.cpp.

void mask_bit_set ( uint16_t *  mask,
unsigned  bit 
)

Tests if a channel is on or off in the channel mask.

Definition at line 61 of file LoRaPHY.cpp.

bool mask_bit_test ( const uint16_t *  mask,
unsigned  bit 
)

Tests if a channel is on or off in the channel mask.

Definition at line 56 of file LoRaPHY.cpp.

uint8_t num_active_channels ( uint16_t *  channel_mask,
uint8_t  start_idx,
uint8_t  stop_idx 
) [protected]

Counts the number of active channels in a given channels mask.

Definition at line 227 of file LoRaPHY.cpp.

uint8_t parse_link_ADR_req ( const uint8_t *  payload,
uint8_t  payload_size,
link_adr_params_t adr_params 
) [protected]

Parses the parameter of an LinkAdrRequest.

Definition at line 311 of file LoRaPHY.cpp.

void put_radio_to_sleep ( void   )

Puts radio in sleep mode.

Requests the radio driver to enter sleep mode.

Definition at line 76 of file LoRaPHY.cpp.

void put_radio_to_standby ( void   )

Puts radio in standby mode.

Requests the radio driver to enter standby mode.

Definition at line 83 of file LoRaPHY.cpp.

bool remove_channel ( uint8_t  channel_id ) [virtual]

Removes a channel from the channel list.

Parameters:
[in]channel_idIndex of the channel to be removed
Returns:
True, if the channel was removed successfully.

Definition at line 1405 of file LoRaPHY.cpp.

uint8_t request_new_channel ( int8_t  channel_id,
channel_params_t new_channel 
) [virtual]

Entertain a new channel request MAC command.

MAC command subsystem processes the new channel request coming form the network server and then MAC layer asks the PHY layer to entertain the request.

Parameters:
channel_idThe channel ID.
new_channelA pointer to the new channel's parameters.
Returns:
bit mask, according to the LoRaWAN spec 1.0.2.

Definition at line 123 of file LoRaPHY.cpp.

void reset_to_default_values ( loramac_protocol_params params,
bool  init = false 
)

reset_to_default_values resets some parameters to default values

Parameters:
paramsPointer to MAC protocol parameters which will be reset
initIf true, most of the values will be modified

Definition at line 531 of file LoRaPHY.cpp.

void restore_default_channels (  ) [virtual]

Enables default channels only.

Falls back to a channel mask where only default channels are enabled, all other channels are disabled.

Definition at line 669 of file LoRaPHY.cpp.

bool rx_config ( rx_config_params_t config ) [virtual]

Configure radio reception.

Parameters:
[in]configA pointer to the RX configuration.
Returns:
True, if the configuration was applied successfully.

Definition at line 869 of file LoRaPHY.cpp.

void set_last_tx_done ( uint8_t  channel,
bool  joined,
lorawan_time_t  last_tx_done_time 
) [virtual]

Process PHY layer state after a successful transmission.

set_last_tx_done Updates times of the last transmission for the particular channel and band upon which last transmission took place.

Parameters:
channelThe channel in use.
joinedBoolean telling if node has joined the network.
last_tx_done_timeThe last TX done time.

Definition at line 252 of file LoRaPHY.cpp.

lorawan_status_t set_next_channel ( channel_selection_params_t nextChanParams,
uint8_t *  channel,
lorawan_time_t time,
lorawan_time_t aggregatedTimeOff 
) [virtual]

Searches and sets the next available channel.

If there are multiple channels found available, one of them is selected randomly.

Parameters:
[in]nextChanParamsParameters for the next channel.
[out]channelThe next channel to use for TX.
[out]timeThe time to wait for the next transmission according to the duty cycle.
[out]aggregatedTimeOffUpdates the aggregated time off.
Returns:
Function status [1: OK, 0: Unable to find a channel on the current datarate].

Definition at line 1257 of file LoRaPHY.cpp.

void set_radio_instance ( LoRaRadio radio )

Stores a reference to Radio object.

Application is responsible for constructing a 'LoRaRadio' object which is passed down to the PHY layer.

Parameters:
radioa reference to radio driver object

Definition at line 71 of file LoRaPHY.cpp.

void set_tx_cont_mode ( cw_mode_params_t continuous_wave,
uint32_t  frequency = 0 
) [virtual]

Puts the radio into continuous wave mode.

Parameters:
[in]continuous_waveA pointer to the function parameters.
[in]frequencyFrequency to transmit at

Definition at line 1422 of file LoRaPHY.cpp.

void setup_public_network_mode ( bool  set )

Enables/Disables public network mode.

Public and private LoRaWAN network constitute different preambles and Net IDs. This API isused to tell the radio which network mode is in use.

Parameters:
settrue or false

Definition at line 90 of file LoRaPHY.cpp.

bool tx_config ( tx_config_params_t tx_config,
int8_t *  tx_power,
lorawan_time_t tx_toa 
) [virtual]

Configure radio transmission.

Parameters:
[in]tx_configStructure containing tx parameters.
[out]tx_powerThe TX power which will be set.
[out]tx_toaThe time-on-air of the frame.
Returns:
True, if the configuration was applied successfully.

Definition at line 913 of file LoRaPHY.cpp.

lorawan_time_t update_band_timeoff ( bool  joined,
bool  dutyCycle,
band_t bands,
uint8_t  nb_bands 
) [protected]

Updates the time-offs of the bands.

Definition at line 267 of file LoRaPHY.cpp.

bool val_in_range ( int8_t  value,
int8_t  min,
int8_t  max 
) [protected]

Verifies, if a value is in a given range.

Definition at line 190 of file LoRaPHY.cpp.

bool verify_channel_DR ( uint16_t *  channelsMask,
int8_t  dr 
) [protected]

Verifies, if a datarate is available on an active channel.

Definition at line 169 of file LoRaPHY.cpp.

bool verify_duty_cycle ( bool  cycle )

verify_duty_cycle Verifies that given cycle is valid

Parameters:
cycleCycle to check
Returns:
True if valid, false otherwise

Definition at line 718 of file LoRaPHY.cpp.

bool verify_frequency_for_band ( uint32_t  freq,
uint8_t  band 
) const [protected, virtual]

Verifies, if a frequency is within a given band.

Definition at line 1133 of file LoRaPHY.cpp.

uint8_t verify_link_ADR_req ( verify_adr_params_t verify_params,
int8_t *  dr,
int8_t *  tx_pow,
uint8_t *  nb_rep 
) [protected]

Verifies and updates the datarate, the TX power and the number of repetitions of a LinkAdrRequest.

Definition at line 340 of file LoRaPHY.cpp.

bool verify_nb_join_trials ( uint8_t  nb_join_trials )

verify_nb_join_trials Verifies that given number of trials is valid

Parameters:
nb_join_trialsNumber to check
Returns:
True if valid, false otherwise

Definition at line 726 of file LoRaPHY.cpp.

bool verify_rx_datarate ( uint8_t  datarate )

verify_rx_datarate Verifies that given RX datarate is valid

Parameters:
datarateDatarate to check
Returns:
true if given datarate is valid, false otherwise

Definition at line 677 of file LoRaPHY.cpp.

bool verify_tx_datarate ( uint8_t  datarate,
bool  use_default = false 
)

verify_tx_datarate Verifies that given TX datarate is valid

Parameters:
datarateDatarate to check
use_defaultIf true validation is done against default value
Returns:
true if given datarate is valid, false otherwise

Definition at line 694 of file LoRaPHY.cpp.

bool verify_tx_power ( uint8_t  tx_power )

verify_tx_power Verifies that given TX power is valid

Parameters:
tx_powerPower to check
Returns:
True if valid, false otherwise

Definition at line 712 of file LoRaPHY.cpp.