Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
LoRaMac Class Reference

LoRaMac Class Implementation of LoRaWAN MAC layer. More...

#include <LoRaMac.h>

Public Member Functions

 LoRaMac ()
 Constructor. More...
 
 ~LoRaMac ()
 Destructor. More...
 
lorawan_status_t initialize (events::EventQueue *queue, mbed::Callback< void(void)>scheduling_failure_handler)
 LoRaMAC layer initialization. More...
 
void disconnect (void)
 Disconnect LoRaMac layer. More...
 
bool nwk_joined ()
 nwk_joined Checks if device has joined to network More...
 
lorawan_status_t add_channel_plan (const lorawan_channelplan_t &plan)
 Adds a channel plan to the system. More...
 
lorawan_status_t remove_channel_plan ()
 Removes a channel plan from the system. More...
 
lorawan_status_t get_channel_plan (lorawan_channelplan_t &plan)
 Access active channel plan. More...
 
lorawan_status_t remove_single_channel (uint8_t id)
 Remove a given channel from the active plan. More...
 
lorawan_status_t multicast_channel_link (multicast_params_t *channel_param)
 LoRaMAC multicast channel link service. More...
 
lorawan_status_t multicast_channel_unlink (multicast_params_t *channel_param)
 LoRaMAC multicast channel unlink service. More...
 
void bind_phy (LoRaPHY &phy)
 Binds phy layer to MAC. More...
 
lorawan_status_t send (loramac_mhdr_t *mac_hdr, const uint8_t fport, const void *fbuffer, uint16_t fbuffer_size)
 Schedules the frame for sending. More...
 
uint8_t get_default_tx_datarate ()
 get_default_tx_datarate Gets the default TX datarate More...
 
void enable_adaptive_datarate (bool adr_enabled)
 enable_adaptive_datarate Enables or disables adaptive datarate. More...
 
lorawan_status_t set_channel_data_rate (uint8_t data_rate)
 Sets up the data rate. More...
 
bool tx_ongoing ()
 tx_ongoing Check whether a prepare is done or not. More...
 
void set_tx_ongoing (bool ongoing)
 set_tx_ongoing Changes the ongoing status for prepared message. More...
 
void reset_ongoing_tx (bool reset_pending=false)
 reset_ongoing_tx Resets _ongoing_tx_msg. More...
 
int16_t prepare_ongoing_tx (const uint8_t port, const uint8_t *data, uint16_t length, uint8_t flags, uint8_t num_retries)
 prepare_ongoing_tx This will prepare (and override) ongoing_tx_msg. More...
 
lorawan_status_t send_ongoing_tx (void)
 send_ongoing_tx Sends the ongoing_tx_msg More...
 
device_class_t get_device_class () const
 device_class Returns active device class More...
 
void set_device_class (const device_class_t &device_class, mbed::Callback< void(void)>rx2_would_be_closure_handler)
 set_device_class Sets active device class. More...
 
void setup_link_check_request ()
 setup_link_check_request Adds link check request command to be put on next outgoing message (when it fits) More...
 
lorawan_status_t prepare_join (const lorawan_connect_t *params, bool is_otaa)
 prepare_join prepares arguments to be ready for join() call. More...
 
lorawan_status_t join (bool is_otaa)
 join Joins the network. More...
 
void on_radio_tx_done (lorawan_time_t timestamp)
 MAC operations upon successful transmission. More...
 
void on_radio_rx_done (const uint8_t *const payload, uint16_t size, int16_t rssi, int8_t snr)
 MAC operations upon reception. More...
 
void on_radio_tx_timeout (void)
 MAC operations upon transmission timeout. More...
 
void on_radio_rx_timeout (bool is_timeout)
 MAC operations upon empty reception slots. More...
 
bool continue_joining_process (void)
 Handles retransmissions of Join requests if an Accept was not received. More...
 
bool continue_sending_process (void)
 Checks if the CONFIRMED data can be sent again or not. More...
 
const loramac_mcps_confirm_tget_mcps_confirmation () const
 Read-only access to MAC primitive blocks. More...
 
void post_process_mcps_req (void)
 Post processing steps in response to actions carried out by controller layer and Mac. More...
 
void set_batterylevel_callback (mbed::Callback< uint8_t(void)> battery_level)
 Set battery level query callback. More...
 
int get_backoff_timer_event_id (void)
 Returns the event ID of backoff timer. More...
 
lorawan_status_t clear_tx_pipe (void)
 Clears out the TX pipe by discarding any outgoing message if the backoff timer is still running. More...
 
lorawan_time_t get_current_time (void)
 Gets the current time. More...
 
rx_slot_t get_current_slot (void)
 Gets the current receive slot. More...
 
uint8_t get_QOS_level (void)
 Indicates what level of QOS is set by network server. More...
 
uint8_t get_prev_QOS_level (void)
 Indicates level of QOS used for the previous outgoing message. More...
 
void lock (void)
 These locks trample through to the upper layers and make the stack thread safe. More...
 

Detailed Description

LoRaMac Class Implementation of LoRaWAN MAC layer.

Definition at line 62 of file LoRaMac.h.

Constructor & Destructor Documentation

LoRaMac ( )

Constructor.

~LoRaMac ( )

Destructor.

Member Function Documentation

lorawan_status_t add_channel_plan ( const lorawan_channelplan_t plan)

Adds a channel plan to the system.

Adds a whole channel plan or a single new channel if the plan contains only one channel and 'plan.nb_channels' is set to 1. Please note that this functionality is not available in all regions. Information on the allowed ranges is available at the LoRaWAN Regional Parameters V1.0.2rB.

Parameters
plan[in] A reference to application provided channel plan.
Returns
lorawan_status_t The status of the operation. The possible values are: LORAWAN_STATUS_OK LORAWAN_STATUS_BUSY LORAWAN_STATUS_PARAMETER_INVALID
void bind_phy ( LoRaPHY phy)

Binds phy layer to MAC.

Parameters
phyLoRaPHY object
lorawan_status_t clear_tx_pipe ( void  )

Clears out the TX pipe by discarding any outgoing message if the backoff timer is still running.

bool continue_joining_process ( void  )

Handles retransmissions of Join requests if an Accept was not received.

Returns
true if a retry will be made
bool continue_sending_process ( void  )

Checks if the CONFIRMED data can be sent again or not.

void disconnect ( void  )

Disconnect LoRaMac layer.

Cancels all outstanding requests and sets LoRaMac's internal state to idle.

void enable_adaptive_datarate ( bool  adr_enabled)

enable_adaptive_datarate Enables or disables adaptive datarate.

Parameters
adr_enabledFlag indicating is adr enabled or disabled.
int get_backoff_timer_event_id ( void  )

Returns the event ID of backoff timer.

lorawan_status_t get_channel_plan ( lorawan_channelplan_t plan)

Access active channel plan.

Provides access to the current active channel plan.

Parameters
plan[out] A reference to application provided channel plan data structure which will be filled in with active channel plan.
Returns
lorawan_status_t The status of the operation. The possible values are: LORAWAN_STATUS_OK LORAWAN_STATUS_BUSY LORAWAN_STATUS_PARAMETER_INVALID
rx_slot_t get_current_slot ( void  )

Gets the current receive slot.

lorawan_time_t get_current_time ( void  )

Gets the current time.

uint8_t get_default_tx_datarate ( )

get_default_tx_datarate Gets the default TX datarate

Returns
default TX datarate.
device_class_t get_device_class ( ) const

device_class Returns active device class

Returns
Device class in use.
const loramac_mcps_confirm_t* get_mcps_confirmation ( ) const

Read-only access to MAC primitive blocks.

uint8_t get_prev_QOS_level ( void  )

Indicates level of QOS used for the previous outgoing message.

uint8_t get_QOS_level ( void  )

Indicates what level of QOS is set by network server.

QOS level is set in response to a LinkADRReq for UNCONFIRMED messages

lorawan_status_t initialize ( events::EventQueue queue,
mbed::Callback< void(void)>  scheduling_failure_handler 
)

LoRaMAC layer initialization.

Initializes the LoRaMAC layer,

Parameters
queue[in] A pointer to the application provided EventQueue.
scheduling_failure_handlerA callback to inform upper layer if a deferred transmission (after backoff or retry) fails to schedule.
Returns
lorawan_status_t The status of the operation. The possible values are: LORAWAN_STATUS_OK LORAWAN_STATUS_PARAMETER_INVALID
lorawan_status_t join ( bool  is_otaa)

join Joins the network.

Parameters
is_otaaTrue if joining is to be done using OTAA, false for ABP.
Returns
LORAWAN_STATUS_OK or a negative error code on failure.
void lock ( void  )

These locks trample through to the upper layers and make the stack thread safe.

Definition at line 436 of file LoRaMac.h.

lorawan_status_t multicast_channel_link ( multicast_params_t channel_param)

LoRaMAC multicast channel link service.

Links a multicast channel into the linked list.

Parameters
[in]channel_paramThe multicast channel parameters to link.
Returns
lorawan_status_t The status of the operation. The possible values are: LORAWAN_STATUS_OK LORAWAN_STATUS_BUSY LORAWAN_STATUS_PARAMETER_INVALID
lorawan_status_t multicast_channel_unlink ( multicast_params_t channel_param)

LoRaMAC multicast channel unlink service.

Unlinks a multicast channel from the linked list.

Parameters
[in]channel_paramThe multicast channel parameters to unlink.
Returns
lorawan_status_t The status of the operation. The possible values are: LORAWAN_STATUS_OK LORAWAN_STATUS_BUSY LORAWAN_STATUS_PARAMETER_INVALID
bool nwk_joined ( )

nwk_joined Checks if device has joined to network

Returns
True if joined to network, false otherwise
void on_radio_rx_done ( const uint8_t *const  payload,
uint16_t  size,
int16_t  rssi,
int8_t  snr 
)

MAC operations upon reception.

void on_radio_rx_timeout ( bool  is_timeout)

MAC operations upon empty reception slots.

Parameters
is_timeoutfalse when radio encountered an error true when the an RX slot went empty
Returns
current RX slot
void on_radio_tx_done ( lorawan_time_t  timestamp)

MAC operations upon successful transmission.

void on_radio_tx_timeout ( void  )

MAC operations upon transmission timeout.

void post_process_mcps_req ( void  )

Post processing steps in response to actions carried out by controller layer and Mac.

lorawan_status_t prepare_join ( const lorawan_connect_t params,
bool  is_otaa 
)

prepare_join prepares arguments to be ready for join() call.

Parameters
paramsJoin parameters to use, if NULL, the default will be used.
is_otaaTrue if joining is to be done using OTAA, false for ABP.
Returns
LORAWAN_STATUS_OK or a negative error code on failure.
int16_t prepare_ongoing_tx ( const uint8_t  port,
const uint8_t *  data,
uint16_t  length,
uint8_t  flags,
uint8_t  num_retries 
)

prepare_ongoing_tx This will prepare (and override) ongoing_tx_msg.

Parameters
portThe application port number.
dataA pointer to the data being sent. The ownership of the buffer is not transferred.
lengthThe size of data in bytes.
flagsA flag used to determine what type of message is being sent.
num_retriesNumber of retries for a confirmed type message
Returns
The number of bytes prepared for sending.
lorawan_status_t remove_channel_plan ( )

Removes a channel plan from the system.

Removes the whole active channel plan except the 'Default Channels'. Please note that this functionality is not available in all regions. Information on the allowed ranges is available at the LoRaWAN Regional Parameters V1.0.2rB.

Returns
lorawan_status_t The status of the operation. The possible values are: LORAWAN_STATUS_OK LORAWAN_STATUS_BUSY LORAWAN_STATUS_PARAMETER_INVALID
lorawan_status_t remove_single_channel ( uint8_t  id)

Remove a given channel from the active plan.

Deactivates the given channel.

Parameters
idId of the channel.
Returns
lorawan_status_t The status of the operation. The possible values are: LORAWAN_STATUS_OK LORAWAN_STATUS_BUSY LORAWAN_STATUS_PARAMETER_INVALID
void reset_ongoing_tx ( bool  reset_pending = false)

reset_ongoing_tx Resets _ongoing_tx_msg.

Parameters
reset_pendingIf true resets pending size also.
lorawan_status_t send ( loramac_mhdr_t mac_hdr,
const uint8_t  fport,
const void *  fbuffer,
uint16_t  fbuffer_size 
)

Schedules the frame for sending.

Prepares a full MAC frame and schedules it for physical transmission.

Parameters
[in]mac_hdrMAC frame header field
[in]fportPayload port
[in]fbufferMAC frame data buffer to be sent
[in]fbuffer_sizeMAC frame data buffer size
Returns
status Status of the operation. LORAWAN_STATUS_OK in case of success and a negative error code in case of failure.
lorawan_status_t send_ongoing_tx ( void  )

send_ongoing_tx Sends the ongoing_tx_msg

Returns
LORAWAN_STATUS_OK or a negative error code on failure.
void set_batterylevel_callback ( mbed::Callback< uint8_t(void)>  battery_level)

Set battery level query callback.

lorawan_status_t set_channel_data_rate ( uint8_t  data_rate)

Sets up the data rate.

set_datarate() first verifies whether the data rate given is valid or not. If it is valid, the system sets the given data rate to the channel.

Parameters
data_rateThe intended data rate, for example DR_0 or DR_1. Note that the macro DR_* can mean different things in different regions.
Returns
LORAWAN_STATUS_OK if everything goes well, otherwise a negative error code.
void set_device_class ( const device_class_t device_class,
mbed::Callback< void(void)>  rx2_would_be_closure_handler 
)

set_device_class Sets active device class.

Parameters
device_classDevice class to use.
rx2_would_be_closure_handlercallback function to inform about would be closure of RX2 window
void set_tx_ongoing ( bool  ongoing)

set_tx_ongoing Changes the ongoing status for prepared message.

Parameters
ongoingThe value indicating the status.
void setup_link_check_request ( )

setup_link_check_request Adds link check request command to be put on next outgoing message (when it fits)

bool tx_ongoing ( )

tx_ongoing Check whether a prepare is done or not.

Returns
True if prepare_ongoing_tx is called, false otherwise.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.