Supla Device, WebInterface, problemy początkującego

User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Cześć, dzisiaj postanowiłem użyć przykładu z webinterface i zobaczyc z czym to się je.
Płytka nodemcu na esp8266, po wgraniu:

Code: Select all

#define STATUS_LED_GPIO 16

#define BUTTON_CFG_RELAY_GPIO 5

#include <SuplaDevice.h>
#include <supla/network/esp_wifi.h>

#include <supla/control/button.h>

#include <supla/device/status_led.h>
#include <supla/storage/littlefs_config.h>
#include <supla/network/esp_web_server.h>
#include <supla/network/html/device_info.h>
#include <supla/network/html/protocol_parameters.h>
#include <supla/network/html/status_led_parameters.h>
#include <supla/network/html/wifi_parameters.h>
#include <supla/device/supla_ca_cert.h>
#include <supla/events.h>

// Choose where Supla should store roller shutter data in persistent memory
// We recommend to use external FRAM memory
#include <supla/storage/eeprom.h>
Supla::Eeprom eeprom;
// #include <supla/storage/fram_spi.h>
// Supla::FramSpi fram(STORAGE_OFFSET);

Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;

Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true); // inverted state
Supla::EspWebServer suplaServer;


// HTML www component (they appear in sections according to creation
// sequence)
Supla::Html::DeviceInfo htmlDeviceInfo(&SuplaDevice);
Supla::Html::WifiParameters htmlWifi;
Supla::Html::ProtocolParameters htmlProto;
Supla::Html::StatusLedParameters htmlStatusLed;

void setup() {

  Serial.begin(9600);

  auto buttonCfgRelay =
    new Supla::Control::Button(BUTTON_CFG_RELAY_GPIO, true, true);

  buttonCfgRelay->configureAsConfigButton(&SuplaDevice);


  // configure defualt Supla CA certificate
  SuplaDevice.setSuplaCACert(suplaCACert);
  SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert);

  SuplaDevice.begin();
}

void loop() {
  SuplaDevice.iterate();
}
płytka ładnie rozgłasza sieć, wpisuję dane mojej sieci wifi, zapisz i reset i niestety taki komunikat:
Deinitializing SRPC
Establishing encrypted connection with: svr73.supla.org (port: 2016)
Connected to Supla Server
Initializing SRPC
Send: [53 55 50 4C 41 14 01 00 00 00 45 00 00 00 48 02 00 00 74 6F 6D 61 73 7A 2E 6D 6C 6F 74 65 6B 40 77 70 2E 70 6C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8C 06 76 E5 67 4C 7D 01 F5 0D 02 33 BB D3 8E F2 AB 0B 46 99 DC F2 32 B9 D0 B7 1C B0 F5 2A AA A2 53 55 50 4C 41 2D 45 53 50 38 32 36 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
Send: [53 55 50 4C 41 ]
Recv: [53 55 50 4C 41 14 01 00 00 00 46 00 00 00 07 00 00 00 11 00 00 00 78 16 01 53 55 50 4C 41 ]
Current status: [31] Registration disabled!
Deinitializing SRPC

Pierwsze pytanie, co robię nie tak?
Drugie pytanie: czy ten kod na górze to "czysty webinterface" czy coś jest tam za dużo lub za mało?
Trzecie pytanie: czy można za pomocą bibliotek supla wgrywać soft OTA?
Last edited by SOYER on Sun Jan 21, 2024 8:35 am, edited 1 time in total.
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Kiedy wyłączyłem certyfikację(?) w config mode to mam takie coś podobnego:

Connecting without certificate validation (INSECURE)
Establishing encrypted connection with: svr73.supla.org (port: 2016)
Connected to Supla Server
Initializing SRPC
Send: [53 55 50 4C 41 14 01 00 00 00 45 00 00 00 48 02 00 00 74 6F 6D 61 73 7A 2E 6D 6C 6F 74 65 6B 40 77 70 2E 70 6C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 F9 5B 9B F1 F7 A2 66 B9 BC 47 99 BA 01 EA 69 D2 69 38 82 42 87 2B 8F 60 0F 74 D5 1A 95 FC 51 53 55 50 4C 41 2D 45 53 50 38 32 36 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
Send: [53 55 50 4C 41 ]
Recv: [53 55 50 4C 41 14 01 00 00 00 46 00 00 00 07 00 00 00 11 00 00 00 78 16 01 53 55 50 4C 41 ]
Current status: [31] Registration disabled!
Deinitializing SRPC
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
lukfud
Posts: 2480
Joined: Thu Nov 23, 2017 11:33 pm
Location: Warszawa
Has thanked: 13 times
Been thanked: 11 times

Post

Code: Select all

Current status: [31] Registration disabled!
Dlaczego nie włączysz rejestracji urządzeń? :)
https://www.facebook.com/groups/supladiy
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

W sensie, że mi się nowe urządzenie zaloguje do cloud?
Racja, robię na module wyjętym z garażu, gdzieś z tyłu głowy miałem, że urządzenie jest zarejestrowane, a przecież wgrywam nowe... :o :lol:
Co z resztą moich pytań?
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
klew
Posts: 13911
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 136 times
Been thanked: 137 times

Post

W bibliotece dla Arduino nie ma ota - lukfud coś tutaj robił, więc może pomóc.

Przykład WebInterface ma też kilka kanałów, przycisków. Także nie jest zupełnie "goły".

Jak włączysz sprawdzanie certyfikatu, to takie logi się pojawią, jakie widzisz ;)
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Dobra, to zawołał @lukfud w sprawie OTA.
Co do mojego przykladu to połączyło i zadziałało, ale...
Teraz ten sam szkic(który wkleiłem na górze) z web interface, dokleiłem do mojego szkicu z garażu. Jak ładnie wystawia panel konfiguracyjny to po przeklikaniu nie rejestruje w serwerze, pewnie dlatego, że jest jakiś konflikt GUID itd. Bo w moim garażowym szkicu mam już na sztywno ustawiony i urządzenie było wcześniej zarejestrowane, a ten web interface pewnie nadaje swój GUID(i co tam jeszcze).
Co wywalić by to się znowu zalogowało jako urządzenie już zarejestrowane, ale z funkcjonalnością WEBINTERFACE.
?
Mój szkic:

Code: Select all

#include <SuplaDevice.h>
#include <supla/sensor/DS18B20.h>
#include <supla/control/relay.h>
#include <supla/control/button.h>
#include <supla/sensor/binary.h>
#include <supla/network/esp_wifi.h>
#include <supla/device/status_led.h>
#include <supla/storage/littlefs_config.h>
#include <supla/network/esp_web_server.h>
#include <supla/network/html/device_info.h>
#include <supla/network/html/protocol_parameters.h>
#include <supla/network/html/status_led_parameters.h>
#include <supla/network/html/wifi_parameters.h>
#include <supla/device/supla_ca_cert.h>
#include <supla/events.h>
#include <supla/storage/eeprom.h>
Supla::Eeprom eeprom;
Supla::ESPWifi wifi;//TP-LINK_B6CF2F", "98316410

#define kran_otw_gar 2   //D4
#define ONE_WIRE D1
#define STATUS_LED_GPIO LED_BUILTIN
#define BUTTON_CFG_RELAY_GPIO 4       //D2


Supla::LittleFsConfig configSupla;
Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true); // inverted state
Supla::EspWebServer suplaServer;
Supla::Html::DeviceInfo htmlDeviceInfo(&SuplaDevice);
Supla::Html::WifiParameters htmlWifi;
Supla::Html::ProtocolParameters htmlProto;
Supla::Html::StatusLedParameters htmlStatusLed;

void setup() {
  Serial.begin(9600);
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
  char GUID[SUPLA_GUID_SIZE] = {xxxxx};

  // Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
  char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {xxxx};
   //wifi.enableSSL(false);
   auto buttonCfgRelay =
    new Supla::Control::Button(BUTTON_CFG_RELAY_GPIO, true, true);

  buttonCfgRelay->configureAsConfigButton(&SuplaDevice);
 // configure defualt Supla CA certificate
  SuplaDevice.setSuplaCACert(suplaCACert);
  SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert);
  
  auto re1 = new Supla::Control::Relay(D5, false);
  auto re2 = new Supla::Control::Relay(D6, false);
  auto re3 = new Supla::Control::Relay(D7, false);
  auto re4 = new Supla::Control::Relay(D8, false);

  new Supla::Sensor::DS18B20(ONE_WIRE);
  new Supla::Sensor::Binary(kran_otw_gar, true);//D4 pullUp

  SuplaDevice.begin(GUID,              // Global Unique Identifier 
                    "svr73.supla.org",  // SUPLA server address
                    "xxx",   // Email address used to login to Supla Cloud
                    AUTHKEY);          // Authorization key
}

void loop() {
   SuplaDevice.iterate();

}
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
lukfud
Posts: 2480
Joined: Thu Nov 23, 2017 11:33 pm
Location: Warszawa
Has thanked: 13 times
Been thanked: 11 times

Post

Dodając:

Code: Select all

#include <supla/network/esp_web_server.h>
Supla::EspWebServer suplaServer;
#include <ESP8266HTTPUpdateServer.h>
ESP8266HTTPUpdateServer httpUpdater;
void setup() {
  httpUpdater.setup(suplaServer.getServerPtr(), "/update");
}
będzie możliwość aktualizacji pod adresem http://192.168.4.1/update

Generowanie GUID w WebI jest automatyczne i nie masz na to wpływu ;)
https://www.facebook.com/groups/supladiy
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Czyli to:

Code: Select all

// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
  char GUID[SUPLA_GUID_SIZE] = {xxxxx};

  // Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
  char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {xxxx};
mogę wyrzucić z mojego kodu?

Teraz będę musiał na nowo ustawić całe urządzenie w cloud?
Czy po każdorazowym wejściu w tryb konfiguracyjny i zmianie np. nazwy i hasła do wifi, będzie trzeba na nowo konfigurowac urządzenie w cloud? Raczej nie.(?)
No i w końcu jak przebiega ta aktualizacja przez OTA po dopisaniu tych linijek? Jakie narzędzia? Arduino IDE?
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
lukfud
Posts: 2480
Joined: Thu Nov 23, 2017 11:33 pm
Location: Warszawa
Has thanked: 13 times
Been thanked: 11 times

Post

Tak, możesz wyrzucić te linie.
Klucze (guid, authkey) generują się tylko przy pierwszych uruchomieniu i usunąć je możesz czyszcząc flash.

Co masz na myśli pisząc OTA, bo w tych kilku liniach odnośnie aktualizacji zawarta jest odpowiedź na Twoje pytanie ;)
https://www.facebook.com/groups/supladiy
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

lukfud wrote: Sat Jan 20, 2024 11:48 am Tak, możesz wyrzucić te linie.
Klucze (guid, authkey) generują się tylko przy pierwszych uruchomieniu i usunąć je możesz czyszcząc flash.

Co masz na myśli pisząc OTA, bo w tych kilku liniach odnośnie aktualizacji zawarta jest odpowiedź na Twoje pytanie ;)
Może Ty coś widzisz w tych liniach, ale uwierz mi ja nic tam nie widzę :D :?
Mając na mysli OTA, myślę o OTA takim jak go używałem w innych projektach na nodemcu, czyli po odpaleniu arduino IDE urządzenie było widoczne pod konkretną nazwą w zakładce "port".
Np:

Code: Select all

#include <ArduinoOTA.h>
 ArduinoOTA.setHostname("PMS5003_ESP");   
  ArduinoOTA.begin();  
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79

Return to “Pomoc”