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:
Jordan Yates 2021-06-25 13:32:17 +10:00 committed by Christopher Friedt
commit f397361c8a

View file

@ -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