Skip to content

Commit 2b1fcf1

Browse files
committed
Added API to allow restrt of the WiFi module
Relates to #228
1 parent 399c42b commit 2b1fcf1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/emonesp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,6 @@
161161
extern String currentfirmware;
162162
extern String buildenv;
163163

164+
void restart_system();
165+
164166
#endif // _EMONESP_H

src/main.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,19 @@ void hardware_setup()
256256

257257
enableLoopWDT();
258258
}
259+
260+
class SystemRestart : public MicroTasks::Alarm
261+
{
262+
public:
263+
void Trigger()
264+
{
265+
DBUGLN("Restarting...");
266+
net_wifi_disconnect();
267+
ESPAL.reset();
268+
}
269+
} systemRestartAlarm;
270+
271+
void restart_system()
272+
{
273+
systemRestartAlarm.Set(1000, false);
274+
}

0 commit comments

Comments
 (0)