lorawan: queriable payload sizes
Add the ability for applications to query the maximum size of packets that can be sent. This must be dynamically queried as the sizes change with datarate, region, and as MAC commands are added by the stack. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
parent
62d4c6947c
commit
fa09d0d612
@ -205,6 +205,19 @@ void lorawan_enable_adr(bool enable);
|
||||
*/
|
||||
int lorawan_set_datarate(enum lorawan_datarate dr);
|
||||
|
||||
/**
|
||||
* @brief Get the current payload sizes
|
||||
*
|
||||
* Query the current payload sizes. The maximum payload size varies with
|
||||
* datarate, while the current payload size can be less due to MAC layer
|
||||
* commands which are inserted into uplink packets.
|
||||
*
|
||||
* @param max_next_payload_size Maximum payload size for the next transmission
|
||||
* @param max_payload_size Maximum payload size for this datarate
|
||||
*/
|
||||
void lorawan_get_payload_sizes(uint8_t *max_next_payload_size,
|
||||
uint8_t *max_payload_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -349,6 +349,18 @@ int lorawan_set_datarate(enum lorawan_datarate dr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void lorawan_get_payload_sizes(uint8_t *max_next_payload_size,
|
||||
uint8_t *max_payload_size)
|
||||
{
|
||||
LoRaMacTxInfo_t txInfo;
|
||||
|
||||
/* QueryTxPossible cannot fail */
|
||||
(void)LoRaMacQueryTxPossible(0, &txInfo);
|
||||
|
||||
*max_next_payload_size = txInfo.MaxPossibleApplicationDataSize;
|
||||
*max_payload_size = txInfo.CurrentPossiblePayloadSize;
|
||||
}
|
||||
|
||||
void lorawan_enable_adr(bool enable)
|
||||
{
|
||||
MibRequestConfirm_t mib_req;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user