Browse Source

partial sending of rfbridge codes

sensors
Max Prokhorov 5 years ago
parent
commit
cde1aba561
2 changed files with 16 additions and 6 deletions
  1. +14
    -5
      code/espurna/rfbridge.ino
  2. +2
    -1
      code/html/custom.js

+ 14
- 5
code/espurna/rfbridge.ino View File

@ -88,17 +88,18 @@ static bool _rfbToChar(byte * in, char * out, int n = RF_MESSAGE_SIZE) {
#if WEB_SUPPORT
void _rfbWebSocketSendCodes() {
void _rfbWebSocketSendCodeArray(unsigned char start, unsigned char size) {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
JsonObject& rfb = root.createObject("rfb");
rfb["size"] = relayCount();
JsonObject& rfb = root.createNestedObject("rfb");
rfb["size"] = size;
rfb["start"] = start;
JsonArray& on = rfb.createNestedArray("on");
JsonArray& off = rfb.createNestedArray("off");
for (byte id=0; id<relayCount(); id++) {
for (byte id=start; id<start+size; id++) {
on.add(rfbRetrieve(id, true));
off.add(rfbRetrieve(id, false));
}
@ -106,6 +107,14 @@ void _rfbWebSocketSendCodes() {
wsSend(rfb);
}
void _rfbWebSocketSendCode(unsigned char id) {
_rfbWebSocketSendCodeArray(id, 1);
}
void _rfbWebSocketSendCodes() {
_rfbWebSocketSendCodeArray(0, relayCount());
}
void _rfbWebSocketOnSend(JsonObject& root) {
root["rfbVisible"] = 1;
root["rfbCount"] = relayCount();
@ -342,7 +351,7 @@ void _rfbDecode() {
// Websocket update
#if WEB_SUPPORT
_rfbWebSocketSendCode(_learnId, _learnStatus, buffer);
_rfbWebSocketSendCode(_learnId);
#endif
}


+ 2
- 1
code/html/custom.js View File

@ -1217,11 +1217,12 @@ function processData(data) {
if ("rfb" === key) {
var rfb = data.rfb;
var size = data.size;
var start = data.start;
var on = rfb["on"];
var off = rfb["off"];
for (var i=0; i<size; ++i) {
for (var i=start; i<start+size; ++i) {
$("input[name='rfbcode'][data-id='" + i + "'][data-status='1']").val(on[i]);
$("input[name='rfbcode'][data-id='" + i + "'][data-status='0']").val(off[i]);
}


Loading…
Cancel
Save