14#include "../evt/ksEvent.h"
15#include "../ksComponent.h"
22 #define WebServerClass WebServer
25 namespace esp8266webserver
27 template<
typename ServerType = WiFiServer>
class ESP8266WebServerTemplate;
29 #define WebServerClass esp8266webserver::ESP8266WebServerTemplate<WiFiServer>
174 void onAppLog(std::string&& message);
212 bool init(ksApplication*
app) override;
226 bool loop(ksApplication*
app) override;
void triggerFactoryReset()
Triggers factory reset (erase config and reboot).
Definition ksDevicePortal.cpp:145
std::unique_ptr< ArduinoOTAClass > arduinoOTA
Arduino OTA object.
Definition ksDevicePortal.h:71
ksf::ksApplication * app
Application pointer.
Definition ksDevicePortal.h:55
void onWebsocketTextMessage(uint8_t clientNum, const std::string_view &message)
Handles websocket text message.
Definition ksDevicePortal.cpp:209
bool init(ksApplication *app) override
Initializes the device portal component.
Definition ksDevicePortal.cpp:103
void setupWsServer()
Starts device portal WebSocket server.
Definition ksDevicePortal.cpp:609
void updateFinished(bool fromPortal)
Implements post-OTA update actions.
Definition ksDevicePortal.cpp:191
std::string portalPassword
Portal password.
Definition ksDevicePortal.h:65
bool postInit(ksApplication *app) override
Post-initializes the device portal component.
Definition ksDevicePortal.cpp:113
std::weak_ptr< ksMqttConnector > mqttConnectorWp
MQTT connector.
Definition ksDevicePortal.h:66
std::shared_ptr< ksf::evt::ksEvent< const std::string_view &, bool &, std::string & > > onHandlePortalCommand
Definition ksDevicePortal.h:191
void requestAppBreak()
Causes the application exit (and ksAppRotator to spawn and process next defined application).
Definition ksDevicePortal.h:76
uint32_t scanNetworkTimestamp
Timestamp of last scan.
Definition ksDevicePortal.h:63
bool breakApp
Flag to break app logic.
Definition ksDevicePortal.h:57
std::string handle_executeCommand(const std::string_view &body)
Websocket handler for user commands endpoint.
Definition ksDevicePortal.cpp:152
std::unique_ptr< misc::ksWSServer > webSocket
Web socket server.
Definition ksDevicePortal.h:69
void onAppLog(std::string &&message)
Broadcasts application log message to all connected Websocket clients.
Definition ksDevicePortal.cpp:130
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateEnd
Definition ksDevicePortal.h:184
void onRequest_index()
HTTP handler for index endpoint.
Definition ksDevicePortal.cpp:554
void onRequest_otaChunk()
HTTP handler for OTA chunk endpoint.
Definition ksDevicePortal.cpp:506
void onRequest_notFound() const
HTTP handler for 404 "not found" endpoint.
Definition ksDevicePortal.cpp:492
uint32_t logKeepAliveTimestamp
Flag indicating whether logs are enabled.
Definition ksDevicePortal.h:60
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateStart
Definition ksDevicePortal.h:180
std::unique_ptr< DNSServer > dnsServer
DNS server.
Definition ksDevicePortal.h:70
ksDevicePortal()
Constructs the Device Portal component.
Definition ksDevicePortal.cpp:84
bool loop(ksApplication *app) override
Handles core logic of the device portal component.
Definition ksDevicePortal.cpp:622
void handle_getIdentity(std::string &response)
Websocket handler for identity endpoint (device details).
Definition ksDevicePortal.cpp:335
bool inRequest_NeedAuthentication()
Checks if current HTTP request requires authentication.
Definition ksDevicePortal.cpp:197
void onRequest_otaFinish()
HTTP handler for OTA finish endpoint.
Definition ksDevicePortal.cpp:537
uint32_t lastLoopExecutionTimestamp
Time of last loop execution (us)/.
Definition ksDevicePortal.h:61
void rebootDevice()
Reboots the device.
Definition ksDevicePortal.cpp:139
void setupHttpServer()
Starts device portal HTTP server.
Definition ksDevicePortal.cpp:579
uint32_t loopExecutionTime
Diff (loop exec time).
Definition ksDevicePortal.h:62
std::unique_ptr< WebServerClass > webServer
HTTP server.
Definition ksDevicePortal.h:68
void handle_scanNetworks(std::string &response)
Websocket handler for network scan endpoint.
Definition ksDevicePortal.cpp:376
void handle_getDeviceParams(std::string &response)
Websocket handler for device parameters endpoint.
Definition ksDevicePortal.cpp:423
A component which is responsible for MQTT connection management.
Definition ksMqttConnector.h:45
A class that is a base for user-defined application.
Definition ksApplication.h:43
Base component class.
Definition ksComponent.h:51
Wrapper around WebSocketsServerCore that adds WebSocket authentication and better message handling.
Definition ksWSServer.h:29