first notifier working demo
NOTES: udp broadcast notifier? timeout problem!!
This commit is contained in:
parent
acfdb4ab75
commit
e22fb965f7
@ -35,6 +35,8 @@
|
|||||||
document.S_form.BTNON.checked = (this.responseXML.getElementsByTagName('btnon')[0].innerHTML)!=0?true:false;
|
document.S_form.BTNON.checked = (this.responseXML.getElementsByTagName('btnon')[0].innerHTML)!=0?true:false;
|
||||||
document.S_form.TFADE.checked = (this.responseXML.getElementsByTagName('tfade')[0].innerHTML)!=0?true:false;
|
document.S_form.TFADE.checked = (this.responseXML.getElementsByTagName('tfade')[0].innerHTML)!=0?true:false;
|
||||||
document.S_form.TDLAY.value = this.responseXML.getElementsByTagName('tdlay')[0].innerHTML;
|
document.S_form.TDLAY.value = this.responseXML.getElementsByTagName('tdlay')[0].innerHTML;
|
||||||
|
document.S_form.TLDUR.value = this.responseXML.getElementsByTagName('tldur')[0].innerHTML;
|
||||||
|
document.S_form.TLFDE.checked = (this.responseXML.getElementsByTagName('tlfde')[0].innerHTML)!=0?true:false;
|
||||||
document.S_form.NRCVE.checked = (this.responseXML.getElementsByTagName('nrcve')[0].innerHTML)!=0?true:false;
|
document.S_form.NRCVE.checked = (this.responseXML.getElementsByTagName('nrcve')[0].innerHTML)!=0?true:false;
|
||||||
document.S_form.NRBRI.value = this.responseXML.getElementsByTagName('nrbri')[0].innerHTML;
|
document.S_form.NRBRI.value = this.responseXML.getElementsByTagName('nrbri')[0].innerHTML;
|
||||||
document.S_form.NSDIR.checked = (this.responseXML.getElementsByTagName('nsdir')[0].innerHTML)!=0?true:false;
|
document.S_form.NSDIR.checked = (this.responseXML.getElementsByTagName('nsdir')[0].innerHTML)!=0?true:false;
|
||||||
|
@ -35,28 +35,30 @@ boolean only_ap = false;
|
|||||||
uint8_t led_amount = 16;
|
uint8_t led_amount = 16;
|
||||||
uint8_t buttonPin = 3; //needs pull-up
|
uint8_t buttonPin = 3; //needs pull-up
|
||||||
boolean buttonEnabled = true;
|
boolean buttonEnabled = true;
|
||||||
String notifier_ips[]{"10.10.1.128","10.10.1.129"};
|
String notifier_ips[]{"10.10.1.191","10.10.1.129"};
|
||||||
boolean notifyDirect = true, notifyButton = true, notifyForward = true;
|
boolean notifyDirect = true, notifyButton = true, notifyForward = true;
|
||||||
boolean receiveNotifications = true;
|
boolean receiveNotifications = true;
|
||||||
uint8_t bri_n = 100;
|
uint8_t bri_n = 100;
|
||||||
uint8_t nightlightDelayMins = 60;
|
uint8_t nightlightDelayMins = 60;
|
||||||
boolean nightlightFade = true;
|
boolean nightlightFade = true;
|
||||||
|
|
||||||
double transitionResolution = 0.01;
|
double transitionResolution = 0.015;
|
||||||
|
|
||||||
//Internal vars
|
//Internal vars
|
||||||
byte col_old[]{0, 0, 0};
|
byte col_old[]{0, 0, 0};
|
||||||
byte col_t[]{0, 0, 0};
|
byte col_t[]{0, 0, 0};
|
||||||
|
byte col_it[]{0, 0, 0};
|
||||||
long transitionStartTime;
|
long transitionStartTime;
|
||||||
long nightlightStartTime;
|
long nightlightStartTime;
|
||||||
float tper_last = 0;
|
float tper_last = 0;
|
||||||
byte bri = 127;
|
byte bri = 127;
|
||||||
byte bri_old = 0;
|
byte bri_old = 0;
|
||||||
byte bri_t = 0;
|
byte bri_t = 0;
|
||||||
|
byte bri_it = 0;
|
||||||
byte bri_last = 127;
|
byte bri_last = 127;
|
||||||
boolean transitionActive = false;
|
boolean transitionActive = false;
|
||||||
boolean buttonPressedBefore = false;
|
boolean buttonPressedBefore = false;
|
||||||
int notifier_ips_count = 0;
|
int notifier_ips_count = 1;
|
||||||
String notifier_ips_raw = "";
|
String notifier_ips_raw = "";
|
||||||
boolean nightlightActive = false;
|
boolean nightlightActive = false;
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ void saveSettingsToEEPROM()
|
|||||||
{
|
{
|
||||||
EEPROM.write(i, appass.charAt(i-160));
|
EEPROM.write(i, appass.charAt(i-160));
|
||||||
}
|
}
|
||||||
|
EEPROM.write(224, nightlightDelayMins);
|
||||||
|
EEPROM.write(225, nightlightFade);
|
||||||
EEPROM.write(228, aphide);
|
EEPROM.write(228, aphide);
|
||||||
EEPROM.write(227, apchannel);
|
EEPROM.write(227, apchannel);
|
||||||
EEPROM.write(229, led_amount);
|
EEPROM.write(229, led_amount);
|
||||||
|
@ -79,6 +79,12 @@ void XML_response_settings()
|
|||||||
resp = resp + "</tfade><tdlay>";
|
resp = resp + "</tfade><tdlay>";
|
||||||
resp = resp + transitionDelay;
|
resp = resp + transitionDelay;
|
||||||
resp = resp + "</tdlay>";
|
resp = resp + "</tdlay>";
|
||||||
|
resp = resp + "<tldur>";
|
||||||
|
resp = resp + nightlightDelayMins;
|
||||||
|
resp = resp + "</tldur>";
|
||||||
|
resp = resp + "<tlfde>";
|
||||||
|
resp = resp + bool2int(nightlightFade);
|
||||||
|
resp = resp + "</tlfde>";
|
||||||
resp = resp + "<nrcve>";
|
resp = resp + "<nrcve>";
|
||||||
resp = resp + bool2int(receiveNotifications);
|
resp = resp + bool2int(receiveNotifications);
|
||||||
resp = resp + "</nrcve><nrbri>";
|
resp = resp + "</nrcve><nrbri>";
|
||||||
|
@ -68,6 +68,9 @@ void wledInit()
|
|||||||
server.on("/button.png", HTTP_GET, [](){
|
server.on("/button.png", HTTP_GET, [](){
|
||||||
if(!handleFileRead("/button.png")) server.send(404, "text/plain", "FileNotFound");
|
if(!handleFileRead("/button.png")) server.send(404, "text/plain", "FileNotFound");
|
||||||
});
|
});
|
||||||
|
server.on("/moon.png", HTTP_GET, [](){
|
||||||
|
if(!handleFileRead("/moon.png")) server.send(404, "text/plain", "FileNotFound");
|
||||||
|
});
|
||||||
server.on("/favicon.ico", HTTP_GET, [](){
|
server.on("/favicon.ico", HTTP_GET, [](){
|
||||||
if(!handleFileRead("/favicon.ico")) server.send(404, "text/plain", "FileNotFound");
|
if(!handleFileRead("/favicon.ico")) server.send(404, "text/plain", "FileNotFound");
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ void notify(int callMode)
|
|||||||
case 3: if (!notifyForward) return; break;
|
case 3: if (!notifyForward) return; break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
String snd = "/ajax_in&N=1&A=";
|
String snd = "/ajax_inputs&N=1&A=";
|
||||||
snd = snd + bri;
|
snd = snd + bri;
|
||||||
snd = snd + "&R=";
|
snd = snd + "&R=";
|
||||||
snd = snd + col[0];
|
snd = snd + col[0];
|
||||||
@ -15,17 +15,27 @@ void notify(int callMode)
|
|||||||
snd = snd + col[1];
|
snd = snd + col[1];
|
||||||
snd = snd + "&B=";
|
snd = snd + "&B=";
|
||||||
snd = snd + col[2];
|
snd = snd + col[2];
|
||||||
|
//snd = snd + " HTTP/1.1";
|
||||||
|
|
||||||
HTTPClient hclient;
|
WiFiClient hclient;
|
||||||
|
hclient.setTimeout(50);
|
||||||
|
|
||||||
for (int i = 0; i < notifier_ips_count; i++)
|
for (int i = 0; i < notifier_ips_count; i++)
|
||||||
{
|
{
|
||||||
String url = "http://";
|
|
||||||
url = url + notifier_ips[i];
|
Serial.println("NCON...");
|
||||||
url = url + snd;
|
if (hclient.connect(notifier_ips[i].c_str(), 80))
|
||||||
|
{
|
||||||
hclient.begin(url);
|
Serial.println("CON!");
|
||||||
hclient.GET();
|
Serial.println(snd);
|
||||||
hclient.end();
|
hclient.print(String("GET ") + snd + " HTTP/1.1\r\n" +
|
||||||
|
"Host: " + notifier_ips[i] + "\r\n" +
|
||||||
|
"Connection: close\r\n\r\n");
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Serial.println("NO CONNECTION");
|
||||||
|
hclient.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,14 @@ void setLedsStandard()
|
|||||||
void colorUpdated(int callMode)
|
void colorUpdated(int callMode)
|
||||||
{
|
{
|
||||||
//call for notifier -> 0: init 1: direct change 2: button 3: notification
|
//call for notifier -> 0: init 1: direct change 2: button 3: notification
|
||||||
if (col[0] == col_old[0] && col[1] == col_old[1] && col[2] == col_old[2] && bri == bri_old)
|
if (col[0] == col_it[0] && col[1] == col_it[1] && col[2] == col_it[2] && bri == bri_it)
|
||||||
{
|
{
|
||||||
return; //no change
|
return; //no change
|
||||||
}
|
}
|
||||||
|
col_it[0] = col[0];
|
||||||
|
col_it[1] = col[1];
|
||||||
|
col_it[2] = col[2];
|
||||||
|
bri_it = bri;
|
||||||
if (bri > 0) bri_last = bri;
|
if (bri > 0) bri_last = bri;
|
||||||
notify(callMode);
|
notify(callMode);
|
||||||
if (fadeTransition || seqTransition)
|
if (fadeTransition || seqTransition)
|
||||||
|
Loading…
Reference in New Issue
Block a user