Последний код перед отправкой
parent
4196da49c3
commit
4c17c8034b
|
@ -22,11 +22,12 @@
|
||||||
#define TRIGGER_PIN 39
|
#define TRIGGER_PIN 39
|
||||||
#define SERVO_PIN 33
|
#define SERVO_PIN 33
|
||||||
|
|
||||||
unsigned int VersionSW = 4; //65536 Версия прошивки
|
unsigned int VersionSW = 5; //65536 Версия прошивки
|
||||||
|
|
||||||
//2 поиск по metrics local
|
//2 поиск по metrics local
|
||||||
//3 -
|
//3 -
|
||||||
//4 - тестовая для проверки загрузки прошивки
|
//4 - тестовая для проверки загрузки прошивки
|
||||||
|
//5 - логин и пароль
|
||||||
|
|
||||||
Servo servoAir;
|
Servo servoAir;
|
||||||
int posServo = 0;
|
int posServo = 0;
|
||||||
|
@ -45,18 +46,18 @@ WiFiClient espClient;
|
||||||
PubSubClient MqttClient(espClient);
|
PubSubClient MqttClient(espClient);
|
||||||
|
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP, "0.ua.pool.ntp.org", 7200, 60000); //Собственно сервер времени смещение и частоат запроса, но он вручную
|
NTPClient timeClient(ntpUDP, "192.168.89.210", 0, 30000); //Собственно сервер времени смещение и частоат запроса, но он вручную
|
||||||
|
|
||||||
const char *spacePref = "ota-config";
|
const char *spacePref = "ota-config";
|
||||||
const PROGMEM char *mqttHostName = "metrics"; //Хостнейм брокера 192.168.89.210 cctv.automation.art:8889
|
const PROGMEM char *mqttHostName = "metrics"; //Хостнейм брокера 192.168.89.210 cctv.automation.art:8889
|
||||||
unsigned int mqttPort = 1883; //Порт брокера 1883
|
unsigned int mqttPort = 1883; //Порт брокера 1883
|
||||||
|
|
||||||
const PROGMEM char *mqttLogin = NULL, //Логин пароль - необходимо сменить код при connect()
|
const PROGMEM char *mqttLogin = "AA_Lab", //Логин пароль - необходимо сменить код при connect()
|
||||||
*mqttPass = NULL;
|
*mqttPass = "automation.art$";
|
||||||
const char *mqttIPHost; //тут хранится IP хоста по хостнейму
|
const char *mqttIPHost; //тут хранится IP хоста по хостнейму
|
||||||
|
|
||||||
unsigned long timingUpdate, timingReqSensor, timingSendMqtt, timingAjaxUpdate; //Таймеры для millis()
|
unsigned long timingUpdate, timingReqSensor, timingSendMqtt, timingAjaxUpdate; //Таймеры для millis()
|
||||||
int PROGMEM nextM5Update = 450000; //каждые 7.5 минут запрос обновления с сервера
|
int PROGMEM nextM5Update = 60000; //450000 //каждые 7.5 минут запрос обновления с сервера
|
||||||
|
|
||||||
String getMacAddress();
|
String getMacAddress();
|
||||||
String macc = getMacAddress();
|
String macc = getMacAddress();
|
||||||
|
@ -128,7 +129,7 @@ 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);
|
||||||
wm.setClass("invert");
|
wm.setClass("invert");
|
||||||
wm.setConfigPortalTimeout(90); // auto close configportal after n seconds
|
wm.setConfigPortalTimeout(30); // auto close configportal after n seconds
|
||||||
wm.setWiFiAutoReconnect(true);
|
wm.setWiFiAutoReconnect(true);
|
||||||
bool res;
|
bool res;
|
||||||
res = wm.autoConnect("AirAnglePortal", "12345678"); // Подключение к анонимной точке доступа
|
res = wm.autoConnect("AirAnglePortal", "12345678"); // Подключение к анонимной точке доступа
|
||||||
|
@ -208,10 +209,12 @@ void firstStart()
|
||||||
|
|
||||||
void moveServo(int SetAngleTmp, int SpeedAngleTmp, int posServoTmp)
|
void moveServo(int SetAngleTmp, int SpeedAngleTmp, int posServoTmp)
|
||||||
{
|
{
|
||||||
servoAir.attach(SERVO_PIN);
|
|
||||||
|
|
||||||
if ((SetAngleTmp >= 0 && SetAngleTmp <= 100) && (SpeedAngleTmp >= 0 && SpeedAngleTmp <= 50))
|
if ((SetAngleTmp >= 0 && SetAngleTmp <= 100) && (SpeedAngleTmp >= 0 && SpeedAngleTmp <= 50))
|
||||||
{
|
{
|
||||||
|
servoAir.attach(SERVO_PIN);
|
||||||
|
|
||||||
MapAngle = map(SetAngleTmp, 0, 100, 2, 178);
|
MapAngle = map(SetAngleTmp, 0, 100, 2, 178);
|
||||||
// 544 мкс — для 0° и 2400 мкс — для 180°.
|
// 544 мкс — для 0° и 2400 мкс — для 180°.
|
||||||
|
|
||||||
|
@ -247,8 +250,11 @@ void moveServo(int SetAngleTmp, int SpeedAngleTmp, int posServoTmp)
|
||||||
Serial.println(posServo);
|
Serial.println(posServo);
|
||||||
|
|
||||||
OTApreferences.end();
|
OTApreferences.end();
|
||||||
|
|
||||||
|
servoAir.detach();
|
||||||
|
|
||||||
}
|
}
|
||||||
servoAir.detach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Функция получения данных из MQTT если мы подпишемся на топики
|
//Функция получения данных из MQTT если мы подпишемся на топики
|
||||||
|
@ -493,7 +499,7 @@ void reconnectMqtt()
|
||||||
|
|
||||||
const char *clientId = macc.c_str();
|
const char *clientId = macc.c_str();
|
||||||
//macc += String(random(0xffff), HEX);
|
//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(bufTopic, "CONNECTED", true);
|
||||||
MqttClient.publish(bufWillTopic, "ONLINE", true);
|
MqttClient.publish(bufWillTopic, "ONLINE", true);
|
||||||
|
@ -518,7 +524,7 @@ void reconnectMqtt()
|
||||||
5 : MQTT_CONNECT_UNAUTHORIZED - the client was not authorized to connect
|
5 : MQTT_CONNECT_UNAUTHORIZED - the client was not authorized to connect
|
||||||
*/
|
*/
|
||||||
mqttSendFlag = false;
|
mqttSendFlag = false;
|
||||||
delay(3000);
|
delay(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue