Skip to content

Commit c34b5e6

Browse files
author
Hasnain Virk
committed
[IOTCELL-741] Separating public data structures
Any data structure used in LoRaWANBase class should be available in a separate header in order to make the code easy to port and easy to read as the developer doesn't need to know about all the internal data structures being used in Mbed LoRaWAN stack.
1 parent 68ebbb0 commit c34b5e6

File tree

4 files changed

+365
-348
lines changed

4 files changed

+365
-348
lines changed

features/lorawan/LoRaWANBase.h

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#ifndef LORAWAN_BASE_H_
2020
#define LORAWAN_BASE_H_
2121

22-
#include "system/lorawan_data_structures.h"
2322
#include "events/EventQueue.h"
23+
#include "lorawan_types.h"
2424

2525
class LoRaWANBase {
2626

@@ -286,38 +286,6 @@ class LoRaWANBase {
286286
virtual int16_t receive(uint8_t* data, uint16_t length, uint8_t& port, int& flags) = 0;
287287

288288
/** Add application callbacks to the stack.
289-
*
290-
* 'lorawan_app_callbacks_t' is a structure that holds pointers to the application
291-
* provided methods which are needed to be called in response to certain
292-
* requests. The structure is default constructed to set all pointers to NULL.
293-
* So if the user does not provide the pointer, a response will not be posted.
294-
* However, the 'lorawan_events' callback is mandatory to be provided as it
295-
* contains essential events.
296-
*
297-
* Events that can be posted to user via 'lorawan_events' are:
298-
*
299-
* CONNECTED - When the connection is complete
300-
* DISCONNECTED - When the protocol is shut down in response to disconnect()
301-
* TX_DONE - When a packet is sent
302-
* TX_TIMEOUT, - When stack was unable to send packet in TX window
303-
* TX_ERROR, - A general TX error
304-
* TX_CRYPTO_ERROR, - If MIC fails, or any other crypto relted error
305-
* TX_SCHEDULING_ERROR, - When stack is unable to schedule packet
306-
* RX_DONE, - When there is something to receive
307-
* RX_TIMEOUT, - Not yet mapped
308-
* RX_ERROR - A general RX error
309-
*
310-
* Other responses to certain standard requests are an item for the future.
311-
* For example, a link check request could be sent whenever the device tries
312-
* to send a message and if the network server responds with a link check resposne,
313-
* the stack notifies the application be calling the appropriate method. For example,
314-
* 'link_check_resp' callback could be used to collect a response for a link check
315-
* request MAC command and the result is thus transported to the application
316-
* via callback function provided.
317-
*
318-
* As can be seen from declaration, mbed::Callback<void(uint8_t, uint8_t)> *link_check_resp)
319-
* carries two parameters. First one is Demodulation Margin and the second one
320-
* is number of gateways involved in the path to network server.
321289
*
322290
* An example of using this API with a latch onto 'lorawan_events' could be:
323291
*
@@ -352,6 +320,9 @@ class LoRaWANBase {
352320
*
353321
* @param callbacks A pointer to the structure containing application
354322
* callbacks.
323+
*
324+
* @return LORAWAN_STATUS_OK on success, a negative error
325+
* code on failure.
355326
*/
356327
virtual lorawan_status_t add_app_callbacks(lorawan_app_callbacks_t *callbacks) = 0;
357328

features/lorawan/LoRaWANInterface.h

Lines changed: 38 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -383,73 +383,44 @@ class LoRaWANInterface: public LoRaWANBase {
383383
virtual int16_t receive(uint8_t* data, uint16_t length, uint8_t& port, int& flags);
384384

385385
/** Add application callbacks to the stack.
386-
*
387-
* 'lorawan_app_callbacks' is a structure that holds pointers to the application
388-
* provided methods which are needed to be called in response to certain
389-
* requests. The structure is default constructed to set all pointers to NULL.
390-
* So if the user does not provide the pointer, a response will not be posted.
391-
* However, the 'lorawan_events' callback is mandatory to be provided as it
392-
* contains essential events.
393-
*
394-
* Events that can be posted to user via 'lorawan_events' are:
395-
*
396-
* CONNECTED - When the connection is complete
397-
* DISCONNECTED - When the protocol is shut down in response to disconnect()
398-
* TX_DONE - When a packet is sent
399-
* TX_TIMEOUT, - When stack was unable to send packet in TX window
400-
* TX_ERROR, - A general TX error
401-
* TX_CRYPTO_ERROR, - If MIC fails, or any other crypto relted error
402-
* TX_SCHEDULING_ERROR, - When stack is unable to schedule packet
403-
* RX_DONE, - When there is something to receive
404-
* RX_TIMEOUT, - Not yet mapped
405-
* RX_ERROR - A general RX error
406-
*
407-
* Other responses to certain standard requests are an item for the future.
408-
* For example, a link check request could be sent whenever the device tries
409-
* to send a message and if the network server responds with a link check resposne,
410-
* the stack notifies the application be calling the appropriate method. For example,
411-
* 'link_check_resp' callback could be used to collect a response for a link check
412-
* request MAC command and the result is thus transported to the application
413-
* via callback function provided.
414-
*
415-
* As can be seen from declaration, mbed::Callback<void(uint8_t, uint8_t)> *link_check_resp)
416-
* carries two parameters. First one is Demodulation Margin and the second one
417-
* is number of gateways involved in the path to network server.
418-
*
419-
* An example of using this API with a latch onto 'lorawan_events' could be:
420-
*
421-
* LoRaWANInterface lorawan(radio);
422-
* lorawan_app_callbacks cbs;
423-
* static void my_event_handler();
424-
*
425-
* int main()
426-
* {
427-
* lorawan.initialize(&queue);
428-
* cbs.events = mbed::callback(my_event_handler);
429-
* lorawan.add_app_callbacks(&cbs);
430-
* lorawan.connect();
431-
* }
432-
*
433-
* static void my_event_handler(lora_events_t events)
434-
* {
435-
* switch(events) {
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-
* @param callbacks A pointer to the structure containing application
451-
* callbacks.
452-
*/
386+
*
387+
* An example of using this API with a latch onto 'lorawan_events' could be:
388+
*
389+
* LoRaWANInterface lorawan(radio);
390+
* lorawan_app_callbacks_t cbs;
391+
* static void my_event_handler();
392+
*
393+
* int main()
394+
* {
395+
* lorawan.initialize();
396+
* cbs.lorawan_events = mbed::callback(my_event_handler);
397+
* lorawan.add_app_callbacks(&cbs);
398+
* lorawan.connect();
399+
* }
400+
*
401+
* static void my_event_handler(lora_events_t events)
402+
* {
403+
* switch(events) {
404+
* case CONNECTED:
405+
* //do something
406+
* break;
407+
* case DISCONNECTED:
408+
* //do something
409+
* break;
410+
* case TX_DONE:
411+
* //do something
412+
* break;
413+
* default:
414+
* break;
415+
* }
416+
* }
417+
*
418+
* @param callbacks A pointer to the structure containing application
419+
* callbacks.
420+
*
421+
* @return LORAWAN_STATUS_OK on success, a negative error
422+
* code on failure.
423+
*/
453424
virtual lorawan_status_t add_app_callbacks(lorawan_app_callbacks_t *callbacks);
454425

455426
/** Change device class

0 commit comments

Comments
 (0)