mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-23 22:37:16 +00:00
tuya: modify WifiState() in support.ino to reflect not-connected-state instead of reimplementing it
This commit is contained in:
parent
8f3f1f3958
commit
faab6f1221
@ -1110,7 +1110,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
wifi_state_flag = Settings.sta_config;
|
||||
snprintf_P(stemp1, sizeof(stemp1), kWifiConfig[Settings.sta_config]);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_WIFICONFIG "\":\"%s " D_JSON_SELECTED "\"}"), stemp1);
|
||||
if (WifiState() != WIFI_RESTART) {
|
||||
if (WifiState() > WIFI_RESTART) {
|
||||
// snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s after restart"), mqtt_data);
|
||||
restart_flag = 2;
|
||||
}
|
||||
@ -1795,7 +1795,7 @@ void ButtonHandler()
|
||||
// Success
|
||||
} else {
|
||||
if (multipress[button_index] < 3) { // Single or Double press
|
||||
if (WifiState()) { // WPSconfig, Smartconfig or Wifimanager active
|
||||
if (WifiState() > WIFI_RESTART) { // WPSconfig, Smartconfig or Wifimanager active
|
||||
restart_flag = 1;
|
||||
} else {
|
||||
ExecuteCommandPower(button_index + multipress[button_index], POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally
|
||||
|
@ -1613,7 +1613,7 @@ void WifiCheck(uint8_t param)
|
||||
|
||||
int WifiState()
|
||||
{
|
||||
int state;
|
||||
int state = -1;
|
||||
|
||||
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
|
||||
state = WIFI_RESTART;
|
||||
|
@ -151,7 +151,7 @@ void TuyaPacketProcess()
|
||||
else if (tuya_byte_counter == 7 && tuya_buffer[3] == 3 && tuya_buffer[6] == 2) { // WiFi LED has been sucessfully set.
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: WiFi LED set ACK"));
|
||||
tuya_wifi_state = TuyaWifiState();
|
||||
tuya_wifi_state = WifiState();
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,20 +225,9 @@ boolean TuyaModuleSelected()
|
||||
return true;
|
||||
}
|
||||
|
||||
int TuyaWifiState()
|
||||
{
|
||||
int state = -1;
|
||||
|
||||
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
|
||||
state = WIFI_RESTART;
|
||||
}
|
||||
if (wifi_config_type) { state = wifi_config_type; }
|
||||
return state;
|
||||
}
|
||||
|
||||
void TuyaSetWifiLed(){
|
||||
uint8_t wifi_state = 0x02;
|
||||
switch(TuyaWifiState()){
|
||||
switch(WifiState()){
|
||||
case WIFI_SMARTCONFIG:
|
||||
wifi_state = 0x00;
|
||||
break;
|
||||
@ -254,7 +243,7 @@ void TuyaSetWifiLed(){
|
||||
break;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), "TYA: Set WiFi LED to state %d (%d)", wifi_state, TuyaWifiState());
|
||||
snprintf_P(log_data, sizeof(log_data), "TYA: Set WiFi LED to state %d (%d)", wifi_state, WifiState());
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
TuyaSerial->write((uint8_t)0x55); // header 55AA
|
||||
@ -342,7 +331,7 @@ boolean Xdrv16(byte function)
|
||||
result = TuyaButtonPressed();
|
||||
break;
|
||||
case FUNC_EVERY_SECOND:
|
||||
if(TuyaSerial && tuya_wifi_state!=TuyaWifiState()) { TuyaSetWifiLed(); }
|
||||
if(TuyaSerial && tuya_wifi_state!=WifiState()) { TuyaSetWifiLed(); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user