Skip to content

Delays, yields & problems between nRF52/54 and ESP8266w/WiFi w/RF24Ethernet #267

@TMRh20

Description

@TMRh20

As it stands, with the existing code, users may experience WDT timer resets with ESP8266 if using WiFi along with RF24Ethernet. I haven't been able to test fully with ESP32 yet.

I was able to work around the issue by removing all the delay() calls in RF24Network, and replacing with millis() based functions. This is because the RF24Network write() function is called from within lwIP callbacks, and yield() should not be called within the callbacks, but the delay() function calls yield so it causes issues. This is only an issue when using WiFi, since it uses lwIP as well.

The problem with the workaround is that it negatively affects nRF52 & 54 based devices, which then end up hanging on network.write() eventually.

Essentially, we need two types of delays, one millis() based for ESP8266 and possibly ESP32, and another delay() based for devices that don't use WiFi like the nRF52 & 54.

I was thinking of defining an internal RF24Network delay function:

void RF24NetworkDelay(uin32_t delay){
    uint32_t timer = millis();
    while(millis() < timer + delay){}
}

Then do some trickery, something like

#if defined ESP8266
    #define RF24NETWORK_DELAY(x) RF24NetworkDelay(x)
#else
    #define RF24NETWORK_DELAY(x) delay(x)
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions