From 29caf0036d4ea834a3641ad4d015dce8886acfe3 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 4 Jan 2021 06:25:44 +0300 Subject: [PATCH] wifi: yield after disconnecting --- code/espurna/rpnrules.cpp | 1 + code/espurna/ws.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/espurna/rpnrules.cpp b/code/espurna/rpnrules.cpp index 68790936..dc4bc182 100644 --- a/code/espurna/rpnrules.cpp +++ b/code/espurna/rpnrules.cpp @@ -689,6 +689,7 @@ void _rpnInit() { rpn_operator_set(_rpn_ctxt, "disconnect", 0, [](rpn_context & ctxt) -> rpn_error { wifiDisconnect(); + yield(); return 0; }); diff --git a/code/espurna/ws.cpp b/code/espurna/ws.cpp index dee0ac05..ac4fc6f4 100644 --- a/code/espurna/ws.cpp +++ b/code/espurna/ws.cpp @@ -21,7 +21,6 @@ Copyright (C) 2016-2019 by Xose PĂ©rez #include "libs/WebSocketIncommingBuffer.h" AsyncWebSocket _ws("/ws"); -Ticker _ws_defer; // ----------------------------------------------------------------------------- // Periodic updates @@ -344,7 +343,11 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) { } if (strcmp(action, "reconnect") == 0) { - _ws_defer.once_ms(100, wifiDisconnect); + static Ticker timer; + timer.once_ms_scheduled(100, []() { + wifiDisconnect(); + yield(); + }); return; }