From 5387d531e09141ddd6ae35a433b9e7a83ccf75cc Mon Sep 17 00:00:00 2001 From: SmartUaWIn Date: Fri, 19 Mar 2021 23:13:43 +0200 Subject: [PATCH] =?UTF-8?q?=D0=BA=D1=83=D1=85=D0=BD=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=81=D1=87=D0=BB=D0=B5=D0=B4=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AAOffice_kitchen.ino | 88 ++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/AAOffice_kitchen.ino b/AAOffice_kitchen.ino index 398e08f..bbd89bd 100644 --- a/AAOffice_kitchen.ino +++ b/AAOffice_kitchen.ino @@ -1,7 +1,7 @@ /* Отправка данных на MQTT про обновление */ - + #include // https://github.com/tzapu/WiFiManager #include //Сохранение настроек хеша прошивки @@ -32,7 +32,7 @@ byte errorID = 0; //Сбор и вывод ошибок //5 WiFiManager wm; // обьект менеджера -WiFiManagerParameter custom_field; +//WiFiManagerParameter custom_field; Preferences OTApreferences; //Обьект хранения настроек хеша прошивки StaticJsonDocument<200> doc; @@ -43,6 +43,7 @@ IPAddress IpMqtt; WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP, "0.ua.pool.ntp.org", 7200, 60000); //Собственно сервер времени смещение и частоат запроса, но он вручную +const char *wmhostname="KitchenWater"; const PROGMEM char *willmess = "{\"conn\":\"err\"}"; const PROGMEM char *mqttHostName = "cctv.automation.art"; //Хостнейм брокера 192.168.89.210 cctv.automation.art:8889 @@ -99,8 +100,6 @@ void setup() // FALLING – прерывание будет запущено, если значение на контакте изменится с «HIGH» на «LOW» // RISING – прерывание будет запущено, если значение на контакте изменится с «LOW» на «HIGH» - WiFi.mode(WIFI_STA); - Serial.setDebugOutput(true); String topicTemp = "aastudio/" + macc + "/data/0"; @@ -126,10 +125,10 @@ void setup() // 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 // test custom html(radio) - const char *custom_radio_str = "
One
Two
Three"; - new (&custom_field) WiFiManagerParameter(custom_radio_str); // custom html input - wm.addParameter(&custom_field); - wm.setSaveParamsCallback(saveParamCallback); + //const char *custom_radio_str = "
One
Two
Three"; + //new (&custom_field) WiFiManagerParameter(custom_radio_str); // custom html input + //wm.addParameter(&custom_field); + //wm.setSaveParamsCallback(saveParamCallback); // 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!) // const char* menu[] = {"wifi","info","param","sep","restart","exit"}; @@ -137,36 +136,38 @@ void setup() std::vector menu = {"wifi", "info", "param", "sep", "restart", "exit"}; wm.setMenu(menu); // set dark theme - wm.setClass("invert"); + wm.setClass("invert"); //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.setShowStaticFields(true); // force show static ip fields // wm.setShowDnsFields(true); // force show dns field always // 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.setAPClientCheck(true); // avoid timeout if client connected to softap // wifi scan settings // wm.setRemoveDuplicateAPs(false); // do not remove duplicate ap names (true) 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.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.setWiFiAutoReconnect(true); // if true, enable autoreconnecting + // wm.setWiFiAutoReconnect(true); // if true, enable autoreconnecting + // wm.setConfigPortalBlocking(false); + wm.setHostname(wmhostname); + wm.setConfigPortalBlocking(false); bool res; - // res = wm.autoConnect(); // auto generated AP name from chipid - // res = wm.autoConnect("AutoConnectAP"); // anonymous ap - res = wm.autoConnect("KitchenM5Portal", "12345678"); // Подключение к анонимной точке доступа - if (!res) - { - Serial.println("Failed to connect or hit timeout"); - //ESP.restart(); - } - else - { - Serial.println("connected - OK"); - } + + // res = wm.autoConnect("KitchenM5Portal", "12345678"); + // if (!res) + // { + // Serial.println("Failed to connect or hit timeout"); + // //ESP.restart(); + // } + // else + // { + // Serial.println("connected - OK"); + // } //Запрос IP сервера MQTT и установка сервера setMqttServer(); @@ -241,7 +242,11 @@ void checkButton() disconnectMQTT(); wm.resetSettings(); - ESP.restart(); + + // + wm.startConfigPortal(); + + // ESP.restart(); } String getParam(String name) @@ -254,12 +259,6 @@ String getParam(String name) return value; } -void saveParamCallback() -{ - //Serial.\println("[CALLBACK] saveParamCallback fired"); - //Serial.\println("PARAM customfieldid = " + getParam("customfieldid")); - getParam("customfieldid"); -} //Обновление прошивки, происходит проверка и загрузка //Делается Get запрос на хостинг проверяется хеш, если хеш @@ -410,7 +409,7 @@ int SendMqttReq(bool sendVal = true, bool sendStatus = true, byte statusConn = 1 if (sendStatus == true) { - char *conn; + const char *conn; switch (statusConn) { @@ -556,8 +555,8 @@ void loop() } // 40 секунд и происходит сброс настроек WIFI - if (M5.Btn.wasReleasefor(40000)) - { + if (M5.Btn.wasReleasefor(10000)) + { checkButton(); } @@ -577,8 +576,9 @@ void loop() } //Таймер отправки данных в брокер - + MqttClient.loop(); + wm.process(); } int disconnectMQTT() @@ -607,15 +607,15 @@ int buzAlarm(bool buzFlag) Serial.println(buzFlag); if (buzFlag == true) - { - digitalWrite(buzzerPin, HIGH); - delay(100); - digitalWrite(buzzerPin, LOW); - delay(100); - digitalWrite(buzzerPin, HIGH); - delay(200); - digitalWrite(buzzerPin, LOW); - delay(200); + { + // digitalWrite(buzzerPin, HIGH); + // delay(100); + // digitalWrite(buzzerPin, LOW); + // delay(100); + // digitalWrite(buzzerPin, HIGH); + // delay(200); + // digitalWrite(buzzerPin, LOW); + // delay(200); } else {