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:155
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:214
bool init(ksApplication *app) override
Initializes the device portal component.
Definition ksDevicePortal.cpp:114
void setupWsServer()
Starts device portal WebSocket server.
Definition ksDevicePortal.cpp:618
void updateFinished(bool fromPortal)
Implements post-OTA update actions.
Definition ksDevicePortal.cpp:196
std::string portalPassword
Portal password.
Definition ksDevicePortal.h:66
bool postInit(ksApplication *app) override
Post-initializes the device portal component.
Definition ksDevicePortal.cpp:120
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:162
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:140
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateEnd
Definition ksDevicePortal.h:185
void onRequest_index()
HTTP handler for index endpoint.
Definition ksDevicePortal.cpp:563
void onRequest_otaChunk()
HTTP handler for OTA chunk endpoint.
Definition ksDevicePortal.cpp:515
void onRequest_notFound() const
HTTP handler for 404 "not found" endpoint.
Definition ksDevicePortal.cpp:501
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:632
void handle_getIdentity(std::string &response)
Websocket handler for identity endpoint (device details).
Definition ksDevicePortal.cpp:339
bool inRequest_NeedAuthentication()
Checks if current HTTP request requires authentication.
Definition ksDevicePortal.cpp:202
void onRequest_otaFinish()
HTTP handler for OTA finish endpoint.
Definition ksDevicePortal.cpp:546
uint32_t lastLoopExecutionTimestamp
Time of last loop execution (us)/.
Definition ksDevicePortal.h:62
void rebootDevice()
Reboots the device.
Definition ksDevicePortal.cpp:149
void setupHttpServer()
Starts device portal HTTP server.
Definition ksDevicePortal.cpp:588
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:384
void handle_getDeviceParams(std::string &response)
Websocket handler for device parameters endpoint.
Definition ksDevicePortal.cpp:431
A class that serves as the base for user-defined applications.
Definition ksApplication.h:44
Base component class.
Definition ksComponent.h:36