From b0940783b6d1156b085e4413b0bd2533dcf83192 Mon Sep 17 00:00:00 2001
From: matlen67 <45318154+matlen67@users.noreply.github.com>
Date: Wed, 28 Nov 2018 19:24:15 +0100
Subject: [PATCH] Add files via upload
---
ansluta arduino code/ansluta.ino | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/ansluta arduino code/ansluta.ino b/ansluta arduino code/ansluta.ino
index 01ca300..e18191f 100644
--- a/ansluta arduino code/ansluta.ino
+++ b/ansluta arduino code/ansluta.ino
@@ -10,7 +10,7 @@
* CC2500 (WLC240) (ebay)
Wired:
- NodeMCU CC2500
+ NodeMCU CC2500
SPI GPIO Board
---------------------- --------
@@ -51,6 +51,8 @@ String header;
press button within 5 sec on your original ansluta remote
is a valid address detect it will be displayed
*/
+
+// pute here your AddressBytes
byte AddressByteA = 0xD0;
byte AddressByteB = 0x9A;
@@ -108,22 +110,32 @@ void setup(){
}
void loop(){
+
WiFiClient client = server.available(); // Listen for incoming clients
- if (client) { // If a new client connects,
+ if (client) { // If a new client connects,
if(DEBUG){
- Serial.println("New Client."); // print a message out in the serial port
+ Serial.println("New Client."); // print a message out in the serial port
}
String currentLine = ""; // make a String to hold incoming data from the client
String adrByte = "";
boolean adrState = false;
+ int timeOut = 0;
+
while (client.connected()) { // loop while the client's connected
+ timeOut ++;
+ if (timeOut >= 500000){ // dirty workaround because ClientTimeout not Work!
+ client.stop(); // Chrome keep alive the connection and block other connection (Fhem,Firefox)
+ }
+
if (client.available()) { // if there's bytes to read from the client,
+
char c = client.read(); // read a byte, then
if(DEBUG){
Serial.write(c); // print it out the serial monitor
}
header += c;
+
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
@@ -154,6 +166,7 @@ void loop(){
if(DEBUG){
Serial.println("Ansluta 50% ");
}
+
SendCommand(AddressByteA,AddressByteB, Light_ON_50);
} else if (header.indexOf("GET /ansluta/100") >= 0) {
if(DEBUG){
@@ -173,8 +186,9 @@ void loop(){
client.println("
");
client.println("
Listen for adressbyte...
"); client.println("Press button on original remote!
"); - client.println("