Fix reception of class C messages

- Do not put radio into sleep when message is received in class c mode
- Experimental feature for acknowledging confirmed downlink messages
pull/6411/head
Kimmo Vaisanen 2018-02-22 15:24:44 +02:00 committed by Antti Kauppila
parent a26fca8bf5
commit 32075b91b5
2 changed files with 20 additions and 4 deletions

View File

@ -888,8 +888,7 @@ void LoRaWANStack::mcps_indication_handler(loramac_mcps_indication_t *mcps_indic
_rx_msg.msg.mcps_indication.port = mcps_indication->port;
// no copy, just set the pointer for the user
_rx_msg.msg.mcps_indication.buffer =
mcps_indication->buffer;
_rx_msg.msg.mcps_indication.buffer = mcps_indication->buffer;
// Notify application about received frame..
tr_debug("Received %d bytes", _rx_msg.msg.mcps_indication.buffer_size);
@ -901,11 +900,26 @@ void LoRaWANStack::mcps_indication_handler(loramac_mcps_indication_t *mcps_indic
(void)ret;
}
loramac_mib_req_confirm_t mib_req;
mib_req.type = MIB_DEVICE_CLASS;
lorawan_status_t status = mib_get_request(&mib_req);
// 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 (mcps_indication->fpending_status) {
if (status != LORAWAN_STATUS_OK || mib_req.param.dev_class != CLASS_C) {
handle_tx(mcps_indication->port, NULL, 0, MSG_CONFIRMED_FLAG);
}
}
// 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 (mib_req.param.dev_class == CLASS_C && mcps_indication->type == MCPS_CONFIRMED) {
handle_tx(mcps_indication->port, NULL, 0, MSG_CONFIRMED_FLAG);
}
} else {

View File

@ -334,7 +334,9 @@ void LoRaMac::on_radio_rx_done(uint8_t *payload, uint16_t size, int16_t rssi,
mcps.get_indication().dl_frame_counter = 0;
mcps.get_indication().type = MCPS_UNCONFIRMED;
lora_phy->put_radio_to_sleep();
if (_params.dev_class != CLASS_C) {
lora_phy->put_radio_to_sleep();
}
_lora_time.stop( _params.timers.rx_window2_timer );
@ -962,7 +964,7 @@ void LoRaMac::on_mac_state_check_timer_event(void)
if (_params.flags.bits.mcps_ind == 1) {
_params.flags.bits.mcps_ind = 0;
if (_params.dev_class== CLASS_C) {
if (_params.dev_class == CLASS_C) {
// Activate RX2 window for Class C
open_continuous_rx2_window();
}