1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.62k stars 799 forks source link

[RF] Use exponential backoff delay in initCC1101() #1874

Closed ianmtaylor1 closed 10 months ago

ianmtaylor1 commented 10 months ago

Description:

In #1812, the function initCC1101() was created to poll getCC1101() until it returns true before using the CC1101 chip. A 500ms delay was put between polls.

In my experience, this delay is too long as the the chip is often ready very shortly after the first check. This change makes the function use exponential backoff to initially check quickly (16ms), then double the wait time until waiting the original 500ms.

A simpler change would be to just use a smaller constant delay, but exponential backoff is a good compromise in case there are instances where a longer delay is needed.

Checklist:

1technophile commented 10 months ago

Thanks!