Skip to content

Commit

Permalink
Fix AT+FRMCNT
Browse files Browse the repository at this point in the history
The counters are uint32_t and thus need to be printed as %lu.
Furthermore, we need to select either AFCntDown or FCntDown depending on
the LoRaWAN protocol version negotiated between the device and the
network server.

Note: UINT32_MAX is a special value that indicates that the counter is
set to the initial value, i.e., no uplink or downlink has taken place so
far.
  • Loading branch information
janakj committed Apr 5, 2022
1 parent c55be3a commit 26f52dd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,18 @@ static void pctx(atci_param_t *param)

static void get_frmcnt(void)
{
uint32_t down;
LoRaMacNvmData_t *state = lrw_get_state();
OK("%ld,%ld", state->Crypto.FCntList.FCntUp ,state->Crypto.FCntList.FCntDown);

MibRequestConfirm_t r = { .Type = MIB_LORAWAN_VERSION };
LoRaMacMibGetRequestConfirm(&r);

if (r.Param.LrWanVersion.LoRaWan.Fields.Minor == 0)
down = state->Crypto.FCntList.FCntDown;
else
down = state->Crypto.FCntList.AFCntDown;

OK("%lu,%lu", state->Crypto.FCntList.FCntUp, down);
}


Expand Down

0 comments on commit 26f52dd

Please sign in to comment.