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;
176 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:149
std::unique_ptr< ArduinoOTAClass > arduinoOTA
Arduino OTA object.
Definition ksDevicePortal.h:73
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:208
bool init(ksApplication *app) override
Initializes the device portal component.
Definition ksDevicePortal.cpp:107
void setupWsServer()
Starts device portal WebSocket server.
Definition ksDevicePortal.cpp:612
void updateFinished(bool fromPortal)
Implements post-OTA update actions.
Definition ksDevicePortal.cpp:190
std::string portalPassword
Portal password.
Definition ksDevicePortal.h:67
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:68
std::shared_ptr< ksf::evt::ksEvent< const std::string_view &, bool &, std::string & > > onHandlePortalCommand
Definition ksDevicePortal.h:193
void requestAppBreak()
Causes the application exit (and ksAppRotator to spawn and process next defined application).
Definition ksDevicePortal.h:78
uint32_t scanNetworkTimestamp
Timestamp of last scan.
Definition ksDevicePortal.h:65
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:156
std::unique_ptr< misc::ksWSServer > webSocket
Web socket server.
Definition ksDevicePortal.h:71
void onAppLog(std::string &&message)
Broadcasts application log message to all connected Websocket clients.
Definition ksDevicePortal.cpp:134
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateEnd
Definition ksDevicePortal.h:186
void onRequest_index()
HTTP handler for index endpoint.
Definition ksDevicePortal.cpp:557
void onRequest_otaChunk()
HTTP handler for OTA chunk endpoint.
Definition ksDevicePortal.cpp:509
void onRequest_notFound() const
HTTP handler for 404 "not found" endpoint.
Definition ksDevicePortal.cpp:495
bool isSafeToCallEndOta
Flag indicating that OTA class is initialized.
Definition ksDevicePortal.h:59
uint32_t logKeepAliveTimestamp
Flag indicating whether logs are enabled.
Definition ksDevicePortal.h:62
std::shared_ptr< ksf::evt::ksEvent<> > onUpdateStart
Definition ksDevicePortal.h:182
std::unique_ptr< DNSServer > dnsServer
DNS server.
Definition ksDevicePortal.h:72
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:626
void handle_getIdentity(std::string &response)
Websocket handler for identity endpoint (device details).
Definition ksDevicePortal.cpp:333
bool inRequest_NeedAuthentication()
Checks if current HTTP request requires authentication.
Definition ksDevicePortal.cpp:196
void onRequest_otaFinish()
HTTP handler for OTA finish endpoint.
Definition ksDevicePortal.cpp:540
uint32_t lastLoopExecutionTimestamp
Time of last loop execution (us)/.
Definition ksDevicePortal.h:63
void rebootDevice()
Reboots the device.
Definition ksDevicePortal.cpp:143
void setupHttpServer()
Starts device portal HTTP server.
Definition ksDevicePortal.cpp:582
uint32_t loopExecutionTime
Diff (loop exec time).
Definition ksDevicePortal.h:64
std::unique_ptr< WebServerClass > webServer
HTTP server.
Definition ksDevicePortal.h:70
void handle_scanNetworks(std::string &response)
Websocket handler for network scan endpoint.
Definition ksDevicePortal.cpp:378
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