Reconnect periodically

pull/183/head
Karai Csaba 9 years ago committed by cskarai
parent 03d17bc072
commit 2e63586c16
  1. 9
      examples/arduino/EspLinkSample/WebServer.cpp
  2. 2
      examples/arduino/EspLinkSample/WebServer.h

@ -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;

Loading…
Cancel
Save