Committing the scripts I have now that work.

This commit is contained in:
2022-07-30 20:25:33 +02:00
parent 0d36280a18
commit 34b4b58ef2
3 changed files with 38 additions and 33 deletions

View File

@@ -12,6 +12,7 @@
#include <ESPmDNS.h> #include <ESPmDNS.h>
#include <Servo.h> #include <Servo.h>
#include <PubSubClient.h> #include <PubSubClient.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
// WiFi Info // WiFi Info
@@ -35,38 +36,6 @@ int pos = 0;
Servo leftServo; Servo leftServo;
Servo rightServo; 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) { void callback(char* topic, byte* message, unsigned int length) {
Serial.print("Message arrived on topic: "); Serial.print("Message arrived on topic: ");
@@ -117,11 +86,46 @@ void setupWifi() {
Serial.println(WiFi.localIP()); 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() { void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.println("Starting up"); Serial.println("Starting up");
setupWifi(); setupWifi();
setupOTA();
Serial.print("Subscribing to "); Serial.print("Subscribing to ");
Serial.println(mqtt_broker); Serial.println(mqtt_broker);
@@ -163,4 +167,4 @@ void loop() {
} }
mqttClient.loop(); mqttClient.loop();
} }

1
id_rsa.pub Normal file
View File

@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv7pPqO7sLo4kbvv6jT5tv9RuFx2MXNLJblPVgcvhsGHNIOPsDmyylAxbxAf2ABDMnP+s0Toljzt2w1MJPR4/4QAscva00UOJwQPl7i+KywTx2s7csk8sOmj/qr2c0rFdx5c6jIY1HS7XJGYXyum1krJ3hBkUI6T8xFj3URA8fAl6smylAnqUgFphMMQXHtQGaPu7QJ2rE1Zxo9N6myhD1IRnSwlC/a0WQbkKJZw+0EfxSXL1IbIUBF6504YnWdTZkyQ1uI05ki5oDnCzo1RFPwfjo5qRUToIDqofsi8XIbCfVgWXNvdtCXKIaYuXb00o+nAhs7IP7b6JIcTBxjgb7 rsa-key-20220726