swimtracker-firmware/firmware/src/WifiAPI.h

35 lines
713 B
C
Raw Normal View History

2021-06-06 10:49:09 +02:00
#include "Dtypes.h"
#include "MessageCodes.h"
#include "SwimTrackerConfig.h"
#include <ArduinoWebsockets.h>
#include <ArduinoJson.h>
class WifiManager;
class WifiAPI
{
public:
WifiAPI(WifiManager &wifiManager)
: wifiManager_(wifiManager), restartScheduled_(false)
{
}
void onClientConnect(websockets::WebsocketsClient &client) {}
bool handleMessage(websockets::WebsocketsClient &client, MessageCode code, const char *payload, size_t size);
template <typename TServer>
void iteration(TServer &server)
{
if (restartScheduled_)
{
Serial.print("Restart triggered by WifiAPI");
ESP.restart();
}
}
private:
WifiManager &wifiManager_;
bool restartScheduled_;
};