кухня посчледние изменения
parent
f18723883c
commit
5387d531e0
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Отправка данных на MQTT про обновление
|
Отправка данных на MQTT про обновление
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||||
#include <Preferences.h> //Сохранение настроек хеша прошивки
|
#include <Preferences.h> //Сохранение настроек хеша прошивки
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ byte errorID = 0; //Сбор и вывод ошибок
|
||||||
//5
|
//5
|
||||||
|
|
||||||
WiFiManager wm; // обьект менеджера
|
WiFiManager wm; // обьект менеджера
|
||||||
WiFiManagerParameter custom_field;
|
//WiFiManagerParameter custom_field;
|
||||||
Preferences OTApreferences; //Обьект хранения настроек хеша прошивки
|
Preferences OTApreferences; //Обьект хранения настроек хеша прошивки
|
||||||
StaticJsonDocument<200> doc;
|
StaticJsonDocument<200> doc;
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ IPAddress IpMqtt;
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP, "0.ua.pool.ntp.org", 7200, 60000); //Собственно сервер времени смещение и частоат запроса, но он вручную
|
NTPClient timeClient(ntpUDP, "0.ua.pool.ntp.org", 7200, 60000); //Собственно сервер времени смещение и частоат запроса, но он вручную
|
||||||
|
|
||||||
|
const char *wmhostname="KitchenWater";
|
||||||
const PROGMEM char *willmess = "{\"conn\":\"err\"}";
|
const PROGMEM char *willmess = "{\"conn\":\"err\"}";
|
||||||
|
|
||||||
const PROGMEM char *mqttHostName = "cctv.automation.art"; //Хостнейм брокера 192.168.89.210 cctv.automation.art:8889
|
const PROGMEM char *mqttHostName = "cctv.automation.art"; //Хостнейм брокера 192.168.89.210 cctv.automation.art:8889
|
||||||
|
@ -99,8 +100,6 @@ void setup()
|
||||||
// FALLING – прерывание будет запущено, если значение на контакте изменится с «HIGH» на «LOW»
|
// FALLING – прерывание будет запущено, если значение на контакте изменится с «HIGH» на «LOW»
|
||||||
// RISING – прерывание будет запущено, если значение на контакте изменится с «LOW» на «HIGH»
|
// RISING – прерывание будет запущено, если значение на контакте изменится с «LOW» на «HIGH»
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
|
||||||
|
|
||||||
Serial.setDebugOutput(true);
|
Serial.setDebugOutput(true);
|
||||||
|
|
||||||
String topicTemp = "aastudio/" + macc + "/data/0";
|
String topicTemp = "aastudio/" + macc + "/data/0";
|
||||||
|
@ -126,10 +125,10 @@ void setup()
|
||||||
// test custom html input type(checkbox)
|
// test custom html input type(checkbox)
|
||||||
// new (&custom_field) WiFiManagerParameter("customfieldid", "Custom Field Label", "Custom Field Value", customFieldLength,"placeholder=\"Custom Field Placeholder\" type=\"checkbox\""); // custom html type
|
// new (&custom_field) WiFiManagerParameter("customfieldid", "Custom Field Label", "Custom Field Value", customFieldLength,"placeholder=\"Custom Field Placeholder\" type=\"checkbox\""); // custom html type
|
||||||
// test custom html(radio)
|
// test custom html(radio)
|
||||||
const char *custom_radio_str = "<br/><label for='customfieldid'>Custom Field Label</label><input type='radio' name='customfieldid' value='1' checked> One<br><input type='radio' name='customfieldid' value='2'> Two<br><input type='radio' name='customfieldid' value='3'> Three";
|
//const char *custom_radio_str = "<br/><label for='customfieldid'>Custom Field Label</label><input type='radio' name='customfieldid' value='1' checked> One<br><input type='radio' name='customfieldid' value='2'> Two<br><input type='radio' name='customfieldid' value='3'> Three";
|
||||||
new (&custom_field) WiFiManagerParameter(custom_radio_str); // custom html input
|
//new (&custom_field) WiFiManagerParameter(custom_radio_str); // custom html input
|
||||||
wm.addParameter(&custom_field);
|
//wm.addParameter(&custom_field);
|
||||||
wm.setSaveParamsCallback(saveParamCallback);
|
//wm.setSaveParamsCallback(saveParamCallback);
|
||||||
// custom menu via array or vector
|
// custom menu via array or vector
|
||||||
// menu tokens, "wifi","wifinoscan","info","param","close","sep","erase","restart","exit" (sep is seperator) (if param is in menu, params will not show up in wifi page!)
|
// menu tokens, "wifi","wifinoscan","info","param","close","sep","erase","restart","exit" (sep is seperator) (if param is in menu, params will not show up in wifi page!)
|
||||||
// const char* menu[] = {"wifi","info","param","sep","restart","exit"};
|
// const char* menu[] = {"wifi","info","param","sep","restart","exit"};
|
||||||
|
@ -137,36 +136,38 @@ void setup()
|
||||||
std::vector<const char *> menu = {"wifi", "info", "param", "sep", "restart", "exit"};
|
std::vector<const char *> menu = {"wifi", "info", "param", "sep", "restart", "exit"};
|
||||||
wm.setMenu(menu);
|
wm.setMenu(menu);
|
||||||
// set dark theme
|
// set dark theme
|
||||||
wm.setClass("invert");
|
wm.setClass("invert");
|
||||||
//set static ip
|
//set static ip
|
||||||
// wm.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); // set static ip,gw,sn
|
// wm.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); // set static ip,gw,sn
|
||||||
// wm.setShowStaticFields(true); // force show static ip fields
|
// wm.setShowStaticFields(true); // force show static ip fields
|
||||||
// wm.setShowDnsFields(true); // force show dns field always
|
// wm.setShowDnsFields(true); // force show dns field always
|
||||||
// wm.setConnectTimeout(20); // how long to try to connect for before continuing
|
// wm.setConnectTimeout(20); // how long to try to connect for before continuing
|
||||||
wm.setConfigPortalTimeout(60); // auto close configportal after n seconds
|
// wm.setConfigPortalTimeout(60); // auto close configportal after n seconds
|
||||||
// wm.setCaptivePortalEnable(false); // disable captive portal redirection
|
// wm.setCaptivePortalEnable(false); // disable captive portal redirection
|
||||||
// wm.setAPClientCheck(true); // avoid timeout if client connected to softap
|
// wm.setAPClientCheck(true); // avoid timeout if client connected to softap
|
||||||
// wifi scan settings
|
// wifi scan settings
|
||||||
// wm.setRemoveDuplicateAPs(false); // do not remove duplicate ap names (true)
|
// wm.setRemoveDuplicateAPs(false); // do not remove duplicate ap names (true)
|
||||||
wm.setMinimumSignalQuality(10); // set min RSSI (percentage) to show in scans, null = 8%
|
wm.setMinimumSignalQuality(10); // set min RSSI (percentage) to show in scans, null = 8%
|
||||||
// wm.setShowInfoErase(false); // do not show erase button on info page
|
// wm.setShowInfoErase(false); // do not show erase button on info page
|
||||||
// wm.setScanDispPerc(true); // show RSSI as percentage not graph icons
|
wm.setScanDispPerc(true); // show RSSI as percentage not graph icons
|
||||||
// wm.setBreakAfterConfig(true); // always exit configportal even if wifi save fails
|
// wm.setBreakAfterConfig(true); // always exit configportal even if wifi save fails
|
||||||
wm.setWiFiAutoReconnect(true); // if true, enable autoreconnecting
|
// wm.setWiFiAutoReconnect(true); // if true, enable autoreconnecting
|
||||||
|
// wm.setConfigPortalBlocking(false);
|
||||||
|
wm.setHostname(wmhostname);
|
||||||
|
wm.setConfigPortalBlocking(false);
|
||||||
|
|
||||||
bool res;
|
bool res;
|
||||||
// res = wm.autoConnect(); // auto generated AP name from chipid
|
|
||||||
// res = wm.autoConnect("AutoConnectAP"); // anonymous ap
|
// res = wm.autoConnect("KitchenM5Portal", "12345678");
|
||||||
res = wm.autoConnect("KitchenM5Portal", "12345678"); // Подключение к анонимной точке доступа
|
// if (!res)
|
||||||
if (!res)
|
// {
|
||||||
{
|
// Serial.println("Failed to connect or hit timeout");
|
||||||
Serial.println("Failed to connect or hit timeout");
|
// //ESP.restart();
|
||||||
//ESP.restart();
|
// }
|
||||||
}
|
// else
|
||||||
else
|
// {
|
||||||
{
|
// Serial.println("connected - OK");
|
||||||
Serial.println("connected - OK");
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
//Запрос IP сервера MQTT и установка сервера
|
//Запрос IP сервера MQTT и установка сервера
|
||||||
setMqttServer();
|
setMqttServer();
|
||||||
|
@ -241,7 +242,11 @@ void checkButton()
|
||||||
|
|
||||||
disconnectMQTT();
|
disconnectMQTT();
|
||||||
wm.resetSettings();
|
wm.resetSettings();
|
||||||
ESP.restart();
|
|
||||||
|
//
|
||||||
|
wm.startConfigPortal();
|
||||||
|
|
||||||
|
// ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getParam(String name)
|
String getParam(String name)
|
||||||
|
@ -254,12 +259,6 @@ String getParam(String name)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveParamCallback()
|
|
||||||
{
|
|
||||||
//Serial.\println("[CALLBACK] saveParamCallback fired");
|
|
||||||
//Serial.\println("PARAM customfieldid = " + getParam("customfieldid"));
|
|
||||||
getParam("customfieldid");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Обновление прошивки, происходит проверка и загрузка
|
//Обновление прошивки, происходит проверка и загрузка
|
||||||
//Делается Get запрос на хостинг проверяется хеш, если хеш
|
//Делается Get запрос на хостинг проверяется хеш, если хеш
|
||||||
|
@ -410,7 +409,7 @@ int SendMqttReq(bool sendVal = true, bool sendStatus = true, byte statusConn = 1
|
||||||
|
|
||||||
if (sendStatus == true)
|
if (sendStatus == true)
|
||||||
{
|
{
|
||||||
char *conn;
|
const char *conn;
|
||||||
|
|
||||||
switch (statusConn)
|
switch (statusConn)
|
||||||
{
|
{
|
||||||
|
@ -556,8 +555,8 @@ void loop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 40 секунд и происходит сброс настроек WIFI
|
// 40 секунд и происходит сброс настроек WIFI
|
||||||
if (M5.Btn.wasReleasefor(40000))
|
if (M5.Btn.wasReleasefor(10000))
|
||||||
{
|
{
|
||||||
checkButton();
|
checkButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,8 +576,9 @@ void loop()
|
||||||
}
|
}
|
||||||
|
|
||||||
//Таймер отправки данных в брокер
|
//Таймер отправки данных в брокер
|
||||||
|
|
||||||
MqttClient.loop();
|
MqttClient.loop();
|
||||||
|
wm.process();
|
||||||
}
|
}
|
||||||
|
|
||||||
int disconnectMQTT()
|
int disconnectMQTT()
|
||||||
|
@ -607,15 +607,15 @@ int buzAlarm(bool buzFlag)
|
||||||
Serial.println(buzFlag);
|
Serial.println(buzFlag);
|
||||||
|
|
||||||
if (buzFlag == true)
|
if (buzFlag == true)
|
||||||
{
|
{
|
||||||
digitalWrite(buzzerPin, HIGH);
|
// digitalWrite(buzzerPin, HIGH);
|
||||||
delay(100);
|
// delay(100);
|
||||||
digitalWrite(buzzerPin, LOW);
|
// digitalWrite(buzzerPin, LOW);
|
||||||
delay(100);
|
// delay(100);
|
||||||
digitalWrite(buzzerPin, HIGH);
|
// digitalWrite(buzzerPin, HIGH);
|
||||||
delay(200);
|
// delay(200);
|
||||||
digitalWrite(buzzerPin, LOW);
|
// digitalWrite(buzzerPin, LOW);
|
||||||
delay(200);
|
// delay(200);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue