Let WebServer handle other EspLink calls

pull/193/head
cskarai 8 years ago committed by Thorsten von Eicken
parent f368545aa7
commit adbea01deb
  1. 9
      arduino/libraries/EspLink/WebServer.cpp
  2. 6
      arduino/libraries/EspLink/WebServer.h

@ -10,7 +10,7 @@ void webServerCallback(CmdRequest *req)
WebServer::getInstance()->handleRequest(req);
}
WebServer::WebServer(Stream &streamIn, const WebMethod * PROGMEM methodsIn):espLink(streamIn, webServerCallback),methods(methodsIn),stream(streamIn)
WebServer::WebServer(Stream &streamIn, const WebMethod * PROGMEM methodsIn):espLink(streamIn, webServerCallback),methods(methodsIn),stream(streamIn),esplink_cb(NULL)
{
instance = this;
}
@ -89,6 +89,13 @@ void WebServer::invokeMethod(RequestReason reason, WebMethod * method, CmdReques
void WebServer::handleRequest(CmdRequest *req)
{
if( req->cmd->cmd != CMD_WEB_REQ_CB )
{
if( esplink_cb != NULL )
esplink_cb(req);
return;
}
uint16_t shrt;
espLink.cmdPopArg(req, &shrt, 2);
RequestReason reason = (RequestReason)shrt;

@ -56,6 +56,8 @@ class WebServer
uint32_t last_connect_ts;
CmdRequestCB esplink_cb;
protected:
EspLink espLink;
@ -67,6 +69,8 @@ class WebServer
void registerCallback();
void setEspLinkCallback(CmdRequestCB cb) { esplink_cb = cb; }
static WebServer * getInstance() { return instance; }
uint8_t * getRemoteIp() { return remote_ip; }
uint16_t getRemotePort() { return remote_port; }
@ -80,6 +84,8 @@ class WebServer
int32_t getArgInt();
char * getArgString();
uint8_t getArgBoolean();
EspLink * getEspLink() { return &espLink; }
};
#endif /* WEB_SERVER_H */

Loading…
Cancel
Save