relayctl: make blinking optional, set default fw version to 7

This commit is contained in:
Evgeny Zinoviev 2023-01-01 18:47:10 +03:00
parent d2a5d8c6c2
commit 5e39b5c7c0
2 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#define FW_VERSION 3 #define FW_VERSION 7
#define DEFAULT_WIFI_AP_SSID "" #define DEFAULT_WIFI_AP_SSID ""
#define DEFAULT_WIFI_STA_SSID "" #define DEFAULT_WIFI_STA_SSID ""
@ -28,5 +28,6 @@
// 12 bytes string // 12 bytes string
#define HOME_SECRET_SIZE 12 #define HOME_SECRET_SIZE 12
#define HOME_SECRET "" #define HOME_SECRET ""
#define MQTT_BLINK 1
#define ARRAY_SIZE(X) sizeof((X))/sizeof((X)[0]) #define ARRAY_SIZE(X) sizeof((X))/sizeof((X)[0])

View File

@ -34,7 +34,9 @@ static volatile enum WiFiConnectionState wifi_state = WiFiConnectionState::WAITI
static void* service = nullptr; static void* service = nullptr;
static WiFiEventHandler wifiConnectHandler, wifiDisconnectHandler; static WiFiEventHandler wifiConnectHandler, wifiDisconnectHandler;
static Ticker wifiTimer; static Ticker wifiTimer;
#if MQTT_BLINK
static StopWatch blinkStopWatch; static StopWatch blinkStopWatch;
#endif
static DNSServer* dnsServer = nullptr; static DNSServer* dnsServer = nullptr;
@ -127,7 +129,9 @@ void loop() {
service = new mqtt::MQTT(); service = new mqtt::MQTT();
((mqtt::MQTT*)service)->connect(); ((mqtt::MQTT*)service)->connect();
#if MQTT_BLINK
blinkStopWatch.save(); blinkStopWatch.save();
#endif
} }
auto mqtt = (mqtt::MQTT*)service; auto mqtt = (mqtt::MQTT*)service;
@ -140,12 +144,13 @@ void loop() {
mqtt->sendStat(); mqtt->sendStat();
} }
#if MQTT_BLINK
// periodically blink board led // periodically blink board led
if (blinkStopWatch.elapsed(5000)) { if (blinkStopWatch.elapsed(5000)) {
// PRINTF("free heap: %d\n", ESP.getFreeHeap());
board_led.blink(1, 10); board_led.blink(1, 10);
blinkStopWatch.save(); blinkStopWatch.save();
} }
#endif
} }
} else { } else {
if (dnsServer != nullptr) if (dnsServer != nullptr)