Skip to content

LoRa: State machine work #6808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/lorawan/LoRaRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ typedef struct radio_events {
* FSK : N/A (set to 0)
* LoRa: SNR value in dB
*/
mbed::Callback<void(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)> rx_done;
mbed::Callback<void(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)> rx_done;

/**
* Callback when Reception is timed out
Expand Down
4 changes: 2 additions & 2 deletions features/lorawan/LoRaWANBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ class LoRaWANBase {
* lorawan.connect();
* }
*
* static void my_event_handler(lora_events_t events)
* static void my_event_handler(lorawan_event_t event)
* {
* switch(events) {
* switch(event) {
* case CONNECTED:
* //do something
* break;
Expand Down
19 changes: 19 additions & 0 deletions features/lorawan/LoRaWANInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,95 +34,114 @@ LoRaWANInterface::~LoRaWANInterface()

lorawan_status_t LoRaWANInterface::initialize(EventQueue *queue)
{
Lock lock(*this);
return _lw_stack.initialize_mac_layer(queue);
}

lorawan_status_t LoRaWANInterface::connect()
{
Lock lock(*this);
return _lw_stack.connect();
}

lorawan_status_t LoRaWANInterface::connect(const lorawan_connect_t &connect)
{
Lock lock(*this);
return _lw_stack.connect(connect);
}

lorawan_status_t LoRaWANInterface::disconnect()
{
Lock lock(*this);
return _lw_stack.shutdown();
}

lorawan_status_t LoRaWANInterface::add_link_check_request()
{
Lock lock(*this);
return _lw_stack.set_link_check_request();
}

void LoRaWANInterface::remove_link_check_request()
{
Lock lock(*this);
_lw_stack.remove_link_check_request();
}

lorawan_status_t LoRaWANInterface::set_datarate(uint8_t data_rate)
{
Lock lock(*this);
return _lw_stack.set_channel_data_rate(data_rate);
}

lorawan_status_t LoRaWANInterface::set_confirmed_msg_retries(uint8_t count)
{
Lock lock(*this);
return _lw_stack.set_confirmed_msg_retry(count);
}

lorawan_status_t LoRaWANInterface::enable_adaptive_datarate()
{
Lock lock(*this);
return _lw_stack.enable_adaptive_datarate(true);
}

lorawan_status_t LoRaWANInterface::disable_adaptive_datarate()
{
Lock lock(*this);
return _lw_stack.enable_adaptive_datarate(false);
}

lorawan_status_t LoRaWANInterface::set_channel_plan(const lorawan_channelplan_t &channel_plan)
{
Lock lock(*this);
return _lw_stack.add_channels(channel_plan);
}

lorawan_status_t LoRaWANInterface::get_channel_plan(lorawan_channelplan_t &channel_plan)
{
Lock lock(*this);
return _lw_stack.get_enabled_channels(channel_plan);
}

lorawan_status_t LoRaWANInterface::remove_channel(uint8_t id)
{
Lock lock(*this);
return _lw_stack.remove_a_channel(id);
}

lorawan_status_t LoRaWANInterface::remove_channel_plan()
{
Lock lock(*this);
return _lw_stack.drop_channel_list();
}

int16_t LoRaWANInterface::send(uint8_t port, const uint8_t* data, uint16_t length, int flags)
{
Lock lock(*this);
return _lw_stack.handle_tx(port, data, length, flags);
}

int16_t LoRaWANInterface::receive(uint8_t port, uint8_t* data, uint16_t length, int flags)
{
Lock lock(*this);
return _lw_stack.handle_rx(data, length, port, flags, true);
}

int16_t LoRaWANInterface::receive(uint8_t* data, uint16_t length, uint8_t& port, int& flags)
{
Lock lock(*this);
return _lw_stack.handle_rx(data, length, port, flags, false);
}

lorawan_status_t LoRaWANInterface::add_app_callbacks(lorawan_app_callbacks_t *callbacks)
{
Lock lock(*this);
return _lw_stack.set_lora_callbacks(callbacks);
}

lorawan_status_t LoRaWANInterface::set_device_class(const device_class_t device_class)
{
Lock lock(*this);
return _lw_stack.set_device_class(device_class);
}
11 changes: 9 additions & 2 deletions features/lorawan/LoRaWANInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define LORAWANINTERFACE_H_

#include "platform/Callback.h"
#include "platform/ScopedLock.h"
#include "LoRaWANStack.h"
#include "LoRaRadio.h"
#include "LoRaWANBase.h"
Expand Down Expand Up @@ -398,9 +399,9 @@ class LoRaWANInterface: public LoRaWANBase {
* lorawan.connect();
* }
*
* static void my_event_handler(lora_events_t events)
* static void my_event_handler(lorawan_event_t event)
* {
* switch(events) {
* switch(event) {
* case CONNECTED:
* //do something
* break;
Expand Down Expand Up @@ -435,7 +436,13 @@ class LoRaWANInterface: public LoRaWANBase {
*/
virtual lorawan_status_t set_device_class(const device_class_t device_class);

void lock(void) { _lw_stack.lock(); }
void unlock(void) { _lw_stack.unlock(); }


private:
typedef mbed::ScopedLock<LoRaWANInterface> Lock;

LoRaWANStack _lw_stack;
};

Expand Down
Loading