lora: sx12xx_common: sleep after RX timeout
If no packet was received in the provided timeout, manually transition to sleep mode. If a packet was received, the rx_done callback automatically transitions the modem to sleep. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
parent
abdd61c3e9
commit
f397361c8a
1 changed files with 5 additions and 2 deletions
|
@ -85,13 +85,16 @@ int sx12xx_lora_recv(const struct device *dev, uint8_t *data, uint8_t size,
|
|||
|
||||
ret = k_sem_take(&dev_data.data_sem, timeout);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Receive timeout!");
|
||||
LOG_INF("Receive timeout");
|
||||
/* Manually transition to sleep mode on timeout */
|
||||
Radio.Sleep();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Only copy the bytes that can fit the buffer, drop the rest */
|
||||
if (dev_data.rx_len > size)
|
||||
if (dev_data.rx_len > size) {
|
||||
dev_data.rx_len = size;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: We are copying the global buffer here, so it might get
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue