diff --git a/platformio.ini b/platformio.ini index 46ed74f..cdaf4a1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,6 +1,3 @@ -[platformio] -env_default = basic_esp01 - [common] framework = arduino platform = espressif8266 @@ -42,15 +39,4 @@ upload_speed = ${common.upload_speed} monitor_baud = ${common.monitor_baud} framework = ${common.framework} lib_deps = ${common.lib_deps} - ESPmDNS - -[env:ota] -src_filter = +<*> - + -platform = ${common.platform} -board = ${common.board} -upload_speed = ${common.upload_speed} -monitor_baud = ${common.monitor_baud} -framework = ${common.framework} -lib_deps = ${common.lib_deps} - ESP8266mDNS - ArduinoOTA \ No newline at end of file + ESPmDNS \ No newline at end of file diff --git a/src/OtaTcpPlugin.cpp_ b/src/OtaTcpPlugin.cpp_ deleted file mode 100644 index 54daa9a..0000000 --- a/src/OtaTcpPlugin.cpp_ +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef __OTA_CLASSIC_H__ -#define __OTA_CLASSIC_H__ - -#include "TaskSchedulerDeclarations.h" -#include "ArduinoOTA.h" -#include "Plugin.h" - -using namespace std; -using namespace std::placeholders; - -struct OtaConfig { - int port; - const char* password; -}; - -class OtaTcpPlugin : public Plugin { - private: - OtaConfig config; - Task otaTask; - public: - OtaTcpPlugin(OtaConfig cfg){ - config = cfg; - - } - void enable() { - Serial.println("OTA enable"); - ArduinoOTA.begin(); - otaTask.enable(); - } - void activate(Scheduler* userScheduler){ - // setup task - // TOOD check if we can increase the time OTA needs to be handled - // FIXME make this configurable - otaTask.set(TASK_MILLISECOND * 1000, TASK_FOREVER, [](){ - ArduinoOTA.handle(); - }); - userScheduler->addTask(otaTask); - - // configure OTA - ArduinoOTA.setPort(config.port); - //ArduinoOTA.setHostname(HOSTNAME); - if(strlen(config.password) > 0){ - ArduinoOTA.setPassword(config.password); - } - // setup callbacks - ArduinoOTA.onStart([]() { - Serial.println("OTA: Start"); - }); - ArduinoOTA.onEnd([]() { - Serial.println("OTA: End"); - }); - ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { - Serial.printf("OTA: Progress: %u%%\r", (progress / (total / 100))); - }); - ArduinoOTA.onError([](ota_error_t error) { - Serial.printf("OTA: Error[%u]: ", error); - if (error == OTA_AUTH_ERROR) Serial.println("OTA: Auth Failed"); - else if (error == OTA_BEGIN_ERROR) Serial.println("OTA: Begin Failed"); - else if (error == OTA_CONNECT_ERROR) Serial.println("OTA: Connect Failed"); - else if (error == OTA_RECEIVE_ERROR) Serial.println("OTA: Receive Failed"); - else if (error == OTA_END_ERROR) Serial.println("OTA: End Failed"); - }); - - enable(); - } - void disable(){ - otaTask.disable(); - } -}; - -#endif \ No newline at end of file diff --git a/src/WiFiNet.cpp b/src/WiFiNet.cpp index a8042de..64ecf55 100644 --- a/src/WiFiNet.cpp +++ b/src/WiFiNet.cpp @@ -18,7 +18,7 @@ WiFiNet::WiFiNet( } int WiFiNet::connect(){ - config.fromFile("/config.json"); + config.fromFile("/config/wifi.json"); #ifdef ESP32 WiFi.setHostname(config.hostname.c_str()); #elif defined(ESP8266) diff --git a/src/examples/basic/config.h b/src/examples/basic/config.h index ad108c5..859d343 100644 --- a/src/examples/basic/config.h +++ b/src/examples/basic/config.h @@ -19,8 +19,4 @@ #define HOSTNAME "standalone-node" #define CONNECT_TIMEOUT 10000 -// OTA config -#define OTA_PORT 8266 -#define OTA_PASSWORD "" - #endif \ No newline at end of file diff --git a/src/examples/ota/config.h b/src/examples/ota/config.h deleted file mode 100644 index 051b345..0000000 --- a/src/examples/ota/config.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __STANDALONE_CONFIG__ -#define __STANDALONE_CONFIG__ - -// Scheduler config -#define _TASK_PRIORITY // Support for layered scheduling priority -#define _TASK_SLEEP_ON_IDLE_RUN -#define _TASK_STD_FUNCTION - -// Chip config -#define SERIAL_BAUD_RATE 115200 -#define STARTUP_DELAY 3000 - -// network config -#define SPROCKET_MODE 0 -#define AP_SSID "MyAP" -#define AP_PASSWORD "myApPwd" -#define STATION_SSID "Th1ngs4p" -#define STATION_PASSWORD "th3r31sn0sp00n" -#define HOSTNAME "standalone-node" -#define CONNECT_TIMEOUT 10000 - -// OTA config -#define OTA_PORT 8266 -#define OTA_PASSWORD "" - -#endif \ No newline at end of file diff --git a/src/examples/ota/main.cpp b/src/examples/ota/main.cpp deleted file mode 100644 index 63e28db..0000000 --- a/src/examples/ota/main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "config.h" -#include "WiFiNet.h" -#include "Sprocket.h" -//#include "OtaTcpPlugin.h" - -WiFiNet wifi( - SPROCKET_MODE, - STATION_SSID, - STATION_PASSWORD, - AP_SSID, - AP_PASSWORD, - HOSTNAME, - CONNECT_TIMEOUT); - -Sprocket sprocket( - {STARTUP_DELAY, SERIAL_BAUD_RATE}); - -void setup() -{ - delay(3000); - wifi.connect(); - //sprocket.addPlugin(new OtaTcpPlugin({8266, ""})); - sprocket.activate(); -} - -void loop() -{ - sprocket.loop(); - yield(); -} \ No newline at end of file