Good news everyone…
First, thank you all, for your comments. I have answers now.
In my Arduino application LoRaWAN_OTAA.ino
, I changed the function as below, to print out the values I need. (Please forgive the bad formatting. It was not my fault.)
void lorawan_has_joined_handler(void)
{
if(doOTAA == true)
{
MibRequestConfirm_t mibReq;
Serial.print("OTAA Mode, Network Joined!\r\n");
mibReq.Type = MIB_DEV_ADDR;
if (LORAMAC_STATUS_OK == LoRaMacMibGetRequestConfirm( & mibReq )) {
Serial.printf("uint32_t nodeDevAddr = 0x%08x;\r\n", mibReq.Param.DevAddr );
}
mibReq.Type = MIB_NWK_SKEY;
if (LORAMAC_STATUS_OK == LoRaMacMibGetRequestConfirm( & mibReq )) {
uint8_t *pk = mibReq.Param.NwkSKey;
Serial.printf("uint8_t nodeNwsKey[16] = { 0x%02X,0x%02X,0x%02X,0x%02X, 0x%02X,0x%02X,0x%02X,0x%02X, 0x%02X,0x%02X,0x%02X,0x%02X, 0x%02X,0x%02X,0x%02X,0x%02X };\r\n",
pk[ 0], pk[ 1], pk[ 2], pk[ 3],
pk[ 4], pk[ 5], pk[ 6], pk[ 7],
pk[ 8], pk[ 9], pk[10], pk[11],
pk[12], pk[13], pk[14], pk[15] );
}
mibReq.Type = MIB_APP_SKEY;
if (LORAMAC_STATUS_OK == LoRaMacMibGetRequestConfirm( & mibReq )) {
uint8_t *pk = mibReq.Param.AppSKey;
Serial.printf("uint8_t nodeAppsKey[16] = { 0x%02X,0x%02X,0x%02X,0x%02X, 0x%02X,0x%02X,0x%02X,0x%02X, 0x%02X,0x%02X,0x%02X,0x%02X, 0x%02X,0x%02X,0x%02X,0x%02X };\r\n",
pk[ 0], pk[ 1], pk[ 2], pk[ 3],
pk[ 4], pk[ 5], pk[ 6], pk[ 7],
pk[ 8], pk[ 9], pk[10], pk[11],
pk[12], pk[13], pk[14], pk[15] );
}
mibReq.Type = MIB_UPLINK_COUNTER;
if (LORAMAC_STATUS_OK == LoRaMacMibGetRequestConfirm( & mibReq )) {
uint32_t cc = mibReq.Param.UpLinkCounter;
Serial.printf("uint32_t nUpLinkCounter = %d;\r\n", cc );
}
}
else
{
Serial.print("ABP Mode !!! OK!\r\n");
}
// o o o o o o o o o
Furthermore, I record the last successful Frame-Counter value, which is needed when my device wakes up and re-connects:
// o o o o o o o o o
MibRequestConfirm_t mibReq;
// o o o o o o o o o
mibReq.Type = MIB_UPLINK_COUNTER;
if (LORAMAC_STATUS_OK == LoRaMacMibGetRequestConfirm( & mibReq )) {
uint32_t cc = mibReq.Param.UpLinkCounter;
Serial.printf("uint32_t nUpLinkCounter = %d;\r\n", cc );
}