Merge branch 'arendst/development' into development

This commit is contained in:
reloxx13 2018-07-07 22:46:32 +02:00
commit b11323b271
5 changed files with 53 additions and 13 deletions

View File

@ -1,8 +1,10 @@
/* 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 support for APDS9960 proximity sensor (#3051)
* Add heap and stack debug information
* 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
* Remove version 3, 4 and pre 5.2 settings auto-upgrade. See https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#migration-path

View File

@ -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 ir_receive_decimal : 1; // bit 29 (v6.0.0a)
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;
@ -394,6 +394,20 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
};
} 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
#ifdef USE_ADC_VCC
ADC_MODE(ADC_VCC); // Set ADC input for Power Supply Voltage usage

View File

@ -168,6 +168,7 @@ uint8_t stop_flash_rotate = 0; // Allow flash configuration rotatio
int blinks = 201; // Number of LED blinks
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 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
boolean mdns_begun = false;
uint8_t ntp_force_sync = 0; // Force NTP sync
StateBitfield global_state;
RulesBitfield rules_flag;
char my_version[33]; // Composed version string
@ -1813,6 +1815,7 @@ void SwitchHandler(byte mode)
void StateLoop()
{
power_t power_now;
uint8_t blinkinterval = 1;
state_loop_timer = millis() + (1000 / STATES);
state++;
@ -1890,27 +1893,38 @@ void StateLoop()
\*-------------------------------------------------------------------------------------------*/
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 (restart_flag || ota_state_flag) {
blinkstate = 1; // Stay lit
if (restart_flag || ota_state_flag) { // Overrule blinks and keep led lit
blinkstate = 1; // Stay lit
} 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))) {
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) {
blinks--;
if (200 == blinks) blinks = 0;
if (200 == blinks) blinks = 0; // Disable blink
}
} else {
if (Settings.ledstate &1) {
boolean tstate = power;
if ((SONOFF_TOUCH == Settings.module) || (SONOFF_T11 == Settings.module) || (SONOFF_T12 == Settings.module) || (SONOFF_T13 == Settings.module)) {
tstate = (!power) ? 1 : 0;
}
SetLedPower(tstate);
}
else if (Settings.ledstate &1) {
boolean tstate = power;
if ((SONOFF_TOUCH == Settings.module) || (SONOFF_T11 == Settings.module) || (SONOFF_T12 == Settings.module) || (SONOFF_T13 == Settings.module)) {
tstate = (!power) ? 1 : 0; // As requested invert signal for Touch devices to find them in the dark
}
SetLedPower(tstate);
}
}

View File

@ -1059,6 +1059,7 @@ void WifiBegin(uint8_t flag)
void WifiCheckIp()
{
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
global_state.wifi_down = 0;
wifi_counter = WIFI_CHECK_SEC;
wifi_retry = wifi_retry_init;
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;
} else {
global_state.wifi_down = 1;
wifi_status = WiFi.status();
switch (wifi_status) {
case WL_CONNECTED:
@ -1169,6 +1171,7 @@ void WifiCheck(uint8_t param)
WifiCheckIp();
}
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0) && !wifi_config_type) {
global_state.wifi_down = 0;
#ifdef BE_MINIMAL
if (1 == RtcSettings.ota_loader) {
RtcSettings.ota_loader = 0;
@ -1206,6 +1209,7 @@ void WifiCheck(uint8_t param)
}
#endif // USE_KNX
} else {
global_state.wifi_down = 1;
#if defined(USE_WEBSERVER) && defined(USE_EMULATION)
UdpDisconnect();
#endif // USE_EMULATION

View File

@ -383,6 +383,7 @@ void MqttConnected()
}
mqtt_initial_connection_state = 0;
rules_flag.mqtt_connected = 1;
global_state.mqtt_down = 0;
}
#ifdef USE_MQTT_TLS
@ -443,6 +444,7 @@ void MqttReconnect()
mqtt_connected = false;
mqtt_retry_counter = Settings.mqtt_retry;
global_state.mqtt_down = 1;
#ifndef USE_MQTT_TLS
#ifdef USE_DISCOVERY
@ -512,13 +514,17 @@ void MqttCheck()
{
if (Settings.flag.mqtt_enabled) {
if (!MqttIsConnected()) {
global_state.mqtt_down = 1;
if (!mqtt_retry_counter) {
MqttReconnect();
} else {
mqtt_retry_counter--;
}
} else {
global_state.mqtt_down = 0;
}
} else {
global_state.mqtt_down = 0;
if (mqtt_initial_connection_state) MqttReconnect();
}
}