Change once tickers

This commit is contained in:
Theo Arends 2020-12-26 15:12:46 +01:00
parent 9baa1bd9f4
commit 8d6f8f505f
6 changed files with 8 additions and 10 deletions

View File

@ -158,13 +158,13 @@ void PollUdp(void)
#ifdef USE_EMULATION_WEMO
if (EMUL_WEMO == Settings.flag2.emulation) {
if (strstr_P(packet_buffer, URN_BELKIN_DEVICE) != nullptr) { // type1 echo dot 2g, echo 1g's
TickerMSearch.attach_ms(response_delay, WemoRespondToMSearch, 1);
TickerMSearch.once_ms(response_delay, WemoRespondToMSearch, 1);
return;
}
else if ((strstr_P(packet_buffer, UPNP_ROOTDEVICE) != nullptr) || // type2 Echo 2g (echo & echo plus)
(strstr_P(packet_buffer, SSDPSEARCH_ALL) != nullptr) ||
(strstr_P(packet_buffer, SSDP_ALL) != nullptr)) {
TickerMSearch.attach_ms(response_delay, WemoRespondToMSearch, 2);
TickerMSearch.once_ms(response_delay, WemoRespondToMSearch, 2);
return;
}
}
@ -176,7 +176,7 @@ void PollUdp(void)
(strstr_P(packet_buffer, UPNP_ROOTDEVICE) != nullptr) ||
(strstr_P(packet_buffer, SSDPSEARCH_ALL) != nullptr) ||
(strstr_P(packet_buffer, SSDP_ALL) != nullptr)) {
TickerMSearch.attach_ms(response_delay, HueRespondToMSearch);
TickerMSearch.once_ms(response_delay, HueRespondToMSearch);
return;
}
}

View File

@ -164,6 +164,9 @@ String EthernetMacAddress(void);
#endif
#ifdef USE_ZIGBEE
#define USE_UNISHOX_COMPRESSION // Add support for string compression
#endif
#ifdef USE_EMULATION_HUE
#define USE_UNISHOX_COMPRESSION // Add support for string compression
#endif
// See https://github.com/esp8266/Arduino/pull/4889

View File

@ -80,7 +80,6 @@ void HueRespondToMSearch(void)
{
char message[TOPSZ];
TickerMSearch.detach();
if (PortUdp.beginPacket(udp_remote_ip, udp_remote_port)) {
char response[320];
snprintf_P(response, sizeof(response), HUE_RESPONSE, WiFi.localIP().toString().c_str(), HueBridgeId().c_str());

View File

@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(USE_WEBSERVER) && defined(USE_EMULATION) && defined (USE_EMULATION_WEMO_SINGLE)
#if defined(USE_WEBSERVER) && defined(USE_EMULATION) && defined(USE_EMULATION_WEMO_SINGLE)
/*********************************************************************************************\
* Belkin WeMo emulation
\*********************************************************************************************/
@ -58,7 +58,6 @@ void WemoRespondToMSearch(int echo_type)
{
char message[TOPSZ];
TickerMSearch.detach();
if (PortUdp.beginPacket(udp_remote_ip, udp_remote_port)) {
char type[24];
if (1 == echo_type) { // type1 echo 1g & dot 2g

View File

@ -419,8 +419,6 @@ WemoSwitch *wemoDevice[MAX_FRIENDLYNAMES] = {};
int numOfWemoSwitch = 0;
void WemoRespondToMSearch(int echo_type) {
TickerMSearch.detach();
for (uint32_t i = 0; i < numOfWemoSwitch; i++) {
wemoDevice[i]->WemoRespondToMSearch(echo_type);
}

View File

@ -64,7 +64,6 @@ struct SNFL1 {
Ticker SnfL1StartDelay;
void SnfL1SendDelayed(void) {
SnfL1StartDelay.detach();
SnfL1Send();
}
@ -276,7 +275,7 @@ bool SnfL1SetChannels(void)
static bool first_call = true;
if (first_call) {
SnfL1StartDelay.attach_ms(900, SnfL1SendDelayed); // Allow startup time for Nuvotron microcontroller
SnfL1StartDelay.once_ms(900, SnfL1SendDelayed); // Allow startup time for Nuvotron microcontroller
first_call = false;
} else {
SnfL1Send();