@@ -150,8 +150,8 @@ lorawan_status_t LoRaWANStack::connect()
150
150
const static uint32_t nwk_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
151
151
152
152
connection_params.connect_type = LORAWAN_CONNECTION_ABP;
153
- connection_params.connection_u .abp .nwk_id = const_cast < uint8_t *>( nwk_id) ;
154
- connection_params.connection_u .abp .dev_addr = const_cast < uint8_t *>( dev_addr) ;
153
+ connection_params.connection_u .abp .nwk_id = nwk_id;
154
+ connection_params.connection_u .abp .dev_addr = dev_addr;
155
155
connection_params.connection_u .abp .nwk_skey = const_cast <uint8_t *>(nwk_skey);
156
156
connection_params.connection_u .abp .app_skey = const_cast <uint8_t *>(app_skey);
157
157
@@ -640,61 +640,63 @@ void LoRaWANStack::mcps_indication_handler(loramac_mcps_indication_t *mcps_indic
640
640
}
641
641
#endif
642
642
643
- if (mcps_indication->is_data_recvd == true ) {
644
- switch (mcps_indication->port ) {
645
- case 224 : {
643
+ if (!mcps_indication->is_data_recvd ) {
644
+ return ;
645
+ }
646
+
647
+ switch (mcps_indication->port ) {
648
+ case 224 : {
646
649
#if defined(LORAWAN_COMPLIANCE_TEST)
647
- tr_debug (" Compliance test command received." );
648
- compliance_test_handler (mcps_indication);
650
+ tr_debug (" Compliance test command received." );
651
+ compliance_test_handler (mcps_indication);
649
652
#else
650
- tr_info (" Compliance test disabled." );
653
+ tr_info (" Compliance test disabled." );
651
654
#endif
652
- break ;
653
- }
654
- default : {
655
- if (is_port_valid (mcps_indication->port ) == true ||
656
- mcps_indication->type == MCPS_PROPRIETARY) {
657
-
658
- // Valid message arrived.
659
- _rx_msg.type = LORAMAC_RX_MCPS_INDICATION;
660
- _rx_msg.msg .mcps_indication .buffer_size = mcps_indication->buffer_size ;
661
- _rx_msg.msg .mcps_indication .port = mcps_indication->port ;
662
- _rx_msg.msg .mcps_indication .buffer = mcps_indication->buffer ;
663
-
664
- // Notify application about received frame..
665
- tr_debug (" Received %d bytes" , _rx_msg.msg .mcps_indication .buffer_size );
666
- _rx_msg.receive_ready = true ;
667
-
668
- if (_callbacks.events ) {
669
- const int ret = _queue->call (_callbacks.events , RX_DONE);
670
- MBED_ASSERT (ret != 0 );
671
- (void )ret;
672
- }
655
+ break ;
656
+ }
657
+ default : {
658
+ if (is_port_valid (mcps_indication->port ) == true ||
659
+ mcps_indication->type == MCPS_PROPRIETARY) {
673
660
674
- // TODO: below if clauses can be combined,
675
- // because those are calling same function with same parameters
661
+ // Valid message arrived.
662
+ _rx_msg.type = LORAMAC_RX_MCPS_INDICATION;
663
+ _rx_msg.msg .mcps_indication .buffer_size = mcps_indication->buffer_size ;
664
+ _rx_msg.msg .mcps_indication .port = mcps_indication->port ;
665
+ _rx_msg.msg .mcps_indication .buffer = mcps_indication->buffer ;
676
666
677
- // If fPending bit is set we try to generate an empty packet
678
- // with CONFIRMED flag set. We always set a CONFIRMED flag so
679
- // that we could retry a certain number of times if the uplink
680
- // failed for some reason
681
- if (_loramac.get_device_class () != CLASS_C && mcps_indication->fpending_status ) {
682
- handle_tx (mcps_indication->port , NULL , 0 , MSG_CONFIRMED_FLAG, true );
683
- }
667
+ // Notify application about received frame..
668
+ tr_debug (" Received %d bytes" , _rx_msg.msg .mcps_indication .buffer_size );
669
+ _rx_msg.receive_ready = true ;
684
670
685
- // Class C and node received a confirmed message so we need to
686
- // send an empty packet to acknowledge the message.
687
- // This scenario is unspecified by LoRaWAN 1.0.2 specification,
688
- // but version 1.1.0 says that network SHALL not send any new
689
- // confirmed messages until ack has been sent
690
- if (_loramac.get_device_class () == CLASS_C && mcps_indication->type == MCPS_CONFIRMED) {
691
- handle_tx (mcps_indication->port , NULL , 0 , MSG_CONFIRMED_FLAG, true );
692
- }
693
- } else {
694
- // Invalid port, ports 0, 224 and 225-255 are reserved.
671
+ if (_callbacks.events ) {
672
+ const int ret = _queue->call (_callbacks.events , RX_DONE);
673
+ MBED_ASSERT (ret != 0 );
674
+ (void )ret;
695
675
}
696
- break ;
676
+
677
+ // TODO: below if clauses can be combined,
678
+ // because those are calling same function with same parameters
679
+
680
+ // If fPending bit is set we try to generate an empty packet
681
+ // with CONFIRMED flag set. We always set a CONFIRMED flag so
682
+ // that we could retry a certain number of times if the uplink
683
+ // failed for some reason
684
+ if (_loramac.get_device_class () != CLASS_C && mcps_indication->fpending_status ) {
685
+ handle_tx (mcps_indication->port , NULL , 0 , MSG_CONFIRMED_FLAG, true );
686
+ }
687
+
688
+ // Class C and node received a confirmed message so we need to
689
+ // send an empty packet to acknowledge the message.
690
+ // This scenario is unspecified by LoRaWAN 1.0.2 specification,
691
+ // but version 1.1.0 says that network SHALL not send any new
692
+ // confirmed messages until ack has been sent
693
+ if (_loramac.get_device_class () == CLASS_C && mcps_indication->type == MCPS_CONFIRMED) {
694
+ handle_tx (mcps_indication->port , NULL , 0 , MSG_CONFIRMED_FLAG, true );
695
+ }
696
+ } else {
697
+ // Invalid port, ports 0, 224 and 225-255 are reserved.
697
698
}
699
+ break ;
698
700
}
699
701
}
700
702
}
0 commit comments