Skip to content
1 change: 1 addition & 0 deletions GUI-Generic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,6 @@ void setup() {

void loop() {
SuplaDevice.iterate();
delay(25);
drd.loop();
}
3 changes: 3 additions & 0 deletions GUI-Generic_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

// #define DEBUG_MODE

// Language en - english, pl - polish (default if not defined UI_LANGUAGE)
// #define UI_LANGUAGE en

#define SUPLA_RELAY
#define SUPLA_BUTTON
#define SUPLA_LIMIT_SWITCH
Expand Down
13 changes: 13 additions & 0 deletions GUIGenericCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef GUI_GENERIC_COMMON_H
#define GUI_GENERIC_COMMON_H

#ifndef UI_LANGUAGE
#include "language/pl.h"
#else
#define QUOTE(x) QUOTE_1(x)
#define QUOTE_1(x) #x
#define INCLUDE_FILE(x) QUOTE(language/x.h)
#include INCLUDE_FILE(UI_LANGUAGE)
#endif

#endif // GUI_GENERIC_COMMON_H
52 changes: 46 additions & 6 deletions SuplaCommonPROGMEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,51 @@
#include <pgmspace.h>
#include "SuplaDeviceGUI.h"

const char HTTP_META[] PROGMEM = "<!DOCTYPE HTML><meta http-equiv='content-type' content='text/html; charset=UTF-8'><meta name='viewport' content='width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no'>\n";
const char HTTP_STYLE[] PROGMEM = "<style>body{font-size:14px;font-family:HelveticaNeue,'Helvetica Neue',HelveticaNeueRoman,HelveticaNeue-Roman,'Helvetica Neue Roman',TeXGyreHerosRegular,Helvetica,Tahoma,Geneva,Arial,sans-serif;font-weight:400;font-stretch:normal;background:#00d151;color:#fff;line-height:20px;padding:0}.s{width:460px;margin:0 auto;margin-top:calc(50vh - 340px);border:solid 3px #fff;padding:0 10px 10px;border-radius:3px}#l{display:block;max-width:150px;height:155px;margin:-80px auto 20px;background:#00d151;padding-right:5px}#l path{fill:#000}.w{margin:3px 0 16px;padding:5px 0;border-radius:3px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3)}h1,h3{margin:10px 8px;font-family:HelveticaNeueLight,HelveticaNeue-Light,'Helvetica Neue Light',HelveticaNeue,'Helvetica Neue',TeXGyreHerosRegular,Helvetica,Tahoma,Geneva,Arial,sans-serif;font-weight:300;font-stretch:normal;color:#000;font-size:23px}h1{margin-bottom:14px;color:#fff}span{display:block;margin:10px 7px 14px}i{display:block;font-style:normal;position:relative;border-bottom:solid 1px #00d151;height:42px}i:last-child{border:none}label{position:absolute;display:inline-block;top:0;left:8px;color:#00d151;line-height:41px;}input,select{width:calc(100% - 145px);border:none;font-size:16px;line-height:40px;border-radius:0;letter-spacing:-.5px;background:#fff;color:#000;padding-left:143px;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:0!important;height:40px}select{padding:0;float:right;margin:1px 3px 1px 2px}button{width:100%;border:0;background:#000;padding:5px 10px;font-size:16px;line-height:40px;color:#fff;border-radius:3px;box-shadow:0 1px 3px rgba(0,0,0,.3);cursor:pointer}.c{background:#ffe836;position:fixed;width:100%;line-height:80px;color:#000;top:0;left:0;box-shadow:0 1px 3px rgba(0,0,0,.3);text-align:center;font-size:26px;z-index:100}@media all and (max-height:920px){.s{margin-top:80px}}@media all and (max-width:900px){.s{width:calc(100% - 20px);margin-top:40px;border:none;padding:0 8px;border-radius:0}#l{max-width:80px;height:auto;margin:10px auto 20px}h1,h3{font-size:19px}i{border:none;height:auto}label{display:block;margin:4px 0 12px;color:#00d151;font-size:13px;position:relative;line-height:18px}input,select{width:calc(100% - 10px);font-size:16px;line-height:28px;padding:0 5px;border-bottom:solid 1px #00d151}select{width:100%;float:none;margin:0}}</style>";
const char HTTP_LOGO[] PROGMEM = "<div class='s'><a href='/'><svg version='1.1' id='l' x='0' y='0' viewBox='0 0 200 200' xml:space='preserve'><path d='M59.3,2.5c18.1,0.6,31.8,8,40.2,23.5c3.1,5.7,4.3,11.9,4.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.3,76.4,80.3,76.5,81z M89,42.6c0.1-2.5-0.4-5.4-1.5-8.1C83,23.1,74.2,16.9,61.7,15.8c-10-0.9-18.6,2.4-25.3,9.7c-8.4,9-9.3,22.4-2.2,32.4c6.8,9.6,19.1,14.2,31.4,11.9C79.2,67.1,89,55.9,89,42.6z M102.1,188.6c0.6,0.1,1.5-0.1,2.4-0.2c9.5-1.4,15.3-10.9,11.6-19.2c-2.6-5.9-9.4-9.6-16.8-8.6c-8.3,1.2-14.1,8.9-12.4,16.6C88.2,183.9,94.4,188.6,102.1,188.6z M167.7,88.5c-1,0-2.1,0.1-3.1,0.3c-9,1.7-14.2,10.6-10.8,18.6c2.9,6.8,11.4,10.3,19,7.8c7.1-2.3,11.1-9.1,9.6-15.9C180.9,93,174.8,88.5,167.7,88.5z'/></a></svg>";
const char HTTP_META[] PROGMEM =
"<!DOCTYPE HTML><meta http-equiv='content-type' content='text/html; charset=UTF-8'><meta name='viewport' "
"content='width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no'>\n";
const char HTTP_STYLE[] PROGMEM =
"<style>body{font-size:14px;font-family:HelveticaNeue,'Helvetica Neue',HelveticaNeueRoman,HelveticaNeue-Roman,'Helvetica Neue "
"Roman',TeXGyreHerosRegular,Helvetica,Tahoma,Geneva,Arial,sans-serif;font-weight:400;font-stretch:normal;background:#00d151;color:#fff;line-"
"height:20px;padding:0}.s{width:460px;margin:0 auto;margin-top:calc(50vh - 340px);border:solid 3px #fff;padding:0 10px "
"10px;border-radius:3px}#l{display:block;max-width:150px;height:155px;margin:-80px auto 20px;background:#00d151;padding-right:5px}#l "
"path{fill:#000}.w{margin:3px 0 16px;padding:5px 0;border-radius:3px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3)}h1,h3{margin:10px "
"8px;font-family:HelveticaNeueLight,HelveticaNeue-Light,'Helvetica Neue Light',HelveticaNeue,'Helvetica "
"Neue',TeXGyreHerosRegular,Helvetica,Tahoma,Geneva,Arial,sans-serif;font-weight:300;font-stretch:normal;color:#000;font-size:23px}h1{margin-"
"bottom:14px;color:#fff}span{display:block;margin:10px 7px 14px}i{display:block;font-style:normal;position:relative;border-bottom:solid 1px "
"#00d151;height:42px}i:last-child{border:none}label{position:absolute;display:inline-block;top:0;left:8px;color:#00d151;line-height:41px;}input,"
"select{width:calc(100% - "
"145px);border:none;font-size:16px;line-height:40px;border-radius:0;letter-spacing:-.5px;background:#fff;color:#000;padding-left:143px;-webkit-"
"appearance:none;-moz-appearance:none;appearance:none;outline:0!important;height:40px}select{padding:0;float:right;margin:1px 3px 1px "
"2px}button{width:100%;border:0;background:#000;padding:5px 10px;font-size:16px;line-height:40px;color:#fff;border-radius:3px;box-shadow:0 1px "
"3px rgba(0,0,0,.3);cursor:pointer}.c{background:#ffe836;position:fixed;width:100%;line-height:80px;color:#000;top:0;left:0;box-shadow:0 1px 3px "
"rgba(0,0,0,.3);text-align:center;font-size:26px;z-index:100}@media all and (max-height:920px){.s{margin-top:80px}}@media all and "
"(max-width:900px){.s{width:calc(100% - 20px);margin-top:40px;border:none;padding:0 "
"8px;border-radius:0}#l{max-width:80px;height:auto;margin:10px auto "
"20px}h1,h3{font-size:19px}i{border:none;height:auto}label{display:block;margin:4px 0 "
"12px;color:#00d151;font-size:13px;position:relative;line-height:18px}input,select{width:calc(100% - "
"10px);font-size:16px;line-height:28px;padding:0 5px;border-bottom:solid 1px #00d151}select{width:100%;float:none;margin:0}}</style>";
const char HTTP_LOGO[] PROGMEM =
"<div class='s'><a href='/'><svg version='1.1' id='l' x='0' y='0' viewBox='0 0 200 200' xml:space='preserve'><path "
"d='M59.3,2.5c18.1,0.6,31.8,8,40.2,23.5c3.1,5.7,4.3,11.9,4.1,18.3c-0.1,3.6-0.7,7.1-1.9,10.6c-0.2,0.7-0.1,1.1,0.6,1.5c12.8,7.7,25.5,15.4,38.3,"
"23c2.9,1.7,5.8,3.4,8.7,5.3c1,0.6,1.6,0.6,2.5-0.1c4.5-3.6,9.8-5.3,15.7-5.4c12.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14.2,31.4,11.9C79."
"2,67.1,89,55.9,89,42.6z "
"M102.1,188.6c0.6,0.1,1.5-0.1,2.4-0.2c9.5-1.4,15.3-10.9,11.6-19.2c-2.6-5.9-9.4-9.6-16.8-8.6c-8.3,1.2-14.1,8.9-12.4,16.6C88.2,183.9,94.4,188.6,"
"102.1,188.6z "
"M167.7,88.5c-1,0-2.1,0.1-3.1,0.3c-9,1.7-14.2,10.6-10.8,18.6c2.9,6.8,11.4,10.3,19,7.8c7.1-2.3,11.1-9.1,9.6-15.9C180.9,93,174.8,88.5,167.7,88.5z'/"
"></a></svg>";
const char HTTP_SUMMARY[] PROGMEM = "<h1>{h}</h1><span>LAST STATE: {s}<br>Firmware: SuplaDevice {v}<br>GUID: {g}<br>MAC: {m}</span>\n";
const char HTTP_COPYRIGHT[] PROGMEM = "<a target='_blank' rel='noopener noreferrer' href='https://forum.supla.org/viewtopic.php?f=11&t=7133'><span style='color: #ffffff !important;'>https://forum.supla.org/</span></a>\n";
const char HTTP_COPYRIGHT[] PROGMEM =
"<a target='_blank' rel='noopener noreferrer' href='https://forum.supla.org/viewtopic.php?f=11&t=7133'><span style='color: #ffffff "
"!important;'>https://forum.supla.org/</span></a>\n";

const char GPIO0[] PROGMEM = "GPIO0-D3";
const char GPIO1[] PROGMEM = "GPIO1-TX";
Expand All @@ -26,7 +66,8 @@ const char OFF[] PROGMEM = "OFF";
const char ON[] PROGMEM = "ON";
const char GPIONULL[] PROGMEM = "";

const char* const GPIO_P[] PROGMEM = {GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIONULL, GPIONULL, GPIONULL, GPIO9, GPIO10, GPIONULL, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, OFF};
const char* const GPIO_P[] PROGMEM = {GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIONULL, GPIONULL, GPIONULL,
GPIO9, GPIO10, GPIONULL, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, OFF};

const char ADR44[] PROGMEM = "0x44";
const char ADR45[] PROGMEM = "0x45";
Expand All @@ -44,7 +85,6 @@ const char ODWROCONE[] PROGMEM = "LOW";
const char NORMALNE[] PROGMEM = "HIGH";
const char* const LEVEL_P[] PROGMEM = {ODWROCONE, NORMALNE};

//const char WYLACZONY[] PROGMEM = "WYŁĄCZONY";
const char PAMIETAJSTAN[] PROGMEM = "PAMIĘTAJ STAN";
const char* const MEMORY_P[] PROGMEM = {OFF, ON, PAMIETAJSTAN};

Expand Down
2 changes: 1 addition & 1 deletion SuplaConfigESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void SuplaConfigESP::runAction(int event, int action) {
}
countPresses++;

if (countPresses == 3) {
if (countPresses == 10) {
// Serial.println(F("CONFIG_MODE_3_PRESSES"));
configModeInit();
countPresses = 0;
Expand Down
1 change: 1 addition & 0 deletions SuplaConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ SuplaConfigManager::SuplaConfigManager() {
this->addKey(KEY_MAX_DHT22, "1", 2);
this->addKey(KEY_MAX_DHT11, "1", 2);
this->addKey(KEY_MULTI_MAX_DS18B20, "1", 2);
this->addKey(KEY_ALTITUDE_BME280, "0", 4);

int nr;
String key;
Expand Down
134 changes: 68 additions & 66 deletions SuplaConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,47 @@
#ifndef SuplaConfigManager_h
#define SuplaConfigManager_h

#define DEFAULT_HOSTNAME "GUI Generic"

#define DEFAULT_LOGIN "admin"
#define DEFAULT_LOGIN_PASS "pass"

#define DEFAULT_SERVER "svrX.supla.org"
#define DEFAULT_EMAIL "email@address.com"

#define KEY_SUPLA_GUID "GUID"
#define KEY_SUPLA_AUTHKEY "AUTHKEY"
#define KEY_WIFI_SSID "wifiSSID"
#define KEY_WIFI_PASS "wifiPass"
#define KEY_LOGIN "login"
#define KEY_LOGIN_PASS "loginPass"
#define KEY_HOST_NAME "hostName"
#define KEY_SUPLA_SERVER "suplaServer"
#define KEY_SUPLA_EMAIL "suplaEmail"
#define KEY_DS "ds"
#define KEY_DS_NAME "dsName"
#define KEY_MULTI_MAX_DS18B20 "multiMaxDs"
#define KEY_SUPLA_FUNCTION "function"
#define KEY_MAX_RELAY "maxRelay"
#define KEY_MAX_BUTTON "maxButton"
#define KEY_MAX_LIMIT_SWITCH "maxLimitSwitch"
#define KEY_MAX_DHT11 "maxDht11"
#define KEY_MAX_DHT22 "maxDht22"
#define KEY_MAX_ROLLERSHUTTER "maxRollerShutter"
#define KEY_ALTITUDE_BME280 "altbme280"
#define KEY_ACTIVE_SENSOR "senor"
#define KEY_BOARD "board"

#define GPIO "GPIO"
#define SEPARATOR ','

enum _settings {
NR,
FUNCTION,
LEVEL,
MEMORY,
CFG
#define DEFAULT_HOSTNAME "GUI Generic"

#define DEFAULT_LOGIN "admin"
#define DEFAULT_LOGIN_PASS "pass"

#define DEFAULT_SERVER "svrX.supla.org"
#define DEFAULT_EMAIL "email@address.com"

#define KEY_SUPLA_GUID "GUID"
#define KEY_SUPLA_AUTHKEY "AUTHKEY"
#define KEY_WIFI_SSID "wifiSSID"
#define KEY_WIFI_PASS "wifiPass"
#define KEY_LOGIN "login"
#define KEY_LOGIN_PASS "loginPass"
#define KEY_HOST_NAME "hostName"
#define KEY_SUPLA_SERVER "suplaServer"
#define KEY_SUPLA_EMAIL "suplaEmail"
#define KEY_DS "ds"
#define KEY_DS_NAME "dsName"
#define KEY_MULTI_MAX_DS18B20 "multiMaxDs"
#define KEY_SUPLA_FUNCTION "function"
#define KEY_MAX_RELAY "maxRelay"
#define KEY_MAX_BUTTON "maxButton"
#define KEY_MAX_LIMIT_SWITCH "maxLimitSwitch"
#define KEY_MAX_DHT11 "maxDht11"
#define KEY_MAX_DHT22 "maxDht22"
#define KEY_MAX_ROLLERSHUTTER "maxRollerShutter"
#define KEY_ALTITUDE_BME280 "altbme280"
#define KEY_ACTIVE_SENSOR "sensor"
#define KEY_BOARD "board"

#define GPIO "GPIO"
#define SEPARATOR ','

enum _settings
{
NR,
FUNCTION,
LEVEL,
MEMORY,
CFG
};

enum _function
Expand All @@ -80,34 +81,35 @@ enum _function
FUNCTION_D0
};

#define MAX_GUID SUPLA_GUID_SIZE
#define MAX_AUTHKEY SUPLA_GUID_SIZE
#define MAX_SSID 32
#define MAX_PASSWORD 64
#define MIN_PASSWORD 8
#define MAX_MLOGIN 32
#define MAX_MPASSWORD 64
#define MAX_HOSTNAME 32
#define MAX_SUPLA_SERVER SUPLA_SERVER_NAME_MAXSIZE
#define MAX_EMAIL SUPLA_EMAIL_MAXSIZE
#define MAX_DS18B20_ADDRESS_HEX 16
#define MAX_DS18B20_ADDRESS 8
#define MAX_DS18B20_NAME 8
#define MAX_TYPE_BUTTON 4
#define MAX_MONOSTABLE_TRIGGER 1
#define MAX_FUNCTION 1
#define MAX_DS18B20 10

enum _e_onfig {
E_CONFIG_OK,
E_CONFIG_FS_ACCESS,
E_CONFIG_FILE_NOT_FOUND,
E_CONFIG_FILE_OPEN,
E_CONFIG_PARSE_ERROR,
E_CONFIG_MAX
#define MAX_GUID SUPLA_GUID_SIZE
#define MAX_AUTHKEY SUPLA_GUID_SIZE
#define MAX_SSID 32
#define MAX_PASSWORD 64
#define MIN_PASSWORD 8
#define MAX_MLOGIN 32
#define MAX_MPASSWORD 64
#define MAX_HOSTNAME 32
#define MAX_SUPLA_SERVER SUPLA_SERVER_NAME_MAXSIZE
#define MAX_EMAIL SUPLA_EMAIL_MAXSIZE
#define MAX_DS18B20_ADDRESS_HEX 16
#define MAX_DS18B20_ADDRESS 8
#define MAX_DS18B20_NAME 8
#define MAX_TYPE_BUTTON 4
#define MAX_MONOSTABLE_TRIGGER 1
#define MAX_FUNCTION 1
#define MAX_DS18B20 10

enum _e_onfig
{
E_CONFIG_OK,
E_CONFIG_FS_ACCESS,
E_CONFIG_FILE_NOT_FOUND,
E_CONFIG_FILE_OPEN,
E_CONFIG_PARSE_ERROR,
E_CONFIG_MAX
};

#define CONFIG_MAX_OPTIONS 88
#define CONFIG_MAX_OPTIONS 88

class ConfigOption {
public:
Expand Down
68 changes: 39 additions & 29 deletions SuplaGuiWiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,46 @@ class GUIESPWifi : public Supla::ESPWifi {

void setup() {
if (ConfigESP->configModeESP == NORMAL_MODE) {
gotIpEventHandler = WiFi.onStationModeGotIP([](const WiFiEventStationModeGotIP &event) {
Serial.print(F("local IP: "));
Serial.println(WiFi.localIP());
Serial.print(F("subnetMask: "));
Serial.println(WiFi.subnetMask());
Serial.print(F("gatewayIP: "));
Serial.println(WiFi.gatewayIP());
long rssi = WiFi.RSSI();
Serial.print(F("Signal strength (RSSI): "));
Serial.print(rssi);
Serial.println(F(" dBm"));
});
disconnectedEventHandler =
WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected &event) { Serial.println(F("WiFi station disconnected")); });

Serial.print(F("WiFi: establishing connection with SSID: \""));
Serial.print(ssid);
Serial.println(F("\""));
WiFi.hostname(hostname);
Serial.print(F("Host name: "));
Serial.println(WiFi.hostname());

WiFi.softAPdisconnect(true);
WiFi.setAutoConnect(false);
WiFi.mode(WIFI_STA);

if (!isReady()) {
WiFi.begin(ssid, password);
if (!wifiConfigured) {
wifiConfigured = true;
gotIpEventHandler = WiFi.onStationModeGotIP([](const WiFiEventStationModeGotIP &event) {
Serial.print(F("local IP: "));
Serial.println(WiFi.localIP());
Serial.print(F("subnetMask: "));
Serial.println(WiFi.subnetMask());
Serial.print(F("gatewayIP: "));
Serial.println(WiFi.gatewayIP());
long rssi = WiFi.RSSI();
Serial.print(F("Signal strength (RSSI): "));
Serial.print(rssi);
Serial.println(F(" dBm"));
});
disconnectedEventHandler =
WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected &event) { Serial.println(F("WiFi station disconnected")); });

Serial.print(F("WiFi: establishing connection with SSID: \""));
Serial.print(ssid);
Serial.println(F("\""));
WiFi.hostname(hostname);
Serial.print(F("Host name: "));
Serial.println(WiFi.hostname());

WiFi.softAPdisconnect(true);
WiFi.setAutoConnect(false);
WiFi.mode(WIFI_STA);

if (!isReady()) {
WiFi.begin(ssid, password);
}
}
else {
Serial.println(F("WiFi: resetting WiFi connection"));
if (client) {
delete client;
client = nullptr;
}
WiFi.reconnect();
}

yield();
}
}
Expand Down
Loading