From c13b32e06a37c96fd971dd1303338f95ebca6d25 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Tue, 1 Aug 2023 11:53:32 +0200 Subject: [PATCH] esp-now remote: fix crash with AP = Always initialize ESPNOW only when Wifi (STA or AP) is running --- wled00/remote.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wled00/remote.cpp b/wled00/remote.cpp index ca13d1e9..b79066ed 100644 --- a/wled00/remote.cpp +++ b/wled00/remote.cpp @@ -43,7 +43,7 @@ typedef struct message_structure { } message_structure; static int esp_now_state = ESP_NOW_STATE_UNINIT; -static uint32_t last_seq = -1; +static uint32_t last_seq = UINT32_MAX; static int brightnessBeforeNightMode = NIGHT_MODE_DEACTIVATED; static message_structure incoming; @@ -172,7 +172,7 @@ void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) { void handleRemote() { if (enable_espnow_remote) { - if (esp_now_state == ESP_NOW_STATE_UNINIT) { + if ((esp_now_state == ESP_NOW_STATE_UNINIT) && (interfacesInited || apActive)) { // ESPNOW requires Wifi to be initialized (either STA, or AP Mode) USER_PRINTLN(F("\nInitializing ESP_NOW listener!\n")); // Init ESP-NOW if (esp_now_init() != ESP_OK) { @@ -201,4 +201,4 @@ void handleRemote() { } } -#endif \ No newline at end of file +#endif