Mistake on this page?
Report an issue in GitHub or email us
LoRaWANInterface.h
1 /**
2  * Copyright (c) 2017, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /** @addtogroup LoRaWAN
19  * Mbed OS LoRaWAN Stack
20  * @{
21  */
22 
23 #ifndef LORAWANINTERFACE_H_
24 #define LORAWANINTERFACE_H_
25 
26 #include "platform/Callback.h"
27 #include "platform/ScopedLock.h"
28 #include "events/EventQueue.h"
29 #include "LoRaWANStack.h"
30 #include "LoRaRadio.h"
31 #include "lorawan_types.h"
32 
33 // Forward declaration of LoRaPHY class
34 class LoRaPHY;
35 
36 /** LoRaWANInterface Class
37  * A network interface for LoRaWAN
38  */
40 
41 public:
42 
43  /** Constructs a LoRaWANInterface using the LoRaWANStack instance underneath.
44  *
45  * Currently, LoRaWANStack is a singleton and you should only
46  * construct a single instance of LoRaWANInterface.
47  *
48  * LoRaWANInterface will construct PHY based on "lora.phy" setting in mbed_app.json.
49  *
50  * @param radio A reference to radio object
51  */
53 
54  /** Constructs a LoRaWANInterface using the user provided PHY object.
55 
56  * @param radio A reference to radio object
57  * @param phy A reference to PHY object
58  */
59  LoRaWANInterface(LoRaRadio &radio, LoRaPHY &phy);
60 
62 
63  /** Initialize the LoRa stack.
64  *
65  * You must call this before using the LoRa stack.
66  *
67  * @param queue A pointer to EventQueue provided by the application.
68  *
69  * @return LORAWAN_STATUS_OK on success, a negative error code on failure:
70  * LORAWAN_STATUS_PARAMETER_INVALID is NULL queue is given.
71  */
73 
74  /** Connect OTAA or ABP using the Mbed OS config system
75  *
76  * Connect by Over The Air Activation or Activation By Personalization.
77  * You need to configure the connection properly using the Mbed OS configuration system.
78  *
79  * When connecting through OTAA, the return code for success (LORAWAN_STATUS_CONNECT_IN_PROGRESS)
80  * is negative. However, this is not a real error. It tells you that the connection is in progress,
81  * and an event will notify you of the completion. By default, after the Join Accept message is
82  * received, base stations may provide the node with a CF-List that replaces all user-configured
83  * channels except the Join/Default channels. A CF-List can configure a maximum of five channels
84  * other than the default channels.
85  *
86  * To configure more channels, we recommend that you use the `set_channel_plan()` API after the connection.
87  * By default, the PHY layers configure only the mandatory Join channels. The retransmission back-off
88  * restrictions on these channels are severe, and you may experience long delays or even failures
89  * in the confirmed traffic. If you add more channels, the aggregated duty cycle becomes much more
90  * relaxed as compared to the Join (default) channels only.
91  *
92  * **NOTES ON RECONNECTION:**
93  * Currently, the Mbed OS LoRaWAN implementation does not support non-volatile memory storage.
94  * Therefore, the state and frame counters cannot be restored after a power cycle. However,
95  * if you use the `disconnect()` API to shut down the LoRaWAN protocol, the state and frame
96  * counters are saved. Connecting again restores the previous session. According to the LoRaWAN
97  * 1.0.2 specification, the frame counters are always reset to 0 for OTAA, and a new Join request
98  * lets the network server know that the counters need a reset. The same is said about the ABP,
99  * but there is no way to convey this information to the network server. For a network server,
100  * an ABP device is always connected. That's why storing the frame counters is important for ABP.
101  * That's why we restore frame counters from session information after a disconnection.
102  *
103  * @return Common: LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
104  * LORAWAN_STATUS_PARAMETER_INVALID if connection parameters are invalid.
105  *
106  * For ABP: If everything goes well, LORAWAN_STATUS_OK is returned for first call
107  * followed by a 'CONNECTED' event. Otherwise a negative error code is returned:
108  * Any subsequent call will return LORAWAN_STATUS_ALREADY_CONNECTED and no event follows.
109  *
110  * For OTAA: When a JoinRequest is sent, LORAWAN_STATUS_CONNECT_IN_PROGRESS is returned for
111  * the first call. Any subsequent call will return either LORAWAN_STATUS_BUSY
112  * (if the previous request for connection is still underway) or
113  * LORAWAN_STATUS_ALREADY_CONNECTED (if a network was already joined successfully).
114  * A 'CONNECTED' event is sent to the application when the JoinAccept is received.
115  */
117 
118  /** Connect OTAA or ABP with parameters
119  *
120  * All connection parameters are chosen by you and provided in the data structure passed down.
121  *
122  * When connecting using OTAA, the return code for success (LORAWAN_STATUS_CONNECT_IN_PROGRESS)
123  * is negative. However, this is not a real error. It tells you that connection is in progress,
124  * and an event will notify you of completion. By default, after Join Accept message is received,
125  * base stations may provide the node with a CF-List that replaces all user-configured channels
126  * except the Join/Default channels. A CF-List can configure a maximum of five channels other
127  * than the default channels.
128  *
129  * To configure more channels, we recommend that you use the `set_channel_plan()` API after
130  * the connection. By default, the PHY layers configure only the mandatory Join channels.
131  * The retransmission back-off restrictions on these channels are severe, and you may experience
132  * long delays or even failures in the confirmed traffic. If you add more channels, the aggregated
133  * duty cycle becomes much more relaxed as compared to the Join (default) channels only.
134  *
135  * **NOTES ON RECONNECTION:**
136  * Currently, the Mbed OS LoRaWAN implementation does not support non-volatile memory storage.
137  * Therefore, the state and frame counters cannot be restored after a power cycle. However,
138  * if you use the `disconnect()` API to shut down the LoRaWAN protocol, the state and frame
139  * counters are saved. Connecting again restores the previous session. According to the LoRaWAN
140  * 1.0.2 specification, the frame counters are always reset to zero for OTAA, and a new Join
141  * request lets the network server know that the counters need a reset. The same is said about
142  * the ABP, but there is no way to convey this information to the network server. For a network
143  * server, an ABP device is always connected. That's why storing the frame counters is important
144  * for ABP. That's why we restore frame counters from session information after a disconnection.
145  *
146  * @param connect Options for an end device connection to the gateway.
147  *
148  * @return Common: LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
149  * LORAWAN_STATUS_PARAMETER_INVALID if connection parameters are invalid.
150  *
151  * For ABP: If everything goes well, LORAWAN_STATUS_OK is returned for first call followed
152  * by a 'CONNECTED' event. Otherwise a negative error code is returned.
153  * Any subsequent call will return LORAWAN_STATUS_ALREADY_CONNECTED and no event follows.
154  *
155  * For OTAA: When a JoinRequest is sent, LORAWAN_STATUS_CONNECT_IN_PROGRESS is returned for the
156  * first call. Any subsequent call will return either LORAWAN_STATUS_BUSY
157  * (if the previous request for connection is still underway) or LORAWAN_STATUS_ALREADY_CONNECTED
158  * (if a network was already joined successfully).
159  * A 'CONNECTED' event is sent to the application when the JoinAccept is received.
160  */
162 
163  /** Disconnect the current session.
164  *
165  * @return LORAWAN_STATUS_DEVICE_OFF on success, a negative error code on failure:
166  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
167  */
169 
170  /** Validate the connectivity with the network.
171  *
172  * Application may use this API to submit a request to the stack for validation of its connectivity
173  * to a Network Server. Under the hood, this API schedules a Link Check Request command (LinkCheckReq)
174  * for the network server and once the response, i.e., LinkCheckAns MAC command is received from
175  * the Network Server, user provided method is called.
176  *
177  * One way to use this API may be the validation of connectivity after a long deep sleep.
178  * Mbed LoRaWANStack follows the MAC commands with data frame payload, so the application needs
179  * to send something, and the Network Server may respond during the RX slots.
180  *
181  * This API is usable only when the application sets the 'link_check_resp' callback.
182  * See add_lora_app_callbacks API. If the above mentioned callback is not set,
183  * a LORAWAN_STATUS_PARAMETER_INVALID error is thrown.
184  *
185  * The first parameter to callback function is the demodulation margin, and the second parameter
186  * is the number of gateways that successfully received the last request.
187  *
188  * A 'Link Check Request' MAC command remains set for every subsequent transmission, until/unless
189  * the application explicitly turns it off using the remove_link_check_request() API.
190  *
191  * @return LORAWAN_STATUS_OK on successfully queuing a request, or
192  * a negative error code on failure:
193  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
194  * LORAWAN_STATUS_PARAMETER_INVALID if link_check_resp callback method is not set.
195  *
196  */
198 
199  /** Removes link check request sticky MAC command.
200  *
201  * Any already queued request may still be completed. However, no new requests will be made.
202  */
204 
205  /** Sets up a particular data rate
206  *
207  * @param data_rate The intended data rate, for example DR_0 or DR_1.
208  * Please note that the macro DR_* can mean different things in different regions.
209  * @return LORAWAN_STATUS_OK if everything goes well, otherwise a negative error code:
210  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
211  * LORAWAN_STATUS_PARAMETER_INVALID if ADR is enabled or invalid data rate is given
212  */
213  lorawan_status_t set_datarate(uint8_t data_rate);
214 
215  /** Enables adaptive data rate (ADR)
216  *
217  * The underlying LoRaPHY and LoRaMac layers handle the data rate automatically
218  * based on the radio conditions (network congestion).
219  *
220  * @return LORAWAN_STATUS_OK on success, negative error code on failure:
221  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize()
222  */
224 
225  /** Disables adaptive data rate
226  *
227  * When adaptive data rate (ADR) is disabled, either you can set a certain
228  * data rate, or the MAC layer selects a default value.
229  *
230  * @return LORAWAN_STATUS_OK on success, negative error code on failure:
231  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize()
232  */
234 
235  /** Sets up the retry counter for confirmed messages.
236  *
237  * Valid for confirmed messages only.
238  *
239  * The number of trials to transmit the frame, if the LoRaMAC layer did not receive an
240  * acknowledgment. The MAC performs a data rate adaptation as in the LoRaWAN Specification
241  * V1.0.2, chapter 18.4, table on page 64.
242  *
243  * Note that if the number of retries is set to 1 or 2, MAC does not decrease the data rate,
244  * if the LoRaMAC layer did not receive an acknowledgment.
245  *
246  * @param count The number of retries for confirmed messages.
247  *
248  * @return LORAWAN_STATUS_OK or a negative error code on failure:
249  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize()
250  * LORAWAN_STATUS_PARAMETER_INVALID if count >= 255
251  */
253 
254  /** Sets the channel plan.
255  *
256  * You can provide a list of channels with appropriate parameters filled in. However,
257  * this list is not absolute. The stack applies a CF-List whenever available, which means
258  * that the network can overwrite your channel frequency settings right after Join Accept
259  * is received. You may try to set up any channel or channels after that, and if the channel
260  * requested is already active, the request is silently ignored. A negative error code is
261  * returned if there is any problem with parameters.
262  *
263  * Please note that you can also use this API to add a single channel to the existing channel plan.
264  *
265  * There is no reverse mechanism in the 1.0.2 specification for a node to request a particular
266  * channel. Only the network server can initiate such a request.
267  * You need to ensure that the corresponding base station supports the channel or channels being added.
268  *
269  * If your list includes a default channel (a channel where Join Requests are received),
270  * you cannot fully configure the channel parameters. Either leave the channel settings to default,
271  * or check your corresponding PHY layer implementation. For example, LoRaPHYE868.
272  *
273  * @param channel_plan The channel plan to set.
274  *
275  * @return LORAWAN_STATUS_OK on success, a negative error code on failure:
276  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
277  * LORAWAN_STATUS_PARAMETER_INVALID if number of channels is exceeding the PHY limit,
278  * LORAWAN_STATUS_DATARATE_INVALID if invalid data rate is given,
279  * LORAWAN_STATUS_FREQUENCY_INVALID if invalid frequency is given,
280  * LORAWAN_STATUS_FREQ_AND_DR_INVALID if invalid data rate and freqency are given,
281  * LORAWAN_STATUS_BUSY if TX currently ongoing,
282  * LORAWAN_STATUS_SERVICE_UNKNOWN if custom channel plans are disabled in PHY
283  */
285 
286  /** Gets the channel plans from the LoRa stack.
287  *
288  * Once you have selected a particular PHY layer, a set of channels is automatically activated.
289  * Right after connecting, you can use this API to see the current plan. Otherwise, this API
290  * returns the channel plan that you have set using `set_channel_plan()`.
291  *
292  * @param channel_plan The current channel plan information.
293  *
294  * @return LORAWAN_STATUS_OK on success, a negative error code on failure:
295  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
296  * LORAWAN_STATUS_SERVICE_UNKNOWN if custom channel plans are disabled in PHY
297  */
299 
300  /** Removes an active channel plan.
301  *
302  * You cannot remove default channels (the channels the base stations are listening to).
303  * When a plan is abolished, only the non-default channels are removed.
304  *
305  * @return LORAWAN_STATUS_OK on success, negative error code on failure
306  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
307  * LORAWAN_STATUS_BUSY if TX currently ongoing,
308  * LORAWAN_STATUS_SERVICE_UNKNOWN if custom channel plans are disabled in PHY
309  */
311 
312  /** Removes a single channel.
313  *
314  * You cannot remove default channels (the channels the base stations are listening to).
315  *
316  * @param index The channel index.
317  *
318  * @return LORAWAN_STATUS_OK on success, negative error code on failure:
319  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
320  * LORAWAN_STATUS_PARAMETER_INVALID if invalid channel index is given,
321  * LORAWAN_STATUS_BUSY if TX currently ongoing,
322  * LORAWAN_STATUS_SERVICE_UNKNOWN if custom channel plans are disabled in PHY
323  */
324  lorawan_status_t remove_channel(uint8_t index);
325 
326  /** Send message to gateway
327  *
328  * @param port The application port number. Port numbers 0 and 224 are reserved,
329  * whereas port numbers from 1 to 223 (0x01 to 0xDF) are valid port numbers.
330  * Anything out of this range is illegal.
331  *
332  * @param data A pointer to the data being sent. The ownership of the buffer is not transferred.
333  * The data is copied to the internal buffers.
334  *
335  * @param length The size of data in bytes.
336  *
337  * @param flags A flag used to determine what type of message is being sent, for example:
338  *
339  * MSG_UNCONFIRMED_FLAG = 0x01
340  * MSG_CONFIRMED_FLAG = 0x02
341  * MSG_MULTICAST_FLAG = 0x04
342  * MSG_PROPRIETARY_FLAG = 0x08
343  *
344  * All flags are mutually exclusive, and MSG_MULTICAST_FLAG cannot be set.
345  *
346  * @return The number of bytes sent, or a negative error code on failure:
347  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
348  * LORAWAN_STATUS_NO_ACTIVE_SESSIONS if connection is not open,
349  * LORAWAN_STATUS_WOULD_BLOCK if another TX is ongoing,
350  * LORAWAN_STATUS_PORT_INVALID if trying to send to an invalid port (e.g. to 0)
351  * LORAWAN_STATUS_PARAMETER_INVALID if NULL data pointer is given or flags are invalid.
352  */
353  int16_t send(uint8_t port, const uint8_t *data, uint16_t length, int flags);
354 
355  /** Receives a message from the Network Server on a specific port.
356  *
357  * @param port The application port number. Port numbers 0 and 224 are reserved,
358  * whereas port numbers from 1 to 223 (0x01 to 0xDF) are valid port numbers.
359  * Anything out of this range is illegal.
360  *
361  * @param data A pointer to buffer where the received data will be stored.
362  *
363  * @param length The size of data in bytes.
364  *
365  * @param flags A flag is used to determine what type of message is being sent, for example:
366  *
367  * MSG_UNCONFIRMED_FLAG = 0x01
368  * MSG_CONFIRMED_FLAG = 0x02
369  * MSG_MULTICAST_FLAG = 0x04
370  * MSG_PROPRIETARY_FLAG = 0x08
371  *
372  * All flags can be used in conjunction with one another depending on the intended
373  * use case or reception expectation.
374  *
375  * For example, MSG_CONFIRMED_FLAG and MSG_UNCONFIRMED_FLAG are
376  * not mutually exclusive. In other words, the user can subscribe to
377  * receive both CONFIRMED AND UNCONFIRMED messages at the same time.
378  *
379  * @return It could be one of these:
380  * i) 0 if there is nothing else to read.
381  * ii) Number of bytes written to user buffer.
382  * iii) A negative error code on failure:
383  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
384  * LORAWAN_STATUS_NO_ACTIVE_SESSIONS if connection is not open,
385  * LORAWAN_STATUS_WOULD_BLOCK if there is nothing available to read at the moment,
386  * LORAWAN_STATUS_PARAMETER_INVALID if NULL data or length is given,
387  * LORAWAN_STATUS_WOULD_BLOCK if incorrect port or flags are given,
388  */
389  int16_t receive(uint8_t port, uint8_t *data, uint16_t length, int flags);
390 
391  /** Receives a message from the Network Server on any port.
392  *
393  * @param data A pointer to buffer where the received data will be stored.
394  *
395  * @param length The size of data in bytes
396  *
397  * @param port Return the number of port from which message was received.
398  *
399  * @param flags Return flags to determine what type of message was received.
400  * MSG_UNCONFIRMED_FLAG = 0x01
401  * MSG_CONFIRMED_FLAG = 0x02
402  * MSG_MULTICAST_FLAG = 0x04
403  * MSG_PROPRIETARY_FLAG = 0x08
404  *
405  * @return It could be one of these:
406  * i) 0 if there is nothing else to read.
407  * ii) Number of bytes written to user buffer.
408  * iii) A negative error code on failure:
409  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
410  * LORAWAN_STATUS_NO_ACTIVE_SESSIONS if connection is not open,
411  * LORAWAN_STATUS_PARAMETER_INVALID if NULL data or length is given,
412  * LORAWAN_STATUS_WOULD_BLOCK if there is nothing available to read at the moment.
413  */
414  int16_t receive(uint8_t *data, uint16_t length, uint8_t &port, int &flags);
415 
416  /** Add application callbacks to the stack.
417  *
418  * An example of using this API with a latch onto 'lorawan_events' could be:
419  *
420  *\code
421  * LoRaWANInterface lorawan(radio);
422  * lorawan_app_callbacks_t cbs;
423  * static void my_event_handler();
424  *
425  * int main()
426  * {
427  * lorawan.initialize();
428  * cbs.lorawan_events = mbed::callback(my_event_handler);
429  * lorawan.add_app_callbacks(&cbs);
430  * lorawan.connect();
431  * }
432  *
433  * static void my_event_handler(lorawan_event_t event)
434  * {
435  * switch(event) {
436  * case CONNECTED:
437  * //do something
438  * break;
439  * case DISCONNECTED:
440  * //do something
441  * break;
442  * case TX_DONE:
443  * //do something
444  * break;
445  * default:
446  * break;
447  * }
448  * }
449  *
450  *\endcode
451  *
452  * @param callbacks A pointer to the structure containing application callbacks.
453  *
454  * @return LORAWAN_STATUS_OK on success, a negative error code on failure:
455  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
456  * LORAWAN_STATUS_PARAMETER_INVALID if events callback is not set
457  */
459 
460  /** Change device class
461  *
462  * Change current device class.
463  *
464  * @param device_class The device class
465  *
466  * @return LORAWAN_STATUS_OK on success or other negative error code if request failed:
467  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
468  * LORAWAN_STATUS_UNSUPPORTED if requested class is not supported
469  */
471 
472  /** Get hold of TX meta-data
473  *
474  * Use this method to acquire any TX meta-data related to previous transmission.
475  * TX meta-data is only available right after the transmission is completed.
476  * In other words, you can check for TX meta-data right after receiving the TX_DONE event.
477  *
478  * @param metadata the inbound structure that will be filled if the meta-data is available.
479  *
480  * @return LORAWAN_STATUS_OK if the meta-data is available,
481  * otherwise other negative error code if request failed:
482  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
483  * LORAWAN_STATUS_METADATA_NOT_AVAILABLE if the meta-data is not available
484  */
486 
487  /** Get hold of RX meta-data
488  *
489  * Use this method to acquire any RX meta-data related to current reception.
490  * RX meta-data is only available right after the reception is completed.
491  * In other words, you can check for RX meta-data right after receiving the RX_DONE event.
492  *
493  * @param metadata the inbound structure that will be filled if the meta-data is available.
494  *
495  * @return LORAWAN_STATUS_OK if the meta-data is available,
496  * otherwise other negative error code if request failed:
497  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
498  * LORAWAN_STATUS_METADATA_NOT_AVAILABLE if the meta-data is not available
499  */
501 
502  /** Get hold of backoff time
503  *
504  * In the TX path, because of automatic duty cycling, the transmission is delayed by a certain
505  * amount of time, which is the backoff time. While the system schedules application data to be sent,
506  * the application can inquire about how much time is left in the actual transmission to happen.
507  *
508  * The system will provide you with a backoff time only if the application data is in the TX pipe.
509  * If however, the event is already queued for the transmission, this API returns a
510  * LORAWAN_STATUS_METADATA_NOT_AVAILABLE error code.
511  *
512  * @param backoff the inbound integer that will carry the backoff time if it is available.
513  *
514  * @return LORAWAN_STATUS_OK if the meta-data is available,
515  * otherwise other negative error code if request failed:
516  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
517  * LORAWAN_STATUS_METADATA_NOT_AVAILABLE if the meta-data is not available
518  */
520 
521  /** Cancel outgoing transmission
522  *
523  * This API is used to cancel any outstanding transmission in the TX pipe.
524  * If an event for transmission is not already queued at the end of backoff timer,
525  * the system can cancel the outstanding outgoing packet. Otherwise, the system is
526  * busy sending and can't be held back. The system will not try to resend if the
527  * outgoing message was a CONFIRMED message even if the ack is not received.
528  *
529  * @return LORAWAN_STATUS_OK if the sending is canceled, otherwise
530  * other negative error code if request failed:
531  * LORAWAN_STATUS_NOT_INITIALIZED if system is not initialized with initialize(),
532  * LORAWAN_STATUS_BUSY if the send cannot be canceled
533  * LORAWAN_STATUS_NO_OP if the operation cannot be completed (nothing to cancel)
534  */
536 
537  /** Provides exclusive access to the stack.
538  *
539  * Use only if the stack is being run in it's own separate thread.
540  */
541  void lock(void)
542  {
543  _lw_stack.lock();
544  }
545 
546  /** Releases exclusive access to the stack.
547  *
548  * Use only if the stack is being run in it's own separate thread.
549  */
550  void unlock(void)
551  {
552  _lw_stack.unlock();
553  }
554 
555 private:
556  /** ScopedLock object
557  *
558  * RAII style exclusive access
559  */
561 
562  /** LoRaWANStack object
563  *
564  * Handle for the LoRaWANStack class
565  */
566  LoRaWANStack _lw_stack;
567 
568  /** PHY object if created by LoRaWANInterface
569  *
570  * PHY object if LoRaWANInterface has created it.
571  * If PHY object is provided by the application, this pointer is NULL.
572  */
573  LoRaPHY *_default_phy;
574 };
575 
576 #endif /* LORAWANINTERFACE_H_ */
577 /** @}*/
Meta-data collection for the received packet.
LoRaWANStack Class A controller layer for LoRaWAN MAC and PHY.
Definition: LoRaWANStack.h:60
lorawan_status_t disconnect()
Disconnect the current session.
lorawan_status_t enable_adaptive_datarate()
Enables adaptive data rate (ADR)
Meta-data collection for a transmission.
RAII-style mechanism for owning a lock of Lockable object for the duration of a scoped block...
Definition: ScopedLock.h:62
EventQueue.
Definition: EventQueue.h:52
lorawan_status_t set_datarate(uint8_t data_rate)
Sets up a particular data rate.
lorawan_status_t set_confirmed_msg_retries(uint8_t count)
Sets up the retry counter for confirmed messages.
device_class_t
LoRaWAN device classes definition.
Definition: lorawan_types.h:59
lorawan_status_t get_backoff_metadata(int &backoff)
Get hold of backoff time.
lorawan_status_t remove_channel_plan()
Removes an active channel plan.
LoRaWAN stack layer implementation.
Contains data structures required by LoRaWANBase class.
LoRaPHY Class Parent class for LoRa regional PHY implementations.
Definition: LoRaPHY.h:46
lorawan_status_t set_device_class(device_class_t device_class)
Change device class.
lorawan_status_t get_channel_plan(lorawan_channelplan_t &channel_plan)
Gets the channel plans from the LoRa stack.
lorawan_status_t connect()
Connect OTAA or ABP using the Mbed OS config system.
lorawan_status_t cancel_sending(void)
Cancel outgoing transmission.
Stack level callback functions.
enum lorawan_status lorawan_status_t
lorawan_status_t contains status codes in response to stack operations
lorawan_connect_t structure
void remove_link_check_request()
Removes link check request sticky MAC command.
int16_t send(uint8_t port, const uint8_t *data, uint16_t length, int flags)
Send message to gateway.
LoRaWANInterface Class A network interface for LoRaWAN.
int16_t receive(uint8_t port, uint8_t *data, uint16_t length, int flags)
Receives a message from the Network Server on a specific port.
lorawan_status_t disable_adaptive_datarate()
Disables adaptive data rate.
lorawan_status_t add_app_callbacks(lorawan_app_callbacks_t *callbacks)
Add application callbacks to the stack.
lorawan_status_t remove_channel(uint8_t index)
Removes a single channel.
DO NOT MODIFY, WILL BREAK THE API!
lorawan_status_t set_channel_plan(const lorawan_channelplan_t &channel_plan)
Sets the channel plan.
lorawan_status_t get_rx_metadata(lorawan_rx_metadata &metadata)
Get hold of RX meta-data.
lorawan_status_t initialize(events::EventQueue *queue)
Initialize the LoRa stack.
void unlock(void)
Releases exclusive access to the stack.
lorawan_status_t get_tx_metadata(lorawan_tx_metadata &metadata)
Get hold of TX meta-data.
void lock(void)
Provides exclusive access to the stack.
LoRaWANInterface(LoRaRadio &radio)
Constructs a LoRaWANInterface using the LoRaWANStack instance underneath.
Interface for the radios, containing the main functions that a radio needs, and five callback functio...
Definition: LoRaRadio.h:440
lorawan_status_t add_link_check_request()
Validate the connectivity with the network.
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.