16#include "../evt/ksEvent.h"
17#include "../ksComponent.h"
24 #define WebServerClass WebServer
27 namespace esp8266webserver
29 template<
typename ServerType = WiFiServer>
class ESP8266WebServerTemplate;
31 #define WebServerClass esp8266webserver::ESP8266WebServerTemplate<WiFiServer>
41 class ksMqttConnector;
177 void onAppLog(std::string&& message);
A component that implements a web-based configuration portal accessible from the local network.
Definition ksDevicePortal.h:53
void triggerFactoryReset()
Triggers factory reset (erase config and reboot).
Definition ksDevicePortal.cpp:150
std::unique_ptr< ArduinoOTAClass > arduinoOTA
Arduino OTA object.
Definition ksDevicePortal.h:74
ksf::ksApplication * app
Application pointer.
Definition ksDevicePortal.h:57
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:108
void setupWsServer()
Starts device portal WebSocket server.
Definition ksDevicePortal.cpp:613
void updateFinished(bool fromPortal)
Implements post-OTA update actions.
Definition ksDevicePortal.cpp:191
std::string portalPassword
Portal password.
Definition ksDevicePortal.h:68
bool postInit(ksApplication *app) override
Post-initializes the device portal component.
Definition ksDevicePortal.cpp:114
std::weak_ptr< ksMqttConnector > mqttConnectorWp
MQTT connector.
Definition ksDevicePortal.h:69
std::shared_ptr< ksf::evt::ksEvent< const std::string_view &, bool &, std::string & > > onHandlePortalCommand
Definition ksDevicePortal.h:194
void requestAppBreak()
Causes the application exit (and ksAppRotator to spawn and process next defined application).
Definition ksDevicePortal.h:79
uint32_t scanNetworkTimestamp
Timestamp of last scan.
Definition ksDevicePortal.h:66
bool breakApp
Flag to break app logic.
Definition ksDevicePortal.h:59
std::string handle_executeCommand(const std::string_view &body)
Websocket handler for user commands endpoint.
Definition ksDevicePortal.cpp:157
std::unique_ptr< misc::ksWSServer > webSocket
Web socket server.
Definition ksDevicePortal.h:72
void onAppLog(std::string &&message)
Broadcasts application log message to all connected Websocket clients.
Definition ksDevicePortal.cpp:135
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateEnd
Definition ksDevicePortal.h:187
void onRequest_index()
HTTP handler for index endpoint.
Definition ksDevicePortal.cpp:558
void onRequest_otaChunk()
HTTP handler for OTA chunk endpoint.
Definition ksDevicePortal.cpp:510
void onRequest_notFound() const
HTTP handler for 404 "not found" endpoint.
Definition ksDevicePortal.cpp:496
bool isSafeToCallEndOta
Flag indicating that OTA class is initialized.
Definition ksDevicePortal.h:60
uint32_t logKeepAliveTimestamp
Flag indicating whether logs are enabled.
Definition ksDevicePortal.h:63
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateStart
Definition ksDevicePortal.h:183
std::unique_ptr< DNSServer > dnsServer
DNS server.
Definition ksDevicePortal.h:73
struct ksf::comps::ksDevicePortal::@0 bitflags
Bit flags for internal use.
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:334
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:541
uint32_t lastLoopExecutionTimestamp
Time of last loop execution (us).
Definition ksDevicePortal.h:64
void rebootDevice()
Reboots the device.
Definition ksDevicePortal.cpp:144
void setupHttpServer()
Starts device portal HTTP server.
Definition ksDevicePortal.cpp:583
uint32_t loopExecutionTime
Diff (loop exec time).
Definition ksDevicePortal.h:65
std::unique_ptr< WebServerClass > webServer
HTTP server.
Definition ksDevicePortal.h:71
void handle_scanNetworks(std::string &response)
Websocket handler for network scan endpoint.
Definition ksDevicePortal.cpp:382
void handle_getDeviceParams(std::string &response)
Websocket handler for device parameters endpoint.
Definition ksDevicePortal.cpp:425
A class that serves as the base for user-defined applications.
Definition ksApplication.h:44
Base component class.
Definition ksComponent.h:36