Skip to content

Commit

Permalink
lora: sx12xx_common: sleep after RX timeout
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Jordan Yates authored and cfriedt committed Aug 8, 2021
1 parent abdd61c commit f397361
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/lora/sx12xx_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f397361

Please sign in to comment.