Added WiFi section to JSON info (#288)

Add tt command to JSON API (#291)
This commit is contained in:
cschwinne 2019-10-29 02:21:23 +01:00
parent 6eef3a9037
commit 1beb9c4bb8
4 changed files with 33 additions and 2 deletions

View File

@ -100,7 +100,7 @@
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 1910292 #define VERSION 1910293
char versionString[] = "0.8.6"; char versionString[] = "0.8.6";
@ -283,6 +283,7 @@ uint16_t transitionDelayDefault = transitionDelay;
uint16_t transitionDelayTemp = transitionDelay; uint16_t transitionDelayTemp = transitionDelay;
unsigned long transitionStartTime; unsigned long transitionStartTime;
float tperLast = 0; //crossfade transition progress, 0.0f - 1.0f float tperLast = 0; //crossfade transition progress, 0.0f - 1.0f
bool jsonTransitionOnce = false;
//nightlight //nightlight
bool nightlightActive = false; bool nightlightActive = false;

View File

@ -293,6 +293,20 @@ void handleConnection() {
} }
} }
//by https://github.com/tzapu/WiFiManager/blob/master/WiFiManager.cpp
int getSignalQuality(int rssi)
{
int quality = 0;
if (rssi <= -100) {
quality = 0;
} else if (rssi >= -50) {
quality = 100;
} else {
quality = 2 * (rssi + 100);
}
return quality;
}
bool checkClientIsMobile(String useragent) bool checkClientIsMobile(String useragent)
{ {

View File

@ -105,7 +105,8 @@ void colorUpdated(int callMode)
if (fadeTransition) if (fadeTransition)
{ {
//set correct delay if not using notification delay //set correct delay if not using notification delay
if (callMode != 3) transitionDelayTemp = transitionDelay; if (callMode != 3 && !jsonTransitionOnce) transitionDelayTemp = transitionDelay;
jsonTransitionOnce = false;
if (transitionDelayTemp == 0) {setLedsStandard(); strip.trigger(); return;} if (transitionDelayTemp == 0) {setLedsStandard(); strip.trigger(); return;}
if (transitionActive) if (transitionActive)

View File

@ -16,6 +16,12 @@ bool deserializeState(JsonObject root)
transitionDelay = root["transition"]; transitionDelay = root["transition"];
transitionDelay *= 100; transitionDelay *= 100;
} }
if (root.containsKey("tt"))
{
transitionDelayTemp = root["tt"];
transitionDelayTemp *= 100;
jsonTransitionOnce = true;
}
int ps = root["ps"] | -1; int ps = root["ps"] | -1;
if (ps >= 0) applyPreset(ps); if (ps >= 0) applyPreset(ps);
@ -182,15 +188,24 @@ void serializeInfo(JsonObject root)
root["live"] = realtimeActive; root["live"] = realtimeActive;
root["fxcount"] = strip.getModeCount(); root["fxcount"] = strip.getModeCount();
root["palcount"] = strip.getPaletteCount(); root["palcount"] = strip.getPaletteCount();
JsonObject wifi_info = root.createNestedObject("wifi");
wifi_info["bssid"] = WiFi.BSSIDstr();
wifi_info["signal"] = getSignalQuality(WiFi.RSSI());
wifi_info["channel"] = WiFi.channel();
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
root["arch"] = "esp32"; root["arch"] = "esp32";
root["core"] = ESP.getSdkVersion(); root["core"] = ESP.getSdkVersion();
//root["maxalloc"] = ESP.getMaxAllocHeap(); //root["maxalloc"] = ESP.getMaxAllocHeap();
root["lwip"] = 0;
#else #else
root["arch"] = "esp8266"; root["arch"] = "esp8266";
root["core"] = ESP.getCoreVersion(); root["core"] = ESP.getCoreVersion();
//root["maxalloc"] = ESP.getMaxFreeBlockSize(); //root["maxalloc"] = ESP.getMaxFreeBlockSize();
root["lwip"] = LWIP_VERSION_MAJOR;
#endif #endif
root["freeheap"] = ESP.getFreeHeap(); root["freeheap"] = ESP.getFreeHeap();
root["uptime"] = millis()/1000; root["uptime"] = millis()/1000;