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

@ -502,8 +502,14 @@ public:
*/ */
virtual lorawan_status_t cancel_sending(void); virtual lorawan_status_t cancel_sending(void);
void lock(void) { _lw_stack.lock(); } void lock(void)
void unlock(void) { _lw_stack.unlock(); } {
_lw_stack.lock();
}
void unlock(void)
{
_lw_stack.unlock();
}
private: private:

View File

@ -56,7 +56,7 @@ using namespace events;
#else #else
#error "Must set LoRa PHY layer parameters." #error "Must set LoRa PHY layer parameters."
#endif #endif
#endif #endif //defined(LORAWAN_COMPLIANCE_TEST)
/** /**
* Bit mask for message flags * Bit mask for message flags
@ -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) 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) { if (!callbacks || !callbacks->events) {
return LORAWAN_STATUS_PARAMETER_INVALID; 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() lorawan_status_t LoRaWANStack::connect()
{ {
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) { if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_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) lorawan_status_t LoRaWANStack::connect(const lorawan_connect_t &connect)
{ {
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) { if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED; return LORAWAN_STATUS_NOT_INITIALIZED;
} }
if (!(connect.connect_type == LORAWAN_CONNECTION_OTAA) && if (!(connect.connect_type == LORAWAN_CONNECTION_OTAA)
!(connect.connect_type == LORAWAN_CONNECTION_ABP)) { && !(connect.connect_type == LORAWAN_CONNECTION_ABP)) {
return LORAWAN_STATUS_PARAMETER_INVALID; return LORAWAN_STATUS_PARAMETER_INVALID;
} }
bool is_otaa = (connect.connect_type == LORAWAN_CONNECTION_OTAA); bool is_otaa = (connect.connect_type == LORAWAN_CONNECTION_OTAA);
lorawan_status_t status = _loramac.prepare_join(&connect, is_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) lorawan_status_t LoRaWANStack::add_channels(const lorawan_channelplan_t &channel_plan)
{ {
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) { if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_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) lorawan_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
{ {
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) { if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED; return LORAWAN_STATUS_NOT_INITIALIZED;
} }
@ -206,7 +207,6 @@ lorawan_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
lorawan_status_t LoRaWANStack::drop_channel_list() lorawan_status_t LoRaWANStack::drop_channel_list()
{ {
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) { if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED; return LORAWAN_STATUS_NOT_INITIALIZED;
} }
@ -216,7 +216,6 @@ lorawan_status_t LoRaWANStack::drop_channel_list()
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) { if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
tr_error("Stack not initialized!");
return LORAWAN_STATUS_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) 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) { if (count >= MAX_CONFIRMED_MSG_RETRIES) {
return LORAWAN_STATUS_PARAMETER_INVALID; 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) lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate)
{ {
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
{
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED; 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) lorawan_status_t LoRaWANStack::enable_adaptive_datarate(bool adr_enabled)
{ {
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
{
tr_error("Stack not initialized!");
return LORAWAN_STATUS_NOT_INITIALIZED; return LORAWAN_STATUS_NOT_INITIALIZED;
} }
_loramac.enable_adaptive_datarate(adr_enabled); _loramac.enable_adaptive_datarate(adr_enabled);
return LORAWAN_STATUS_OK; return LORAWAN_STATUS_OK;
} }
@ -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 // check the length of received message whether we can fit into user
// buffer completely or not // buffer completely or not
if (_rx_msg.msg.mcps_indication.buffer_size > length && if (_rx_msg.msg.mcps_indication.buffer_size > length
_rx_msg.prev_read_size == 0) { && _rx_msg.prev_read_size == 0) {
// we can't fit into user buffer. Invoke counter measures // we can't fit into user buffer. Invoke counter measures
_rx_msg.pending_size = _rx_msg.msg.mcps_indication.buffer_size - length; _rx_msg.pending_size = _rx_msg.msg.mcps_indication.buffer_size - length;
base_size = length; base_size = length;
@ -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() 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; _link_check_requested = true;
if (!_callbacks.link_check_resp) { if (!_callbacks.link_check_resp) {
tr_error("Must assign a callback function for link check request. "); 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() lorawan_status_t LoRaWANStack::shutdown()
{ {
if (DEVICE_STATE_NOT_INITIALIZED == _device_current_state) {
return LORAWAN_STATUS_NOT_INITIALIZED;
}
return state_controller(DEVICE_STATE_SHUTDOWN); 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) { if (device_class == CLASS_B) {
return LORAWAN_STATUS_UNSUPPORTED; return LORAWAN_STATUS_UNSUPPORTED;
} }
@ -1127,8 +1139,7 @@ void LoRaWANStack::process_connected_state()
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 if (_device_current_state != DEVICE_STATE_IDLE
&& && _device_current_state != DEVICE_STATE_SHUTDOWN) {
_device_current_state != DEVICE_STATE_SHUTDOWN) {
op_status = LORAWAN_STATUS_BUSY; op_status = LORAWAN_STATUS_BUSY;
return; return;
} }

View File

@ -425,8 +425,14 @@ public:
*/ */
lorawan_status_t stop_sending(void); lorawan_status_t stop_sending(void);
void lock(void) { _loramac.lock(); } void lock(void)
void unlock(void) { _loramac.unlock(); } {
_loramac.lock();
}
void unlock(void)
{
_loramac.unlock();
}
private: private:
typedef mbed::ScopedLock<LoRaWANStack> Lock; typedef mbed::ScopedLock<LoRaWANStack> Lock;

View File

@ -425,10 +425,11 @@ void LoRaMac::extract_data_and_mac_commands(const uint8_t *payload,
if (fopts_len > 0) { if (fopts_len > 0) {
// Decode Options field MAC commands. Omit the fPort. // Decode Options field MAC commands. Omit the fPort.
if (_mac_commands.process_mac_commands(payload, 8, if (_mac_commands.process_mac_commands(payload, 8,
payload_start_index - 1, snr, payload_start_index - 1,
snr,
_mlme_confirmation, _mlme_confirmation,
_params.sys_params, _lora_phy) _params.sys_params,
!= LORAWAN_STATUS_OK) { _lora_phy) != LORAWAN_STATUS_OK) {
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_ERROR; _mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
return; return;
} }
@ -738,11 +739,13 @@ rx_slot_t LoRaMac::on_radio_rx_timeout(bool is_timeout)
if (_params.rx_slot == RX_SLOT_WIN_1) { if (_params.rx_slot == RX_SLOT_WIN_1) {
if (_params.is_node_ack_requested == true) { if (_params.is_node_ack_requested == true) {
_mcps_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT _mcps_confirmation.status = is_timeout ?
: LORAMAC_EVENT_INFO_STATUS_RX1_ERROR; LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
} }
_mlme_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT _mlme_confirmation.status = is_timeout ?
: LORAMAC_EVENT_INFO_STATUS_RX1_ERROR; LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
if (_device_class != CLASS_C) { 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) {
@ -751,12 +754,14 @@ rx_slot_t LoRaMac::on_radio_rx_timeout(bool is_timeout)
} }
} else { } else {
if (_params.is_node_ack_requested == true) { if (_params.is_node_ack_requested == true) {
_mcps_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT _mcps_confirmation.status = is_timeout ?
: LORAMAC_EVENT_INFO_STATUS_RX2_ERROR; LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
} }
_mlme_confirmation.status = is_timeout ? LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT _mlme_confirmation.status = is_timeout ?
: LORAMAC_EVENT_INFO_STATUS_RX2_ERROR; LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT :
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR;
} }
if (_device_class == CLASS_C) { if (_device_class == CLASS_C) {
@ -929,8 +934,7 @@ void LoRaMac::on_ack_timeout_timer_event(void)
if ((_params.ack_timeout_retry_counter % 2) if ((_params.ack_timeout_retry_counter % 2)
&& (_params.sys_params.adr_on)) { && (_params.sys_params.adr_on)) {
tr_debug("Trading datarate for range"); 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 = _lora_phy.get_next_lower_tx_datarate(_params.sys_params.channel_data_rate);
_params.sys_params.channel_data_rate);
} }
_mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter; _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(); _mac_commands.clear_command_buffer();
_params.is_node_ack_requested = false; _params.is_node_ack_requested = false;
_mcps_confirmation.ack_received = false; _mcps_confirmation.ack_received = false;
_mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter;
// now that is a critical failure // now that is a critical failure
lorawan_status_t status = handle_retransmission(); lorawan_status_t status = handle_retransmission();
@ -1331,12 +1336,12 @@ void LoRaMac::set_device_class(const device_class_t& device_class,
} else if (CLASS_C == _device_class) { } else if (CLASS_C == _device_class) {
_params.is_node_ack_requested = false; _params.is_node_ack_requested = false;
_lora_phy.put_radio_to_sleep(); _lora_phy.put_radio_to_sleep();
_lora_phy.compute_rx_win_params( _lora_phy.compute_rx_win_params(_params.sys_params.rx2_channel.datarate,
_params.sys_params.rx2_channel.datarate,
_params.sys_params.min_rx_symb, _params.sys_params.min_rx_symb,
_params.sys_params.max_sys_rx_error, _params.sys_params.max_sys_rx_error,
&_params.rx_window2_config); &_params.rx_window2_config);
} }
if (CLASS_C == _device_class) { if (CLASS_C == _device_class) {
tr_debug("Changing device class to -> CLASS_C"); tr_debug("Changing device class to -> CLASS_C");
open_rx2_window(); open_rx2_window();
@ -1358,10 +1363,10 @@ lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_
{ {
if (params) { if (params) {
if (is_otaa) { if (is_otaa) {
if ((params->connection_u.otaa.dev_eui == NULL) || if ((params->connection_u.otaa.dev_eui == NULL)
(params->connection_u.otaa.app_eui == NULL) || || (params->connection_u.otaa.app_eui == NULL)
(params->connection_u.otaa.app_key == NULL) || || (params->connection_u.otaa.app_key == NULL)
(params->connection_u.otaa.nb_trials == 0)) { || (params->connection_u.otaa.nb_trials == 0)) {
return LORAWAN_STATUS_PARAMETER_INVALID; return LORAWAN_STATUS_PARAMETER_INVALID;
} }
_params.keys.dev_eui = params->connection_u.otaa.dev_eui; _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 // Reset variable JoinRequestTrials
_params.join_request_trial_counter = 0; _params.join_request_trial_counter = 0;
} else { } 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.net_id = params->connection_u.abp.nwk_id;
_params.dev_addr = params->connection_u.abp.dev_addr; _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.net_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
_params.dev_addr = MBED_CONF_LORA_DEVICE_ADDRESS; _params.dev_addr = MBED_CONF_LORA_DEVICE_ADDRESS;
memcpy(_params.keys.nwk_skey, nwk_skey, memcpy(_params.keys.nwk_skey, nwk_skey, sizeof(_params.keys.nwk_skey));
sizeof(_params.keys.nwk_skey));
memcpy(_params.keys.app_skey, app_skey, memcpy(_params.keys.app_skey, app_skey, sizeof(_params.keys.app_skey));
sizeof(_params.keys.app_skey));
#endif #endif
} }
return LORAWAN_STATUS_OK; return LORAWAN_STATUS_OK;
} }
@ -1856,8 +1867,7 @@ lorawan_status_t LoRaMac::multicast_channel_link(multicast_params_t *channel_par
return LORAWAN_STATUS_OK; return LORAWAN_STATUS_OK;
} }
lorawan_status_t LoRaMac::multicast_channel_unlink( lorawan_status_t LoRaMac::multicast_channel_unlink(multicast_params_t *channel_param)
multicast_params_t *channel_param)
{ {
if (channel_param == NULL) { if (channel_param == NULL) {
return LORAWAN_STATUS_PARAMETER_INVALID; return LORAWAN_STATUS_PARAMETER_INVALID;
@ -1933,7 +1943,6 @@ lorawan_status_t LoRaMac::mlme_request( loramac_mlme_req_t *mlmeRequest )
_params.flags.bits.mlme_req = 0; _params.flags.bits.mlme_req = 0;
} }
return status; return status;
} }

View File

@ -460,8 +460,16 @@ public:
* the stack thread safe. * the stack thread safe.
*/ */
#if MBED_CONF_RTOS_PRESENT #if MBED_CONF_RTOS_PRESENT
void lock(void) { osStatus status = _mutex.lock(); MBED_ASSERT(status == osOK); } void lock(void)
void unlock(void) { osStatus status = _mutex.unlock(); MBED_ASSERT(status == osOK); } {
osStatus status = _mutex.lock();
MBED_ASSERT(status == osOK);
}
void unlock(void)
{
osStatus status = _mutex.unlock();
MBED_ASSERT(status == osOK);
}
#else #else
void lock(void) { } void lock(void) { }
void unlock(void) { } void unlock(void) { }

View File

@ -65,261 +65,6 @@
*/ */
#define LC( channelIndex ) ( uint16_t )( 1 << ( channelIndex - 1 ) ) #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. * TX configuration parameters.
*/ */
typedef struct typedef struct {
{
/** /**
* The TX channel. * The TX channel.
*/ */
@ -559,8 +303,7 @@ typedef struct
* This structure contains parameters for ADR request coming from * This structure contains parameters for ADR request coming from
* network server. * network server.
*/ */
typedef struct typedef struct {
{
/*! /*!
* A pointer to the payload containing the MAC commands. * A pointer to the payload containing the MAC commands.
*/ */
@ -594,8 +337,7 @@ typedef struct
/** /**
* Structure containing data for local ADR settings * Structure containing data for local ADR settings
*/ */
typedef struct link_adr_params_s typedef struct link_adr_params_s {
{
/** /**
* The number of repetitions. * The number of repetitions.
*/ */
@ -622,8 +364,7 @@ typedef struct link_adr_params_s
* Structure used to store ADR values received from network * Structure used to store ADR values received from network
* for verification (legality) purposes. * for verification (legality) purposes.
*/ */
typedef struct verify_adr_params_s typedef struct verify_adr_params_s {
{
/*! /*!
* The current status of the AdrLinkRequest. * The current status of the AdrLinkRequest.
*/ */
@ -667,8 +408,7 @@ typedef struct verify_adr_params_s
* Contains rx parameter setup request coming from * Contains rx parameter setup request coming from
* network server. * network server.
*/ */
typedef struct rx_param_setup_req_s typedef struct rx_param_setup_req_s {
{
/** /**
* The datarate to set up. * The datarate to set up.
*/ */
@ -686,8 +426,7 @@ typedef struct rx_param_setup_req_s
/** /**
* The parameter structure for the function RegionNextChannel. * The parameter structure for the function RegionNextChannel.
*/ */
typedef struct channel_selection_params_s typedef struct channel_selection_params_s {
{
/** /**
* The aggregated time-off time. * The aggregated time-off time.
*/ */
@ -713,8 +452,7 @@ typedef struct channel_selection_params_s
/*! /*!
* The parameter structure for the function RegionContinuousWave. * 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. * The current channel index.
*/ */

View File

@ -275,7 +275,7 @@ typedef union {
/** /**
* Byte-access to the bits. * Byte-access to the bits.
*/ */
int8_t value; uint8_t value;
/** /**
* The structure to store the minimum and the maximum datarate. * The structure to store the minimum and the maximum datarate.
*/ */
@ -288,7 +288,7 @@ typedef union {
* The allowed ranges are region-specific. * The allowed ranges are region-specific.
* Please refer to \ref DR_0 to \ref DR_15 for details. * Please refer to \ref DR_0 to \ref DR_15 for details.
*/ */
int8_t min :4; uint8_t min : 4;
/** /**
* The maximum data rate. * The maximum data rate.
* *
@ -297,7 +297,7 @@ typedef union {
* The allowed ranges are region-specific. * The allowed ranges are region-specific.
* Please refer to \ref DR_0 to \ref DR_15 for details. * Please refer to \ref DR_0 to \ref DR_15 for details.
*/ */
int8_t max :4; uint8_t max : 4;
} fields; } fields;
} dr_range_t; } dr_range_t;
@ -346,6 +346,271 @@ typedef struct lora_channelplan {
loramac_channel_t *channels; loramac_channel_t *channels;
} lorawan_channelplan_t; } 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 * Meta-data collection for a transmission
*/ */

View File

@ -431,8 +431,7 @@ typedef union {
/*! /*!
* The structure containing single access to header bits. * The structure containing single access to header bits.
*/ */
struct hdr_bits_s struct hdr_bits_s {
{
/*! /*!
* Major version. * Major version.
*/ */
@ -461,8 +460,7 @@ typedef union {
/*! /*!
* The structure containing single access to bits. * The structure containing single access to bits.
*/ */
struct ctrl_bits_s struct ctrl_bits_s {
{
/*! /*!
* Frame options length. * Frame options length.
*/ */
@ -857,14 +855,6 @@ typedef enum device_states {
DEVICE_STATE_SHUTDOWN DEVICE_STATE_SHUTDOWN
} device_states_t; } 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 * Stack level TX message structure
*/ */