Moim zdaniem, można jeszcze dodać jeden przykład do katalogu "esp", nazwać go
Simple.
Przykład bazowy z minimalną ilością kodu, include, żeby był dostęp do CFG poprzez przycisk oraz automatycznie po wgraniu programu.
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.
*/
#define BUTTON_CFG_GPIO 0
#define STATUS_LED_GPIO 2
#include <SuplaDevice.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/control/button.h>
#include <supla/storage/eeprom.h>
Supla::Eeprom eeprom;
Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;
Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true); // inverted state
Supla::EspWebServer suplaServer;
auto buttonCfg = new Supla::Control::Button(BUTTON_CFG_GPIO, true, true);
void setup() {
Serial.begin(115200);
buttonCfg->configureAsConfigButton(&SuplaDevice);
// HTML www component
new Supla::Html::DeviceInfo(&SuplaDevice);
new Supla::Html::WifiParameters;
new Supla::Html::ProtocolParameters;
new Supla::Html::StatusLedParameters;
SuplaDevice.setInitialMode(Supla::InitialMode::StartInCfgMode);
SuplaDevice.begin();
}
void loop() {
SuplaDevice.iterate();
}