mirror of
https://github.com/Anonym-tsk/smart-domofon.git
synced 2025-12-19 14:09:04 +03:00
Code moved
This commit is contained in:
17
native/src/config/hardware.h
Normal file
17
native/src/config/hardware.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef HW_H_
|
||||
#define HW_H_
|
||||
|
||||
// Hardware configuration
|
||||
#define PIN_RELAY_ANSWER 16 //D0
|
||||
#define PIN_RELAY_DOOR_OPEN 5 //D1
|
||||
|
||||
#define PIN_LED_RED 4 //D2
|
||||
#define PIN_LED_GREEN 0 //D3
|
||||
#define PIN_LED_BLUE 2 //D4
|
||||
|
||||
#define PIN_CALL_DETECT 14 //D5
|
||||
|
||||
#define PIN_BUTTON_GREEN 12 //D6
|
||||
#define PIN_BUTTON_RED 13 //D7
|
||||
|
||||
#endif // HW_H_
|
||||
19
native/src/config/mqtt.h
Normal file
19
native/src/config/mqtt.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef MQTT_H_
|
||||
#define MQTT_H_
|
||||
|
||||
// High level protocol messages
|
||||
#define MSG_STATUS_READY "R" // ready; sent after successfull boot-up or after receiving of 'P' message
|
||||
#define MSG_STATUS_LAST_WILL "L" // last will message; send when device goes offline
|
||||
|
||||
#define MSG_OUT_CALL "C" // call; sent after detecting of incoming intercom call
|
||||
#define MSG_OUT_HANGUP "H" // hangup; sent after detected incoming call finished
|
||||
#define MSG_OUT_OPENED_BY_BUTTON "B" // button; sent when "door open" has been performed by green hw button press
|
||||
#define MSG_OUT_REJECTED_BY_BUTTON "J" // reJected; sent when incoming call has been rejected by red hw button press
|
||||
#define MSG_OUT_SUCCESS "S" // success; sent in response to 'O' or 'N' command
|
||||
#define MSG_OUT_FAIL "F" // fail; sent in response to 'O' or 'N' command (this means that 'O' or 'N' command has been received but no incoming call detected)
|
||||
|
||||
#define MSG_IN_OPEN 'O' // door open command
|
||||
#define MSG_IN_REJECT 'N' // call reject command (door will not open)
|
||||
#define MSG_IN_PING 'P' // ping command (answers with 'R')
|
||||
|
||||
#endif // MQTT_H_
|
||||
25
native/src/config/software.h
Normal file
25
native/src/config/software.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef SW_H_
|
||||
#define SW_H_
|
||||
|
||||
// Software configuration
|
||||
#define HOST_NAME "domofon"
|
||||
#define HOST_PASSWORD "domofon"
|
||||
#define OTA_PORT 8266
|
||||
#define WIFI_SSID ""
|
||||
#define WIFI_PASSWORD ""
|
||||
|
||||
#define MQTT_SERVER_ADDR ""
|
||||
#define MQTT_SERVER_PORT 1883
|
||||
#define MQTT_USER_NAME ""
|
||||
#define MQTT_USER_PASSWORD ""
|
||||
#define MQTT_CLIENT_ID "domofon"
|
||||
#define MQTT_TOPIC_IN "domofon/in"
|
||||
#define MQTT_TOPIC_OUT "domofon/out"
|
||||
#define MQTT_TOPIC_STATUS "domofon/status"
|
||||
|
||||
#define CALL_HANGUP_DETECT_DELAY 3000
|
||||
#define RELAY_ANSWER_ON_TIME 1500
|
||||
#define RELAY_OPEN_ON_TIME 600
|
||||
#define RELAY_AFTER_OPEN_ON_TIME 500
|
||||
|
||||
#endif // SW_H_
|
||||
12
native/src/debug.ino
Normal file
12
native/src/debug.ino
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
void DEBUG_LN(const char *text) {
|
||||
Serial.println(text);
|
||||
webSocket().printfAll("%s\n", text);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void DEBUG_F(const char *format, Args... args) {
|
||||
Serial.printf(format, args...);
|
||||
webSocket().printfAll(format, args...);
|
||||
}
|
||||
146
native/src/domofon.ino
Normal file
146
native/src/domofon.ino
Normal file
@@ -0,0 +1,146 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
EState state = IDLE;
|
||||
EAction action = NO_ACTION;
|
||||
|
||||
Bounce debouncerBtnGreen = Bounce();
|
||||
Bounce debouncerBtnRed = Bounce();
|
||||
|
||||
unsigned long lastCallDetectedTime = 0;
|
||||
|
||||
void callAnswer() {
|
||||
DEBUG_LN("[HW] Call answer...");
|
||||
digitalWrite(PIN_RELAY_DOOR_OPEN, RELAY_OFF);
|
||||
digitalWrite(PIN_RELAY_ANSWER, RELAY_ON);
|
||||
DEBUG_LN("[HW] Done");
|
||||
}
|
||||
|
||||
void callHangUp() {
|
||||
DEBUG_LN("[HW] Hang up...");
|
||||
digitalWrite(PIN_RELAY_ANSWER, RELAY_OFF);
|
||||
digitalWrite(PIN_RELAY_DOOR_OPEN, RELAY_OFF);
|
||||
DEBUG_LN("[HW] Done");
|
||||
}
|
||||
|
||||
void doorOpen() {
|
||||
DEBUG_LN("[HW] Door open...");
|
||||
digitalWrite(PIN_RELAY_DOOR_OPEN, RELAY_ON);
|
||||
delay(RELAY_OPEN_ON_TIME);
|
||||
digitalWrite(PIN_RELAY_DOOR_OPEN, RELAY_OFF);
|
||||
DEBUG_LN("[HW] Done");
|
||||
}
|
||||
|
||||
void answerAndOpen() {
|
||||
callAnswer();
|
||||
delay(RELAY_ANSWER_ON_TIME);
|
||||
doorOpen();
|
||||
delay(RELAY_AFTER_OPEN_ON_TIME);
|
||||
callHangUp();
|
||||
}
|
||||
|
||||
void answerAndReject() {
|
||||
callAnswer();
|
||||
delay(RELAY_ANSWER_ON_TIME);
|
||||
callHangUp();
|
||||
}
|
||||
|
||||
void handleIdle(EState oldState) {
|
||||
if (oldState != IDLE) {
|
||||
mqttSendCommand(MSG_OUT_HANGUP);
|
||||
ledOff();
|
||||
DEBUG_LN("[HW] Current state: IDLE");
|
||||
}
|
||||
|
||||
if (action != NO_ACTION) {
|
||||
mqttSendCommand(MSG_OUT_FAIL);
|
||||
action = NO_ACTION;
|
||||
}
|
||||
|
||||
if (debouncerBtnGreen.fell()) {
|
||||
DEBUG_LN("[HW] Button click");
|
||||
ledBlink(PIN_LED_GREEN, 2);
|
||||
}
|
||||
}
|
||||
|
||||
void handleCall(EState oldState) {
|
||||
if (oldState != CALL) {
|
||||
action = NO_ACTION;
|
||||
mqttSendCommand(MSG_OUT_CALL);
|
||||
ledOn(PIN_LED_RED);
|
||||
DEBUG_LN("[HW] Current state: CALL");
|
||||
}
|
||||
|
||||
if (action == NO_ACTION) {
|
||||
if (debouncerBtnRed.fell()) {
|
||||
action = REJECT_BY_BUTTON;
|
||||
} else if (debouncerBtnGreen.fell()) {
|
||||
action = OPEN_BY_BUTTON;
|
||||
}
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case OPEN_BY_BUTTON:
|
||||
answerAndOpen();
|
||||
mqttSendCommand(MSG_OUT_OPENED_BY_BUTTON);
|
||||
break;
|
||||
|
||||
case REJECT_BY_BUTTON:
|
||||
answerAndReject();
|
||||
mqttSendCommand(MSG_OUT_REJECTED_BY_BUTTON);
|
||||
break;
|
||||
|
||||
case OPEN:
|
||||
answerAndOpen();
|
||||
mqttSendCommand(MSG_OUT_SUCCESS);
|
||||
break;
|
||||
|
||||
case REJECT:
|
||||
answerAndReject();
|
||||
mqttSendCommand(MSG_OUT_SUCCESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
action = NO_ACTION;
|
||||
}
|
||||
|
||||
void setStateIdle() {
|
||||
state = IDLE;
|
||||
}
|
||||
|
||||
void setStateCall() {
|
||||
state = CALL;
|
||||
}
|
||||
|
||||
void domofonSetup() {
|
||||
debouncerBtnGreen.attach(PIN_BUTTON_GREEN);
|
||||
debouncerBtnGreen.interval(25);
|
||||
debouncerBtnRed.attach(PIN_BUTTON_RED);
|
||||
debouncerBtnRed.interval(25);
|
||||
}
|
||||
|
||||
void domofonLoop() {
|
||||
debouncerBtnGreen.update();
|
||||
debouncerBtnRed.update();
|
||||
|
||||
EState oldState = state;
|
||||
|
||||
if (digitalRead(PIN_CALL_DETECT) == LOW) {
|
||||
setStateCall();
|
||||
lastCallDetectedTime = millis();
|
||||
} else if (millis() - lastCallDetectedTime > CALL_HANGUP_DETECT_DELAY) {
|
||||
setStateIdle();
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case IDLE:
|
||||
handleIdle(oldState);
|
||||
break;
|
||||
|
||||
case CALL:
|
||||
handleCall(oldState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
28
native/src/hardware.ino
Normal file
28
native/src/hardware.ino
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
Ticker _defer_restart;
|
||||
|
||||
void hardwareSetup() {
|
||||
pinMode(PIN_BUTTON_GREEN, INPUT_PULLUP);
|
||||
pinMode(PIN_BUTTON_RED, INPUT_PULLUP);
|
||||
pinMode(PIN_CALL_DETECT, INPUT_PULLUP);
|
||||
pinMode(PIN_LED_RED, OUTPUT);
|
||||
pinMode(PIN_LED_GREEN, OUTPUT);
|
||||
pinMode(PIN_LED_BLUE, OUTPUT);
|
||||
pinMode(PIN_RELAY_ANSWER, OUTPUT);
|
||||
pinMode(PIN_RELAY_DOOR_OPEN, OUTPUT);
|
||||
|
||||
digitalWrite(PIN_LED_RED, LED_OFF);
|
||||
digitalWrite(PIN_LED_GREEN, LED_OFF);
|
||||
digitalWrite(PIN_LED_BLUE, LED_OFF);
|
||||
digitalWrite(PIN_RELAY_ANSWER, RELAY_OFF);
|
||||
digitalWrite(PIN_RELAY_DOOR_OPEN, RELAY_OFF);
|
||||
}
|
||||
|
||||
void restart() {
|
||||
ESP.reset();
|
||||
}
|
||||
|
||||
void deferredRestart(unsigned long delay) {
|
||||
_defer_restart.once_ms(delay, restart);
|
||||
}
|
||||
13
native/src/inc/include.h
Normal file
13
native/src/inc/include.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <Arduino.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include <FS.h>
|
||||
#include <PubSubClient.h>
|
||||
#include <Bounce2.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <Ticker.h>
|
||||
|
||||
#include "../config/hardware.h"
|
||||
#include "../config/software.h"
|
||||
#include "../config/mqtt.h"
|
||||
#include "types.h"
|
||||
22
native/src/inc/types.h
Normal file
22
native/src/inc/types.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef TYPES_H_
|
||||
#define TYPES_H_
|
||||
|
||||
#define LED_ON HIGH
|
||||
#define LED_OFF LOW
|
||||
#define RELAY_ON LOW
|
||||
#define RELAY_OFF HIGH
|
||||
|
||||
typedef enum {
|
||||
IDLE,
|
||||
CALL
|
||||
} EState;
|
||||
|
||||
typedef enum {
|
||||
NO_ACTION,
|
||||
OPEN,
|
||||
OPEN_BY_BUTTON,
|
||||
REJECT,
|
||||
REJECT_BY_BUTTON
|
||||
} EAction;
|
||||
|
||||
#endif // TYPES_H_
|
||||
21
native/src/led.ino
Normal file
21
native/src/led.ino
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
void ledBlink(int pin, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
digitalWrite(pin, LED_ON);
|
||||
delay(125);
|
||||
digitalWrite(pin, LED_OFF);
|
||||
delay(125);
|
||||
}
|
||||
}
|
||||
|
||||
void ledOff() {
|
||||
digitalWrite(PIN_LED_GREEN, LED_OFF);
|
||||
digitalWrite(PIN_LED_RED, LED_OFF);
|
||||
digitalWrite(PIN_LED_BLUE, LED_OFF);
|
||||
}
|
||||
|
||||
void ledOn(int pin) {
|
||||
ledOff();
|
||||
digitalWrite(pin, LED_ON);
|
||||
}
|
||||
20
native/src/main.ino
Normal file
20
native/src/main.ino
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
// Код частично заимствован и переделан
|
||||
// @see https://github.com/Metori/mqtt_domofon
|
||||
|
||||
void setup() {
|
||||
hardwareSetup();
|
||||
wifiSetup();
|
||||
otaSetup();
|
||||
mqttSetup();
|
||||
webServerSetup();
|
||||
domofonSetup();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
wifiLoop();
|
||||
otaLoop();
|
||||
mqttLoop();
|
||||
domofonLoop();
|
||||
}
|
||||
89
native/src/mqtt.ino
Normal file
89
native/src/mqtt.ino
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
WiFiClient espClient;
|
||||
PubSubClient mqttClient(espClient);
|
||||
|
||||
void mqttSendCommand(const char *msg) {
|
||||
mqttClient.publish(MQTT_TOPIC_OUT, msg);
|
||||
DEBUG_F("[MQTT] Message sent: %s\n", msg);
|
||||
}
|
||||
|
||||
void mqttSendStatus(const char *msg) {
|
||||
mqttClient.publish(MQTT_TOPIC_STATUS, msg, true);
|
||||
DEBUG_F("[MQTT] Status sent: %s\n", msg);
|
||||
}
|
||||
|
||||
void onMqttMsgReceived(char* topic, byte* payload, unsigned int len) {
|
||||
if (len != 1) {
|
||||
char* command = (char*)malloc(len + 2);
|
||||
memcpy(command, payload, len);
|
||||
command[len] = '\0';
|
||||
|
||||
DEBUG_F("[MQTT] Message received [%u]: %s\n", len, command);
|
||||
return;
|
||||
}
|
||||
|
||||
char cmd = (char)payload[0];
|
||||
DEBUG_F("[MQTT] Command received: %c\n", cmd);
|
||||
|
||||
switch (cmd) {
|
||||
case MSG_IN_OPEN:
|
||||
action = OPEN;
|
||||
break;
|
||||
|
||||
case MSG_IN_REJECT:
|
||||
action = REJECT;
|
||||
break;
|
||||
|
||||
case MSG_IN_PING:
|
||||
mqttSendStatus(MSG_STATUS_READY);
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_LN("[MQTT] Unknown command");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void mqttConnect() {
|
||||
DEBUG_F("[MQTT] (Re)connecting to server on %s...\n", MQTT_SERVER_ADDR);
|
||||
|
||||
for (int i = 0; !mqttClient.connected(); i++) {
|
||||
// Если не получилось за 5 попыток - перезагружаемся
|
||||
if (i >= 5) {
|
||||
ESP.restart();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mqttClient.connect(MQTT_CLIENT_ID, MQTT_USER_NAME, MQTT_USER_PASSWORD, MQTT_TOPIC_STATUS, 0, 1, MSG_STATUS_LAST_WILL)) {
|
||||
// Ждем 2 секунды
|
||||
DEBUG_F(".");
|
||||
ledBlink(PIN_LED_GREEN, 8);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LN("\n[MQTT] Done");
|
||||
mqttSendStatus(MSG_STATUS_READY);
|
||||
mqttClient.subscribe(MQTT_TOPIC_IN);
|
||||
|
||||
setStateIdle();
|
||||
DEBUG_LN("[MQTT] Current state: IDLE");
|
||||
}
|
||||
|
||||
void mqttStop() {
|
||||
mqttClient.disconnect();
|
||||
ledOff();
|
||||
}
|
||||
|
||||
void mqttSetup() {
|
||||
mqttClient.setServer(MQTT_SERVER_ADDR, MQTT_SERVER_PORT);
|
||||
mqttClient.setCallback(onMqttMsgReceived);
|
||||
mqttConnect();
|
||||
}
|
||||
|
||||
void mqttLoop() {
|
||||
if (!mqttClient.connected()) {
|
||||
mqttConnect();
|
||||
}
|
||||
mqttClient.loop();
|
||||
}
|
||||
58
native/src/ota.ino
Normal file
58
native/src/ota.ino
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
void otaSetup() {
|
||||
ArduinoOTA.setHostname(HOST_NAME);
|
||||
ArduinoOTA.setPort(OTA_PORT);
|
||||
|
||||
ArduinoOTA.setPassword(HOST_PASSWORD);
|
||||
|
||||
ArduinoOTA.onStart([]() {
|
||||
DEBUG_LN("[OTA] Start update");
|
||||
webServerStop();
|
||||
mqttStop();
|
||||
});
|
||||
|
||||
ArduinoOTA.onEnd([]() {
|
||||
DEBUG_LN("[OTA] End update");
|
||||
});
|
||||
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
DEBUG_F("[OTA] Progress: %u%%\n", (progress / (total / 100)));
|
||||
});
|
||||
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
String type;
|
||||
switch (error) {
|
||||
// "Ошибка при аутентификации"
|
||||
case OTA_AUTH_ERROR:
|
||||
type = "Auth Failed";
|
||||
break;
|
||||
// "Ошибка при начале OTA-апдейта"
|
||||
case OTA_BEGIN_ERROR:
|
||||
type = "Begin Failed";
|
||||
break;
|
||||
// "Ошибка при подключении"
|
||||
case OTA_CONNECT_ERROR:
|
||||
type = "Connect Failed";
|
||||
break;
|
||||
// "Ошибка при получении данных"
|
||||
case OTA_RECEIVE_ERROR:
|
||||
type = "Receive Failed";
|
||||
break;
|
||||
// "Ошибка при завершении OTA-апдейта"
|
||||
case OTA_END_ERROR:
|
||||
type = "End Failed";
|
||||
break;
|
||||
default:
|
||||
type = "Unknown";
|
||||
}
|
||||
|
||||
DEBUG_F("[OTA] Error[%u]: %s\n", error, type.c_str());
|
||||
});
|
||||
|
||||
ArduinoOTA.begin();
|
||||
}
|
||||
|
||||
void otaLoop() {
|
||||
ArduinoOTA.handle();
|
||||
}
|
||||
72
native/src/server.ino
Normal file
72
native/src/server.ino
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
AsyncWebServer _server(80);
|
||||
AsyncWebSocket _ws("/ws");
|
||||
|
||||
AsyncWebSocket webSocket() {
|
||||
return _ws;
|
||||
}
|
||||
|
||||
void _wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
|
||||
uint32_t id = client->id();
|
||||
|
||||
switch (type) {
|
||||
case WS_EVT_CONNECT:
|
||||
DEBUG_F("[WS] Client connected - ID: %u\n", id);
|
||||
client->ping();
|
||||
break;
|
||||
|
||||
case WS_EVT_DISCONNECT:
|
||||
DEBUG_F("[WS] Client disconnected - ID: %u\n", id);
|
||||
break;
|
||||
|
||||
case WS_EVT_ERROR:
|
||||
DEBUG_F("[WS] Error - ID: %u, code: %u, error: %s\n", id, *((uint16_t*)arg), (char*)data);
|
||||
break;
|
||||
|
||||
case WS_EVT_PONG:
|
||||
DEBUG_F("[WS] Pong - ID: %u\n", id);
|
||||
break;
|
||||
|
||||
case WS_EVT_DATA:
|
||||
AwsFrameInfo * info = (AwsFrameInfo*)arg;
|
||||
if (info->final && info->index == 0 && info->len == len) {
|
||||
if (info->opcode == WS_TEXT) {
|
||||
DEBUG_F("[WS] Message received - ID: %u, message: %s\n", id, (char*)data);
|
||||
} else {
|
||||
DEBUG_F("[WS] Bynary messages not supported - ID: %u\n", id);
|
||||
}
|
||||
} else if (info->final && (info->index + len) == info->len) {
|
||||
DEBUG_F("[WS] Message too long - ID: %u\n", id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void webServerStop() {
|
||||
DEBUG_LN("[WS] Server stopped");
|
||||
SPIFFS.end();
|
||||
_ws.enable(false);
|
||||
_ws.closeAll(1012);
|
||||
}
|
||||
|
||||
void webServerSetup() {
|
||||
SPIFFS.begin();
|
||||
|
||||
_server.rewrite("/", "/index.html");
|
||||
_server.onNotFound([](AsyncWebServerRequest *request) {
|
||||
request->send(404, "text/plain", "404: Not Found");
|
||||
});
|
||||
_server.on("/restart", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
request->send(200);
|
||||
DEBUG_LN("Restarting...");
|
||||
webServerStop();
|
||||
mqttStop();
|
||||
deferredRestart(200);
|
||||
});
|
||||
_server.serveStatic("/", SPIFFS, "/");
|
||||
_server.begin();
|
||||
|
||||
_ws.onEvent(_wsEvent);
|
||||
_server.addHandler(&_ws);
|
||||
}
|
||||
44
native/src/wifi.ino
Normal file
44
native/src/wifi.ino
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
void wifiDisconnect() {
|
||||
WiFi.disconnect();
|
||||
ledOff();
|
||||
}
|
||||
|
||||
void wifiConnect() {
|
||||
DEBUG_F("[WIFI] (Re)connecting to \"%s\"\n", WIFI_SSID);
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.hostname(HOST_NAME);
|
||||
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
||||
|
||||
for (int i = 0; WiFi.status() != WL_CONNECTED; i++) {
|
||||
// Если не получилось за 5 попыток - перезагружаемся
|
||||
if (i >= 5) {
|
||||
ESP.restart();
|
||||
return;
|
||||
}
|
||||
|
||||
// Ждем 2 секунды
|
||||
DEBUG_F(".");
|
||||
ledBlink(PIN_LED_BLUE, 8);
|
||||
}
|
||||
|
||||
DEBUG_LN("\n[WIFI] Done");
|
||||
DEBUG_F("[WIFI] IP address: %s\n", WiFi.localIP().toString().c_str());
|
||||
}
|
||||
|
||||
void wifiReconnect() {
|
||||
wifiDisconnect();
|
||||
wifiConnect();
|
||||
}
|
||||
|
||||
void wifiSetup() {
|
||||
wifiConnect();
|
||||
}
|
||||
|
||||
void wifiLoop() {
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
wifiReconnect();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user