Skip to content

Commit

Permalink
Merge pull request #853 from Jojo-1000/listen-filter
Browse files Browse the repository at this point in the history
Add a setting to ignore some protocols when listening
  • Loading branch information
sidoh authored Nov 23, 2024
2 parents 18f437e + 157a4bb commit f37b20e
Show file tree
Hide file tree
Showing 18 changed files with 1,213 additions and 149 deletions.
4 changes: 2 additions & 2 deletions dist/bundle.css.gz.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/bundle.js.gz.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.html.gz.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define index_html_gz_len 1832
static const char index_html_filename[] = "/dist/index.63a1e3f9.html";
static const char index_html_gz[] PROGMEM = {31,139,8,0,0,0,0,0,2,10,237,88,91,115,218,56,20,126,239,204,254,7,213,219,157,49,99,98,145,20,18,66,66,102,133,77,154,180,132,152,54,217,221,116,103,103,107,108,249,18,140,205,202,2,67,50,252,247,61,178,13,216,64,218,62,236,219,214,51,88,150,116,116,244,157,79,231,162,225,213,249,107,253,86,187,123,48,186,200,227,227,224,226,213,185,104,80,96,134,110,91,162,161,36,6,168,105,67,51,166,220,68,150,103,178,152,242,182,116,127,119,121,208,148,86,195,161,57,166,109,105,230,211,100,18,49,46,33,43,10,57,13,65,44,241,109,238,181,109,58,243,45,122,144,118,170,200,15,125,238,155,193,65,108,153,1,109,31,170,53,161,134,251,60,160,23,55,126,207,119,61,142,174,166,195,115,156,13,189,58,15,252,112,132,60,70,157,182,100,155,220,108,249,99,211,165,120,126,224,195,46,103,67,51,166,199,245,42,33,164,67,72,151,116,225,45,90,141,116,162,206,128,144,75,23,186,154,120,145,129,120,93,147,213,252,234,233,146,242,83,238,227,183,205,62,233,232,138,150,232,248,113,16,147,211,201,253,45,233,124,156,98,232,95,13,18,162,184,6,35,70,253,102,72,200,231,166,211,36,218,124,120,10,253,119,163,68,251,29,147,136,232,15,143,10,49,26,167,218,64,63,185,36,35,162,97,28,146,247,15,31,240,128,12,112,82,39,150,59,195,196,56,57,212,18,237,147,110,52,137,66,70,15,208,103,96,70,31,43,53,130,231,93,139,24,135,76,75,200,13,142,70,68,119,148,43,114,141,79,192,164,30,110,196,68,55,78,27,132,212,238,1,79,29,187,208,255,131,41,192,196,45,118,245,64,195,160,111,86,235,19,242,22,119,147,78,189,11,248,154,9,59,33,70,237,154,130,254,19,163,78,134,78,179,71,200,244,61,78,180,223,244,25,200,123,214,59,162,93,41,186,219,121,194,73,12,246,157,96,210,185,83,62,15,200,141,54,171,17,211,13,49,121,127,135,245,129,174,116,13,177,255,73,76,110,29,172,19,29,235,115,192,235,30,193,73,212,251,216,237,212,176,155,16,253,243,19,172,239,1,95,128,191,243,64,148,228,159,27,242,227,249,241,252,120,254,231,15,228,185,210,115,31,195,75,233,39,132,188,123,186,94,143,94,63,214,200,7,143,144,43,175,153,143,68,226,213,79,63,59,73,154,162,225,87,88,145,62,99,34,82,190,30,63,22,198,62,245,146,23,160,116,110,194,126,121,132,221,232,201,111,189,143,229,90,160,235,247,246,75,214,188,215,11,178,218,125,93,52,31,244,178,137,151,154,144,177,196,231,113,161,214,252,145,131,16,53,233,247,158,75,76,178,193,217,251,0,85,235,118,32,244,212,203,96,58,35,99,253,109,52,128,3,125,252,25,214,53,71,192,83,111,6,56,53,71,129,181,79,24,210,173,129,5,71,142,2,175,43,236,230,125,168,54,32,31,226,81,46,175,47,238,160,223,24,91,185,62,210,150,16,163,65,91,18,101,86,66,124,49,129,10,95,44,189,18,194,80,156,99,190,16,69,26,161,159,131,200,180,253,208,69,207,208,65,104,18,197,80,229,163,176,133,28,127,78,237,179,116,144,71,147,22,106,212,126,201,122,1,117,120,161,203,153,25,198,78,196,198,173,236,51,48,57,149,15,96,186,138,196,187,146,73,57,112,179,56,136,253,39,218,66,71,245,201,188,48,232,152,99,63,88,180,16,97,112,185,168,162,24,84,28,196,148,249,142,144,89,190,58,199,57,212,243,216,98,254,132,95,200,206,52,180,4,68,36,87,208,243,79,32,4,70,197,28,89,118,216,129,75,5,106,35,201,227,124,18,183,48,134,33,245,49,182,105,224,207,152,26,82,142,93,15,199,190,29,121,152,198,147,230,209,241,241,223,176,181,184,184,252,237,77,135,191,38,116,120,132,211,151,237,199,28,207,40,139,97,151,24,195,77,71,61,198,210,217,102,43,199,15,104,12,27,253,249,83,106,198,115,214,160,148,236,22,146,82,192,177,71,41,151,170,171,41,128,98,152,220,107,173,97,42,72,26,78,67,59,160,170,21,199,27,185,32,130,219,85,38,41,165,48,114,161,183,39,195,134,217,116,204,178,116,70,232,68,220,237,174,67,46,75,205,250,225,169,84,69,135,181,74,46,178,172,190,0,49,229,242,187,224,61,126,7,186,195,26,181,14,45,171,81,18,222,6,119,116,84,107,156,54,246,192,251,11,168,21,237,250,96,45,70,193,137,62,173,105,236,193,77,82,22,55,201,202,202,144,236,28,210,27,102,27,217,145,53,29,195,181,85,205,214,117,3,42,122,178,36,166,165,202,89,182,66,116,84,8,12,225,31,133,3,42,206,138,29,96,90,52,249,48,163,124,202,194,116,54,29,89,238,7,154,146,41,199,204,218,194,151,177,252,21,132,249,49,172,48,102,93,21,20,193,26,120,151,135,109,234,80,6,19,156,77,105,25,95,38,176,23,33,103,139,30,4,248,61,11,228,41,19,225,5,135,82,21,235,216,66,139,166,161,0,87,171,162,177,57,255,8,67,126,234,213,141,181,21,185,122,135,114,203,19,203,43,171,163,85,185,71,67,89,102,16,70,96,40,173,160,246,197,198,197,16,242,29,36,191,94,77,170,209,168,82,156,4,31,244,88,148,160,144,38,168,203,88,196,100,169,79,121,18,177,17,90,45,65,137,25,163,48,226,40,218,156,95,234,46,155,207,28,154,193,162,177,15,123,192,202,40,152,209,13,162,245,170,229,6,180,101,10,59,100,42,54,221,7,185,192,202,121,129,146,45,244,226,104,35,240,249,196,100,161,252,69,200,44,68,250,124,243,12,4,45,145,252,230,185,160,70,65,135,75,252,230,121,163,107,89,249,82,52,104,109,199,55,143,9,52,21,143,169,196,10,162,1,112,182,135,226,212,210,125,252,45,43,95,115,150,75,72,111,178,200,113,91,238,236,199,58,157,209,32,154,8,231,21,113,52,97,145,61,77,151,74,168,221,134,1,123,51,191,138,44,65,108,105,97,129,206,93,227,197,174,234,58,203,84,211,76,171,102,100,128,155,214,86,102,111,155,252,130,162,60,171,237,170,89,185,130,240,130,13,61,223,141,163,177,246,169,53,160,125,116,138,202,106,64,225,149,215,38,7,20,234,212,148,49,160,65,144,124,29,218,116,46,34,48,79,128,91,107,251,116,158,138,201,5,202,4,157,59,26,46,218,89,73,82,3,26,186,220,43,57,236,58,245,184,148,231,121,167,179,184,182,33,59,102,117,95,170,168,105,58,84,33,159,79,2,115,33,206,53,140,66,42,157,109,7,219,38,164,86,104,139,245,16,229,24,254,220,70,247,215,217,70,124,199,193,54,123,124,35,165,124,51,169,236,73,43,151,38,108,97,195,237,37,101,51,133,39,149,163,111,185,39,20,215,91,12,131,104,40,151,2,109,23,174,144,217,133,154,177,2,129,12,164,220,127,236,229,89,255,118,248,72,45,14,253,108,85,9,136,112,12,154,157,78,129,174,149,217,169,247,137,202,157,69,89,161,124,237,144,144,43,129,141,247,22,81,145,196,203,12,100,145,180,111,151,188,54,125,115,135,172,250,237,106,46,219,177,246,67,241,183,148,106,78,38,52,180,53,207,15,108,57,87,88,94,189,237,69,138,82,230,171,20,30,47,157,209,215,18,254,38,145,167,211,242,151,61,222,210,130,172,94,76,36,203,47,213,44,167,254,87,88,55,217,35,251,192,24,125,226,38,227,104,117,41,79,67,42,207,29,187,106,242,117,107,106,77,219,238,206,224,163,7,87,51,26,82,8,1,253,246,70,203,254,211,19,113,71,109,184,125,201,69,38,54,41,42,83,40,154,101,37,237,193,197,59,187,112,195,87,254,87,226,48,178,23,200,10,204,56,22,127,233,177,145,248,3,208,246,103,200,183,219,210,4,180,20,251,171,244,114,209,203,62,84,85,61,135,139,245,76,168,203,27,161,46,213,158,254,129,249,47,126,241,208,9,210,20,0,0};
#define index_html_gz_len 1844
static const char index_html_filename[] = "/dist/index.6f3cb771.html";
static const char index_html_gz[] PROGMEM = {31,139,8,0,0,0,0,0,2,10,237,88,91,115,226,184,18,126,79,213,252,7,173,207,108,149,41,19,139,36,16,72,130,83,167,177,201,36,51,132,64,38,217,221,204,214,214,142,177,101,163,96,100,142,36,112,46,197,127,63,37,219,128,157,144,153,121,216,183,29,61,88,183,86,235,235,79,173,110,149,119,218,191,56,87,246,205,221,160,139,198,114,26,157,238,180,85,133,34,151,133,150,70,152,166,6,136,235,159,238,180,167,68,186,200,27,187,92,16,105,105,183,55,103,187,45,109,53,204,220,41,177,180,5,37,201,44,230,82,67,94,204,36,97,210,210,18,234,203,177,229,147,5,245,200,110,218,169,34,202,168,164,110,180,43,60,55,34,214,158,89,83,106,36,149,17,57,189,164,61,26,142,37,58,159,143,218,56,27,218,105,71,148,77,208,152,147,192,210,124,87,186,199,116,234,134,4,63,236,82,47,102,39,35,87,144,195,122,21,0,58,0,93,232,118,0,84,109,67,39,238,12,1,206,66,0,176,213,7,134,234,115,1,171,249,85,233,66,185,148,251,248,160,213,135,142,99,216,137,131,239,135,2,142,102,183,87,208,185,158,227,196,193,231,195,4,140,112,192,97,80,191,28,1,124,105,5,45,176,31,70,71,48,168,127,152,36,246,239,24,98,112,238,238,13,24,52,142,236,161,211,60,131,9,216,24,51,248,120,247,9,15,97,136,147,58,120,225,2,195,160,185,103,39,246,103,103,208,2,3,38,119,48,104,242,14,64,31,27,53,192,15,93,15,6,123,220,78,224,18,199,19,112,2,227,28,46,112,211,14,161,135,27,2,156,193,81,3,160,118,139,19,167,142,67,1,206,31,220,128,14,92,225,208,137,108,220,2,99,81,235,3,28,224,110,210,169,119,131,22,180,18,222,132,65,237,130,0,244,155,131,58,140,130,86,15,96,254,17,39,246,111,206,162,5,198,216,251,0,246,185,225,132,157,39,156,8,48,194,38,134,206,141,241,101,8,151,246,162,6,110,200,48,124,188,193,206,208,49,186,3,181,127,83,192,85,128,29,112,176,243,80,3,28,238,3,116,234,125,28,118,106,56,76,192,249,242,132,161,211,155,99,133,191,115,7,70,242,191,75,248,89,126,150,159,229,95,94,38,119,229,254,173,0,0,163,159,0,124,120,186,88,143,94,220,215,224,211,24,224,124,220,202,71,98,245,233,167,205,78,146,134,104,0,40,172,72,203,20,84,200,119,196,125,97,236,115,47,121,3,74,231,146,245,203,35,252,210,73,126,235,93,151,115,129,227,220,250,111,89,243,209,41,200,218,183,117,85,125,114,202,38,158,217,74,198,83,205,195,66,174,249,35,7,161,114,210,239,189,16,92,216,224,236,125,26,2,92,13,149,158,122,25,76,103,50,88,183,7,13,12,224,76,191,36,0,173,73,11,160,183,240,1,236,192,24,2,60,225,75,128,1,86,28,5,6,0,156,227,48,239,59,131,86,2,192,240,36,151,119,30,111,18,128,198,212,203,245,129,165,33,78,34,75,83,105,86,67,242,113,70,44,173,152,122,53,132,79,119,218,66,62,170,36,141,208,127,162,216,245,41,11,209,243,14,66,8,205,98,65,37,141,217,49,10,232,3,241,79,210,65,25,207,142,81,163,246,107,214,139,72,32,11,93,201,93,38,130,152,79,143,179,102,228,74,162,239,54,106,191,86,145,250,86,50,169,32,102,114,87,208,39,114,140,246,235,179,135,194,96,224,78,105,244,120,140,128,83,55,170,34,225,50,177,43,8,167,129,146,89,238,180,113,14,181,45,60,78,103,242,84,15,230,204,83,16,145,94,65,207,239,118,144,122,181,8,137,60,159,117,92,65,144,133,180,177,148,51,113,140,177,231,51,243,94,248,36,162,11,110,50,34,113,56,198,130,250,241,24,19,49,107,237,31,30,254,61,165,145,122,184,252,61,158,143,254,155,144,209,62,78,63,62,21,18,47,8,23,52,102,2,239,153,53,179,137,181,147,205,86,1,141,136,64,22,250,243,93,106,198,115,86,161,148,236,99,164,165,128,197,152,16,169,85,87,83,158,207,6,174,28,31,175,97,26,72,27,205,153,31,17,211,19,98,35,23,197,158,27,101,146,90,10,35,23,58,104,142,26,110,43,112,203,210,25,161,51,245,182,187,96,82,215,90,245,70,93,171,162,189,90,37,23,89,86,223,128,152,114,249,67,240,238,127,0,93,45,168,123,238,193,232,168,36,252,18,220,254,254,94,235,224,112,11,188,191,78,222,237,168,122,125,176,30,39,174,36,159,215,52,246,40,155,232,234,37,89,89,25,146,157,67,250,194,180,144,31,123,243,41,97,210,204,214,117,35,162,122,186,166,166,181,202,73,182,66,117,76,78,34,229,31,133,3,42,206,170,29,144,149,62,89,243,97,78,228,156,179,116,54,29,89,110,7,154,146,169,11,238,189,192,151,177,252,13,132,249,49,172,48,102,93,83,112,15,89,72,112,175,60,236,147,128,112,100,33,201,231,164,140,47,19,216,138,80,242,199,94,236,250,183,60,210,231,92,93,47,250,68,170,106,29,127,180,227,57,83,224,106,85,52,117,31,174,137,228,52,245,234,198,218,138,92,125,64,164,55,86,203,43,171,163,53,229,152,48,93,231,68,204,98,38,72,5,89,167,27,23,67,136,6,72,255,101,53,105,198,147,74,113,18,33,57,230,113,130,24,73,80,151,243,152,235,90,159,200,36,230,19,180,90,130,18,87,32,22,75,20,111,206,47,117,151,77,51,135,54,224,241,148,10,98,114,34,226,104,65,54,136,214,171,150,27,208,158,171,236,208,137,218,116,27,228,2,43,237,2,37,47,208,171,163,141,35,98,38,46,103,250,87,37,243,168,194,231,251,231,57,143,150,72,127,255,92,80,99,160,189,37,126,255,188,209,181,172,124,45,26,180,182,227,187,199,100,160,189,226,49,149,88,65,36,18,100,27,197,169,165,219,248,91,86,190,229,44,103,52,34,186,138,113,47,220,153,10,135,44,72,20,207,148,243,170,123,52,227,177,63,79,151,106,200,178,44,164,249,155,249,213,205,82,196,150,22,22,232,124,109,188,218,213,92,71,153,106,26,105,205,140,140,90,21,213,86,102,191,52,249,13,69,121,84,123,173,102,229,10,202,11,54,244,252,48,142,198,218,167,214,128,182,209,169,50,235,192,13,137,190,54,57,34,18,121,115,206,9,147,138,228,11,230,147,7,117,3,243,0,248,98,109,159,60,164,98,122,129,50,69,231,43,13,167,86,150,146,204,136,176,80,142,75,14,187,14,61,33,145,121,220,233,60,94,248,186,150,231,125,173,98,166,225,208,244,169,152,69,238,163,58,87,22,51,162,157,188,188,108,155,43,181,66,91,204,135,40,199,240,231,75,116,127,157,108,196,95,57,216,102,143,239,132,148,239,6,149,45,97,229,204,165,17,241,145,140,83,54,83,120,90,249,246,45,183,92,197,245,22,163,40,30,233,165,139,246,26,174,146,121,13,53,99,101,206,85,178,185,189,238,229,81,255,106,116,79,60,121,123,221,203,86,149,128,40,199,32,217,233,20,232,90,153,157,122,159,202,220,217,45,43,164,175,87,36,228,74,144,181,61,137,170,32,94,102,32,187,73,219,118,201,115,211,119,119,200,178,223,107,205,101,59,214,126,168,126,75,153,238,108,70,152,111,143,105,228,235,185,194,242,234,151,94,100,24,101,190,74,215,227,173,51,250,86,192,223,4,242,116,90,255,186,197,91,142,209,251,231,98,32,89,126,173,102,49,245,159,194,186,137,30,89,3,99,244,89,186,92,162,213,163,60,189,82,121,236,120,173,38,95,183,166,214,245,253,238,130,48,217,163,66,18,70,184,174,57,87,151,118,246,79,79,221,59,226,107,85,164,23,153,216,132,168,76,161,170,150,149,180,215,198,249,131,123,167,141,243,95,137,163,216,127,68,94,228,10,161,126,233,241,137,250,1,232,211,5,162,190,165,205,220,144,20,251,171,240,114,218,203,26,166,105,182,177,79,23,74,93,94,41,117,169,246,244,7,230,255,1,85,126,183,220,210,20,0,0};
15 changes: 14 additions & 1 deletion docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
email: [email protected]
license:
name: MIT
version: 1.0.0
version: 1.0.1
servers:
- url: http://milight-hub
tags:
Expand Down Expand Up @@ -1249,6 +1249,19 @@ components:
type: integer
description: Controls how many cycles are spent listening for packets. Set to 0 to disable passive listening.
default: 3
ignored_listen_protocols:
type: array
description: Improve listen reliability by ignoring specific protocol types. Leave empty if you are unsure.
default: []
items:
type: string
enum:
- RGBW
- CCT
- FUT089
- RGB
- FUT020
uniqueItems: true
state_flush_interval:
type: integer
description: Controls how many miliseconds must pass between states being flushed to persistent storage. Set to 0 to disable throttling.
Expand Down
2 changes: 1 addition & 1 deletion lib/Helpers/Size.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define _SIZE_H

template<typename T, size_t sz>
size_t size(T(&)[sz]) {
constexpr size_t size(T(&)[sz]) {
return sz;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Radio/MiLightRadioConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#include <MiLightRadioConfig.h>

#include <ListenProtocols.h>

MiLightRadioConfig MiLightRadioConfig::ALL_CONFIGS[] = {
MiLightRadioConfig(0x147A, 0x258B, 7, 9, 40, 71, 0xAA, 0x05), // rgbw
MiLightRadioConfig(0x050A, 0x55AA, 7, 4, 39, 74, 0xAA, 0x05), // cct
MiLightRadioConfig(0x7236, 0x1809, 9, 8, 39, 70, 0xAA, 0x05), // rgb+cct, fut089
MiLightRadioConfig(0x9AAB, 0xBCCD, 6, 3, 38, 73, 0x55, 0x0A), // rgb
MiLightRadioConfig(0x50A0, 0xAA55, 6, 6, 41, 76, 0xAA, 0x0A) // FUT020
};

static_assert(ListenProtocolHelpers::numProtocols() == MiLightRadioConfig::NUM_CONFIGS, "Listen protocols do not match");
19 changes: 19 additions & 0 deletions lib/Settings/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ void Settings::patch(JsonObject parsedSettings) {
JsonArray arr = parsedSettings[FPSTR(SettingsKeys::GROUP_STATE_FIELDS)];
groupStateFields = JsonHelpers::jsonArrToVector<GroupStateField, const char*>(arr, GroupStateFieldHelpers::getFieldByName);
}
if (parsedSettings.containsKey(FPSTR(SettingsKeys::IGNORED_LISTEN_PROTOCOLS))) {
ignoredListenProtocols = 0;
JsonArray arr = parsedSettings[FPSTR(SettingsKeys::IGNORED_LISTEN_PROTOCOLS)];
for(JsonVariant v : arr){
ignoredListenProtocols |= (1 << ListenProtocolHelpers::indexFromName(v.as<String>()));
}
}

// this key will only be present in old settings files, but for backwards
// compatability, parse it if it's present.
Expand Down Expand Up @@ -355,6 +362,7 @@ void Settings::serialize(Print& stream, const bool prettyPrint) const {
root[FPSTR(SettingsKeys::HOME_ASSISTANT_DISCOVERY_PREFIX)] = this->homeAssistantDiscoveryPrefix;
root[FPSTR(SettingsKeys::WIFI_MODE)] = wifiModeToString(this->wifiMode);
root[FPSTR(SettingsKeys::DEFAULT_TRANSITION_PERIOD)] = this->defaultTransitionPeriod;


JsonArray channelArr = root.createNestedArray(FPSTR(SettingsKeys::RF24_CHANNELS));
JsonHelpers::vectorToJsonArr<RF24Channel, String>(channelArr, rf24Channels, RF24ChannelHelpers::nameFromValue);
Expand All @@ -373,6 +381,13 @@ void Settings::serialize(Print& stream, const bool prettyPrint) const {
JsonArray groupStateFieldArr = root.createNestedArray(FPSTR(SettingsKeys::GROUP_STATE_FIELDS));
JsonHelpers::vectorToJsonArr<GroupStateField, const char*>(groupStateFieldArr, groupStateFields, GroupStateFieldHelpers::getFieldName);

JsonArray ignoredProtocolsArr = root.createNestedArray(FPSTR(SettingsKeys::IGNORED_LISTEN_PROTOCOLS));
for (uint8_t i = 0; i < ListenProtocolHelpers::numProtocols(); ++i) {
if (ignoredListenProtocols & (1 << i)) {
ignoredProtocolsArr.add(ListenProtocolHelpers::nameFromIndex(i));
}
}

if (prettyPrint) {
serializeJsonPretty(root, stream);
} else {
Expand Down Expand Up @@ -441,6 +456,10 @@ String Settings::wifiModeToString(WifiMode mode) {
}
}

bool Settings::isListenProtocolEnabled(uint8_t index) const {
return (ignoredListenProtocols & (1 << index)) == 0;
}

void Settings::addAlias(const char *alias, const BulbId &bulbId) {
groupIdAliases[alias] = GroupAlias(groupIdAliasNextId++, alias, bulbId);
}
Expand Down
Loading

0 comments on commit f37b20e

Please sign in to comment.