mirror of
https://github.com/jeelabs/esp-link.git
synced 2026-03-07 09:46:48 +01:00
Reconnect periodically
This commit is contained in:
committed by
Thorsten von Eicken
parent
3df5993c0a
commit
2d679decfe
@@ -1,4 +1,7 @@
|
||||
#include "WebServer.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
#define RESUBSCRIBE_LIMIT 1000
|
||||
|
||||
WebServer * WebServer::instance = NULL;
|
||||
|
||||
@@ -19,7 +22,10 @@ void WebServer::init()
|
||||
|
||||
void WebServer::loop()
|
||||
{
|
||||
// TODO: resubscribe periodically
|
||||
// resubscribe periodically
|
||||
uint32_t elapsed = millis() - last_connect_ts;
|
||||
if( elapsed > RESUBSCRIBE_LIMIT )
|
||||
registerCallback();
|
||||
espLink.readLoop();
|
||||
}
|
||||
|
||||
@@ -28,6 +34,7 @@ void WebServer::registerCallback()
|
||||
espLink.sendPacketStart(CMD_CB_ADD, 100, 1);
|
||||
espLink.sendPacketArg(5, (uint8_t *)"webCb");
|
||||
espLink.sendPacketEnd();
|
||||
last_connect_ts = millis();
|
||||
}
|
||||
|
||||
void WebServer::invokeMethod(RequestReason reason, WebMethod * method, CmdRequest *req)
|
||||
|
||||
@@ -55,6 +55,8 @@ class WebServer
|
||||
int16_t args_to_send;
|
||||
|
||||
char * value_ptr;
|
||||
|
||||
uint32_t last_connect_ts;
|
||||
|
||||
protected:
|
||||
EspLink espLink;
|
||||
|
||||
Reference in New Issue
Block a user