6.4.1.9 Fix mDNS addService

6.4.1.9 20190115
 * Add support for Mi LED Desk Lamp with rotary switch (#4887)
 * Fix mDNS addService (#4938)
This commit is contained in:
Theo Arends 2019-01-15 16:11:42 +01:00
parent 6b7becb30a
commit e5fd45c9c8
7 changed files with 29 additions and 25 deletions

View File

@ -1,4 +1,8 @@
/* 6.4.1.8 20190107 /* 6.4.1.9 20190115
* Add support for Mi LED Desk Lamp with rotary switch (#4887)
* Fix mDNS addService (#4938)
*
* 6.4.1.8 20190107
* Change sonoff_template.h layout regarding optional module flags like ADC0 * Change sonoff_template.h layout regarding optional module flags like ADC0
* Add command SetOption62 1 to force no Button/Switch pullup on dedicated modules. Currently only supported on Shelly2 (#4841) * Add command SetOption62 1 to force no Button/Switch pullup on dedicated modules. Currently only supported on Shelly2 (#4841)
* Fix Display exception 28 when JSON value is NULL received * Fix Display exception 28 when JSON value is NULL received
@ -11,9 +15,7 @@
* Add support for Luminea ZX2820 Smart Socket with Energy monitoring (#4921) * Add support for Luminea ZX2820 Smart Socket with Energy monitoring (#4921)
* Add define MDNS_ENABLE to control initial mDNS state (#4923) * Add define MDNS_ENABLE to control initial mDNS state (#4923)
* Add split interlock part 1 (#4910) * Add split interlock part 1 (#4910)
* Add support for rotary switch *
* Add support for Mi Desk Lamp
*
* 6.4.1.7 20190106 * 6.4.1.7 20190106
* Fix HLW8012, HJL01 and BL0937 based energy sensors low Power (below 10W) measurement regression from 6.4.1.6 * Fix HLW8012, HJL01 and BL0937 based energy sensors low Power (below 10W) measurement regression from 6.4.1.6
* Add Power status functionality to LED2 when configured leaving LED1 for Link status indication * Add Power status functionality to LED2 when configured leaving LED1 for Link status indication

View File

@ -167,7 +167,6 @@ byte syslog_level; // Current copy of Settings.syslog_l
//byte mdns_delayed_start = 0; // mDNS delayed start //byte mdns_delayed_start = 0; // mDNS delayed start
boolean latest_uptime_flag = true; // Signal latest uptime boolean latest_uptime_flag = true; // Signal latest uptime
boolean pwm_present = false; // Any PWM channel configured with SetOption15 0 boolean pwm_present = false; // Any PWM channel configured with SetOption15 0
boolean mdns_begun = false; // mDNS active
myio my_module; // Active copy of Module GPIOs (17 x 8 bits) myio my_module; // Active copy of Module GPIOs (17 x 8 bits)
gpio_flag my_module_flag; // Active copy of Module GPIO flags gpio_flag my_module_flag; // Active copy of Module GPIO flags
StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits) StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits)

View File

@ -1759,8 +1759,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_REL1, // GPIO14 Relay GPIO_REL1, // GPIO14 Relay
0, 0, 0 0, 0, 0
}, },
{ "Mi Desk Lamp", // Mi LED Desk Lamp { "Mi Desk Lamp", // Mi LED Desk Lamp - https://www.mi.com/global/smartlamp/
// https://www.mi.com/global/smartlamp/
0, 0, 0, 0,
GPIO_KEY1, // GPIO02 Button GPIO_KEY1, // GPIO02 Button
0, 0,
@ -1769,11 +1768,11 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
// GPIO06 (SD_CLK Flash) // GPIO06 (SD_CLK Flash)
// GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT) // GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT)
// GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT) // GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT)
0, 0, // GPIO09 (SD_DATA2 Flash QIO or ESP8285)
0, 0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285)
// GPIO11 (SD_CMD Flash) // GPIO11 (SD_CMD Flash)
GPIO_ROT_A, // GPIO12 Rotary switch A pin GPIO_ROT_A, // GPIO12 Rotary switch A pin
GPIO_ROT_B, // GPIO13 Rotary switch B pin GPIO_ROT_B, // GPIO13 Rotary switch B pin
0, 0, 0, 0 0, 0, 0, 0
} }
}; };

View File

@ -20,7 +20,7 @@
#ifndef _SONOFF_VERSION_H_ #ifndef _SONOFF_VERSION_H_
#define _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_
#define VERSION 0x06040108 #define VERSION 0x06040109
#define D_PROGRAMNAME "Sonoff-Tasmota" #define D_PROGRAMNAME "Sonoff-Tasmota"
#define D_AUTHOR "Theo Arends" #define D_AUTHOR "Theo Arends"

View File

@ -204,18 +204,18 @@ void ButtonHandler(void)
} }
} }
if ((MI_DESK_LAMP == Settings.module) && (button_index == 0) && (rotary_changed) && (light_power)) { if ((MI_DESK_LAMP == Settings.module) && (button_index == 0) && (rotary_changed) && (light_power)) {
rotary_changed = 0; // Color temp changed, no need to turn of the light rotary_changed = 0; // Color temp changed, no need to turn of the light
} else { } else {
if (single_press && SendKey(0, button_index + multipress[button_index], POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set if (single_press && SendKey(0, button_index + multipress[button_index], POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set
// Success // Success
} else { } else {
if (multipress[button_index] < 3) { // Single or Double press if (multipress[button_index] < 3) { // Single or Double press
if (WifiState() > WIFI_RESTART) { // WPSconfig, Smartconfig or Wifimanager active if (WifiState() > WIFI_RESTART) { // WPSconfig, Smartconfig or Wifimanager active
restart_flag = 1; restart_flag = 1;
} else { } else {
ExecuteCommandPower(button_index + multipress[button_index], POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally ExecuteCommandPower(button_index + multipress[button_index], POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally
} }
} else { // 3 - 7 press } else { // 3 - 7 press
if (!Settings.flag.button_restrict) { if (!Settings.flag.button_restrict) {
snprintf_P(scmnd, sizeof(scmnd), kCommands[multipress[button_index] -3]); snprintf_P(scmnd, sizeof(scmnd), kCommands[multipress[button_index] -3]);
ExecuteCommand(scmnd, SRC_BUTTON); ExecuteCommand(scmnd, SRC_BUTTON);

View File

@ -33,7 +33,8 @@ uint8_t rotary_changed = 0;
/********************************************************************************************/ /********************************************************************************************/
void update_position(void) { void update_position(void)
{
uint8_t s; uint8_t s;
/* /*
@ -58,7 +59,8 @@ void update_position(void) {
rotary_state = (s >> 2); rotary_state = (s >> 2);
} }
void update_rotary(void) { void update_rotary(void)
{
if (MI_DESK_LAMP == Settings.module){ if (MI_DESK_LAMP == Settings.module){
if (light_power) { if (light_power) {
update_position(); update_position();
@ -132,7 +134,7 @@ void RotaryHandler(void)
Settings.light_dimmer = d; Settings.light_dimmer = d;
} }
} }
rotary_last_position = 128; rotary_last_position = 128;
rotary_position = 128; rotary_position = 128;
} }
interrupts(); interrupts();

View File

@ -41,6 +41,7 @@ uint8_t wifi_status;
uint8_t wps_result; uint8_t wps_result;
uint8_t wifi_config_type = 0; uint8_t wifi_config_type = 0;
uint8_t wifi_config_counter = 0; uint8_t wifi_config_counter = 0;
uint8_t mdns_begun = 0; // mDNS active
uint8_t wifi_scan_state; uint8_t wifi_scan_state;
uint8_t wifi_bssid[6]; uint8_t wifi_bssid[6];
@ -492,7 +493,7 @@ void WifiCheck(uint8_t param)
// mdns_delayed_start--; // mdns_delayed_start--;
// } else { // } else {
// mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START]; // mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
mdns_begun = MDNS.begin(my_hostname); mdns_begun = (uint8_t)MDNS.begin(my_hostname);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MDNS "%s"), (mdns_begun) ? D_INITIALIZED : D_FAILED); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MDNS "%s"), (mdns_begun) ? D_INITIALIZED : D_FAILED);
AddLog(LOG_LEVEL_INFO); AddLog(LOG_LEVEL_INFO);
// } // }
@ -505,7 +506,8 @@ void WifiCheck(uint8_t param)
StartWebserver(Settings.webserver, WiFi.localIP()); StartWebserver(Settings.webserver, WiFi.localIP());
#ifdef USE_DISCOVERY #ifdef USE_DISCOVERY
#ifdef WEBSERVER_ADVERTISE #ifdef WEBSERVER_ADVERTISE
if (mdns_begun) { if (1 == mdns_begun) {
mdns_begun = 2;
MDNS.addService("http", "tcp", WEB_PORT); MDNS.addService("http", "tcp", WEB_PORT);
} }
#endif // WEBSERVER_ADVERTISE #endif // WEBSERVER_ADVERTISE
@ -530,7 +532,7 @@ void WifiCheck(uint8_t param)
#if defined(USE_WEBSERVER) && defined(USE_EMULATION) #if defined(USE_WEBSERVER) && defined(USE_EMULATION)
UdpDisconnect(); UdpDisconnect();
#endif // USE_EMULATION #endif // USE_EMULATION
mdns_begun = false; mdns_begun = 0;
#ifdef USE_KNX #ifdef USE_KNX
knx_started = false; knx_started = false;
#endif // USE_KNX #endif // USE_KNX