Skip to content

Commit

Permalink
Update OTA examples, they use SimpleMDNS now
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgerhardt committed Nov 19, 2024
1 parent 72b6176 commit 616efc8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
19 changes: 9 additions & 10 deletions examples/arduino-ota/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFi.h>
#include <SimpleMDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "Updater_Signing.h"

#ifndef STASSID
#define STASSID "YourSSID"
#define STAPSK "YourPassword"
#define STASSID "your-ssid"
#define STAPSK "your-password"
#endif

const char* ssid = STASSID;
Expand All @@ -23,11 +22,11 @@ void setup() {
rp2040.restart();
}

// Port defaults to 8266
// ArduinoOTA.setPort(8266);
// Port defaults to 2040
// ArduinoOTA.setPort(2040);

// Hostname defaults to esp8266-[ChipID]
// ArduinoOTA.setHostname("myesp8266");
// Hostname defaults to pico-[ChipID]
// ArduinoOTA.setHostname("mypico");

// No authentication by default
// ArduinoOTA.setPassword("admin");
Expand Down Expand Up @@ -75,4 +74,4 @@ void setup() {

void loop() {
ArduinoOTA.handle();
}
}
27 changes: 20 additions & 7 deletions examples/arduino-signed-ota/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
// Simple Signed OTA example
// Released to the public domain by Earle Philhower, Aug 2022
//
// Note that the actual code of this is the same as the BasicOTA. No user
// code changes are needed, only the presence of public.key and private.key
// in the sketch directory. The core will automatically sign any binaries
// and include the necessary code to verify signatures. For more info
// check the documentation
//
// After uploading this sketch, try uploading the SignedOTA-Blink sketch
// All unsigned binaries, or binaries signed with a different private
// key will fail to upload.

#include <Arduino.h>
#include <WiFi.h>
#include <SimpleMDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "Updater_Signing.h"

#ifndef STASSID
#define STASSID "YourSSID"
#define STAPSK "YourPassword"
#define STASSID "your-ssid"
#define STAPSK "your-password"
#endif

const char* ssid = STASSID;
Expand Down Expand Up @@ -51,7 +64,7 @@ void setup() {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
Serial.printf("Progress: %u%%\r\n", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
Expand All @@ -75,4 +88,4 @@ void setup() {

void loop() {
ArduinoOTA.handle();
}
}

0 comments on commit 616efc8

Please sign in to comment.