Mistake on this page?
Report an issue in GitHub or email us
LoRaMac.h
Go to the documentation of this file.
1 /**
2  * \file LoRaMac.h
3  *
4  * \brief LoRa MAC layer implementation
5  *
6  * \copyright Revised BSD License, see LICENSE.TXT file include in the project
7  *
8  * \code
9  * ______ _
10  * / _____) _ | |
11  * ( (____ _____ ____ _| |_ _____ ____| |__
12  * \____ \| ___ | (_ _) ___ |/ ___) _ \
13  * _____) ) ____| | | || |_| ____( (___| | | |
14  * (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  * (C)2013 Semtech
16  *
17  * ___ _____ _ ___ _ _____ ___ ___ ___ ___
18  * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
19  * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
20  * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
21  * embedded.connectivity.solutions===============
22  *
23  * \endcode
24  *
25  * \author Miguel Luis ( Semtech )
26  *
27  * \author Gregory Cristian ( Semtech )
28  *
29  * \author Daniel Jaeckle ( STACKFORCE )
30  *
31  * \defgroup LORAMAC LoRa MAC layer implementation
32  * This module specifies the API implementation of the LoRaMAC layer.
33  * This is a placeholder for a detailed description of the LoRaMac
34  * layer and the supported features.
35  *
36  * Copyright (c) 2017, Arm Limited and affiliates.
37  * SPDX-License-Identifier: BSD-3-Clause
38  *
39  */
40 #ifndef MBED_LORAWAN_MAC_H__
41 #define MBED_LORAWAN_MAC_H__
42 
43 #include "events/EventQueue.h"
44 
45 #include "lorastack/phy/LoRaPHY.h"
46 
47 #include "system/LoRaWANTimer.h"
49 
50 #include "LoRaMacChannelPlan.h"
51 #include "LoRaMacCommand.h"
52 #include "LoRaMacCrypto.h"
53 #if MBED_CONF_RTOS_PRESENT
54 #include "rtos/Mutex.h"
55 #endif
56 
57 #include "platform/ScopedLock.h"
58 
59 /** LoRaMac Class
60  * Implementation of LoRaWAN MAC layer
61  */
62 class LoRaMac {
63 
64 public:
65 
66  /**
67  * Constructor
68  */
69  LoRaMac();
70 
71  /**
72  * Destructor
73  */
74  ~LoRaMac();
75 
76  /**
77  * @brief LoRaMAC layer initialization
78  *
79  * @details Initializes the LoRaMAC layer,
80  *
81  *
82  * @param queue [in] A pointer to the application provided EventQueue.
83  *
84  * @param scheduling_failure_handler A callback to inform upper layer if a deferred
85  * transmission (after backoff or retry) fails to schedule.
86  *
87  * @return `lorawan_status_t` The status of the operation. The possible values are:
88  * \ref LORAWAN_STATUS_OK
89  * \ref LORAWAN_STATUS_PARAMETER_INVALID
90  */
92  mbed::Callback<void(void)>scheduling_failure_handler);
93 
94  /**
95  * @brief Disconnect LoRaMac layer
96  *
97  * @details Cancels all outstanding requests and sets LoRaMac's
98  * internal state to idle.
99  */
100  void disconnect(void);
101 
102  /**
103  * @brief nwk_joined Checks if device has joined to network
104  * @return True if joined to network, false otherwise
105  */
106  bool nwk_joined();
107 
108  /**
109  * @brief Adds a channel plan to the system.
110  *
111  * @details Adds a whole channel plan or a single new channel if the plan
112  * contains only one channel and 'plan.nb_channels' is set to 1.
113  * Please note that this functionality is not available in all regions.
114  * Information on the allowed ranges is available at the
115  * LoRaWAN Regional Parameters V1.0.2rB.
116  *
117  * @param plan [in] A reference to application provided channel plan.
118  *
119  * @return `lorawan_status_t` The status of the operation. The possible values are:
120  * \ref LORAWAN_STATUS_OK
121  * \ref LORAWAN_STATUS_BUSY
122  * \ref LORAWAN_STATUS_PARAMETER_INVALID
123  */
125 
126  /**
127  * @brief Removes a channel plan from the system.
128  *
129  * @details Removes the whole active channel plan except the 'Default Channels'.
130  * Please note that this functionality is not available in all regions.
131  * Information on the allowed ranges is available at the
132  * LoRaWAN Regional Parameters V1.0.2rB.
133  *
134  * @return `lorawan_status_t` The status of the operation. The possible values are:
135  * \ref LORAWAN_STATUS_OK
136  * \ref LORAWAN_STATUS_BUSY
137  * \ref LORAWAN_STATUS_PARAMETER_INVALID
138  */
140 
141  /**
142  * @brief Access active channel plan.
143  *
144  * @details Provides access to the current active channel plan.
145  *
146  * @param plan [out] A reference to application provided channel plan data
147  * structure which will be filled in with active channel
148  * plan.
149  *
150  * @return `lorawan_status_t` The status of the operation. The possible values are:
151  * \ref LORAWAN_STATUS_OK
152  * \ref LORAWAN_STATUS_BUSY
153  * \ref LORAWAN_STATUS_PARAMETER_INVALID
154  */
156 
157  /**
158  * @brief Remove a given channel from the active plan.
159  *
160  * @details Deactivates the given channel.
161  *
162  * @param id Id of the channel.
163  *
164  * @return `lorawan_status_t` The status of the operation. The possible values are:
165  * \ref LORAWAN_STATUS_OK
166  * \ref LORAWAN_STATUS_BUSY
167  * \ref LORAWAN_STATUS_PARAMETER_INVALID
168  */
170 
171  /**
172  * @brief LoRaMAC multicast channel link service.
173  *
174  * @details Links a multicast channel into the linked list.
175  *
176  * @param [in] channel_param The multicast channel parameters to link.
177  *
178  * @return `lorawan_status_t` The status of the operation. The possible values are:
179  * \ref LORAWAN_STATUS_OK
180  * \ref LORAWAN_STATUS_BUSY
181  * \ref LORAWAN_STATUS_PARAMETER_INVALID
182  */
184 
185  /**
186  * @brief LoRaMAC multicast channel unlink service.
187  *
188  * @details Unlinks a multicast channel from the linked list.
189  *
190  * @param [in] channel_param The multicast channel parameters to unlink.
191  *
192  * @return `lorawan_status_t` The status of the operation. The possible values are:
193  * \ref LORAWAN_STATUS_OK
194  * \ref LORAWAN_STATUS_BUSY
195  * \ref LORAWAN_STATUS_PARAMETER_INVALID
196  */
198 
199  /** Binds phy layer to MAC.
200  *
201  * @param phy LoRaPHY object
202  */
203  void bind_phy(LoRaPHY &phy);
204 
205  /**
206  * @brief Schedules the frame for sending.
207  *
208  * @details Prepares a full MAC frame and schedules it for physical
209  * transmission.
210  *
211  * @param [in] mac_hdr MAC frame header field
212  * @param [in] fport Payload port
213  * @param [in] fbuffer MAC frame data buffer to be sent
214  * @param [in] fbuffer_size MAC frame data buffer size
215  *
216  * @return status Status of the operation. LORAWAN_STATUS_OK in case
217  * of success and a negative error code in case of
218  * failure.
219  */
220  lorawan_status_t send(loramac_mhdr_t *mac_hdr, const uint8_t fport,
221  const void *fbuffer, uint16_t fbuffer_size);
222 
223  /**
224  * @brief get_default_tx_datarate Gets the default TX datarate
225  * @return default TX datarate.
226  */
227  uint8_t get_default_tx_datarate();
228 
229  /**
230  * @brief enable_adaptive_datarate Enables or disables adaptive datarate.
231  * @param adr_enabled Flag indicating is adr enabled or disabled.
232  */
233  void enable_adaptive_datarate(bool adr_enabled);
234 
235  /** Sets up the data rate.
236  *
237  * `set_datarate()` first verifies whether the data rate given is valid or not.
238  * If it is valid, the system sets the given data rate to the channel.
239  *
240  * @param data_rate The intended data rate, for example DR_0 or DR_1.
241  * Note that the macro DR_* can mean different
242  * things in different regions.
243  *
244  * @return LORAWAN_STATUS_OK if everything goes well, otherwise
245  * a negative error code.
246  */
247  lorawan_status_t set_channel_data_rate(uint8_t data_rate);
248 
249  /**
250  * @brief tx_ongoing Check whether a prepare is done or not.
251  * @return True if prepare_ongoing_tx is called, false otherwise.
252  */
253  bool tx_ongoing();
254 
255  /**
256  * @brief set_tx_ongoing Changes the ongoing status for prepared message.
257  * @param ongoing The value indicating the status.
258  */
259  void set_tx_ongoing(bool ongoing);
260 
261  /**
262  * @brief reset_ongoing_tx Resets _ongoing_tx_msg.
263  * @param reset_pending If true resets pending size also.
264  */
265  void reset_ongoing_tx(bool reset_pending = false);
266 
267  /**
268  * @brief prepare_ongoing_tx This will prepare (and override) ongoing_tx_msg.
269  * @param port The application port number.
270  *
271  * @param data A pointer to the data being sent. The ownership of the
272  * buffer is not transferred.
273  *
274  * @param length The size of data in bytes.
275  *
276  * @param flags A flag used to determine what type of
277  * message is being sent.
278  *
279  * @param num_retries Number of retries for a confirmed type message
280  *
281  * @return The number of bytes prepared for sending.
282  */
283  int16_t prepare_ongoing_tx(const uint8_t port, const uint8_t *data,
284  uint16_t length, uint8_t flags, uint8_t num_retries);
285 
286  /**
287  * @brief send_ongoing_tx Sends the ongoing_tx_msg
288  * @return LORAWAN_STATUS_OK or a negative error code on failure.
289  */
291 
292  /**
293  * @brief device_class Returns active device class
294  * @return Device class in use.
295  */
297 
298  /**
299  * @brief set_device_class Sets active device class.
300  * @param device_class Device class to use.
301  * @param rx2_would_be_closure_handler callback function to inform about
302  * would be closure of RX2 window
303  */
304  void set_device_class(const device_class_t &device_class,
305  mbed::Callback<void(void)>rx2_would_be_closure_handler);
306 
307  /**
308  * @brief setup_link_check_request Adds link check request command
309  * to be put on next outgoing message (when it fits)
310  */
312 
313  /**
314  * @brief prepare_join prepares arguments to be ready for join() call.
315  * @param params Join parameters to use, if NULL, the default will be used.
316  * @param is_otaa True if joining is to be done using OTAA, false for ABP.
317  *
318  * @return LORAWAN_STATUS_OK or a negative error code on failure.
319  */
320  lorawan_status_t prepare_join(const lorawan_connect_t *params, bool is_otaa);
321 
322  /**
323  * @brief join Joins the network.
324  * @param is_otaa True if joining is to be done using OTAA, false for ABP.
325  * @return LORAWAN_STATUS_OK or a negative error code on failure.
326  */
327  lorawan_status_t join(bool is_otaa);
328 
329  /**
330  * MAC operations upon successful transmission
331  */
332  void on_radio_tx_done(lorawan_time_t timestamp);
333 
334  /**
335  * MAC operations upon reception
336  */
337  void on_radio_rx_done(const uint8_t *const payload, uint16_t size,
338  int16_t rssi, int8_t snr);
339 
340  /**
341  * MAC operations upon transmission timeout
342  */
343  void on_radio_tx_timeout(void);
344 
345  /**
346  * MAC operations upon empty reception slots
347  *
348  * @param is_timeout false when radio encountered an error
349  * true when the an RX slot went empty
350  *
351  * @return current RX slot
352  */
353  void on_radio_rx_timeout(bool is_timeout);
354 
355  /**
356  * Handles retransmissions of Join requests if an Accept
357  * was not received.
358  *
359  * @returns true if a retry will be made
360  */
361  bool continue_joining_process(void);
362 
363  /**
364  * Checks if the CONFIRMED data can be sent again or not.
365  */
366  bool continue_sending_process(void);
367 
368  /**
369  * Read-only access to MAC primitive blocks
370  */
372  const loramac_mcps_indication_t *get_mcps_indication() const;
373  const loramac_mlme_confirm_t *get_mlme_confirmation() const;
374  const loramac_mlme_indication_t *get_mlme_indication() const;
375 
376  /**
377  * Post processing steps in response to actions carried out
378  * by controller layer and Mac
379  */
380  void post_process_mcps_req(void);
381  void post_process_mcps_ind(void);
382  void post_process_mlme_request(void);
383  void post_process_mlme_ind(void);
384 
385  /**
386  * Set battery level query callback
387  */
388  void set_batterylevel_callback(mbed::Callback<uint8_t(void)> battery_level);
389 
390  /**
391  * Returns the event ID of backoff timer.
392  */
393  int get_backoff_timer_event_id(void);
394 
395  /**
396  * Clears out the TX pipe by discarding any outgoing message if the backoff
397  * timer is still running.
398  */
400 
401  /**
402  * Gets the current time
403  */
405 
406  /**
407  * Gets the current receive slot
408  */
410 
411  /**
412  * Indicates what level of QOS is set by network server. QOS level is set
413  * in response to a LinkADRReq for UNCONFIRMED messages
414  */
415  uint8_t get_QOS_level(void);
416 
417  /**
418  *Indicates level of QOS used for the previous outgoing message
419  */
420  uint8_t get_prev_QOS_level(void);
421 
422  /**
423  * These locks trample through to the upper layers and make
424  * the stack thread safe.
425  */
426 #if MBED_CONF_RTOS_PRESENT
427  void lock(void)
428  {
429  _mutex.lock();
430  }
431  void unlock(void)
432  {
433  _mutex.unlock();
434  }
435 #else
436  void lock(void) { }
437  void unlock(void) { }
438 #endif
439 
440 private:
441  /**
442  * @brief Queries the LoRaMAC the maximum possible FRMPayload size to send.
443  * The LoRaMAC takes the scheduled MAC commands into account and returns
444  * corresponding value.
445  *
446  * @param fopts_len [in] Number of mac commands in the queue pending.
447  *
448  * @return Size of the biggest packet that can be sent.
449  * Please note that if the size of the MAC commands in the queue do
450  * not fit into the payload size on the related datarate, the LoRaMAC will
451  * omit the MAC commands.
452  */
453  uint8_t get_max_possible_tx_size(uint8_t fopts_len);
454 
455  /**
456  * @brief set_nwk_joined This is used for ABP mode for which real joining does not happen
457  * @param joined True if device has joined in network, false otherwise
458  */
459  void set_nwk_joined(bool joined);
460 
461  /**
462  * @brief Configures the events to trigger an MLME-Indication with
463  * a MLME type of MLME_SCHEDULE_UPLINK.
464  */
465  void set_mlme_schedule_ul_indication(void);
466 
467  /**
468  * @brief Resets MAC specific parameters to default
469  */
470  void reset_mac_parameters(void);
471 
472  /**
473  * Handles a Join Accept frame
474  */
475  void handle_join_accept_frame(const uint8_t *payload, uint16_t size);
476 
477  /**
478  * Handles data frames
479  */
480  void handle_data_frame(const uint8_t *payload, uint16_t size, uint8_t ptr_pos,
481  uint8_t msg_type, int16_t rssi, int8_t snr);
482 
483  /**
484  * Send a Join Request
485  */
486  lorawan_status_t send_join_request();
487 
488  /**
489  * Handles retransmissions
490  */
491  lorawan_status_t handle_retransmission();
492 
493  /**
494  * Checks if the frame is valid
495  */
496  void check_frame_size(uint16_t size);
497 
498  /**
499  * Performs MIC
500  */
501  bool message_integrity_check(const uint8_t *payload, uint16_t size,
502  uint8_t *ptr_pos, uint32_t address,
503  uint32_t *downlink_counter, const uint8_t *nwk_skey);
504 
505  /**
506  * Decrypts and extracts data and MAC commands from the received encrypted
507  * payload
508  */
509  void extract_data_and_mac_commands(const uint8_t *payload, uint16_t size,
510  uint8_t fopts_len, uint8_t *nwk_skey,
511  uint8_t *app_skey, uint32_t address,
512  uint32_t downlink_frame_counter,
513  int16_t rssi, int8_t snr);
514  /**
515  * Decrypts and extracts MAC commands from the received encrypted
516  * payload if there is no data
517  */
518  void extract_mac_commands_only(const uint8_t *payload, int8_t snr, uint8_t fopts_len);
519 
520  /**
521  * Callback function to be executed when the DC backoff timer expires
522  */
523  void on_backoff_timer_expiry(void);
524 
525  /**
526  * At the end of an RX1 window timer, an RX1 window is opened using this method.
527  */
528  void open_rx1_window(void);
529 
530  /**
531  * At the end of an RX2 window timer, an RX2 window is opened using this method.
532  */
533  void open_rx2_window(void);
534 
535  /**
536  * A method to retry a CONFIRMED message after a particular time period
537  * (ACK_TIMEOUT = TIME_IN_MS) if the ack was not received
538  */
539  void on_ack_timeout_timer_event(void);
540 
541  /*!
542  * \brief Check if the OnAckTimeoutTimer has do be disabled. If so, the
543  * function disables it.
544  *
545  * \param [in] node_ack_requested Set to true, if the node has requested an ACK
546  * \param [in] dev_class The device class
547  * \param [in] ack_received Set to true, if the node has received an ACK
548  * \param [in] ack_timeout_retries_counter Retries counter for confirmed uplinks
549  * \param [in] ack_timeout_retries Maximum retries for confirmed uplinks
550  */
551  void check_to_disable_ack_timeout(bool node_ack_requested,
552  device_class_t dev_class,
553  bool ack_received,
554  uint8_t ack_timeout_retries_counter,
555  uint8_t ack_timeout_retries);
556 
557  /**
558  * Validates if the payload fits into the frame, taking the datarate
559  * into account.
560  *
561  * Please Refer to chapter 4.3.2 of the LoRaWAN specification, v1.0.2
562  */
563  bool validate_payload_length(uint16_t length, int8_t datarate, uint8_t fopts_len);
564 
565  /**
566  * Prepares MAC frame on the behest of send() API.
567  */
568  lorawan_status_t prepare_frame(loramac_mhdr_t *mac_hdr,
569  loramac_frame_ctrl_t *fctrl, const uint8_t fport,
570  const void *fbuffer, uint16_t fbuffer_size);
571 
572  /**
573  * Schedules a transmission on the behest of send() API.
574  */
575  lorawan_status_t schedule_tx();
576 
577  /**
578  * Calculates the back-off time for the band of a channel.
579  * Takes in the last used channel id as a parameter.
580  */
581  void calculate_backOff(uint8_t channel_id);
582 
583  /**
584  * Hands over the MAC frame to PHY layer.
585  */
586  lorawan_status_t send_frame_on_channel(uint8_t channel);
587 
588  /**
589  * Resets MAC primitive blocks
590  */
591  void reset_mcps_confirmation(void);
592  void reset_mlme_confirmation(void);
593  void reset_mcps_indication(void);
594 
595  /**
596  * @brief set_tx_continuous_wave Puts the system in continuous transmission mode
597  * @param [in] channel A Channel to use
598  * @param [in] datarate A datarate to use
599  * @param [in] tx_power A RF output power to use
600  * @param [in] max_eirp A maximum possible EIRP to use
601  * @param [in] antenna_gain Antenna gain to use
602  * @param [in] timeout Time in seconds while the radio is kept in continuous wave mode
603  */
604  void set_tx_continuous_wave(uint8_t channel, int8_t datarate, int8_t tx_power,
605  float max_eirp, float antenna_gain, uint16_t timeout);
606 
607 private:
609 #if MBED_CONF_RTOS_PRESENT
610  rtos::Mutex _mutex;
611 #endif
612 
613  /**
614  * Timer subsystem handle
615  */
616  LoRaWANTimeHandler _lora_time;
617 
618  /**
619  * LoRa PHY layer object storage
620  */
621  LoRaPHY *_lora_phy;
622 
623  /**
624  * MAC command handle
625  */
626  LoRaMacCommand _mac_commands;
627 
628  /**
629  * Channel planning subsystem
630  */
631  LoRaMacChannelPlan _channel_plan;
632 
633  /**
634  * Crypto handling subsystem
635  */
636  LoRaMacCrypto _lora_crypto;
637 
638  /**
639  * Central MAC layer data storage
640  */
641  loramac_protocol_params _params;
642 
643  /**
644  * EventQueue object storage
645  */
646  events::EventQueue *_ev_queue;
647 
648  /**
649  * Class C doesn't timeout in RX2 window as it is a continuous window.
650  * We use this callback to inform the LoRaWANStack controller that we did
651  * not receive a downlink in a time equal to normal Class A type RX2
652  * window timeout. This marks a 'would-be' closure for RX2, actual RX2 is
653  * not closed. Mostly network servers will send right at the beginning of
654  * RX2 window if they have something to send. So if we didn't receive anything
655  * in the time period equal to would be RX2 delay (which is a function of
656  * uplink message length and data rate), we will invoke this callback to let
657  * the upper layer know.
658  */
659  mbed::Callback<void(void)> _rx2_would_be_closure_for_class_c;
660 
661  /**
662  * Transmission is async, i.e., a call to schedule_tx() may be deferred to
663  * a time after a certain back off. We use this callback to inform the
664  * controller layer that a specific TX transaction failed to schedule after
665  * backoff or retry.
666  */
667  mbed::Callback<void(void)> _scheduling_failure_handler;
668 
669  timer_event_t _rx2_closure_timer_for_class_c;
670 
671  /**
672  * Structure to hold MCPS indication data.
673  */
674  loramac_mcps_indication_t _mcps_indication;
675 
676  /**
677  * Structure to hold MCPS confirm data.
678  */
679  loramac_mcps_confirm_t _mcps_confirmation;
680 
681  /**
682  * Structure to hold MLME indication data.
683  */
684  loramac_mlme_indication_t _mlme_indication;
685 
686  /**
687  * Structure to hold MLME confirm data.
688  */
689  loramac_mlme_confirm_t _mlme_confirmation;
690 
691  loramac_tx_message_t _ongoing_tx_msg;
692 
693  bool _is_nwk_joined;
694 
695  bool _can_cancel_tx;
696 
697  bool _continuous_rx2_window_open;
698 
699  device_class_t _device_class;
700 
701  uint8_t _prev_qos_level;
702 
703  bool _demod_ongoing;
704 };
705 
706 #endif // MBED_LORAWAN_MAC_H__
device_class_t get_device_class() const
device_class Returns active device class
LoRa MAC layer implementation.
bool continue_sending_process(void)
Checks if the CONFIRMED data can be sent again or not.
void on_radio_rx_timeout(bool is_timeout)
MAC operations upon empty reception slots.
lorawan_status_t get_channel_plan(lorawan_channelplan_t &plan)
Access active channel plan.
void reset_ongoing_tx(bool reset_pending=false)
reset_ongoing_tx Resets _ongoing_tx_msg.
bool continue_joining_process(void)
Handles retransmissions of Join requests if an Accept was not received.
RAII-style mechanism for owning a lock of Lockable object for the duration of a scoped block...
Definition: ScopedLock.h:63
An abstract class providing radio object to children and provide base for implementing LoRa PHY layer...
lorawan_status_t add_channel_plan(const lorawan_channelplan_t &plan)
Adds a channel plan to the system.
LoRaMac Class Implementation of LoRaWAN MAC layer.
Definition: LoRaMac.h:62
EventQueue.
Definition: EventQueue.h:60
device_class_t
LoRaWAN device classes definition.
Definition: lorawan_types.h:59
bool nwk_joined()
nwk_joined Checks if device has joined to network
~LoRaMac()
Destructor.
Stack level TX message structure.
Timer object description.
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.
uint32_t lorawan_time_t
Timer time variable definition.
lorawan_status_t join(bool is_otaa)
join Joins the network.
lorawan_status_t multicast_channel_link(multicast_params_t *channel_param)
LoRaMAC multicast channel link service.
lorawan_status_t remove_channel_plan()
Removes a channel plan from the system.
uint8_t get_default_tx_datarate()
get_default_tx_datarate Gets the default TX datarate
uint8_t get_prev_QOS_level(void)
Indicates level of QOS used for the previous outgoing message.
LoRaPHY Class Parent class for LoRa regional PHY implementations.
Definition: LoRaPHY.h:46
/ _____) _ | | ( (____ _____ ____ _| |_ _____ ____| |__ ____ | ___ | (_ _) ___ |/ ___) _ \ _____) ) _...
Definition: LoRaWANTimer.h:29
int get_backoff_timer_event_id(void)
Returns the event ID of backoff timer.
lorawan_status_t set_channel_data_rate(uint8_t data_rate)
Sets up the data rate.
bool tx_ongoing()
tx_ongoing Check whether a prepare is done or not.
enum lorawan_status lorawan_status_t
lorawan_status_t contains status codes in response to stack operations
lorawan_connect_t structure
void on_radio_rx_done(const uint8_t *const payload, uint16_t size, int16_t rssi, int8_t snr)
MAC operations upon reception.
lorawan_status_t clear_tx_pipe(void)
Clears out the TX pipe by discarding any outgoing message if the backoff timer is still running...
const loramac_mcps_confirm_t * get_mcps_confirmation() const
Read-only access to MAC primitive blocks.
lorawan_status_t send_ongoing_tx(void)
send_ongoing_tx Sends the ongoing_tx_msg
void enable_adaptive_datarate(bool adr_enabled)
enable_adaptive_datarate Enables or disables adaptive datarate.
lorawan_status_t prepare_join(const lorawan_connect_t *params, bool is_otaa)
prepare_join prepares arguments to be ready for join() call.
void lock(void)
These locks trample through to the upper layers and make the stack thread safe.
Definition: LoRaMac.h:436
The Mutex class is used to synchronize the execution of threads.
Definition: Mutex.h:68
void setup_link_check_request()
setup_link_check_request Adds link check request command to be put on next outgoing message (when it ...
DO NOT MODIFY, WILL BREAK THE API!
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.
void on_radio_tx_done(lorawan_time_t timestamp)
MAC operations upon successful transmission.
void set_tx_ongoing(bool ongoing)
set_tx_ongoing Changes the ongoing status for prepared message.
LoRaMacCommand Class Helper class for LoRaMac layer to handle any MAC commands.
lorawan_status_t multicast_channel_unlink(multicast_params_t *channel_param)
LoRaMAC multicast channel unlink service.
void bind_phy(LoRaPHY &phy)
Binds phy layer to MAC.
uint8_t get_QOS_level(void)
Indicates what level of QOS is set by network server.
lorawan_time_t get_current_time(void)
Gets the current time.
lorawan_status_t initialize(events::EventQueue *queue, mbed::Callback< void(void)>scheduling_failure_handler)
LoRaMAC layer initialization.
LoRaMac()
Constructor.
Contains common data structures used by Mbed-OS LoRaWAN mplementation.
void on_radio_tx_timeout(void)
MAC operations upon transmission timeout.
lorawan_status_t remove_single_channel(uint8_t id)
Remove a given channel from the active plan.
rx_slot_t get_current_slot(void)
Gets the current receive slot.
void disconnect(void)
Disconnect LoRaMac layer.
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.
Callback class based on template specialization.
Definition: Callback.h:39
void set_batterylevel_callback(mbed::Callback< uint8_t(void)> battery_level)
Set battery level query callback.
void post_process_mcps_req(void)
Post processing steps in response to actions carried out by controller layer and Mac.
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.