Invert LED States Rozetka ESP

This commit is contained in:
2022-05-09 17:03:33 +03:00
parent 61c072bbcc
commit 78063175ca
3 changed files with 27 additions and 21 deletions

View File

@@ -1,7 +1,10 @@
{ {
// See http://go.microsoft.com/fwlink/?LinkId=827846 // See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format // for the documentation about the extensions.json format
"recommendations": [ "recommendations": [
"platformio.platformio-ide" "platformio.platformio-ide"
] ],
} "unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

View File

@@ -1,7 +1,10 @@
{ {
// See http://go.microsoft.com/fwlink/?LinkId=827846 // See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format // for the documentation about the extensions.json format
"recommendations": [ "recommendations": [
"platformio.platformio-ide" "platformio.platformio-ide"
] ],
} "unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

View File

@@ -9,9 +9,9 @@
#define BUTT2 (2) #define BUTT2 (2)
#define SOCK1 (4) #define SOCK1 (4)
#define SOCK2 (5) #define SOCK2 (5)
#define LED_WF (13) #define LED_WF (13) //Green
#define LED_MQ (12) #define LED_MQ (12) //Blue
#define LED_WRK (14) #define LED_WRK (14) //Red
const char* ssid = "wf-home"; const char* ssid = "wf-home";
const char* password = "0ndthnrf"; const char* password = "0ndthnrf";
@@ -162,14 +162,14 @@ void onWifiConnect(const WiFiEventStationModeGotIP& event) {
Serial.print("IP: "); Serial.print("IP: ");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
connectToMqtt(); connectToMqtt();
digitalWrite(LED_WF, LOW); digitalWrite(LED_WF, HIGH);
} }
void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) { void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) {
Serial.println("Disconnected from Wi-Fi."); Serial.println("Disconnected from Wi-Fi.");
mqttReconnectTimer.detach(); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi mqttReconnectTimer.detach(); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
wifiReconnectTimer.once(2, connectToWifi); wifiReconnectTimer.once(2, connectToWifi);
digitalWrite(LED_WF, HIGH); digitalWrite(LED_WF, LOW);
} }
void onMqttConnect(bool sessionPresent) { void onMqttConnect(bool sessionPresent) {
@@ -183,7 +183,7 @@ void onMqttConnect(bool sessionPresent) {
mqttClient.subscribe(TOPIC"roz1/on1_set", 1); mqttClient.subscribe(TOPIC"roz1/on1_set", 1);
mqttClient.subscribe(TOPIC"roz1/on2_set", 1); mqttClient.subscribe(TOPIC"roz1/on2_set", 1);
nSec = 59; nSec = 59;
digitalWrite(LED_MQ, LOW); digitalWrite(LED_MQ, HIGH);
} }
void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) { void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
@@ -192,7 +192,7 @@ void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
if (WiFi.isConnected()) { if (WiFi.isConnected()) {
mqttReconnectTimer.once(2, connectToMqtt); mqttReconnectTimer.once(2, connectToMqtt);
} }
digitalWrite(LED_MQ, HIGH); digitalWrite(LED_MQ, LOW);
} }
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total){ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total){