Add files via upload

This commit is contained in:
matlen67 2018-11-28 19:24:15 +01:00 committed by GitHub
parent d0fa135cbd
commit b0940783b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 6 deletions

View File

@ -10,7 +10,7 @@
* CC2500 (WLC240) (ebay) * CC2500 (WLC240) (ebay)
Wired: Wired:
NodeMCU CC2500 NodeMCU CC2500
SPI GPIO Board SPI GPIO Board
---------------------- -------- ---------------------- --------
@ -51,6 +51,8 @@ String header;
press button within 5 sec on your original ansluta remote press button within 5 sec on your original ansluta remote
is a valid address detect it will be displayed is a valid address detect it will be displayed
*/ */
// pute here your AddressBytes
byte AddressByteA = 0xD0; byte AddressByteA = 0xD0;
byte AddressByteB = 0x9A; byte AddressByteB = 0x9A;
@ -108,22 +110,32 @@ void setup(){
} }
void loop(){ void loop(){
WiFiClient client = server.available(); // Listen for incoming clients WiFiClient client = server.available(); // Listen for incoming clients
if (client) { // If a new client connects, if (client) { // If a new client connects,
if(DEBUG){ 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 currentLine = ""; // make a String to hold incoming data from the client
String adrByte = ""; String adrByte = "";
boolean adrState = false; boolean adrState = false;
int timeOut = 0;
while (client.connected()) { // loop while the client's connected 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, if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then char c = client.read(); // read a byte, then
if(DEBUG){ if(DEBUG){
Serial.write(c); // print it out the serial monitor Serial.write(c); // print it out the serial monitor
} }
header += c; header += c;
if (c == '\n') { // if the byte is a newline character if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row. // 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: // that's the end of the client HTTP request, so send a response:
@ -154,6 +166,7 @@ void loop(){
if(DEBUG){ if(DEBUG){
Serial.println("Ansluta 50% "); Serial.println("Ansluta 50% ");
} }
SendCommand(AddressByteA,AddressByteB, Light_ON_50); SendCommand(AddressByteA,AddressByteB, Light_ON_50);
} else if (header.indexOf("GET /ansluta/100") >= 0) { } else if (header.indexOf("GET /ansluta/100") >= 0) {
if(DEBUG){ if(DEBUG){
@ -173,8 +186,9 @@ void loop(){
client.println("<br>"); client.println("<br>");
client.println("<p>Listen for adressbyte...</p>"); client.println("<p>Listen for adressbyte...</p>");
client.println("<p>Press button on original remote!</p>"); client.println("<p>Press button on original remote!</p>");
client.println("</body></html>"); //client.println("</body></html>");
client.println(); client.println();
delay(10); delay(10);
client.flush(); client.flush();
//client.stop(); //client.stop();
@ -203,8 +217,7 @@ void loop(){
} }
client.println("</body></html>"); client.println("</body></html>");
// The HTTP response ends with another blank line // The HTTP response ends with another blank line
client.println(); client.println();
// Break out of the while loop // Break out of the while loop
@ -220,7 +233,9 @@ void loop(){
// Clear the header variable // Clear the header variable
header = ""; header = "";
// Close the connection // Close the connection
//delay(1);
client.stop(); client.stop();
if(DEBUG){ if(DEBUG){
Serial.println("Client disconnected."); Serial.println("Client disconnected.");
Serial.println(""); Serial.println("");