![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
work1
Dependencies: mbed MAX44009 mbed-os Si7021
app/AppLora.h@1:3656b45f17a8, 2020-05-27 (annotated)
- Committer:
- danaeb
- Date:
- Wed May 27 12:34:37 2020 +0000
- Revision:
- 1:3656b45f17a8
- Parent:
- AppLora.h@0:d3e390d62607
app_create
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
danaeb | 0:d3e390d62607 | 1 | #ifndef TASK_LORA_H |
danaeb | 0:d3e390d62607 | 2 | #define TASK_LORA_H |
danaeb | 0:d3e390d62607 | 3 | |
danaeb | 0:d3e390d62607 | 4 | #include "mbed.h" |
danaeb | 0:d3e390d62607 | 5 | #include "liboo/types.h" |
danaeb | 0:d3e390d62607 | 6 | #include "tools.h" |
danaeb | 0:d3e390d62607 | 7 | #include "lorawan/system/lorawan_data_structures.h" |
danaeb | 0:d3e390d62607 | 8 | |
danaeb | 0:d3e390d62607 | 9 | class AppLora{ |
danaeb | 0:d3e390d62607 | 10 | public: |
danaeb | 0:d3e390d62607 | 11 | typedef enum{ |
danaeb | 0:d3e390d62607 | 12 | EVENT_DISCONNECTED, |
danaeb | 0:d3e390d62607 | 13 | EVENT_CONNECTED, |
danaeb | 0:d3e390d62607 | 14 | EVENT_TX_DONE, |
danaeb | 0:d3e390d62607 | 15 | EVENT_RX_DONE, |
danaeb | 0:d3e390d62607 | 16 | EVENT_UPLINK_REQUIERED, |
danaeb | 0:d3e390d62607 | 17 | EVENT_TX_ERROR, |
danaeb | 0:d3e390d62607 | 18 | EVENT_RX_ERROR, |
danaeb | 0:d3e390d62607 | 19 | EVENT_CONNECTION_ERROR, // not network |
danaeb | 0:d3e390d62607 | 20 | EVENT_JOIN_FAILURE // wrong OTAA keys |
danaeb | 0:d3e390d62607 | 21 | }EVENT; |
danaeb | 0:d3e390d62607 | 22 | static void initialize(EventQueue *queue); |
danaeb | 0:d3e390d62607 | 23 | static s16 get_rx_message(u8 *data, u16 data_size, u8 &app_port); |
danaeb | 0:d3e390d62607 | 24 | static s16 send_message(u8 *data, u8 data_size, u8 app_port, bool confirmed); |
danaeb | 0:d3e390d62607 | 25 | static void set_lora_callback(Callback<void(EVENT)> lora_callback); |
danaeb | 0:d3e390d62607 | 26 | static void connect(void); |
danaeb | 0:d3e390d62607 | 27 | static void disconnect(void); |
danaeb | 0:d3e390d62607 | 28 | static u32 get_random(void); |
danaeb | 0:d3e390d62607 | 29 | static u8 get_next_transmission_max_size(void); |
danaeb | 0:d3e390d62607 | 30 | |
danaeb | 0:d3e390d62607 | 31 | |
danaeb | 0:d3e390d62607 | 32 | private: |
danaeb | 0:d3e390d62607 | 33 | AppLora(){}; // private constructor that prevent anyone from |
danaeb | 0:d3e390d62607 | 34 | // creating the instance |
danaeb | 0:d3e390d62607 | 35 | static void _send_empty_uplink(void); |
danaeb | 0:d3e390d62607 | 36 | static void _enter_active_mode(void); |
danaeb | 0:d3e390d62607 | 37 | static void _enter_lowpower_mode(void); |
danaeb | 0:d3e390d62607 | 38 | static void _pin_active_mode(void); |
danaeb | 0:d3e390d62607 | 39 | static void _pin_lowpower_mode(void); |
danaeb | 0:d3e390d62607 | 40 | static void _lora_event_handler(lorawan_event_t event); |
danaeb | 0:d3e390d62607 | 41 | static void _call_callback(EVENT lora_event); |
danaeb | 0:d3e390d62607 | 42 | |
danaeb | 0:d3e390d62607 | 43 | static Callback<void(EVENT)> _lora_callback; |
danaeb | 0:d3e390d62607 | 44 | static events::EventQueue *_queue; |
danaeb | 0:d3e390d62607 | 45 | static lorawan_app_callbacks_t _callbacks; |
danaeb | 0:d3e390d62607 | 46 | static DigitalInOut _txco; |
danaeb | 0:d3e390d62607 | 47 | }; |
danaeb | 0:d3e390d62607 | 48 | |
danaeb | 0:d3e390d62607 | 49 | #endif |
danaeb | 0:d3e390d62607 | 50 |