mirror of https://github.com/ARMmbed/mbed-os.git
LoRa: Removed unneeded function and cleaned up some code
parent
d1bbd21e01
commit
1310392d1b
|
|
@ -150,8 +150,8 @@ lorawan_status_t LoRaWANStack::connect()
|
||||||
const static uint32_t nwk_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
|
const static uint32_t nwk_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
|
||||||
|
|
||||||
connection_params.connect_type = LORAWAN_CONNECTION_ABP;
|
connection_params.connect_type = LORAWAN_CONNECTION_ABP;
|
||||||
connection_params.connection_u.abp.nwk_id = const_cast<uint8_t *>(nwk_id);
|
connection_params.connection_u.abp.nwk_id = nwk_id;
|
||||||
connection_params.connection_u.abp.dev_addr = const_cast<uint8_t *>(dev_addr);
|
connection_params.connection_u.abp.dev_addr = dev_addr;
|
||||||
connection_params.connection_u.abp.nwk_skey = const_cast<uint8_t *>(nwk_skey);
|
connection_params.connection_u.abp.nwk_skey = const_cast<uint8_t *>(nwk_skey);
|
||||||
connection_params.connection_u.abp.app_skey = const_cast<uint8_t *>(app_skey);
|
connection_params.connection_u.abp.app_skey = const_cast<uint8_t *>(app_skey);
|
||||||
|
|
||||||
|
|
@ -640,61 +640,63 @@ void LoRaWANStack::mcps_indication_handler(loramac_mcps_indication_t *mcps_indic
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mcps_indication->is_data_recvd == true) {
|
if (!mcps_indication->is_data_recvd) {
|
||||||
switch (mcps_indication->port) {
|
return;
|
||||||
case 224: {
|
}
|
||||||
|
|
||||||
|
switch (mcps_indication->port) {
|
||||||
|
case 224: {
|
||||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||||
tr_debug("Compliance test command received.");
|
tr_debug("Compliance test command received.");
|
||||||
compliance_test_handler(mcps_indication);
|
compliance_test_handler(mcps_indication);
|
||||||
#else
|
#else
|
||||||
tr_info("Compliance test disabled.");
|
tr_info("Compliance test disabled.");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
if (is_port_valid(mcps_indication->port) == true ||
|
if (is_port_valid(mcps_indication->port) == true ||
|
||||||
mcps_indication->type == MCPS_PROPRIETARY) {
|
mcps_indication->type == MCPS_PROPRIETARY) {
|
||||||
|
|
||||||
// Valid message arrived.
|
// Valid message arrived.
|
||||||
_rx_msg.type = LORAMAC_RX_MCPS_INDICATION;
|
_rx_msg.type = LORAMAC_RX_MCPS_INDICATION;
|
||||||
_rx_msg.msg.mcps_indication.buffer_size = mcps_indication->buffer_size;
|
_rx_msg.msg.mcps_indication.buffer_size = mcps_indication->buffer_size;
|
||||||
_rx_msg.msg.mcps_indication.port = mcps_indication->port;
|
_rx_msg.msg.mcps_indication.port = mcps_indication->port;
|
||||||
_rx_msg.msg.mcps_indication.buffer = mcps_indication->buffer;
|
_rx_msg.msg.mcps_indication.buffer = mcps_indication->buffer;
|
||||||
|
|
||||||
// Notify application about received frame..
|
// Notify application about received frame..
|
||||||
tr_debug("Received %d bytes", _rx_msg.msg.mcps_indication.buffer_size);
|
tr_debug("Received %d bytes", _rx_msg.msg.mcps_indication.buffer_size);
|
||||||
_rx_msg.receive_ready = true;
|
_rx_msg.receive_ready = true;
|
||||||
|
|
||||||
if (_callbacks.events) {
|
if (_callbacks.events) {
|
||||||
const int ret = _queue->call(_callbacks.events, RX_DONE);
|
const int ret = _queue->call(_callbacks.events, RX_DONE);
|
||||||
MBED_ASSERT(ret != 0);
|
MBED_ASSERT(ret != 0);
|
||||||
(void)ret;
|
(void)ret;
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: below if clauses can be combined,
|
|
||||||
// because those are calling same function with same parameters
|
|
||||||
|
|
||||||
// If fPending bit is set we try to generate an empty packet
|
|
||||||
// with CONFIRMED flag set. We always set a CONFIRMED flag so
|
|
||||||
// that we could retry a certain number of times if the uplink
|
|
||||||
// failed for some reason
|
|
||||||
if (_loramac.get_device_class() != CLASS_C && mcps_indication->fpending_status) {
|
|
||||||
handle_tx(mcps_indication->port, NULL, 0, MSG_CONFIRMED_FLAG, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Class C and node received a confirmed message so we need to
|
|
||||||
// send an empty packet to acknowledge the message.
|
|
||||||
// This scenario is unspecified by LoRaWAN 1.0.2 specification,
|
|
||||||
// but version 1.1.0 says that network SHALL not send any new
|
|
||||||
// confirmed messages until ack has been sent
|
|
||||||
if (_loramac.get_device_class() == CLASS_C && mcps_indication->type == MCPS_CONFIRMED) {
|
|
||||||
handle_tx(mcps_indication->port, NULL, 0, MSG_CONFIRMED_FLAG, true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Invalid port, ports 0, 224 and 225-255 are reserved.
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
//TODO: below if clauses can be combined,
|
||||||
|
// because those are calling same function with same parameters
|
||||||
|
|
||||||
|
// If fPending bit is set we try to generate an empty packet
|
||||||
|
// with CONFIRMED flag set. We always set a CONFIRMED flag so
|
||||||
|
// that we could retry a certain number of times if the uplink
|
||||||
|
// failed for some reason
|
||||||
|
if (_loramac.get_device_class() != CLASS_C && mcps_indication->fpending_status) {
|
||||||
|
handle_tx(mcps_indication->port, NULL, 0, MSG_CONFIRMED_FLAG, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Class C and node received a confirmed message so we need to
|
||||||
|
// send an empty packet to acknowledge the message.
|
||||||
|
// This scenario is unspecified by LoRaWAN 1.0.2 specification,
|
||||||
|
// but version 1.1.0 says that network SHALL not send any new
|
||||||
|
// confirmed messages until ack has been sent
|
||||||
|
if (_loramac.get_device_class() == CLASS_C && mcps_indication->type == MCPS_CONFIRMED) {
|
||||||
|
handle_tx(mcps_indication->port, NULL, 0, MSG_CONFIRMED_FLAG, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Invalid port, ports 0, 224 and 225-255 are reserved.
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -964,8 +964,8 @@ void LoRaMac::on_rx_window1_timer_event(void)
|
||||||
_lora_phy.rx_config(&_params.rx_window1_config,
|
_lora_phy.rx_config(&_params.rx_window1_config,
|
||||||
(int8_t*) &_mcps_indication.rx_datarate);
|
(int8_t*) &_mcps_indication.rx_datarate);
|
||||||
|
|
||||||
rx_window_setup(_params.rx_window1_config.is_rx_continuous,
|
_lora_phy.setup_rx_window(_params.rx_window1_config.is_rx_continuous,
|
||||||
_params.sys_params.max_rx_win_time);
|
_params.sys_params.max_rx_win_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRaMac::on_rx_window2_timer_event(void)
|
void LoRaMac::on_rx_window2_timer_event(void)
|
||||||
|
|
@ -978,18 +978,17 @@ void LoRaMac::on_rx_window2_timer_event(void)
|
||||||
_params.rx_window2_config.is_repeater_supported = _params.is_repeater_supported;
|
_params.rx_window2_config.is_repeater_supported = _params.is_repeater_supported;
|
||||||
_params.rx_window2_config.rx_slot = RX_SLOT_WIN_2;
|
_params.rx_window2_config.rx_slot = RX_SLOT_WIN_2;
|
||||||
|
|
||||||
|
_params.rx_window2_config.is_rx_continuous = true;
|
||||||
|
|
||||||
if (_device_class != CLASS_C) {
|
if (_device_class != CLASS_C) {
|
||||||
_params.rx_window2_config.is_rx_continuous = false;
|
_params.rx_window2_config.is_rx_continuous = false;
|
||||||
} else {
|
|
||||||
// Setup continuous listening for class c
|
|
||||||
_params.rx_window2_config.is_rx_continuous = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lora_phy.rx_config(&_params.rx_window2_config,
|
if (_lora_phy.rx_config(&_params.rx_window2_config,
|
||||||
(int8_t*) &_mcps_indication.rx_datarate) == true) {
|
(int8_t*) &_mcps_indication.rx_datarate) == true) {
|
||||||
|
|
||||||
rx_window_setup(_params.rx_window2_config.is_rx_continuous,
|
_lora_phy.setup_rx_window(_params.rx_window2_config.is_rx_continuous,
|
||||||
_params.sys_params.max_rx_win_time);
|
_params.sys_params.max_rx_win_time);
|
||||||
|
|
||||||
_params.rx_slot = RX_SLOT_WIN_2;
|
_params.rx_slot = RX_SLOT_WIN_2;
|
||||||
}
|
}
|
||||||
|
|
@ -1037,11 +1036,6 @@ void LoRaMac::on_ack_timeout_timer_event(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRaMac::rx_window_setup(bool rx_continuous, uint32_t max_rx_window_time)
|
|
||||||
{
|
|
||||||
_lora_phy.setup_rx_window(rx_continuous, max_rx_window_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoRaMac::validate_payload_length(uint8_t length, int8_t datarate,
|
bool LoRaMac::validate_payload_length(uint8_t length, int8_t datarate,
|
||||||
uint8_t fopts_len)
|
uint8_t fopts_len)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -452,11 +452,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void on_ack_timeout_timer_event(void);
|
void on_ack_timeout_timer_event(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes and opens the reception window
|
|
||||||
*/
|
|
||||||
void rx_window_setup(bool rx_continuous, uint32_t max_rx_window_time);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates if the payload fits into the frame, taking the datarate
|
* Validates if the payload fits into the frame, taking the datarate
|
||||||
* into account.
|
* into account.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue