Skip to content

Commit

Permalink
lorawan: restore datarate after join
Browse files Browse the repository at this point in the history
Restore the user requested datarate upon a successful join. Several
regions overwrite the configured datarate through `RegionAlternateDr`,
which means that for these regions, `LoRaMacQueryTxPossible` will not
be evaluating the requested datarate for the first transmission after
joining.

Fixes #31551.

Signed-off-by: Jordan Yates <[email protected]>
  • Loading branch information
Jordan Yates authored and nashif committed Feb 3, 2021
1 parent f553007 commit b5b9f2c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions subsys/lorawan/lorawan.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,22 @@ int lorawan_join(const struct lorawan_join_config *join_cfg)
}

out:
/*
* Several regions (AS923, AU915, US915) overwrite the datarate as part
* of the join process. Reset the datarate to the value requested
* (and validated) in lorawan_set_datarate so that the MAC layer is
* aware of the set datarate for LoRaMacQueryTxPossible. This is only
* performed when ADR is disabled as it the network servers
* responsibility to increase datarates when ADR is enabled.
*/
if ((ret == 0) && (!lorawan_adr_enable)) {
MibRequestConfirm_t mib_req;

mib_req.Type = MIB_CHANNELS_DATARATE;
mib_req.Param.ChannelsDatarate = lorawan_datarate;
LoRaMacMibSetRequestConfirm(&mib_req);
}

k_mutex_unlock(&lorawan_join_mutex);
return ret;
}
Expand Down

0 comments on commit b5b9f2c

Please sign in to comment.