Fix meter lifecycle and MQTT/HA integration bugs #1
+2
-1
@@ -13,6 +13,7 @@
|
|||||||
#define PWM_RES 10
|
#define PWM_RES 10
|
||||||
#define MQTT_MANUFACTURER "Baumann Enkataleiptics"
|
#define MQTT_MANUFACTURER "Baumann Enkataleiptics"
|
||||||
#define AUTH_USERNAME "admin"
|
#define AUTH_USERNAME "admin"
|
||||||
|
#define MQTT_PROBE_TIMEOUT_MS 400 // keep short: blocks loop()/handleClient() per reconnect attempt
|
||||||
|
|
||||||
struct MeterConfig {
|
struct MeterConfig {
|
||||||
int pin;
|
int pin;
|
||||||
@@ -340,7 +341,7 @@ static void mqttLoop() {
|
|||||||
if (now > mqttReconnectAt) {
|
if (now > mqttReconnectAt) {
|
||||||
Serial.printf("[MQTT] probing %s:%d\n", mqttCfg.host, mqttCfg.port);
|
Serial.printf("[MQTT] probing %s:%d\n", mqttCfg.host, mqttCfg.port);
|
||||||
WiFiClient probe;
|
WiFiClient probe;
|
||||||
bool reachable = probe.connect(mqttCfg.host, mqttCfg.port, 1500);
|
bool reachable = probe.connect(mqttCfg.host, mqttCfg.port, MQTT_PROBE_TIMEOUT_MS);
|
||||||
probe.stop();
|
probe.stop();
|
||||||
|
|
||||||
if (reachable) {
|
if (reachable) {
|
||||||
|
|||||||
Reference in New Issue
Block a user