mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Add wifi/mqtt status blinkyblinky
6.1.0a * Add wifi and mqtt status led blinkyblinky to be disabled by SetOption31 1. Does not work when LedPower is On (deliberate) (#871, #2230, #3114, #3155) * Remove not needed functionality from Sonoff-minimal to save space
This commit is contained in:
parent
eed4bfd494
commit
f9ce86a6e8
@ -1,8 +1,10 @@
|
|||||||
/* 6.1.0a
|
/* 6.1.0a
|
||||||
|
* Add wifi and mqtt status led blinkyblinky to be disabled by SetOption31 1. Does not work when LedPower is On (deliberate) (#871, #2230, #3114, #3155)
|
||||||
* Add experimental (untested) TM1638 switch support (#2226)
|
* Add experimental (untested) TM1638 switch support (#2226)
|
||||||
* Add support for APDS9960 proximity sensor (#3051)
|
* Add support for APDS9960 proximity sensor (#3051)
|
||||||
* Add heap and stack debug information
|
* Add heap and stack debug information
|
||||||
* Add debug facilities using optional xdrv_99_debug.ino to enable in user_config.h
|
* Add debug facilities using optional xdrv_99_debug.ino to enable in user_config.h
|
||||||
|
* Remove not needed functionality from Sonoff-minimal to save space
|
||||||
*
|
*
|
||||||
* 6.1.0 20180706
|
* 6.1.0 20180706
|
||||||
* Remove version 3, 4 and pre 5.2 settings auto-upgrade. See https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#migration-path
|
* Remove version 3, 4 and pre 5.2 settings auto-upgrade. See https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#migration-path
|
||||||
|
@ -56,7 +56,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
|
|||||||
uint32_t rf_receive_decimal : 1; // bit 28 (v6.0.0a)
|
uint32_t rf_receive_decimal : 1; // bit 28 (v6.0.0a)
|
||||||
uint32_t ir_receive_decimal : 1; // bit 29 (v6.0.0a)
|
uint32_t ir_receive_decimal : 1; // bit 29 (v6.0.0a)
|
||||||
uint32_t hass_light : 1; // bit 30 (v6.0.0b)
|
uint32_t hass_light : 1; // bit 30 (v6.0.0b)
|
||||||
uint32_t spare31 : 1;
|
uint32_t global_state : 1; // bit 31 (v6.1.0)
|
||||||
};
|
};
|
||||||
} SysBitfield;
|
} SysBitfield;
|
||||||
|
|
||||||
@ -394,6 +394,20 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
|
|||||||
};
|
};
|
||||||
} RulesBitfield;
|
} RulesBitfield;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
uint8_t data;
|
||||||
|
struct {
|
||||||
|
uint8_t wifi_down : 1;
|
||||||
|
uint8_t mqtt_down : 1;
|
||||||
|
uint8_t spare02 : 1;
|
||||||
|
uint8_t spare03 : 1;
|
||||||
|
uint8_t spare04 : 1;
|
||||||
|
uint8_t spare05 : 1;
|
||||||
|
uint8_t spare06 : 1;
|
||||||
|
uint8_t spare07 : 1;
|
||||||
|
};
|
||||||
|
} StateBitfield;
|
||||||
|
|
||||||
// See issue https://github.com/esp8266/Arduino/issues/2913
|
// See issue https://github.com/esp8266/Arduino/issues/2913
|
||||||
#ifdef USE_ADC_VCC
|
#ifdef USE_ADC_VCC
|
||||||
ADC_MODE(ADC_VCC); // Set ADC input for Power Supply Voltage usage
|
ADC_MODE(ADC_VCC); // Set ADC input for Power Supply Voltage usage
|
||||||
|
@ -168,6 +168,7 @@ uint8_t stop_flash_rotate = 0; // Allow flash configuration rotatio
|
|||||||
|
|
||||||
int blinks = 201; // Number of LED blinks
|
int blinks = 201; // Number of LED blinks
|
||||||
uint8_t blinkstate = 0; // LED state
|
uint8_t blinkstate = 0; // LED state
|
||||||
|
uint8_t blinkspeed = 1; // LED blink rate
|
||||||
|
|
||||||
uint8_t blockgpio0 = 4; // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit
|
uint8_t blockgpio0 = 4; // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit
|
||||||
uint8_t lastbutton[MAX_KEYS] = { NOT_PRESSED, NOT_PRESSED, NOT_PRESSED, NOT_PRESSED }; // Last button states
|
uint8_t lastbutton[MAX_KEYS] = { NOT_PRESSED, NOT_PRESSED, NOT_PRESSED, NOT_PRESSED }; // Last button states
|
||||||
@ -191,6 +192,7 @@ uint8_t light_type = 0; // Light types
|
|||||||
bool pwm_present = false; // Any PWM channel configured with SetOption15 0
|
bool pwm_present = false; // Any PWM channel configured with SetOption15 0
|
||||||
boolean mdns_begun = false;
|
boolean mdns_begun = false;
|
||||||
uint8_t ntp_force_sync = 0; // Force NTP sync
|
uint8_t ntp_force_sync = 0; // Force NTP sync
|
||||||
|
StateBitfield global_state;
|
||||||
RulesBitfield rules_flag;
|
RulesBitfield rules_flag;
|
||||||
|
|
||||||
char my_version[33]; // Composed version string
|
char my_version[33]; // Composed version string
|
||||||
@ -1813,6 +1815,7 @@ void SwitchHandler(byte mode)
|
|||||||
void StateLoop()
|
void StateLoop()
|
||||||
{
|
{
|
||||||
power_t power_now;
|
power_t power_now;
|
||||||
|
uint8_t blinkinterval = 1;
|
||||||
|
|
||||||
state_loop_timer = millis() + (1000 / STATES);
|
state_loop_timer = millis() + (1000 / STATES);
|
||||||
state++;
|
state++;
|
||||||
@ -1890,27 +1893,38 @@ void StateLoop()
|
|||||||
\*-------------------------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
if (!(state % ((STATES/10)*2))) {
|
if (!(state % ((STATES/10)*2))) {
|
||||||
|
if (!Settings.flag.global_state) { // Problem blinkyblinky enabled
|
||||||
|
if (global_state.data) { // Any problem
|
||||||
|
if (global_state.mqtt_down) { blinkinterval = 9; } // MQTT problem so blink every 2 seconds (slowest)
|
||||||
|
if (global_state.wifi_down) { blinkinterval = 4; } // Wifi problem so blink every second (slow)
|
||||||
|
blinks = 201; // Allow only a single blink in case the problem is solved
|
||||||
|
}
|
||||||
|
}
|
||||||
if (blinks || restart_flag || ota_state_flag) {
|
if (blinks || restart_flag || ota_state_flag) {
|
||||||
if (restart_flag || ota_state_flag) {
|
if (restart_flag || ota_state_flag) { // Overrule blinks and keep led lit
|
||||||
blinkstate = 1; // Stay lit
|
blinkstate = 1; // Stay lit
|
||||||
} else {
|
} else {
|
||||||
blinkstate ^= 1; // Blink
|
blinkspeed--;
|
||||||
|
if (!blinkspeed) {
|
||||||
|
blinkspeed = blinkinterval; // Set interval to 0.2 (default), 1 or 2 seconds
|
||||||
|
blinkstate ^= 1; // Blink
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((!(Settings.ledstate &0x08)) && ((Settings.ledstate &0x06) || (blinks > 200) || (blinkstate))) {
|
if ((!(Settings.ledstate &0x08)) && ((Settings.ledstate &0x06) || (blinks > 200) || (blinkstate))) {
|
||||||
SetLedPower(blinkstate);
|
// if ( (!Settings.flag.global_state && global_state.data) || ((!(Settings.ledstate &0x08)) && ((Settings.ledstate &0x06) || (blinks > 200) || (blinkstate))) ) {
|
||||||
|
SetLedPower(blinkstate); // Set led on or off
|
||||||
}
|
}
|
||||||
if (!blinkstate) {
|
if (!blinkstate) {
|
||||||
blinks--;
|
blinks--;
|
||||||
if (200 == blinks) blinks = 0;
|
if (200 == blinks) blinks = 0; // Disable blink
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (Settings.ledstate &1) {
|
else if (Settings.ledstate &1) {
|
||||||
boolean tstate = power;
|
boolean tstate = power;
|
||||||
if ((SONOFF_TOUCH == Settings.module) || (SONOFF_T11 == Settings.module) || (SONOFF_T12 == Settings.module) || (SONOFF_T13 == Settings.module)) {
|
if ((SONOFF_TOUCH == Settings.module) || (SONOFF_T11 == Settings.module) || (SONOFF_T12 == Settings.module) || (SONOFF_T13 == Settings.module)) {
|
||||||
tstate = (!power) ? 1 : 0;
|
tstate = (!power) ? 1 : 0; // As requested invert signal for Touch devices to find them in the dark
|
||||||
}
|
|
||||||
SetLedPower(tstate);
|
|
||||||
}
|
}
|
||||||
|
SetLedPower(tstate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,6 +1059,7 @@ void WifiBegin(uint8_t flag)
|
|||||||
void WifiCheckIp()
|
void WifiCheckIp()
|
||||||
{
|
{
|
||||||
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
|
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
|
||||||
|
global_state.wifi_down = 0;
|
||||||
wifi_counter = WIFI_CHECK_SEC;
|
wifi_counter = WIFI_CHECK_SEC;
|
||||||
wifi_retry = wifi_retry_init;
|
wifi_retry = wifi_retry_init;
|
||||||
AddLog_P((wifi_status != WL_CONNECTED) ? LOG_LEVEL_INFO : LOG_LEVEL_DEBUG_MORE, S_LOG_WIFI, PSTR(D_CONNECTED));
|
AddLog_P((wifi_status != WL_CONNECTED) ? LOG_LEVEL_INFO : LOG_LEVEL_DEBUG_MORE, S_LOG_WIFI, PSTR(D_CONNECTED));
|
||||||
@ -1070,6 +1071,7 @@ void WifiCheckIp()
|
|||||||
}
|
}
|
||||||
wifi_status = WL_CONNECTED;
|
wifi_status = WL_CONNECTED;
|
||||||
} else {
|
} else {
|
||||||
|
global_state.wifi_down = 1;
|
||||||
wifi_status = WiFi.status();
|
wifi_status = WiFi.status();
|
||||||
switch (wifi_status) {
|
switch (wifi_status) {
|
||||||
case WL_CONNECTED:
|
case WL_CONNECTED:
|
||||||
@ -1169,6 +1171,7 @@ void WifiCheck(uint8_t param)
|
|||||||
WifiCheckIp();
|
WifiCheckIp();
|
||||||
}
|
}
|
||||||
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0) && !wifi_config_type) {
|
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0) && !wifi_config_type) {
|
||||||
|
global_state.wifi_down = 0;
|
||||||
#ifdef BE_MINIMAL
|
#ifdef BE_MINIMAL
|
||||||
if (1 == RtcSettings.ota_loader) {
|
if (1 == RtcSettings.ota_loader) {
|
||||||
RtcSettings.ota_loader = 0;
|
RtcSettings.ota_loader = 0;
|
||||||
@ -1206,6 +1209,7 @@ void WifiCheck(uint8_t param)
|
|||||||
}
|
}
|
||||||
#endif // USE_KNX
|
#endif // USE_KNX
|
||||||
} else {
|
} else {
|
||||||
|
global_state.wifi_down = 1;
|
||||||
#if defined(USE_WEBSERVER) && defined(USE_EMULATION)
|
#if defined(USE_WEBSERVER) && defined(USE_EMULATION)
|
||||||
UdpDisconnect();
|
UdpDisconnect();
|
||||||
#endif // USE_EMULATION
|
#endif // USE_EMULATION
|
||||||
|
@ -383,6 +383,7 @@ void MqttConnected()
|
|||||||
}
|
}
|
||||||
mqtt_initial_connection_state = 0;
|
mqtt_initial_connection_state = 0;
|
||||||
rules_flag.mqtt_connected = 1;
|
rules_flag.mqtt_connected = 1;
|
||||||
|
global_state.mqtt_down = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MQTT_TLS
|
#ifdef USE_MQTT_TLS
|
||||||
@ -443,6 +444,7 @@ void MqttReconnect()
|
|||||||
|
|
||||||
mqtt_connected = false;
|
mqtt_connected = false;
|
||||||
mqtt_retry_counter = Settings.mqtt_retry;
|
mqtt_retry_counter = Settings.mqtt_retry;
|
||||||
|
global_state.mqtt_down = 1;
|
||||||
|
|
||||||
#ifndef USE_MQTT_TLS
|
#ifndef USE_MQTT_TLS
|
||||||
#ifdef USE_DISCOVERY
|
#ifdef USE_DISCOVERY
|
||||||
@ -512,13 +514,17 @@ void MqttCheck()
|
|||||||
{
|
{
|
||||||
if (Settings.flag.mqtt_enabled) {
|
if (Settings.flag.mqtt_enabled) {
|
||||||
if (!MqttIsConnected()) {
|
if (!MqttIsConnected()) {
|
||||||
|
global_state.mqtt_down = 1;
|
||||||
if (!mqtt_retry_counter) {
|
if (!mqtt_retry_counter) {
|
||||||
MqttReconnect();
|
MqttReconnect();
|
||||||
} else {
|
} else {
|
||||||
mqtt_retry_counter--;
|
mqtt_retry_counter--;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
global_state.mqtt_down = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
global_state.mqtt_down = 0;
|
||||||
if (mqtt_initial_connection_state) MqttReconnect();
|
if (mqtt_initial_connection_state) MqttReconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user