Supla Button 2.0 i kolejne wersje...
Czy Supla Button nadal działa? Wrzucałem na NodeMCU chyba wszystkie firmware i cały czas mam odpowiedz w konsoli 'Błąd połączenia z hostem'. Przeglądnąłem ten temat strona po stronie chyba już z 5x i jestem na 99% pewny, że wszystko robię zgodnie z tym co zostało tutaj napisane.
tez mi nie dziala mam tak
w monitorze
Supla mode = 1
19:07:50.965 -> scandone
19:07:51.902 -> state: 0 -> 2 (b0)
19:07:51.902 -> state: 2 -> 3 (0)
19:07:51.949 -> state: 3 -> 0 (12)
19:07:52.933 -> reconnect
19:07:55.793 -> scandone
19:07:55.793 -> state: 0 -> 2 (b0)
19:07:55.793 -> state: 2 -> 3 (0)
19:07:55.840 -> state: 3 -> 5 (10)
19:07:55.840 -> add 0
19:07:55.840 -> aid 8
19:07:55.840 -> cnt
19:07:55.887 ->
19:07:55.887 -> connected with vodafoneE120, channel 1
19:07:55.887 -> dhcp client start...
19:07:55.933 -> ip:192.168.10.101,mask:255.255.255.0,gw:192.168.10.1
19:07:55.933 -> Polaczono z WIFI
19:07:55.933 -> MAC:84:0D:8E:8C:A9:D7 IP:192.168.10.101 M:255.255.255.0 GW:192.168.10.1
19:07:56.261 -> Koniec polaczenia
19:07:56.308 -> state: 5 -> 0 (0)
19:07:56.308 -> rm 0
19:07:56.308 -> Dobranocdel if0
19:07:56.308 -> bcn 0
19:07:56.308 -> del if1
19:07:56.308 -> usl
19:07:56.402 -> enter deep sleep⸮
Kod: Zaznacz cały
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <DoubleResetDetector.h> //Bilioteka by Stephen Denne
// Number of seconds after reset during which a
// subseqent reset will be considered a double reset.
#define DRD_TIMEOUT 5
// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0
DoubleResetDetector drd(DRD_TIMEOUT, DRD_ADDRESS);
//********************************************************PARAMETRY KONFIGURACYJNE****************************************************************
const char* ssid = "vodafoneE120";
const char* password = "xxxxx";
const char* WiFi_hostname = "Supla_BUTTON_V2";
byte Adres_z_DHCP = 1; //1 = DHCP, 0 = Statyczne_IP
IPAddress staticIP(192,168,1,100);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
const char* host = "supla.fracz.com";
String url_1 = "/api/scenes/execute/a294aa63-fd2e-4452-b2f6-e64f7d7253c9"; //Adres PUBLICZNY SCENY 1
String Klucz_dostepu_1 = "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnQiOnsiaWQiOiI2N2M2YzY5NC01YzI5LTQ0YmMtYWNiOS0wNDI1YjIyM2UxNmUifSwiaXNzIjoiaHR0cHM6XC9cL3N1cGxhLmZyYWN6LmNvbSIsImlhdCI6MTU0OTU1OTYyNywibmJmIjoxNTQ5NTU5NjI3LCJleHAiOjE3MDcyMzk2Mjd9.m-ImfVf94Bwhs5i5Vdj45qifJ9cMscuW_0pwtPsnNPg";
String url_2 = "/api/scenes/execute/f33803e5-c540-4819-ab9f-3c7d5789c42e"; //Adres PUBLICZNY SCENY 2
String Klucz_dostepu_2 = "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnQiOnsiaWQiOiJlNGM4MTIzMi00YTRkLTQ2YWMtYmJiZC0yZjZhODc0M2ZmOWYifSwiaXNzIjoiaHR0cHM6XC9cL3N1cGxhLmZyYWN6LmNvbSIsImlhdCI6MTU0NzMxNTMxNiwibmJmIjoxNTQ3MzE1MzE2LCJleHAiOjE3MDQ5OTUzMTZ9.DyDj4ynOdZzNmvDzXz2ZLCvKgMgbIauphUAvn5JeBcQ";
const int httpsPort = 443; //Port serwera
const unsigned Czas_max_timeout = 40000; //Czas TIMEOUT szukania WIFI w milisekundach = 10 sekund
const byte debug = 1; //1 = Włączone debugowanie, 0 = Wyłączone
//************************************************************************************************************************************************
byte supla_mode = 0;
void setup()
{
if (debug == 1){
Serial.begin(115200);
Serial.println();
Serial.println();
Serial.println();
}
if (drd.detectDoubleReset()) {
supla_mode = 2;
} else {
supla_mode = 1;
}
for (int i=0; i <= 1000; i++){
delay(1);
drd.loop();
if (i == 500){
WiFi.hostname(WiFi_hostname);
WiFi.begin(ssid, password);
if (Adres_z_DHCP == 0){
WiFi.config(staticIP, gateway, subnet);
}
}
// Call the double reset detector loop method every so often,
// so that it can recognise when the timeout expires.
// You can also call drd.stop() when you wish to no longer
// consider the next reset as a double reset.
}
drd.stop();
}
void loop()
{
if (debug == 1){
Serial.print("Supla mode = ");
Serial.println(supla_mode);
}
for (unsigned timeout=0; timeout <= Czas_max_timeout; timeout++){
if (WiFi.status() != WL_CONNECTED){
delay(1);
}
else
{
timeout = Czas_max_timeout;
if (debug == 1){
Serial.println("Polaczono z WIFI");
Serial.print("MAC:");Serial.print(WiFi.macAddress());
Serial.print(" IP:");Serial.print(WiFi.localIP());
Serial.print(" M:");Serial.print(WiFi.subnetMask());
Serial.print(" GW:");Serial.println(WiFi.gatewayIP());
}
}
}
if (WiFi.status() == WL_CONNECTED){
WiFiClientSecure client;
if (client.connect(host, httpsPort)) {
if (debug == 1){
Serial.print("Poloczono z ");
Serial.println(host);
}
if (supla_mode == 1){
client.println(String("GET ") + url_1 + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: SuplaButtonESP8266\r\n" +
Klucz_dostepu_1 + "\r\n" +
"Connection: close\r\n\r\n");
}
if (supla_mode == 2){
client.println(String("GET ") + url_2 + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: SuplaButtonESP8266\r\n" +
Klucz_dostepu_2 + "\r\n" +
"Connection: close\r\n\r\n");
}
String line = client.readStringUntil('\r');
if (line == "HTTP/1.1 204 No Content"){
Serial.println("Wykonano scene");
// error = 0;
}
}
if (debug == 1){
Serial.println("Koniec polaczenia");
}
}
WiFi.disconnect();
if (debug == 1){
Serial.print("Dobranoc");
}
ESP.deepSleep(0);
}
Supla mode = 1
19:07:50.965 -> scandone
19:07:51.902 -> state: 0 -> 2 (b0)
19:07:51.902 -> state: 2 -> 3 (0)
19:07:51.949 -> state: 3 -> 0 (12)
19:07:52.933 -> reconnect
19:07:55.793 -> scandone
19:07:55.793 -> state: 0 -> 2 (b0)
19:07:55.793 -> state: 2 -> 3 (0)
19:07:55.840 -> state: 3 -> 5 (10)
19:07:55.840 -> add 0
19:07:55.840 -> aid 8
19:07:55.840 -> cnt
19:07:55.887 ->
19:07:55.887 -> connected with vodafoneE120, channel 1
19:07:55.887 -> dhcp client start...
19:07:55.933 -> ip:192.168.10.101,mask:255.255.255.0,gw:192.168.10.1
19:07:55.933 -> Polaczono z WIFI
19:07:55.933 -> MAC:84:0D:8E:8C:A9:D7 IP:192.168.10.101 M:255.255.255.0 GW:192.168.10.1
19:07:56.261 -> Koniec polaczenia
19:07:56.308 -> state: 5 -> 0 (0)
19:07:56.308 -> rm 0
19:07:56.308 -> Dobranocdel if0
19:07:56.308 -> bcn 0
19:07:56.308 -> del if1
19:07:56.308 -> usl
19:07:56.402 -> enter deep sleep⸮