use blue led to indicate mqtt connectivity
This commit is contained in:
parent
22add7aea8
commit
ddbefdae5d
@ -3,7 +3,7 @@
|
|||||||
#define SEND_PIN 12
|
#define SEND_PIN 12
|
||||||
#define RECEIVE_PIN 13
|
#define RECEIVE_PIN 13
|
||||||
#define RED_LED LED_BUILTIN
|
#define RED_LED LED_BUILTIN
|
||||||
// #define BLUE_LED 2
|
#define BLUE_LED 2
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -17,6 +17,10 @@ mapswitches onSwitches;
|
|||||||
mapswitches offSwitches;
|
mapswitches offSwitches;
|
||||||
unordered_map<string, Ha::Switch*> p1Switches;
|
unordered_map<string, Ha::Switch*> p1Switches;
|
||||||
|
|
||||||
|
void turnLed(uint8_t led, bool on = true) {
|
||||||
|
on ? digitalWrite(led, LOW) : digitalWrite(led, HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
|
|
||||||
namespace Board {
|
namespace Board {
|
||||||
@ -28,19 +32,18 @@ namespace Board {
|
|||||||
}
|
}
|
||||||
}, &ts);
|
}, &ts);
|
||||||
|
|
||||||
void turnOffLed(uint8_t led) {
|
|
||||||
digitalWrite(led, HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Serial.begin(9600, SERIAL_8N1, SERIAL_TX_ONLY);
|
// Serial.begin(9600, SERIAL_8N1, SERIAL_TX_ONLY);
|
||||||
|
|
||||||
pinMode(RED_LED, OUTPUT);
|
pinMode(RED_LED, OUTPUT);
|
||||||
turnOffLed(RED_LED);
|
pinMode(BLUE_LED, OUTPUT);
|
||||||
// pinMode(BLUE_LED, OUTPUT);
|
turnLed(RED_LED, false);
|
||||||
// turnOffLed(BLUE_LED);
|
turnLed(BLUE_LED);
|
||||||
|
|
||||||
Wifi::setup();
|
Wifi::setup();
|
||||||
Ota::setup();
|
Ota::setup();
|
||||||
Mqtt::setup();
|
Mqtt::setup();
|
||||||
|
|
||||||
tReadCommand.enable();
|
tReadCommand.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,10 +55,12 @@ namespace Mqtt {
|
|||||||
client.subscribe(mainTopic, 0);
|
client.subscribe(mainTopic, 0);
|
||||||
tReConnect.disable();
|
tReConnect.disable();
|
||||||
Serial.println("Connected to MQTT");
|
Serial.println("Connected to MQTT");
|
||||||
|
turnLed(BLUE_LED, false);
|
||||||
});
|
});
|
||||||
client.onDisconnect([](AsyncMqttClientDisconnectReason reason) {
|
client.onDisconnect([](AsyncMqttClientDisconnectReason reason) {
|
||||||
tReConnect.enableDelayed();
|
tReConnect.enableDelayed();
|
||||||
Serial.println("Disconnected from MQTT");
|
Serial.println("Disconnected from MQTT");
|
||||||
|
turnLed(BLUE_LED);
|
||||||
});
|
});
|
||||||
client.onMessage(onMessage);
|
client.onMessage(onMessage);
|
||||||
client.setServer(MQTT_HOST, MQTT_PORT);
|
client.setServer(MQTT_HOST, MQTT_PORT);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user