diff --git a/AAOffice_ventatom/AAOffice_ventatom.ino b/AAOffice_ventatom/AAOffice_ventatom.ino index 02f0c63..7510155 100644 --- a/AAOffice_ventatom/AAOffice_ventatom.ino +++ b/AAOffice_ventatom/AAOffice_ventatom.ino @@ -22,11 +22,12 @@ #define TRIGGER_PIN 39 #define SERVO_PIN 33 -unsigned int VersionSW = 4; //65536 Версия прошивки +unsigned int VersionSW = 5; //65536 Версия прошивки //2 поиск по metrics local //3 - -//4 - тестовая для проверки загрузки прошивки +//4 - тестовая для проверки загрузки прошивки +//5 - логин и пароль Servo servoAir; int posServo = 0; @@ -44,19 +45,19 @@ StaticJsonDocument<200> doc, docResult; WiFiClient espClient; PubSubClient MqttClient(espClient); -WiFiUDP ntpUDP; -NTPClient timeClient(ntpUDP, "0.ua.pool.ntp.org", 7200, 60000); //Собственно сервер времени смещение и частоат запроса, но он вручную - +WiFiUDP ntpUDP; +NTPClient timeClient(ntpUDP, "192.168.89.210", 0, 30000); //Собственно сервер времени смещение и частоат запроса, но он вручную + const char *spacePref = "ota-config"; const PROGMEM char *mqttHostName = "metrics"; //Хостнейм брокера 192.168.89.210 cctv.automation.art:8889 unsigned int mqttPort = 1883; //Порт брокера 1883 -const PROGMEM char *mqttLogin = NULL, //Логин пароль - необходимо сменить код при connect() - *mqttPass = NULL; +const PROGMEM char *mqttLogin = "AA_Lab", //Логин пароль - необходимо сменить код при connect() + *mqttPass = "automation.art$"; const char *mqttIPHost; //тут хранится IP хоста по хостнейму unsigned long timingUpdate, timingReqSensor, timingSendMqtt, timingAjaxUpdate; //Таймеры для millis() -int PROGMEM nextM5Update = 450000; //каждые 7.5 минут запрос обновления с сервера +int PROGMEM nextM5Update = 60000; //450000 //каждые 7.5 минут запрос обновления с сервера String getMacAddress(); String macc = getMacAddress(); @@ -128,9 +129,9 @@ void setup() std::vector menu = {"wifi", "info", "param", "sep", "restart", "exit"}; wm.setMenu(menu); wm.setClass("invert"); - wm.setConfigPortalTimeout(90); // auto close configportal after n seconds + wm.setConfigPortalTimeout(30); // auto close configportal after n seconds wm.setWiFiAutoReconnect(true); - bool res; + bool res; res = wm.autoConnect("AirAnglePortal", "12345678"); // Подключение к анонимной точке доступа if (!res) { @@ -208,10 +209,12 @@ void firstStart() void moveServo(int SetAngleTmp, int SpeedAngleTmp, int posServoTmp) { - servoAir.attach(SERVO_PIN); + if ((SetAngleTmp >= 0 && SetAngleTmp <= 100) && (SpeedAngleTmp >= 0 && SpeedAngleTmp <= 50)) { + servoAir.attach(SERVO_PIN); + MapAngle = map(SetAngleTmp, 0, 100, 2, 178); // 544 мкс — для 0° и 2400 мкс — для 180°. @@ -247,8 +250,11 @@ void moveServo(int SetAngleTmp, int SpeedAngleTmp, int posServoTmp) Serial.println(posServo); OTApreferences.end(); + + servoAir.detach(); + } - servoAir.detach(); + } //Функция получения данных из MQTT если мы подпишемся на топики @@ -493,7 +499,7 @@ void reconnectMqtt() const char *clientId = macc.c_str(); //macc += String(random(0xffff), HEX); - if (MqttClient.connect(clientId, bufWillTopic, 2, true, "OFFLINE")) //mqttLogin, mqttPass + if (MqttClient.connect(clientId, mqttLogin, mqttPass, bufWillTopic, 2, true, "OFFLINE")) //mqttLogin, mqttPass { MqttClient.publish(bufTopic, "CONNECTED", true); MqttClient.publish(bufWillTopic, "ONLINE", true); @@ -518,7 +524,7 @@ void reconnectMqtt() 5 : MQTT_CONNECT_UNAUTHORIZED - the client was not authorized to connect */ mqttSendFlag = false; - delay(3000); + delay(2000); } } } diff --git a/AAOffice_ventatom/AAOffice_ventatom.ino.m5stick_c.bin b/AAOffice_ventatom/AAOffice_ventatom.ino.m5stick_c.bin index fa07824..10c7daf 100644 Binary files a/AAOffice_ventatom/AAOffice_ventatom.ino.m5stick_c.bin and b/AAOffice_ventatom/AAOffice_ventatom.ino.m5stick_c.bin differ diff --git a/AAOffice_ventatom/~$кумент Microsoft Word.docx b/AAOffice_ventatom/~$кумент Microsoft Word.docx deleted file mode 100644 index c654af8..0000000 Binary files a/AAOffice_ventatom/~$кумент Microsoft Word.docx and /dev/null differ diff --git a/AAOffice_ventatom/Документ Microsoft Word.docx b/AAOffice_ventatom/Документ Microsoft Word.docx index e69de29..55848e2 100644 Binary files a/AAOffice_ventatom/Документ Microsoft Word.docx and b/AAOffice_ventatom/Документ Microsoft Word.docx differ