mirror of https://github.com/arendst/Tasmota.git
Add command ``Wifi 0/1`` for ESP8266
Add command ``Wifi 0/1`` for ESP8266 to turn wifi Off and On. When wifi is Off it is always returned On after a restart except for a wake-up from deepsleep (#11839)
This commit is contained in:
parent
199ce169b8
commit
147440fd99
|
@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
|
|||
## [Unreleased] - Development
|
||||
|
||||
## [9.4.0.1]
|
||||
### Added
|
||||
- Command ``Wifi 0/1`` for ESP8266 to turn wifi Off and On. When wifi is Off it is always returned On after a restart except for a wake-up from deepsleep (#11839)
|
||||
|
||||
### Changed
|
||||
- Command ``Power`` should not reset pulsetime (#11805)
|
||||
- Zigbee refactored storage for device configuration and device last known data (#11838)
|
||||
|
|
|
@ -78,6 +78,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
|
|||
|
||||
## Changelog v9.4.0.1
|
||||
### Added
|
||||
- Command ``Wifi 0/1`` for ESP8266 to turn wifi Off and On. When wifi is Off it is always returned On after a restart except for a wake-up from deepsleep [#11839](https://github.com/arendst/Tasmota/issues/11839)
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
|
|||
D_CMND_MODULE "|" D_CMND_MODULES "|" D_CMND_GPIO "|" D_CMND_GPIOS "|" D_CMND_TEMPLATE "|" D_CMND_PWM "|" D_CMND_PWMFREQUENCY "|" D_CMND_PWMRANGE "|"
|
||||
D_CMND_BUTTONDEBOUNCE "|" D_CMND_SWITCHDEBOUNCE "|" D_CMND_SYSLOG "|" D_CMND_LOGHOST "|" D_CMND_LOGPORT "|"
|
||||
D_CMND_SERIALBUFFER "|" D_CMND_SERIALSEND "|" D_CMND_BAUDRATE "|" D_CMND_SERIALCONFIG "|" D_CMND_SERIALDELIMITER "|"
|
||||
D_CMND_IPADDRESS "|" D_CMND_NTPSERVER "|" D_CMND_AP "|" D_CMND_SSID "|" D_CMND_PASSWORD "|" D_CMND_HOSTNAME "|" D_CMND_WIFICONFIG "|"
|
||||
D_CMND_IPADDRESS "|" D_CMND_NTPSERVER "|" D_CMND_AP "|" D_CMND_SSID "|" D_CMND_PASSWORD "|" D_CMND_HOSTNAME "|" D_CMND_WIFICONFIG "|" D_CMND_WIFI "|"
|
||||
D_CMND_DEVICENAME "|" D_CMND_FN "|" D_CMND_FRIENDLYNAME "|" D_CMND_SWITCHMODE "|" D_CMND_INTERLOCK "|" D_CMND_TELEPERIOD "|" D_CMND_RESET "|" D_CMND_TIME "|" D_CMND_TIMEZONE "|" D_CMND_TIMESTD "|"
|
||||
D_CMND_TIMEDST "|" D_CMND_ALTITUDE "|" D_CMND_LEDPOWER "|" D_CMND_LEDSTATE "|" D_CMND_LEDMASK "|" D_CMND_LEDPWM_ON "|" D_CMND_LEDPWM_OFF "|" D_CMND_LEDPWM_MODE "|"
|
||||
D_CMND_WIFIPOWER "|" D_CMND_TEMPOFFSET "|" D_CMND_HUMOFFSET "|" D_CMND_SPEEDUNIT "|" D_CMND_GLOBAL_TEMP "|" D_CMND_GLOBAL_HUM"|" D_CMND_SWITCHTEXT "|"
|
||||
|
@ -41,7 +41,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
|
|||
#endif // USE_DEVICE_GROUPS
|
||||
D_CMND_SENSOR "|" D_CMND_DRIVER
|
||||
#ifdef ESP32
|
||||
"|Info|" D_CMND_TOUCH_CAL "|" D_CMND_TOUCH_THRES "|" D_CMND_TOUCH_NUM "|" D_CMND_CPU_FREQUENCY "|" D_CMND_WIFI
|
||||
"|Info|" D_CMND_TOUCH_CAL "|" D_CMND_TOUCH_THRES "|" D_CMND_TOUCH_NUM "|" D_CMND_CPU_FREQUENCY
|
||||
#endif // ESP32
|
||||
;
|
||||
|
||||
|
@ -53,7 +53,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
|
|||
&CmndModule, &CmndModules, &CmndGpio, &CmndGpios, &CmndTemplate, &CmndPwm, &CmndPwmfrequency, &CmndPwmrange,
|
||||
&CmndButtonDebounce, &CmndSwitchDebounce, &CmndSyslog, &CmndLoghost, &CmndLogport,
|
||||
&CmndSerialBuffer, &CmndSerialSend, &CmndBaudrate, &CmndSerialConfig, &CmndSerialDelimiter,
|
||||
&CmndIpAddress, &CmndNtpServer, &CmndAp, &CmndSsid, &CmndPassword, &CmndHostname, &CmndWifiConfig,
|
||||
&CmndIpAddress, &CmndNtpServer, &CmndAp, &CmndSsid, &CmndPassword, &CmndHostname, &CmndWifiConfig, &CmndWifi,
|
||||
&CmndDevicename, &CmndFriendlyname, &CmndFriendlyname, &CmndSwitchMode, &CmndInterlock, &CmndTeleperiod, &CmndReset, &CmndTime, &CmndTimezone, &CmndTimeStd,
|
||||
&CmndTimeDst, &CmndAltitude, &CmndLedPower, &CmndLedState, &CmndLedMask, &CmndLedPwmOn, &CmndLedPwmOff, &CmndLedPwmMode,
|
||||
&CmndWifiPower, &CmndTempOffset, &CmndHumOffset, &CmndSpeedUnit, &CmndGlobalTemp, &CmndGlobalHum, &CmndSwitchText,
|
||||
|
@ -69,7 +69,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
|
|||
#endif // USE_DEVICE_GROUPS
|
||||
&CmndSensor, &CmndDriver
|
||||
#ifdef ESP32
|
||||
, &CmndInfo, &CmndTouchCal, &CmndTouchThres, &CmndTouchNum, &CmndCpuFrequency, &CmndWifi
|
||||
, &CmndInfo, &CmndTouchCal, &CmndTouchThres, &CmndTouchNum, &CmndCpuFrequency
|
||||
#endif // ESP32
|
||||
};
|
||||
|
||||
|
@ -2114,6 +2114,15 @@ void CmndWifiPower(void)
|
|||
ResponseCmndChar(WifiGetOutputPower().c_str());
|
||||
}
|
||||
|
||||
void CmndWifi(void)
|
||||
{
|
||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {
|
||||
Settings.flag4.network_wifi = XdrvMailbox.payload;
|
||||
if (Settings.flag4.network_wifi) { WifiEnable(); }
|
||||
}
|
||||
ResponseCmndStateText(Settings.flag4.network_wifi);
|
||||
}
|
||||
|
||||
#ifdef USE_I2C
|
||||
void CmndI2cScan(void)
|
||||
{
|
||||
|
@ -2217,15 +2226,6 @@ void CmndInfo(void) {
|
|||
ResponseCmndDone();
|
||||
}
|
||||
|
||||
void CmndWifi(void)
|
||||
{
|
||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {
|
||||
Settings.flag4.network_wifi = XdrvMailbox.payload;
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
}
|
||||
ResponseCmndStateText(Settings.flag4.network_wifi);
|
||||
}
|
||||
|
||||
void CmndCpuFrequency(void) {
|
||||
if ((80 == XdrvMailbox.payload) || (160 == XdrvMailbox.payload) || (240 == XdrvMailbox.payload)) {
|
||||
setCpuFrequencyMhz(XdrvMailbox.payload);
|
||||
|
|
|
@ -1288,6 +1288,8 @@ void Every250mSeconds(void)
|
|||
if (Settings.flag4.network_wifi) {
|
||||
WifiCheck(TasmotaGlobal.wifi_state_flag);
|
||||
TasmotaGlobal.wifi_state_flag = WIFI_RESTART;
|
||||
} else {
|
||||
WifiDisable();
|
||||
}
|
||||
break;
|
||||
case 3: // Every x.75 second
|
||||
|
@ -1326,7 +1328,7 @@ void Every250mSeconds(void)
|
|||
StopWebserver();
|
||||
}
|
||||
#ifdef USE_EMULATION
|
||||
if (Settings.flag2.emulation) { UdpConnect(); }
|
||||
if (Settings.flag2.emulation) { UdpConnect(); }
|
||||
#endif // USE_EMULATION
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
|
|
|
@ -567,6 +567,10 @@ RF_PRE_INIT()
|
|||
}
|
||||
#endif // WIFI_RF_PRE_INIT
|
||||
|
||||
void WifiEnable(void) {
|
||||
Wifi.counter = 1;
|
||||
}
|
||||
|
||||
void WifiConnect(void)
|
||||
{
|
||||
if (!Settings.flag4.network_wifi) { return; }
|
||||
|
@ -623,6 +627,14 @@ void WifiShutdown(bool option = false)
|
|||
delay(100); // Flush anything in the network buffers.
|
||||
}
|
||||
|
||||
void WifiDisable(void) {
|
||||
if (!TasmotaGlobal.global_state.wifi_down) {
|
||||
WifiShutdown();
|
||||
WifiSetMode(WIFI_OFF);
|
||||
}
|
||||
TasmotaGlobal.global_state.wifi_down = 1;
|
||||
}
|
||||
|
||||
void EspRestart(void)
|
||||
{
|
||||
ResetPwm();
|
||||
|
|
|
@ -288,6 +288,17 @@ void setup(void) {
|
|||
UpdateQuickPowerCycle(true);
|
||||
}
|
||||
|
||||
if (ResetReason() != REASON_DEEP_SLEEP_AWAKE) {
|
||||
#ifdef ESP8266
|
||||
Settings.flag4.network_wifi = 1; // Make sure we're in control
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
if (!Settings.flag4.network_ethernet) {
|
||||
Settings.flag4.network_wifi = 1; // Make sure we're in control
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TasmotaGlobal.stop_flash_rotate = Settings.flag.stop_flash_rotate; // SetOption12 - Switch between dynamic or fixed slot flash save location
|
||||
TasmotaGlobal.save_data_counter = Settings.save_data;
|
||||
TasmotaGlobal.sleep = Settings.sleep;
|
||||
|
|
Loading…
Reference in New Issue