From 34b4b58ef2748558d4341178a6b0ff6a5cdcd379 Mon Sep 17 00:00:00 2001 From: matt Date: Sat, 30 Jul 2022 20:25:33 +0200 Subject: [PATCH] Committing the scripts I have now that work. --- esp32-light-switch/esp32-light-switch.ino | 70 ++++++++++++----------- id_rsa.pub | 1 + signal-mgtt.py => signal-mqtt.py | 0 3 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 id_rsa.pub rename signal-mgtt.py => signal-mqtt.py (100%) diff --git a/esp32-light-switch/esp32-light-switch.ino b/esp32-light-switch/esp32-light-switch.ino index df84fdf..dc1e80c 100644 --- a/esp32-light-switch/esp32-light-switch.ino +++ b/esp32-light-switch/esp32-light-switch.ino @@ -12,6 +12,7 @@ #include #include #include +#include #include // WiFi Info @@ -35,38 +36,6 @@ int pos = 0; Servo leftServo; Servo rightServo; - -// Arduino OTA Info -// Port defaults to 3232 -// Hostname defaults to esp3232-[MAC] -ArduinoOTA.setPasswordHash("b2cb7bf46d7afe5ad2ed16d87093d342"); -ArduinoOTA - .onStart([]() { - String type; - if (ArduinoOTA.getCommand() == U_FLASH) - type = "sketch"; - else // U_SPIFFS - type = "filesystem"; - - // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end() - Serial.println("Start updating " + type); - }) - .onEnd([]() { - Serial.println("\nEnd"); - }) - .onProgress([](unsigned int progress, unsigned int total) { - Serial.printf("Progress: %u%%\r", (progress / (total / 100))); - }) - .onError([](ota_error_t error) { - Serial.printf("Error[%u]: ", error); - if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed"); - else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed"); - else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed"); - else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); - else if (error == OTA_END_ERROR) Serial.println("End Failed"); - }); - -ArduinoOTA.begin(); void callback(char* topic, byte* message, unsigned int length) { Serial.print("Message arrived on topic: "); @@ -117,11 +86,46 @@ void setupWifi() { Serial.println(WiFi.localIP()); } +void setupOTA(){ + // Arduino OTA Info + // Port defaults to 3232 + // Hostname defaults to esp3232-[MAC] + ArduinoOTA.setPasswordHash("b2cb7bf46d7afe5ad2ed16d87093d342"); + ArduinoOTA + .onStart([]() { + String type; + if (ArduinoOTA.getCommand() == U_FLASH) + type = "sketch"; + else // U_SPIFFS + type = "filesystem"; + + // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end() + Serial.println("Start updating " + type); + }) + .onEnd([]() { + Serial.println("\nEnd"); + }) + .onProgress([](unsigned int progress, unsigned int total) { + Serial.printf("Progress: %u%%\r", (progress / (total / 100))); + }) + .onError([](ota_error_t error) { + Serial.printf("Error[%u]: ", error); + if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed"); + else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed"); + else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed"); + else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); + else if (error == OTA_END_ERROR) Serial.println("End Failed"); + }); + + ArduinoOTA.begin(); +} + void setup() { Serial.begin(115200); Serial.println("Starting up"); setupWifi(); + setupOTA(); Serial.print("Subscribing to "); Serial.println(mqtt_broker); @@ -163,4 +167,4 @@ void loop() { } mqttClient.loop(); -} \ No newline at end of file +} diff --git a/id_rsa.pub b/id_rsa.pub new file mode 100644 index 0000000..55c55bc --- /dev/null +++ b/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv7pPqO7sLo4kbvv6jT5tv9RuFx2MXNLJblPVgcvhsGHNIOPsDmyylAxbxAf2ABDMnP+s0Toljzt2w1MJPR4/4QAscva00UOJwQPl7i+KywTx2s7csk8sOmj/qr2c0rFdx5c6jIY1HS7XJGYXyum1krJ3hBkUI6T8xFj3URA8fAl6smylAnqUgFphMMQXHtQGaPu7QJ2rE1Zxo9N6myhD1IRnSwlC/a0WQbkKJZw+0EfxSXL1IbIUBF6504YnWdTZkyQ1uI05ki5oDnCzo1RFPwfjo5qRUToIDqofsi8XIbCfVgWXNvdtCXKIaYuXb00o+nAhs7IP7b6JIcTBxjgb7 rsa-key-20220726 diff --git a/signal-mgtt.py b/signal-mqtt.py similarity index 100% rename from signal-mgtt.py rename to signal-mqtt.py