15#include "../evt/ksEvent.h"
16#include "../ksComponent.h"
23 #define WebServerClass WebServer
26 namespace esp8266webserver
28 template<
typename ServerType = WiFiServer>
class ESP8266WebServerTemplate;
30 #define WebServerClass esp8266webserver::ESP8266WebServerTemplate<WiFiServer>
40 class ksMqttConnector;
175 void onAppLog(std::string&& message);
A component that implements a web-based configuration portal accessible from the local network.
Definition ksDevicePortal.h:52
void triggerFactoryReset()
Triggers factory reset (erase config and reboot).
Definition ksDevicePortal.cpp:151
std::unique_ptr< ArduinoOTAClass > arduinoOTA
Arduino OTA object.
Definition ksDevicePortal.h:72
ksf::ksApplication * app
Application pointer.
Definition ksDevicePortal.h:56
void onWebsocketTextMessage(uint8_t clientNum, const std::string_view &message)
Handles websocket text message.
Definition ksDevicePortal.cpp:210
bool init(ksApplication *app) override
Initializes the device portal component.
Definition ksDevicePortal.cpp:110
void setupWsServer()
Starts device portal WebSocket server.
Definition ksDevicePortal.cpp:614
void updateFinished(bool fromPortal)
Implements post-OTA update actions.
Definition ksDevicePortal.cpp:192
std::string portalPassword
Portal password.
Definition ksDevicePortal.h:66
bool postInit(ksApplication *app) override
Post-initializes the device portal component.
Definition ksDevicePortal.cpp:116
std::weak_ptr< ksMqttConnector > mqttConnectorWp
MQTT connector.
Definition ksDevicePortal.h:67
std::shared_ptr< ksf::evt::ksEvent< const std::string_view &, bool &, std::string & > > onHandlePortalCommand
Definition ksDevicePortal.h:192
void requestAppBreak()
Causes the application exit (and ksAppRotator to spawn and process next defined application).
Definition ksDevicePortal.h:77
uint32_t scanNetworkTimestamp
Timestamp of last scan.
Definition ksDevicePortal.h:64
bool breakApp
Flag to break app logic.
Definition ksDevicePortal.h:58
std::string handle_executeCommand(const std::string_view &body)
Websocket handler for user commands endpoint.
Definition ksDevicePortal.cpp:158
std::unique_ptr< misc::ksWSServer > webSocket
Web socket server.
Definition ksDevicePortal.h:70
void onAppLog(std::string &&message)
Broadcasts application log message to all connected Websocket clients.
Definition ksDevicePortal.cpp:136
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateEnd
Definition ksDevicePortal.h:185
void onRequest_index()
HTTP handler for index endpoint.
Definition ksDevicePortal.cpp:559
void onRequest_otaChunk()
HTTP handler for OTA chunk endpoint.
Definition ksDevicePortal.cpp:511
void onRequest_notFound() const
HTTP handler for 404 "not found" endpoint.
Definition ksDevicePortal.cpp:497
uint32_t logKeepAliveTimestamp
Flag indicating whether logs are enabled.
Definition ksDevicePortal.h:61
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateStart
Definition ksDevicePortal.h:181
std::unique_ptr< DNSServer > dnsServer
DNS server.
Definition ksDevicePortal.h:71
bool loop(ksApplication *app) override
Handles core logic of the device portal component.
Definition ksDevicePortal.cpp:627
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:198
void onRequest_otaFinish()
HTTP handler for OTA finish endpoint.
Definition ksDevicePortal.cpp:542
uint32_t lastLoopExecutionTimestamp
Time of last loop execution (us)/.
Definition ksDevicePortal.h:62
void rebootDevice()
Reboots the device.
Definition ksDevicePortal.cpp:145
void setupHttpServer()
Starts device portal HTTP server.
Definition ksDevicePortal.cpp:584
uint32_t loopExecutionTime
Diff (loop exec time).
Definition ksDevicePortal.h:63
std::unique_ptr< WebServerClass > webServer
HTTP server.
Definition ksDevicePortal.h:69
void handle_scanNetworks(std::string &response)
Websocket handler for network scan endpoint.
Definition ksDevicePortal.cpp:380
void handle_getDeviceParams(std::string &response)
Websocket handler for device parameters endpoint.
Definition ksDevicePortal.cpp:427
A class that serves as the base for user-defined applications.
Definition ksApplication.h:44
Base component class.
Definition ksComponent.h:36