35 lines
713 B
C
35 lines
713 B
C
|
#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_;
|
||
|
};
|