While no preset is selected, as can happen after performing a default reset through the "Reset Defaults" button in the system tab, toggle buttons in the preference tab are not updated.
Looking at the source code it seems that the problem is caused by the server sending the preset slot number as char "as is" in gbs-control.ino:
toSend[2] = (char)uopt->presetSlot;.
In fact, upon reset, the slot number is always set to 0, which is interpreted as string termination character by the WebSocket client. This results in the ping message being converted to "#0" and thus the subsequent bytes used for encoding the various settings are effectively always ignored, resulting in all toggle buttons being set to off.
This can be observed on the client side in the onmessage callback. While parsing the received message:
While no preset is selected, as can happen after performing a default reset through the "Reset Defaults" button in the system tab, toggle buttons in the preference tab are not updated.
Looking at the source code it seems that the problem is caused by the server sending the preset slot number as char "as is" in
gbs-control.ino
:toSend[2] = (char)uopt->presetSlot;
.In fact, upon reset, the slot number is always set to 0, which is interpreted as string termination character by the WebSocket client. This results in the ping message being converted to
"#0"
and thus the subsequent bytes used for encoding the various settings are effectively always ignored, resulting in all toggle buttons being set to off.This can be observed on the client side in the
onmessage
callback. While parsing the received message:const [messageDataAt0, messageDataAt1, messageDataAt2, messageDataAt3, messageDataAt4, messageDataAt5,] = message.data;
the various bytes result as follows:
messageDataAt0
is"#"
,messageDataAt1
is"0"
, butmessageDataAt2, messageDataAt3, messageDataAt4, messageDataAt5
are all set toundefined
.