Compare commits

...

2 Commits
bnb ... master

Author SHA1 Message Date
Thomas Kolb 3ac26d35d2 Make AP more friendly in congested WiFi situations 2023-08-14 23:32:31 +02:00
Thomas Kolb ecfc78c48a Decide on UDP or animation display after showing IP for 30 seconds 2023-08-11 21:46:50 +02:00
1 changed files with 18 additions and 12 deletions

View File

@ -6,6 +6,8 @@
#include <WiFiMulti.h>
#include <SPIFFS.h>
#include <esp_wifi.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
@ -188,20 +190,20 @@ static void ledFSM(void)
animController.loop();
if(((WiFi.status() == WL_CONNECTED) || (WiFi.getMode() == WIFI_MODE_AP)) &&
udpProto.check()) {
// UDP packet received -> transition to UDP state
nextState = UDP;
ledState = TRANSITION;
// ensure the correct animation plays after UDP transfers stop
animController.changeAnimation(loadSavedAnimation(), false);
}
// change to last used animation after some time
if((millis() - stateEnteredTime) > 60000) {
// change to last used animation or UDP visualization after some time
if((millis() - stateEnteredTime) > 30000) {
// load the saved animation
// FIXME: does not work with transition because of restart() call in ANIMATION state
animController.changeAnimation(loadSavedAnimation(), false);
ledState = ANIMATION;
if(((WiFi.status() == WL_CONNECTED) || (WiFi.getMode() == WIFI_MODE_AP)) &&
udpProto.check()) {
// UDP packet received -> transition to UDP state
nextState = UDP;
ledState = TRANSITION;
} else {
ledState = ANIMATION;
}
}
break;
@ -383,6 +385,10 @@ void wifi_setup(void)
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("🕯️💡☀️", "Licht234");
WiFi.setTxPower(WIFI_POWER_2dBm);
esp_wifi_set_bandwidth(WIFI_IF_AP, WIFI_BW_HT20);
esp_wifi_config_11b_rate(WIFI_IF_AP, true);
esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_11N);
WiFi.enableAP(true);
animController.changeAnimation(std::unique_ptr<Animation>(new ConnectionEstablishedAnimation(&ledFader, false)));