Merge pull request #6938 from hasnainvirk/style_and_bug_fixes

LoRaWAN: Style and bug fixes
pull/7151/head
Cruz Monrreal 2018-06-11 08:46:52 -05:00 committed by GitHub
commit b00a91d15b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 641 additions and 608 deletions

View File

@ -217,7 +217,7 @@ public:
* LORAWAN_STATUS_WOULD_BLOCK if another TX is
* ongoing, or a negative error code on failure.
*/
virtual int16_t send(uint8_t port, const uint8_t* data,
virtual int16_t send(uint8_t port, const uint8_t *data,
uint16_t length, int flags) = 0;
/** Receives a message from the Network Server on a specific port.
@ -259,7 +259,7 @@ public:
* nothing available to read at the moment.
* iv) A negative error code on failure.
*/
virtual int16_t receive(uint8_t port, uint8_t* data, uint16_t length, int flags) = 0;
virtual int16_t receive(uint8_t port, uint8_t *data, uint16_t length, int flags) = 0;
/** Receives a message from the Network Server from any port.
*
@ -283,7 +283,7 @@ public:
* nothing available to read at the moment.
* iv) A negative error code on failure.
*/
virtual int16_t receive(uint8_t* data, uint16_t length, uint8_t& port, int& flags) = 0;
virtual int16_t receive(uint8_t *data, uint16_t length, uint8_t &port, int &flags) = 0;
/** Add application callbacks to the stack.
*

View File

@ -23,7 +23,7 @@
using namespace events;
LoRaWANInterface::LoRaWANInterface(LoRaRadio& radio)
LoRaWANInterface::LoRaWANInterface(LoRaRadio &radio)
{
_lw_stack.bind_radio_driver(radio);
}
@ -116,7 +116,7 @@ lorawan_status_t LoRaWANInterface::remove_channel_plan()
return _lw_stack.drop_channel_list();
}
int16_t LoRaWANInterface::send(uint8_t port, const uint8_t* data, uint16_t length, int flags)
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);
@ -146,13 +146,13 @@ lorawan_status_t LoRaWANInterface::get_backoff_metadata(int &backoff)
return _lw_stack.acquire_backoff_metadata(backoff);
}
int16_t LoRaWANInterface::receive(uint8_t port, uint8_t* data, uint16_t length, int 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)
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);

View File

@ -34,7 +34,7 @@ public:
* construct a single instance of LoRaWANInterface.
*
*/
LoRaWANInterface(LoRaRadio& radio);
LoRaWANInterface(LoRaRadio &radio);
virtual ~LoRaWANInterface();
@ -315,7 +315,7 @@ public:
* LORAWAN_STATUS_WOULD_BLOCK if another TX is
* ongoing, or a negative error code on failure.
*/
virtual int16_t send(uint8_t port, const uint8_t* data, uint16_t length,
virtual int16_t send(uint8_t port, const uint8_t *data, uint16_t length,
int flags);
/** Receives a message from the Network Server on a specific port.
@ -357,7 +357,7 @@ public:
* nothing available to read at the moment.
* iv) A negative error code on failure.
*/
virtual int16_t receive(uint8_t port, uint8_t* data, uint16_t length, int flags);
virtual int16_t receive(uint8_t port, uint8_t *data, uint16_t length, int flags);
/** Receives a message from the Network Server on any port.
*
@ -381,7 +381,7 @@ public:
* nothing available to read at the moment.
* iv) A negative error code on failure.
*/
virtual int16_t receive(uint8_t* data, uint16_t length, uint8_t& port, int& flags);
virtual int16_t receive(uint8_t *data, uint16_t length, uint8_t &port, int &flags);
/** Add application callbacks to the stack.
*
@ -502,8 +502,14 @@ public:
*/
virtual lorawan_status_t cancel_sending(void);
void lock(void) { _lw_stack.lock(); }
void unlock(void) { _lw_stack.unlock(); }
void lock(void)
{
_lw_stack.lock();
}
void unlock(void)
{
_lw_stack.unlock();
}
private:

View File

@ -49,14 +49,14 @@ using namespace mbed;
using namespace events;
#if defined(LORAWAN_COMPLIANCE_TEST)
#if (MBED_CONF_LORA_PHY == 0 || MBED_CONF_LORA_PHY == 4 || MBED_CONF_LORA_PHY == 6 || MBED_CONF_LORA_PHY == 7)
#define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 16
#elif (MBED_CONF_LORA_PHY == 1 || MBED_CONF_LORA_PHY == 2 || MBED_CONF_LORA_PHY == 8 || MBED_CONF_LORA_PHY == 9)
#define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 11
#else
#error "Must set LoRa PHY layer parameters."
#endif
#if (MBED_CONF_LORA_PHY == 0 || MBED_CONF_LORA_PHY == 4 || MBED_CONF_LORA_PHY == 6 || MBED_CONF_LORA_PHY == 7)
#define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 16
#elif (MBED_CONF_LORA_PHY == 1 || MBED_CONF_LORA_PHY == 2 || MBED_CONF_LORA_PHY == 8 || MBED_CONF_LORA_PHY == 9)
#define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 11
#else
#error "Must set LoRa PHY layer parameters."
#endif
#endif //defined(LORAWAN_COMPLIANCE_TEST)
/**
* Bit mask for message flags
@ -98,7 +98,7 @@ LoRaWANStack::LoRaWANStack()
/*****************************************************************************
* Public Methods *
****************************************************************************/
void LoRaWANStack::bind_radio_driver(LoRaRadio& radio)
void LoRaWANStack::bind_radio_driver(LoRaRadio &radio)
{
radio_events.tx_done = mbed::callback(this, &LoRaWANStack::tx_interrupt_handler);
radio_events.rx_done = mbed::callback(this, &LoRaWANStack::rx_interrupt_handler);
@ -115,7 +115,7 @@ void LoRaWANStack::bind_radio_driver(LoRaRadio& radio)
lorawan_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
{
if(!queue) {
if (!queue) {
return LORAWAN_STATUS_PARAMETER_INVALID;
}
@ -127,6 +127,10 @@ lorawan_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
lorawan_status_t LoRaWANStack::set_lora_callbacks(const lorawan_app_callbacks_t *callbacks)
{
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
return LORAWAN_STATUS_NOT_INITIALIZED;
}
if (!callbacks || !callbacks->events) {
return LORAWAN_STATUS_PARAMETER_INVALID;
}
@ -148,7 +152,6 @@ lorawan_status_t LoRaWANStack::set_lora_callbacks(const lorawan_app_callbacks_t
lorawan_status_t LoRaWANStack::connect()
{
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED;
}
@ -164,14 +167,14 @@ lorawan_status_t LoRaWANStack::connect()
lorawan_status_t LoRaWANStack::connect(const lorawan_connect_t &connect)
{
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED;
}
if (!(connect.connect_type == LORAWAN_CONNECTION_OTAA) &&
!(connect.connect_type == LORAWAN_CONNECTION_ABP)) {
if (!(connect.connect_type == LORAWAN_CONNECTION_OTAA)
&& !(connect.connect_type == LORAWAN_CONNECTION_ABP)) {
return LORAWAN_STATUS_PARAMETER_INVALID;
}
bool is_otaa = (connect.connect_type == LORAWAN_CONNECTION_OTAA);
lorawan_status_t status = _loramac.prepare_join(&connect, is_otaa);
@ -186,7 +189,6 @@ lorawan_status_t LoRaWANStack::connect(const lorawan_connect_t &connect)
lorawan_status_t LoRaWANStack::add_channels(const lorawan_channelplan_t &channel_plan)
{
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED;
}
@ -196,7 +198,6 @@ lorawan_status_t LoRaWANStack::add_channels(const lorawan_channelplan_t &channel
lorawan_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
{
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED;
}
@ -206,17 +207,15 @@ lorawan_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
lorawan_status_t LoRaWANStack::drop_channel_list()
{
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED;
}
return _loramac.remove_channel_plan();
}
lorawan_status_t LoRaWANStack::get_enabled_channels(lorawan_channelplan_t& channel_plan)
lorawan_status_t LoRaWANStack::get_enabled_channels(lorawan_channelplan_t &channel_plan)
{
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED;
}
@ -225,6 +224,10 @@ lorawan_status_t LoRaWANStack::get_enabled_channels(lorawan_channelplan_t& chann
lorawan_status_t LoRaWANStack::set_confirmed_msg_retry(uint8_t count)
{
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
return LORAWAN_STATUS_NOT_INITIALIZED;
}
if (count >= MAX_CONFIRMED_MSG_RETRIES) {
return LORAWAN_STATUS_PARAMETER_INVALID;
}
@ -236,9 +239,7 @@ lorawan_status_t LoRaWANStack::set_confirmed_msg_retry(uint8_t count)
lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate)
{
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state)
{
tr_error("Stack not initialized!");
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
return LORAWAN_STATUS_NOT_INITIALIZED;
}
@ -248,11 +249,10 @@ lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate)
lorawan_status_t LoRaWANStack::enable_adaptive_datarate(bool adr_enabled)
{
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED)
{
tr_error("Stack not initialized!");
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
return LORAWAN_STATUS_NOT_INITIALIZED;
}
_loramac.enable_adaptive_datarate(adr_enabled);
return LORAWAN_STATUS_OK;
}
@ -272,7 +272,7 @@ lorawan_status_t LoRaWANStack::stop_sending(void)
return LORAWAN_STATUS_BUSY;
}
int16_t LoRaWANStack::handle_tx(const uint8_t port, const uint8_t* data,
int16_t LoRaWANStack::handle_tx(const uint8_t port, const uint8_t *data,
uint16_t length, uint8_t flags,
bool null_allowed, bool allow_port_0)
{
@ -289,7 +289,7 @@ int16_t LoRaWANStack::handle_tx(const uint8_t port, const uint8_t* data,
return LORAWAN_STATUS_NO_ACTIVE_SESSIONS;
}
if(_loramac.tx_ongoing()) {
if (_loramac.tx_ongoing()) {
return LORAWAN_STATUS_WOULD_BLOCK;
}
@ -334,7 +334,7 @@ int16_t LoRaWANStack::handle_tx(const uint8_t port, const uint8_t* data,
return (status == LORAWAN_STATUS_OK) ? len : (int16_t) status;
}
int16_t LoRaWANStack::handle_rx(uint8_t* data, uint16_t length, uint8_t& port, int& flags, bool validate_params)
int16_t LoRaWANStack::handle_rx(uint8_t *data, uint16_t length, uint8_t &port, int &flags, bool validate_params)
{
if (!_lw_session.active) {
return LORAWAN_STATUS_NO_ACTIVE_SESSIONS;
@ -375,8 +375,8 @@ int16_t LoRaWANStack::handle_rx(uint8_t* data, uint16_t length, uint8_t& port, i
// check the length of received message whether we can fit into user
// buffer completely or not
if (_rx_msg.msg.mcps_indication.buffer_size > length &&
_rx_msg.prev_read_size == 0) {
if (_rx_msg.msg.mcps_indication.buffer_size > length
&& _rx_msg.prev_read_size == 0) {
// we can't fit into user buffer. Invoke counter measures
_rx_msg.pending_size = _rx_msg.msg.mcps_indication.buffer_size - length;
base_size = length;
@ -393,7 +393,7 @@ int16_t LoRaWANStack::handle_rx(uint8_t* data, uint16_t length, uint8_t& port, i
// the buffer. Due to checks above, in case of a pending read, this block
// will be the only one to get invoked
if (_rx_msg.pending_size > 0 && _rx_msg.prev_read_size > 0) {
memcpy(data, base_ptr+_rx_msg.prev_read_size, base_size);
memcpy(data, base_ptr + _rx_msg.prev_read_size, base_size);
}
// we are done handing over received buffer to user. check if there is
@ -410,6 +410,10 @@ int16_t LoRaWANStack::handle_rx(uint8_t* data, uint16_t length, uint8_t& port, i
lorawan_status_t LoRaWANStack::set_link_check_request()
{
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
return LORAWAN_STATUS_NOT_INITIALIZED;
}
_link_check_requested = true;
if (!_callbacks.link_check_resp) {
tr_error("Must assign a callback function for link check request. ");
@ -427,11 +431,19 @@ void LoRaWANStack::remove_link_check_request()
lorawan_status_t LoRaWANStack::shutdown()
{
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
return LORAWAN_STATUS_NOT_INITIALIZED;
}
return state_controller(DEVICE_STATE_SHUTDOWN);
}
lorawan_status_t LoRaWANStack::set_device_class(const device_class_t& device_class)
lorawan_status_t LoRaWANStack::set_device_class(const device_class_t &device_class)
{
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
return LORAWAN_STATUS_NOT_INITIALIZED;
}
if (device_class == CLASS_B) {
return LORAWAN_STATUS_UNSUPPORTED;
}
@ -593,7 +605,7 @@ void LoRaWANStack::handle_ack_expiry_for_class_c(void)
state_controller(DEVICE_STATE_STATUS_CHECK);
}
void LoRaWANStack::process_reception(const uint8_t* const payload, uint16_t size,
void LoRaWANStack::process_reception(const uint8_t *const payload, uint16_t size,
int16_t rssi, int8_t snr)
{
_device_current_state = DEVICE_STATE_RECEIVING;
@ -1012,7 +1024,7 @@ lorawan_status_t LoRaWANStack::state_controller(device_states_t new_state)
return status;
}
void LoRaWANStack::process_shutdown_state(lorawan_status_t& op_status)
void LoRaWANStack::process_shutdown_state(lorawan_status_t &op_status)
{
/**
* Remove channels
@ -1070,7 +1082,7 @@ void LoRaWANStack::process_status_check_state()
}
}
void LoRaWANStack::process_scheduling_state(lorawan_status_t& op_status)
void LoRaWANStack::process_scheduling_state(lorawan_status_t &op_status)
{
if (_device_current_state != DEVICE_STATE_IDLE) {
if (_device_current_state != DEVICE_STATE_RECEIVING
@ -1089,7 +1101,7 @@ void LoRaWANStack::process_scheduling_state(lorawan_status_t& op_status)
}
}
void LoRaWANStack::process_joining_state(lorawan_status_t& op_status)
void LoRaWANStack::process_joining_state(lorawan_status_t &op_status)
{
if (_device_current_state == DEVICE_STATE_CONNECTING) {
_device_current_state = DEVICE_STATE_JOINING;
@ -1124,11 +1136,10 @@ void LoRaWANStack::process_connected_state()
_device_current_state = DEVICE_STATE_IDLE;
}
void LoRaWANStack::process_connecting_state(lorawan_status_t& op_status)
void LoRaWANStack::process_connecting_state(lorawan_status_t &op_status)
{
if (_device_current_state != DEVICE_STATE_IDLE
&&
_device_current_state != DEVICE_STATE_SHUTDOWN) {
&& _device_current_state != DEVICE_STATE_SHUTDOWN) {
op_status = LORAWAN_STATUS_BUSY;
return;
}
@ -1151,7 +1162,7 @@ void LoRaWANStack::process_connecting_state(lorawan_status_t& op_status)
process_connected_state();
}
void LoRaWANStack::process_idle_state(lorawan_status_t& op_status)
void LoRaWANStack::process_idle_state(lorawan_status_t &op_status)
{
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
_device_current_state = DEVICE_STATE_IDLE;
@ -1163,7 +1174,7 @@ void LoRaWANStack::process_idle_state(lorawan_status_t& op_status)
op_status = LORAWAN_STATUS_OK;
}
void LoRaWANStack::process_uninitialized_state(lorawan_status_t& op_status)
void LoRaWANStack::process_uninitialized_state(lorawan_status_t &op_status)
{
op_status = _loramac.initialize(_queue);
@ -1196,7 +1207,7 @@ lorawan_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
_compliance_test.state = 1;
test_req.f_buffer_size = _compliance_test.app_data_size;
test_req.f_buffer[0] = _compliance_test.app_data_buffer[0];
for(uint8_t i = 1; i < MIN(_compliance_test.app_data_size, MBED_CONF_LORA_TX_MAX_SIZE); ++i) {
for (uint8_t i = 1; i < MIN(_compliance_test.app_data_size, MBED_CONF_LORA_TX_MAX_SIZE); ++i) {
test_req.f_buffer[i] = _compliance_test.app_data_buffer[i];
}
break;
@ -1220,7 +1231,7 @@ lorawan_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
tr_info("Transmit unconfirmed compliance test frame %d bytes.", test_req.f_buffer_size);
for (uint8_t i = 0; i < test_req.f_buffer_size; ++i) {
tr_info("Byte %d, data is 0x%x", i+1, ((uint8_t*)test_req.f_buffer)[i]);
tr_info("Byte %d, data is 0x%x", i + 1, ((uint8_t *)test_req.f_buffer)[i]);
}
} else if (_compliance_test.is_tx_confirmed) {
test_req.type = MCPS_CONFIRMED;
@ -1231,7 +1242,7 @@ lorawan_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
tr_info("Transmit confirmed compliance test frame %d bytes.", test_req.f_buffer_size);
for (uint8_t i = 0; i < test_req.f_buffer_size; ++i) {
tr_info("Byte %d, data is 0x%x", i+1, ((uint8_t*)test_req.f_buffer)[i]);
tr_info("Byte %d, data is 0x%x", i + 1, ((uint8_t *)test_req.f_buffer)[i]);
}
} else {
return LORAWAN_STATUS_SERVICE_UNKNOWN;
@ -1310,7 +1321,7 @@ void LoRaWANStack::compliance_test_handler(loramac_mcps_indication_t *mcps_indic
_compliance_test.app_data_size = mcps_indication->buffer_size;
_compliance_test.app_data_buffer[0] = 4;
for(uint8_t i = 1; i < MIN(_compliance_test.app_data_size, LORAMAC_PHY_MAXPAYLOAD); ++i) {
for (uint8_t i = 1; i < MIN(_compliance_test.app_data_size, LORAMAC_PHY_MAXPAYLOAD); ++i) {
_compliance_test.app_data_buffer[i] = mcps_indication->buffer[i] + 1;
}

View File

@ -67,7 +67,7 @@ public:
* @param radio LoRaRadio object, i.e., the radio driver
*
*/
void bind_radio_driver(LoRaRadio& radio);
void bind_radio_driver(LoRaRadio &radio);
/** End device initialization.
* @param queue A pointer to an EventQueue passed from the application.
@ -281,7 +281,7 @@ public:
* LORAWAN_STATUS_WOULD_BLOCK if another TX is
* ongoing, or a negative error code on failure.
*/
int16_t handle_tx(uint8_t port, const uint8_t* data,
int16_t handle_tx(uint8_t port, const uint8_t *data,
uint16_t length, uint8_t flags,
bool null_allowed = false, bool allow_port_0 = false);
@ -334,7 +334,7 @@ public:
* nothing available to read at the moment.
* iv) A negative error code on failure.
*/
int16_t handle_rx(uint8_t* data, uint16_t length, uint8_t& port, int& flags, bool validate_params);
int16_t handle_rx(uint8_t *data, uint16_t length, uint8_t &port, int &flags, bool validate_params);
/** Send Link Check Request MAC command.
*
@ -377,7 +377,7 @@ public:
* LORAWAN_STATUS_UNSUPPORTED is requested class is not supported,
* or other negative error code if request failed.
*/
lorawan_status_t set_device_class(const device_class_t& device_class);
lorawan_status_t set_device_class(const device_class_t &device_class);
/** Acquire TX meta-data
*
@ -425,8 +425,14 @@ public:
*/
lorawan_status_t stop_sending(void);
void lock(void) { _loramac.lock(); }
void unlock(void) { _loramac.unlock(); }
void lock(void)
{
_loramac.lock();
}
void unlock(void)
{
_loramac.unlock();
}
private:
typedef mbed::ScopedLock<LoRaWANStack> Lock;
@ -443,14 +449,14 @@ private:
/**
* Helpers for state controller
*/
void process_uninitialized_state(lorawan_status_t& op_status);
void process_idle_state(lorawan_status_t& op_status);
void process_uninitialized_state(lorawan_status_t &op_status);
void process_idle_state(lorawan_status_t &op_status);
void process_connected_state();
void process_connecting_state(lorawan_status_t& op_status);
void process_joining_state(lorawan_status_t& op_status);
void process_scheduling_state(lorawan_status_t& op_status);
void process_connecting_state(lorawan_status_t &op_status);
void process_joining_state(lorawan_status_t &op_status);
void process_scheduling_state(lorawan_status_t &op_status);
void process_status_check_state();
void process_shutdown_state(lorawan_status_t& op_status);
void process_shutdown_state(lorawan_status_t &op_status);
void state_machine_run_to_completion(void);
/**

View File

@ -202,7 +202,7 @@ void LoRaMac::on_radio_tx_done(void)
}
}
if(_params.is_rx_window_enabled == true) {
if (_params.is_rx_window_enabled == true) {
// start timer after which rx1_window will get opened
_lora_time.start(_params.timers.rx_window1_timer, _params.rx_window1_delay);
@ -317,11 +317,11 @@ void LoRaMac::check_frame_size(uint16_t size)
}
}
bool LoRaMac::message_integrity_check(const uint8_t * const payload,
bool LoRaMac::message_integrity_check(const uint8_t *const payload,
const uint16_t size,
uint8_t * const ptr_pos,
uint8_t *const ptr_pos,
uint32_t address,
uint32_t* downlink_counter,
uint32_t *downlink_counter,
const uint8_t *nwk_skey)
{
uint32_t mic = 0;
@ -349,7 +349,7 @@ bool LoRaMac::message_integrity_check(const uint8_t * const payload,
// sizeof nws_skey must be the same as _params.keys.nwk_skey,
_lora_crypto.compute_mic(payload, size - LORAMAC_MFR_LEN,
nwk_skey,
sizeof(_params.keys.nwk_skey)*8,
sizeof(_params.keys.nwk_skey) * 8,
address, DOWN_LINK, *downlink_counter, &mic);
if (mic_rx != mic) {
@ -390,7 +390,7 @@ void LoRaMac::extract_data_and_mac_commands(const uint8_t *payload,
if (_lora_crypto.decrypt_payload(payload + payload_start_index,
frame_len,
nwk_skey,
sizeof(_params.keys.nwk_skey)*8,
sizeof(_params.keys.nwk_skey) * 8,
address,
DOWN_LINK,
downlink_counter,
@ -425,10 +425,11 @@ void LoRaMac::extract_data_and_mac_commands(const uint8_t *payload,
if (fopts_len > 0) {
// Decode Options field MAC commands. Omit the fPort.
if (_mac_commands.process_mac_commands(payload, 8,
payload_start_index - 1, snr,
payload_start_index - 1,
snr,
_mlme_confirmation,
_params.sys_params, _lora_phy)
!= LORAWAN_STATUS_OK) {
_params.sys_params,
_lora_phy) != LORAWAN_STATUS_OK) {
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
return;
}
@ -477,7 +478,7 @@ void LoRaMac::extract_mac_commands_only(const uint8_t *payload,
}
}
void LoRaMac::handle_data_frame(const uint8_t* const payload,
void LoRaMac::handle_data_frame(const uint8_t *const payload,
const uint16_t size,
uint8_t ptr_pos,
uint8_t msg_type,
@ -655,7 +656,7 @@ void LoRaMac::set_batterylevel_callback(mbed::Callback<uint8_t(void)> battery_le
_mac_commands.set_batterylevel_callback(battery_level);
}
void LoRaMac::on_radio_rx_done(const uint8_t* const payload, uint16_t size,
void LoRaMac::on_radio_rx_done(const uint8_t *const payload, uint16_t size,
int16_t rssi, int8_t snr)
{
// stop the RX1 timer here if its the first RX slot.
@ -706,7 +707,7 @@ void LoRaMac::on_radio_rx_done(const uint8_t* const payload, uint16_t size,
}
}
void LoRaMac::on_radio_tx_timeout( void )
void LoRaMac::on_radio_tx_timeout(void)
{
_lora_time.stop(_params.timers.rx_window1_timer);
_lora_time.stop(_params.timers.rx_window2_timer);
@ -738,25 +739,29 @@ rx_slot_t LoRaMac::on_radio_rx_timeout(bool is_timeout)
if (_params.rx_slot == RX_SLOT_WIN_1) {
if (_params.is_node_ack_requested == true) {
_mcps_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT
: LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
_mcps_confirmation.status = is_timeout ?
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
}
_mlme_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT
: LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
_mlme_confirmation.status = is_timeout ?
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
if (_device_class != CLASS_C) {
if (_lora_time.get_elapsed_time(_params.timers.aggregated_last_tx_time ) >= _params.rx_window2_delay) {
if (_lora_time.get_elapsed_time(_params.timers.aggregated_last_tx_time) >= _params.rx_window2_delay) {
_lora_time.stop(_params.timers.rx_window2_timer);
}
}
} else {
if (_params.is_node_ack_requested == true) {
_mcps_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT
: LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
_mcps_confirmation.status = is_timeout ?
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
}
_mlme_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT
: LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
_mlme_confirmation.status = is_timeout ?
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
}
if (_device_class == CLASS_C) {
@ -929,8 +934,7 @@ void LoRaMac::on_ack_timeout_timer_event(void)
if ((_params.ack_timeout_retry_counter % 2)
&& (_params.sys_params.adr_on)) {
tr_debug("Trading datarate for range");
_params.sys_params.channel_data_rate = _lora_phy.get_next_lower_tx_datarate(
_params.sys_params.channel_data_rate);
_params.sys_params.channel_data_rate = _lora_phy.get_next_lower_tx_datarate(_params.sys_params.channel_data_rate);
}
_mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter;
@ -945,6 +949,7 @@ void LoRaMac::on_ack_timeout_timer_event(void)
_mac_commands.clear_command_buffer();
_params.is_node_ack_requested = false;
_mcps_confirmation.ack_received = false;
_mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter;
// now that is a critical failure
lorawan_status_t status = handle_retransmission();
@ -978,7 +983,7 @@ bool LoRaMac::validate_payload_length(uint16_t length,
void LoRaMac::set_mlme_schedule_ul_indication(void)
{
_mlme_indication.indication_type = MLME_SCHEDULE_UPLINK;
_mlme_indication.pending= true;
_mlme_indication.pending = true;
}
// This is not actual transmission. It just schedules a message in response
@ -1213,7 +1218,7 @@ void LoRaMac::reset_ongoing_tx(bool reset_pending)
}
int16_t LoRaMac::prepare_ongoing_tx(const uint8_t port,
const uint8_t* const data,
const uint8_t *const data,
uint16_t length,
uint8_t flags,
uint8_t num_retries)
@ -1319,7 +1324,7 @@ device_class_t LoRaMac::get_device_class() const
return _device_class;
}
void LoRaMac::set_device_class(const device_class_t& device_class,
void LoRaMac::set_device_class(const device_class_t &device_class,
mbed::Callback<void(void)>ack_expiry_handler)
{
_device_class = device_class;
@ -1331,12 +1336,12 @@ void LoRaMac::set_device_class(const device_class_t& device_class,
} else if (CLASS_C == _device_class) {
_params.is_node_ack_requested = false;
_lora_phy.put_radio_to_sleep();
_lora_phy.compute_rx_win_params(
_params.sys_params.rx2_channel.datarate,
_lora_phy.compute_rx_win_params(_params.sys_params.rx2_channel.datarate,
_params.sys_params.min_rx_symb,
_params.sys_params.max_sys_rx_error,
&_params.rx_window2_config);
}
if (CLASS_C == _device_class) {
tr_debug("Changing device class to -> CLASS_C");
open_rx2_window();
@ -1358,10 +1363,10 @@ lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_
{
if (params) {
if (is_otaa) {
if ((params->connection_u.otaa.dev_eui == NULL) ||
(params->connection_u.otaa.app_eui == NULL) ||
(params->connection_u.otaa.app_key == NULL) ||
(params->connection_u.otaa.nb_trials == 0)) {
if ((params->connection_u.otaa.dev_eui == NULL)
|| (params->connection_u.otaa.app_eui == NULL)
|| (params->connection_u.otaa.app_key == NULL)
|| (params->connection_u.otaa.nb_trials == 0)) {
return LORAWAN_STATUS_PARAMETER_INVALID;
}
_params.keys.dev_eui = params->connection_u.otaa.dev_eui;
@ -1376,6 +1381,13 @@ lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_
// Reset variable JoinRequestTrials
_params.join_request_trial_counter = 0;
} else {
if ((params->connection_u.abp.dev_addr == 0)
|| (params->connection_u.abp.nwk_id == 0)
|| (params->connection_u.abp.nwk_skey == NULL)
|| (params->connection_u.abp.app_skey == NULL)) {
return LORAWAN_STATUS_PARAMETER_INVALID;
}
_params.net_id = params->connection_u.abp.nwk_id;
_params.dev_addr = params->connection_u.abp.dev_addr;
@ -1411,13 +1423,12 @@ lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_
_params.net_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
_params.dev_addr = MBED_CONF_LORA_DEVICE_ADDRESS;
memcpy(_params.keys.nwk_skey, nwk_skey,
sizeof(_params.keys.nwk_skey));
memcpy(_params.keys.nwk_skey, nwk_skey, sizeof(_params.keys.nwk_skey));
memcpy(_params.keys.app_skey, app_skey,
sizeof(_params.keys.app_skey));
memcpy(_params.keys.app_skey, app_skey, sizeof(_params.keys.app_skey));
#endif
}
return LORAWAN_STATUS_OK;
}
@ -1453,7 +1464,7 @@ lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr,
uint16_t i;
uint8_t pkt_header_len = 0;
uint32_t mic = 0;
const void* payload = fbuffer;
const void *payload = fbuffer;
uint8_t frame_port = fport;
lorawan_status_t status = LORAWAN_STATUS_OK;
@ -1605,7 +1616,7 @@ lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr,
break;
case FRAME_TYPE_PROPRIETARY:
if ((fbuffer != NULL) && (_params.tx_buffer_len > 0)) {
memcpy(_params.tx_buffer + pkt_header_len, (uint8_t*) fbuffer,
memcpy(_params.tx_buffer + pkt_header_len, (uint8_t *) fbuffer,
_params.tx_buffer_len);
_params.tx_buffer_len = pkt_header_len + _params.tx_buffer_len;
}
@ -1654,19 +1665,19 @@ lorawan_status_t LoRaMac::send_frame_on_channel(uint8_t channel)
void LoRaMac::reset_mcps_confirmation()
{
memset((uint8_t*) &_mcps_confirmation, 0, sizeof(_mcps_confirmation));
memset((uint8_t *) &_mcps_confirmation, 0, sizeof(_mcps_confirmation));
_mcps_confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
}
void LoRaMac::reset_mlme_confirmation()
{
memset((uint8_t*) &_mlme_confirmation, 0, sizeof(_mlme_confirmation));
memset((uint8_t *) &_mlme_confirmation, 0, sizeof(_mlme_confirmation));
_mlme_confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
}
void LoRaMac::reset_mcps_indication()
{
memset((uint8_t*) &_mcps_indication, 0, sizeof(_mcps_indication));
memset((uint8_t *) &_mcps_indication, 0, sizeof(_mcps_indication));
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
}
@ -1800,7 +1811,7 @@ void LoRaMac::set_nwk_joined(bool joined)
_is_nwk_joined = joined;
}
lorawan_status_t LoRaMac::add_channel_plan(const lorawan_channelplan_t& plan)
lorawan_status_t LoRaMac::add_channel_plan(const lorawan_channelplan_t &plan)
{
if (tx_ongoing()) {
return LORAWAN_STATUS_BUSY;
@ -1818,7 +1829,7 @@ lorawan_status_t LoRaMac::remove_channel_plan()
return _channel_plan.remove_plan();
}
lorawan_status_t LoRaMac::get_channel_plan(lorawan_channelplan_t& plan)
lorawan_status_t LoRaMac::get_channel_plan(lorawan_channelplan_t &plan)
{
return _channel_plan.get_plan(plan, _lora_phy.get_phy_channels());
}
@ -1856,8 +1867,7 @@ lorawan_status_t LoRaMac::multicast_channel_link(multicast_params_t *channel_par
return LORAWAN_STATUS_OK;
}
lorawan_status_t LoRaMac::multicast_channel_unlink(
multicast_params_t *channel_param)
lorawan_status_t LoRaMac::multicast_channel_unlink(multicast_params_t *channel_param)
{
if (channel_param == NULL) {
return LORAWAN_STATUS_PARAMETER_INVALID;
@ -1887,7 +1897,7 @@ lorawan_status_t LoRaMac::multicast_channel_unlink(
return LORAWAN_STATUS_OK;
}
void LoRaMac::bind_radio_driver(LoRaRadio& radio)
void LoRaMac::bind_radio_driver(LoRaRadio &radio)
{
_lora_phy.set_radio_instance(radio);
}
@ -1898,7 +1908,7 @@ void LoRaMac::bind_radio_driver(LoRaRadio& radio)
**************************************************************************/
lorawan_status_t LoRaMac::mlme_request( loramac_mlme_req_t *mlmeRequest )
lorawan_status_t LoRaMac::mlme_request(loramac_mlme_req_t *mlmeRequest)
{
if (LORAMAC_IDLE != _params.mac_state) {
return LORAWAN_STATUS_BUSY;
@ -1933,7 +1943,6 @@ lorawan_status_t LoRaMac::mlme_request( loramac_mlme_req_t *mlmeRequest )
_params.flags.bits.mlme_req = 0;
}
return status;
}
@ -2007,7 +2016,7 @@ lorawan_status_t LoRaMac::LoRaMacSetTxTimer( uint32_t TxDutyCycleTime )
return LORAWAN_STATUS_OK;
}
lorawan_status_t LoRaMac::LoRaMacStopTxTimer( )
lorawan_status_t LoRaMac::LoRaMacStopTxTimer( )
{
_lora_time.stop(tx_next_packet_timer);
return LORAWAN_STATUS_OK;

View File

@ -135,7 +135,7 @@ public:
* \ref LORAWAN_STATUS_BUSY
* \ref LORAWAN_STATUS_PARAMETER_INVALID
*/
lorawan_status_t add_channel_plan(const lorawan_channelplan_t& plan);
lorawan_status_t add_channel_plan(const lorawan_channelplan_t &plan);
/**
* @brief Removes a channel plan from the system.
@ -166,7 +166,7 @@ public:
* \ref LORAWAN_STATUS_BUSY
* \ref LORAWAN_STATUS_PARAMETER_INVALID
*/
lorawan_status_t get_channel_plan(lorawan_channelplan_t& plan);
lorawan_status_t get_channel_plan(lorawan_channelplan_t &plan);
/**
* @brief Remove a given channel from the active plan.
@ -221,7 +221,7 @@ public:
* @param radio LoRaRadio object, i.e., the radio driver
*
*/
void bind_radio_driver(LoRaRadio& radio);
void bind_radio_driver(LoRaRadio &radio);
/**
* @brief Configures the events to trigger an MLME-Indication with
@ -333,7 +333,7 @@ public:
* @param num_retries Number of retries for a confirmed type message
* @return The number of bytes prepared for sending.
*/
int16_t prepare_ongoing_tx(const uint8_t port, const uint8_t* data,
int16_t prepare_ongoing_tx(const uint8_t port, const uint8_t *data,
uint16_t length, uint8_t flags, uint8_t num_retries);
/**
@ -353,7 +353,7 @@ public:
* @param device_class Device class to use.
* @param ack_expiry_handler callback function to inform about ack expiry
*/
void set_device_class(const device_class_t& device_class,
void set_device_class(const device_class_t &device_class,
mbed::Callback<void(void)>ack_expiry_handler);
/**
@ -391,7 +391,7 @@ public:
/**
* MAC operations upon reception
*/
void on_radio_rx_done(const uint8_t* const payload, uint16_t size,
void on_radio_rx_done(const uint8_t *const payload, uint16_t size,
int16_t rssi, int8_t snr);
/**
@ -460,8 +460,16 @@ public:
* the stack thread safe.
*/
#if MBED_CONF_RTOS_PRESENT
void lock(void) { osStatus status = _mutex.lock(); MBED_ASSERT(status == osOK); }
void unlock(void) { osStatus status = _mutex.unlock(); MBED_ASSERT(status == osOK); }
void lock(void)
{
osStatus status = _mutex.lock();
MBED_ASSERT(status == osOK);
}
void unlock(void)
{
osStatus status = _mutex.unlock();
MBED_ASSERT(status == osOK);
}
#else
void lock(void) { }
void unlock(void) { }

View File

@ -65,261 +65,6 @@
*/
#define LC( channelIndex ) ( uint16_t )( 1 << ( channelIndex - 1 ) )
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF12 - BW125
* AU915 | SF10 - BW125
* CN470 | SF12 - BW125
* CN779 | SF12 - BW125
* EU433 | SF12 - BW125
* EU868 | SF12 - BW125
* IN865 | SF12 - BW125
* KR920 | SF12 - BW125
* US915 | SF10 - BW125
* US915_HYBRID | SF10 - BW125
*/
#define DR_0 0
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF11 - BW125
* AU915 | SF9 - BW125
* CN470 | SF11 - BW125
* CN779 | SF11 - BW125
* EU433 | SF11 - BW125
* EU868 | SF11 - BW125
* IN865 | SF11 - BW125
* KR920 | SF11 - BW125
* US915 | SF9 - BW125
* US915_HYBRID | SF9 - BW125
*/
#define DR_1 1
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF10 - BW125
* AU915 | SF8 - BW125
* CN470 | SF10 - BW125
* CN779 | SF10 - BW125
* EU433 | SF10 - BW125
* EU868 | SF10 - BW125
* IN865 | SF10 - BW125
* KR920 | SF10 - BW125
* US915 | SF8 - BW125
* US915_HYBRID | SF8 - BW125
*/
#define DR_2 2
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF9 - BW125
* AU915 | SF7 - BW125
* CN470 | SF9 - BW125
* CN779 | SF9 - BW125
* EU433 | SF9 - BW125
* EU868 | SF9 - BW125
* IN865 | SF9 - BW125
* KR920 | SF9 - BW125
* US915 | SF7 - BW125
* US915_HYBRID | SF7 - BW125
*/
#define DR_3 3
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF8 - BW125
* AU915 | SF8 - BW500
* CN470 | SF8 - BW125
* CN779 | SF8 - BW125
* EU433 | SF8 - BW125
* EU868 | SF8 - BW125
* IN865 | SF8 - BW125
* KR920 | SF8 - BW125
* US915 | SF8 - BW500
* US915_HYBRID | SF8 - BW500
*/
#define DR_4 4
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF7 - BW125
* AU915 | RFU
* CN470 | SF7 - BW125
* CN779 | SF7 - BW125
* EU433 | SF7 - BW125
* EU868 | SF7 - BW125
* IN865 | SF7 - BW125
* KR920 | SF7 - BW125
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_5 5
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF7 - BW250
* AU915 | RFU
* CN470 | SF12 - BW125
* CN779 | SF7 - BW250
* EU433 | SF7 - BW250
* EU868 | SF7 - BW250
* IN865 | SF7 - BW250
* KR920 | RFU
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_6 6
/*!
* Region | SF
* ------------ | :-----:
* AS923 | FSK
* AU915 | RFU
* CN470 | SF12 - BW125
* CN779 | FSK
* EU433 | FSK
* EU868 | FSK
* IN865 | FSK
* KR920 | RFU
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_7 7
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF12 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF12 - BW500
* US915_HYBRID | SF12 - BW500
*/
#define DR_8 8
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF11 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF11 - BW500
* US915_HYBRID | SF11 - BW500
*/
#define DR_9 9
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF10 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF10 - BW500
* US915_HYBRID | SF10 - BW500
*/
#define DR_10 10
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF9 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF9 - BW500
* US915_HYBRID | SF9 - BW500
*/
#define DR_11 11
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF8 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF8 - BW500
* US915_HYBRID | SF8 - BW500
*/
#define DR_12 12
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF7 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF7 - BW500
* US915_HYBRID | SF7 - BW500
*/
#define DR_13 13
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | RFU
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_14 14
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | RFU
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_15 15
@ -527,8 +272,7 @@
/**
* TX configuration parameters.
*/
typedef struct
{
typedef struct {
/**
* The TX channel.
*/
@ -559,8 +303,7 @@ typedef struct
* This structure contains parameters for ADR request coming from
* network server.
*/
typedef struct
{
typedef struct {
/*!
* A pointer to the payload containing the MAC commands.
*/
@ -594,8 +337,7 @@ typedef struct
/**
* Structure containing data for local ADR settings
*/
typedef struct link_adr_params_s
{
typedef struct link_adr_params_s {
/**
* The number of repetitions.
*/
@ -622,8 +364,7 @@ typedef struct link_adr_params_s
* Structure used to store ADR values received from network
* for verification (legality) purposes.
*/
typedef struct verify_adr_params_s
{
typedef struct verify_adr_params_s {
/*!
* The current status of the AdrLinkRequest.
*/
@ -667,8 +408,7 @@ typedef struct verify_adr_params_s
* Contains rx parameter setup request coming from
* network server.
*/
typedef struct rx_param_setup_req_s
{
typedef struct rx_param_setup_req_s {
/**
* The datarate to set up.
*/
@ -686,8 +426,7 @@ typedef struct rx_param_setup_req_s
/**
* The parameter structure for the function RegionNextChannel.
*/
typedef struct channel_selection_params_s
{
typedef struct channel_selection_params_s {
/**
* The aggregated time-off time.
*/
@ -713,8 +452,7 @@ typedef struct channel_selection_params_s
/*!
* The parameter structure for the function RegionContinuousWave.
*/
typedef struct continuous_wave_mode_params_s
{
typedef struct continuous_wave_mode_params_s {
/*!
* The current channel index.
*/

View File

@ -204,7 +204,7 @@ typedef struct lorawan_connect {
*
*/
typedef enum lora_events {
CONNECTED=0,
CONNECTED = 0,
DISCONNECTED,
TX_DONE,
TX_TIMEOUT,
@ -275,7 +275,7 @@ typedef union {
/**
* Byte-access to the bits.
*/
int8_t value;
uint8_t value;
/**
* The structure to store the minimum and the maximum datarate.
*/
@ -288,7 +288,7 @@ typedef union {
* The allowed ranges are region-specific.
* Please refer to \ref DR_0 to \ref DR_15 for details.
*/
int8_t min :4;
uint8_t min : 4;
/**
* The maximum data rate.
*
@ -297,7 +297,7 @@ typedef union {
* The allowed ranges are region-specific.
* Please refer to \ref DR_0 to \ref DR_15 for details.
*/
int8_t max :4;
uint8_t max : 4;
} fields;
} dr_range_t;
@ -346,6 +346,271 @@ typedef struct lora_channelplan {
loramac_channel_t *channels;
} lorawan_channelplan_t;
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF12 - BW125
* AU915 | SF10 - BW125
* CN470 | SF12 - BW125
* CN779 | SF12 - BW125
* EU433 | SF12 - BW125
* EU868 | SF12 - BW125
* IN865 | SF12 - BW125
* KR920 | SF12 - BW125
* US915 | SF10 - BW125
* US915_HYBRID | SF10 - BW125
*/
#define DR_0 0
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF11 - BW125
* AU915 | SF9 - BW125
* CN470 | SF11 - BW125
* CN779 | SF11 - BW125
* EU433 | SF11 - BW125
* EU868 | SF11 - BW125
* IN865 | SF11 - BW125
* KR920 | SF11 - BW125
* US915 | SF9 - BW125
* US915_HYBRID | SF9 - BW125
*/
#define DR_1 1
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF10 - BW125
* AU915 | SF8 - BW125
* CN470 | SF10 - BW125
* CN779 | SF10 - BW125
* EU433 | SF10 - BW125
* EU868 | SF10 - BW125
* IN865 | SF10 - BW125
* KR920 | SF10 - BW125
* US915 | SF8 - BW125
* US915_HYBRID | SF8 - BW125
*/
#define DR_2 2
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF9 - BW125
* AU915 | SF7 - BW125
* CN470 | SF9 - BW125
* CN779 | SF9 - BW125
* EU433 | SF9 - BW125
* EU868 | SF9 - BW125
* IN865 | SF9 - BW125
* KR920 | SF9 - BW125
* US915 | SF7 - BW125
* US915_HYBRID | SF7 - BW125
*/
#define DR_3 3
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF8 - BW125
* AU915 | SF8 - BW500
* CN470 | SF8 - BW125
* CN779 | SF8 - BW125
* EU433 | SF8 - BW125
* EU868 | SF8 - BW125
* IN865 | SF8 - BW125
* KR920 | SF8 - BW125
* US915 | SF8 - BW500
* US915_HYBRID | SF8 - BW500
*/
#define DR_4 4
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF7 - BW125
* AU915 | RFU
* CN470 | SF7 - BW125
* CN779 | SF7 - BW125
* EU433 | SF7 - BW125
* EU868 | SF7 - BW125
* IN865 | SF7 - BW125
* KR920 | SF7 - BW125
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_5 5
/*!
* Region | SF
* ------------ | :-----:
* AS923 | SF7 - BW250
* AU915 | RFU
* CN470 | SF12 - BW125
* CN779 | SF7 - BW250
* EU433 | SF7 - BW250
* EU868 | SF7 - BW250
* IN865 | SF7 - BW250
* KR920 | RFU
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_6 6
/*!
* Region | SF
* ------------ | :-----:
* AS923 | FSK
* AU915 | RFU
* CN470 | SF12 - BW125
* CN779 | FSK
* EU433 | FSK
* EU868 | FSK
* IN865 | FSK
* KR920 | RFU
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_7 7
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF12 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF12 - BW500
* US915_HYBRID | SF12 - BW500
*/
#define DR_8 8
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF11 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF11 - BW500
* US915_HYBRID | SF11 - BW500
*/
#define DR_9 9
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF10 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF10 - BW500
* US915_HYBRID | SF10 - BW500
*/
#define DR_10 10
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF9 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF9 - BW500
* US915_HYBRID | SF9 - BW500
*/
#define DR_11 11
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF8 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF8 - BW500
* US915_HYBRID | SF8 - BW500
*/
#define DR_12 12
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | SF7 - BW500
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | SF7 - BW500
* US915_HYBRID | SF7 - BW500
*/
#define DR_13 13
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | RFU
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_14 14
/*!
* Region | SF
* ------------ | :-----:
* AS923 | RFU
* AU915 | RFU
* CN470 | RFU
* CN779 | RFU
* EU433 | RFU
* EU868 | RFU
* IN865 | RFU
* KR920 | RFU
* US915 | RFU
* US915_HYBRID | RFU
*/
#define DR_15 15
/**
* Enumeration for LoRaWAN connection type.
*/
typedef enum lorawan_connect_type {
LORAWAN_CONNECTION_OTAA = 0, /**< Over The Air Activation */
LORAWAN_CONNECTION_ABP /**< Activation By Personalization */
} lorawan_connect_type_t;
/**
* Meta-data collection for a transmission
*/

View File

@ -431,8 +431,7 @@ typedef union {
/*!
* The structure containing single access to header bits.
*/
struct hdr_bits_s
{
struct hdr_bits_s {
/*!
* Major version.
*/
@ -461,8 +460,7 @@ typedef union {
/*!
* The structure containing single access to bits.
*/
struct ctrl_bits_s
{
struct ctrl_bits_s {
/*!
* Frame options length.
*/
@ -857,14 +855,6 @@ typedef enum device_states {
DEVICE_STATE_SHUTDOWN
} device_states_t;
/**
* Enumeration for LoRaWAN connection type.
*/
typedef enum lorawan_connect_type {
LORAWAN_CONNECTION_OTAA = 0, /**< Over The Air Activation */
LORAWAN_CONNECTION_ABP /**< Activation By Personalization */
} lorawan_connect_type_t;
/**
* Stack level TX message structure
*/