Więc, oficjalny przykład WebInterface
Code: Select all
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* This example shows ESP82xx/ESP32 based device with simple WebInterface
* used to configure Wi-Fi parameters and Supla server connection.
* There is one RollerShutter, one Relay and 3 buttons configured.
* Two buttons are for roller shutter with Action Trigger.
* Third button is for controlling the relay and for switching module to
* config mode.
* After fresh installation, device will be in config mode. It will have its
* own Wi-Fi AP configured. You should connect to it with your mobile phone
* and open http://192.168.4.1 where you can configure the device.
* Status LED is also configured. Please adjust GPIOs to your HW.
*/
#define STATUS_LED_GPIO 2
#define ROLLER_SHUTTER_UP_RELAY_GPIO 4
#define ROLLER_SHUTTER_DOWN_RELAY_GPIO 5
#define RELAY_GPIO 12
#define BUTTON_UP_GPIO 13
#define BUTTON_DOWN_GPIO 14
#define BUTTON_CFG_RELAY_GPIO 0
#include <SuplaDevice.h>
#include <supla/network/esp_wifi.h>
#include <supla/control/roller_shutter.h>
#include <supla/control/relay.h>
#include <supla/control/button.h>
#include <supla/control/action_trigger.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/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;
void setup() {
Serial.begin(115200);
// HTML www component
new Supla::Html::DeviceInfo(&SuplaDevice);
new Supla::Html::WifiParameters;
new Supla::Html::ProtocolParameters;
new Supla::Html::StatusLedParameters;
// Channels configuration
// CH 0 - Roller shutter
auto rs = new Supla::Control::RollerShutter(
ROLLER_SHUTTER_UP_RELAY_GPIO, ROLLER_SHUTTER_DOWN_RELAY_GPIO, true);
// CH 1 - Relay
auto r1 = new Supla::Control::Relay(RELAY_GPIO);
// CH 2 - Action trigger
auto at1 = new Supla::Control::ActionTrigger();
// CH 3 - Action trigger
auto at2 = new Supla::Control::ActionTrigger();
// CH 4 - Action trigger
auto at3 = new Supla::Control::ActionTrigger();
// Buttons configuration
auto buttonOpen = new Supla::Control::Button(BUTTON_UP_GPIO, true, true);
auto buttonClose = new Supla::Control::Button(BUTTON_DOWN_GPIO, true, true);
auto buttonCfgRelay =
new Supla::Control::Button(BUTTON_CFG_RELAY_GPIO, true, true);
buttonOpen->addAction(Supla::OPEN_OR_STOP, *rs, Supla::ON_PRESS);
buttonOpen->setHoldTime(1000);
buttonOpen->setMulticlickTime(300);
buttonClose->addAction(Supla::CLOSE_OR_STOP, *rs, Supla::ON_PRESS);
buttonClose->setHoldTime(1000);
buttonClose->setMulticlickTime(300);
buttonCfgRelay->configureAsConfigButton(&SuplaDevice);
buttonCfgRelay->addAction(Supla::TOGGLE, r1, Supla::ON_CLICK_1);
// Action trigger configuration
at1->setRelatedChannel(rs);
at1->attach(buttonOpen);
at2->setRelatedChannel(rs);
at2->attach(buttonClose);
at3->setRelatedChannel(r1);
at3->attach(buttonCfgRelay);
SuplaDevice.setInitialMode(Supla::InitialMode::StartInCfgMode);
SuplaDevice.begin();
}
void loop() {
SuplaDevice.iterate();
}
platformio.ini
Code: Select all
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =
https://github.com/SUPLA/supla-device.git
logi:
Code: Select all
Button[0] setHoldTime: 5000
Button[0] setMulticlickTime: 300
GPM[3]: DefaultUnitAfterValue "B"
GPM[4]: DefaultUnitAfterValue "B"
GPM[4]: DefaultUnitAfterValue "KB"
GPM[4]: DefaultValueDivider 1024
*** Supla - starting initialization (platform 0)
Clock not configured, using default clock
SD: add flag DEVICE_CONFIG_SUPPORTED
SD: add flag CALCFG_RESTART_DEVICE
Storage initialization
readStorage: 8; Read: [53 55 50 4C 41 1 0 1 ]
Storage: Number of sections 1
Reading section: 0
readStorage: 7; Read: [3 0 0 0 0 0 0 ]
Section type: 3; size: 0
storedCRC 0, CRC calc 65535
LittleFsConfig: file "/supla-dev.cfg" size 450
LittleFsConfig: initializing storage from file...
LittleFsConfig: init result success
*** Supla - Config initalization
SD: add flag CALCFG_ENTER_CFG_MODE
SD: add flag CALCFG_FACTORY_RESET_SUPPORTED
Automatic firmware update is disabled
Device mode: 0
Security level: Supla CA
*** Supla - Config load for elements
SD: add flag CALCFG_IDENTIFY_DEVICE
RemoteDeviceConfig: Registering field 0x000000001
Channel[0] function missing. Using SW defaults
Channel[1] function missing. Using SW defaults
Button[0] don't load config
GPM[3]: config loaded successfully
GPM[3]: RefreshIntervalMs 5000 ms
GPM[4]: config loaded successfully
GPM[4]: RefreshIntervalMs 5000 ms
RemoteDeviceConfig: Registering field 0x000000010
Clock: automaticTimeSync: 1
*** Supla - Config load for elements done
*** Supla - Load state storage
Validating storage state section with current device configuration
Element state section size doesn't match current device configuration
*** Supla - Load state storage done
*** Supla - Init elements
Relay[0] turn OFF (duration 0 ms)
Relay[1] turn OFF (duration 0 ms)
**** Digital write[1], gpio: 255; value 0
Relay[1] turn OFF (duration 0 ms)
**** Digital write[1], gpio: 255; value 0
Relay[1] init done, storedTurnOnDurationMs 0
Button[0]: Initialized: pin 0, pullUp 1, invertLogic 1, state 1
Channel(3) value changed to 27608.00
Channel(4) value changed to 27608.00
*** Supla - Init elements done
GUID: 7215BD6CF1424B65A913935CF6CF727E
Device name: IRCloner
Device software version: SDK 25.10.02-dev
*** Supla - Initializing network layer
[Wi-Fi] Network AP/hostname: IRCLONER-F4CFA2D7CCF5
Using Supla protocol version 23
Current status: [5] SuplaDevice initialized
Enter normal mode
[Wi-Fi] setNormalMode
*** Supla - Initialization done
*** Self-test ***
TEST: ManufacturerID is 0
TEST failed: ProductID is empty
TEST failed: missing public RSA key
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (3):
epc1=0x4021123a epc2=0x00000000 epc3=0x00000000 excvaddr=0x40280172 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffdb0 end: 3fffffd0 offset: 0150
3fffff00: 3fff3b90 00000000 3fff51dc 3fff51dc
3fffff10: 00000000 00000001 3fff2e04 4020c42f
3fffff20: 35313237 43364442 32343146 35364234
3fffff30: 33313941 43353339 46433646 45373237
3fffff40: 43524900 454e4f4c 00000052 00000000
3fffff50: 00000000 00000000 00000000 00000000
3fffff60: 3fff4800 40208642 00000012 3ffe8c24
3fffff70: 3fff4920 00000000 00000012 3fff42ac
3fffff80: 3fff433c 3fff4884 3fff2e04 4020867c
3fffff90: 00000000 00657461 00000000 feefeffe
3fffffa0: feefeffe feefeffe feefeffe 3fff33d0
3fffffb0: 3fffdad0 00000000 3fff33a4 40227188
3fffffc0: feefeffe feefeffe 3fffdab0 40100ed1
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v0009a5a0
~ld
��␃�␛�g�r��g|�␄l␄�␌d`␃␜c�␒␃␄�|␂{�␃d�g�␌�g�␀␌l`␃��{�l�$␓�␄␌␄�
I dalej resety.
Próbowałem też na esp32 jak zasugerował kolega Zibi i tam działa. Nadmienić muszę że też nie obyło się bez problemów bo cytując pare postów wyżej kolegę zzrr:
Przy próbie kompilacji programu zgłasza mi błąd
identyfikator "mbedtls_pkcs5_pbkdf2_hmac_ext" jest niezdefiniowany
i kieruje mnie do funkcji
bool Supla::Crypto::pbkdf2Sha256(const char *password,... w pliku crypto.cpp.
klew pisze: 04 paź 2025, 18:29
Ogólnie możesz też z pliku crypto.cpp w SD wyrzucić od linii 36 do 54 oraz 63. Wtedy zostanie pusta niezaimplenentowana metoda i tyle.
Ta metoda jest obecnie używana tylko do zapisywania "hasha" hasła do web interface (używane tylko na kompilacjach z esp-idf i w zasadzie tylko na komercyjnych urządzeniach).
No ale co esp8266 nie bedzie już działać?