Press inclusion button to reboot after 10 sec, ESP8266 only



  • The patch for the inclusion button, after holding for 10 seconds, the device goes into reboot.
    Only suitable for ESP8266 ..

    MySensors/core/MyInclusionMode.patch

    9c9
    <  * Copyright (C) 2013-2019 Sensnology AB
    ---
    >  * Copyright (C) 2013-2020 Sensnology AB
    21,23d20
    < #if defined(ARDUINO_ARCH_ESP8266)
    < #  include <Esp.h>
    < #endif
    28,29c25,26
    < unsigned long _inclusionStartTime = 0U, _rebootStartTime = 0U;
    < bool _inclusionMode, _rebootMode;
    ---
    > unsigned long _inclusionStartTime;
    > bool _inclusionMode;
    33d29
    < 	_rebootMode = false;
    66,68c62
    < 
    < 	bool b = (hwDigitalRead(MY_INCLUSION_MODE_BUTTON_PIN) == MY_INCLUSION_BUTTON_PRESSED);
    < 	if (!_inclusionMode && b) {
    ---
    > 	if (!_inclusionMode && hwDigitalRead(MY_INCLUSION_MODE_BUTTON_PIN) == MY_INCLUSION_BUTTON_PRESSED) {
    72,84d65
    < #	if defined(ARDUINO_ARCH_ESP8266)
    < 	if (!_rebootMode && b) {
    < 		_rebootStartTime = hwMillis() + 10000U;
    < 		_rebootMode = true;
    < 
    < 	} else if (_rebootMode && b) {
    < 		if (_rebootStartTime < hwMillis())
    < 			ESP.restart();
    < 
    < 	} else if (_rebootMode) {
    < 		_rebootMode = false;
    < 	}
    < #	endif
    86c67,68
    < 	if (_inclusionMode && (hwMillis() - _inclusionStartTime > MY_INCLUSION_MODE_DURATION * 1000L)) {
    ---
    > 
    > 	if (_inclusionMode && hwMillis()-_inclusionStartTime>MY_INCLUSION_MODE_DURATION*1000L) {
    90c72
    < }
    ---
    > }
    \ No newline at end of file
    

Log in to reply
 

Suggested Topics

  • 7
  • 177
  • 17
  • 5
  • 79
  • 2
  • 21

171
Online

9.8k
Users

10.3k
Topics

106.7k
Posts