khoih-prog / Blynk_Async_WM

Simple WiFiManager for Blynk and ESP8266/ESP32 (including ESP32-S2, ESP32-C3) with or without SSL, configuration data saved in either LittleFS, SPIFFS or EEPROM. This library, using AsyncWebServer instead of (ESP8266)WebServer, for configuring/auto(re)connecting ESP8266/ESP32 modules to best or available MultiWiFi APs and MultiBlynk servers at runtime. Enable adding dynamic custom parameters from sketch and input using the same Config Portal. Config Portal will be auto-adjusted to match the number of dynamic parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Static STA IP and DHCP Hostname as well as Config Portal AP channel, IP, SSID, Password can be configured. Multi or Double DetectDetector feature permits entering Config Portal as requested.
MIT License
20 stars 8 forks source link

Sending JSON Data to async Server using SPIFFS and Blynk_Async_WM library #7

Closed philippesikora closed 2 years ago

philippesikora commented 2 years ago

Not an issue but a support Today my application is running fine with Blynk and WebServer for ESP32 I can see a huge benefit in term of reliability to use your Blynk_Async_WM library (mainly autoconnect/autoreconnect of WiFi/Blynk). My understanding is that this library is compliant only with AsyncWebServer Here is the program extract related to Webserver with RTOS mutitask (thank you for your example Async_ESP32_MultiTask.ino), can you help to convert with AsyncWebServer ? (I tried without success !!) Thank you

//**

include

include

WebServer server (81);

String json_grid;

void sendGrid() { server.send(200, "application/json", json_grid); // send json_grid values
}

void handle_NotFound(){
server.send(404, "text/plain", "Not found"); }

void BlynkRun( void * pvParameters ) // essential housekeeping command that keeps the background Blynk library “running”. {

define BLYNK_RUN_INTERVAL_MS 250L

for (;;) { Blynk.run(); // SYNC BLYNK client.loop(); // SYNC MQTT

vTaskDelay(BLYNK_RUN_INTERVAL_MS / portTICK_PERIOD_MS);

} }

void ServerRun( void * pvParameters ) // monitors the presence of a client and delivers the requested HTML page {

define SERVER_RUN_INTERVAL_MS 2000L

for (;;) { server.handleClient(); // SYNC SERVER

vTaskDelay(SERVER_RUN_INTERVAL_MS / portTICK_PERIOD_MS);

} }

//* setup**// xTaskCreatePinnedToCore(BlynkRun, "BlynkRun", 50000, NULL, BlynkRun_Priority, NULL, USING_CORE_2); xTaskCreatePinnedToCore(ServerRun, "ServerRun", 50000, NULL, ServerRun_Priority, NULL, USING_CORE_2);

SPIFFS.begin();

server.on("/grid.json", sendGrid); // sendGrid() send grid.json in javascript file $.getJSON('/wes.json', function(data)) server.onNotFound(handle_NotFound);

server.serveStatic("/js", SPIFFS, "/js"); // Makes index page and images available server.serveStatic("/css", SPIFFS, "/css"); server.serveStatic("/png", SPIFFS, "/png"); server.serveStatic("/", SPIFFS, "/index.html");
server.begin();
//*****//

void loop() {
process_data(); // process data for json_grid. Main code USING_CORE_1 } //**

khoih-prog commented 2 years ago

Hi @philippesikora

Thanks for your interest in those libraries, but I'm sorry I lost my interest in Blynk and have stopped working on Blynk-related libraries since the new commercial-targeting Blynk-2.0 was introduced.

I suggest that you spend more time to try yourself and/or ask for help in Blynk Forum / Arduino Forum

Good Luck,