#ifndef __POWERBOX_H__ #define __POWERBOX_H__ // includes #include #include #include #include #include #include #include #include "PowerOutlet.h" #include "WifiConfig.h" // defines #define HTTP_PORT 80 #define NUMBERPOWEROUTLETS 4 const char *powerOutletsConfigFile = "/powerOutletsConfig.json"; const char *wifiConfigurationFile = "/wifiConfiguration.json"; struct WiFiConfiguration { char wifiNetworkSsid[30]; char wifiNetworkPassword[30]; char softAPSsid[30]; char softAPPassword[30]; char softAPipAddress[15]; char softAPGateway[15]; char softAPSubnet[15]; }; #define TOUCH_THRESHOLD 25 #define TOUCH_DEBOUNCE_TIME 500 // function definitions void processNotFound(AsyncWebServerRequest *request); void processGetPowerOutlets(AsyncWebServerRequest *request); void processGetPowerOutlets_Id(AsyncWebServerRequest *request); void processPutPowerOutlets_Id(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total); void processGetWifiConfig(AsyncWebServerRequest *request); void processHttpWifiConfig(AsyncWebServerRequest *request, JsonVariant &json); void togglePowerOutlet(int id); void turnOffAll(); void setPowerOutletState(int id, bool state); void setonPowerOutlet(int id); void processTouch(); bool setupWebserver(); void setupWifi(); void setupGPIO(); void setupTouchInterfaces(); void initializeTickers(); bool loadPowerOutletsConfiguration(); bool savePowerOutletsConfiguration(); bool loadWiFiConfiguration(); void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len); void handleWebSocketMessage(void *arg, uint8_t *data, size_t len); void notifyWebSocketClients(int id); #endif //__POWERBOX_H