diff --git a/spejsiot/SpejsNode.cpp b/spejsiot/SpejsNode.cpp index bac82c0..dd50e87 100644 --- a/spejsiot/SpejsNode.cpp +++ b/spejsiot/SpejsNode.cpp @@ -19,9 +19,14 @@ void SpejsNode::init(bool debug) { debugf("*** SpejsNode init, runnning on: %s, current rom: %d", deviceID.c_str(), currentSlot); + System.onReady(SystemReadyDelegate(&SpejsNode::systemReady, this)); +} + +void SpejsNode::systemReady() { WifiAccessPoint.enable(false); WifiStation.enable(true); - WifiStation.config(WIFI_SSID, WIFI_PWD); + WifiStation.config(wifiSSID, wifiPassword); + WifiStation.connect(); WifiEvents.onStationGotIP(StationGotIPDelegate(&SpejsNode::gotIP, this)); diff --git a/spejsiot/SpejsNode.h b/spejsiot/SpejsNode.h index 7bbcd03..d3671b9 100644 --- a/spejsiot/SpejsNode.h +++ b/spejsiot/SpejsNode.h @@ -69,6 +69,13 @@ protected: void otaUpdateCallback(bool result); void httpFile(HttpRequest &request, HttpResponse &response); void httpIndex(HttpRequest &request, HttpResponse &response); + + void systemReady(void); + + String wifiSSID = WIFI_SSID; + String wifiPassword = WIFI_PWD; + + bool brokerUseTLS = false; public: MqttClient mqtt; HttpServer http;