Skip to content

Commit 31aaea6

Browse files
author
Hasnain Virk
committed
[IOTCELL-1181] Fixing incorrect NetID causing ABP Failures
The issue rose up when using ARMC6. A test case didn't initialize NetID parameter for ABP while using connect(params) API. NetID is the first 7 bits of the Device Address. It makes sense to actually remove the net-id parameter from ABP settings as the stack can deduce it from device address. However, the ABP structure is exposed in public APIs, so we can't really do that at the moment. Simpler fix is to move the mask that helps us to extract first 7 bits of the device address is exposed in lorawan_types.h and the user can use it to deduce correct net-id.
1 parent 8292aff commit 31aaea6

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ using namespace mbed;
6565
*/
6666
#define DOWN_LINK 1
6767

68-
/**
69-
* A mask for the network ID.
70-
*/
71-
#define LORAWAN_NETWORK_ID_MASK ( uint32_t )0xFE000000
72-
73-
7468
LoRaMac::LoRaMac()
7569
: _lora_time(),
7670
_lora_phy(NULL),
@@ -1434,7 +1428,7 @@ lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_
14341428
const static uint8_t nwk_skey[] = MBED_CONF_LORA_NWKSKEY;
14351429
const static uint8_t app_skey[] = MBED_CONF_LORA_APPSKEY;
14361430

1437-
_params.net_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
1431+
_params.net_id = (MBED_CONF_LORA_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK) >> 25;
14381432
_params.dev_addr = MBED_CONF_LORA_DEVICE_ADDRESS;
14391433

14401434
memcpy(_params.keys.nwk_skey, nwk_skey, sizeof(_params.keys.nwk_skey));

features/lorawan/lorawan_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
#include "platform/Callback.h"
3636

37+
/**
38+
* A mask for the network ID.
39+
*/
40+
#define LORAWAN_NETWORK_ID_MASK (uint32_t) 0xFE000000
41+
3742
/**
3843
* Option Flags for send(), receive() APIs
3944
*

0 commit comments

Comments
 (0)