v0.13.0-b2

Reduced unneeded websockets pushes
This commit is contained in:
cschwinne 2021-07-11 02:38:31 +02:00
parent 6a8ed1192f
commit 123bd0bb92
6 changed files with 1602 additions and 1587 deletions

View File

@ -2,6 +2,14 @@
### Builds after release 0.12.0 ### Builds after release 0.12.0
#### Build 2107100
- Version bump to 0.13.0-b2 "Toki"
- Accept hex color strings in individual LED API
- Fixed transition property not applying unless power/bri/color changed next
- Moved transition field below segments (temporarily)
- Reduced unneeded websockets pushes
#### Build 2107091 #### Build 2107091
- Fixed presets using wrong call mode (e.g. causing buttons to send UDP under direct change type) - Fixed presets using wrong call mode (e.g. causing buttons to send UDP under direct change type)

View File

@ -177,7 +177,7 @@ void _drawOverlayCronixie();
//playlist.cpp //playlist.cpp
void shufflePlaylist(); void shufflePlaylist();
void unloadPlaylist(); void unloadPlaylist();
void loadPlaylist(JsonObject playlistObject, byte presetId = 0); int16_t loadPlaylist(JsonObject playlistObject, byte presetId = 0);
void handlePlaylist(); void handlePlaylist();
//presets.cpp //presets.cpp

File diff suppressed because it is too large Load Diff

View File

@ -218,7 +218,6 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
nightlightDelayMins = nl[F("dur")] | nightlightDelayMins; nightlightDelayMins = nl[F("dur")] | nightlightDelayMins;
nightlightMode = nl[F("mode")] | nightlightMode; nightlightMode = nl[F("mode")] | nightlightMode;
nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri; nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri;
getJsonValue(nl[F("tbri")], nightlightTargetBri);
JsonObject udpn = root["udpn"]; JsonObject udpn = root["udpn"];
notifyDirect = udpn["send"] | notifyDirect; notifyDirect = udpn["send"] | notifyDirect;
@ -313,9 +312,9 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
} }
JsonObject playlist = root[F("playlist")]; JsonObject playlist = root[F("playlist")];
if (!playlist.isNull()) { if (!playlist.isNull() && loadPlaylist(playlist, presetId)) {
loadPlaylist(playlist, presetId); //do not notify here, because the first playlist entry will do
noNotification = true; //do not notify both for this request and the first playlist entry noNotification = true;
} else { } else {
interfaceUpdateCallMode = CALL_MODE_WS_SEND; interfaceUpdateCallMode = CALL_MODE_WS_SEND;
} }

View File

@ -53,16 +53,16 @@ void unloadPlaylist() {
} }
void loadPlaylist(JsonObject playlistObj, byte presetId) { int16_t loadPlaylist(JsonObject playlistObj, byte presetId) {
unloadPlaylist(); unloadPlaylist();
JsonArray presets = playlistObj["ps"]; JsonArray presets = playlistObj["ps"];
playlistLen = presets.size(); playlistLen = presets.size();
if (playlistLen == 0) return; if (playlistLen == 0) return -1;
if (playlistLen > 100) playlistLen = 100; if (playlistLen > 100) playlistLen = 100;
playlistEntries = new PlaylistEntry[playlistLen]; playlistEntries = new PlaylistEntry[playlistLen];
if (playlistEntries == nullptr) return; if (playlistEntries == nullptr) return -1;
byte it = 0; byte it = 0;
for (int ps : presets) { for (int ps : presets) {
@ -113,6 +113,7 @@ void loadPlaylist(JsonObject playlistObj, byte presetId) {
currentPlaylist = presetId; currentPlaylist = presetId;
DEBUG_PRINTLN(F("Playlist loaded.")); DEBUG_PRINTLN(F("Playlist loaded."));
return currentPlaylist;
} }

View File

@ -33,13 +33,20 @@ void wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventTyp
JsonObject root = jsonBuffer.as<JsonObject>(); JsonObject root = jsonBuffer.as<JsonObject>();
if (error || root.isNull()) return; if (error || root.isNull()) return;
if (root.containsKey("lv")) if (root["v"] && root.size() == 1) {
//if the received value is just "{"v":true}", send only to this client
verboseResponse = true;
} else if (root.containsKey("lv"))
{ {
wsLiveClientId = root["lv"] ? client->id() : 0; wsLiveClientId = root["lv"] ? client->id() : 0;
} else { } else {
fileDoc = &jsonBuffer; fileDoc = &jsonBuffer;
verboseResponse = deserializeState(root); verboseResponse = deserializeState(root);
fileDoc = nullptr; fileDoc = nullptr;
if (!interfaceUpdateCallMode) {
//special case, only on playlist load, avoid sending twice in rapid succession
if (millis() - lastInterfaceUpdate > 1700) verboseResponse = false;
}
} }
} }
//update if it takes longer than 300ms until next "broadcast" //update if it takes longer than 300ms until next "broadcast"