Bonjour j'essaye ce programme pour pouvoir faire part la suite des OTA comme les ESP32 :
J'ai mis une sd dans le Shield Ethernet W5100 sur un mega2560 et j'essaye de compiler
/*
This example downloads sketch update over network to SD card.
It doesn't use the ArduionOTA library at all. It is intended for use
with the SDU library of SAMD boards package or with SD bootloader for AVR.
To create the bin file for update of a SAMD board (except of M0),
use in Arduino IDE command "Export compiled binary".
To create a bin file for AVR boards see the instructions in README.MD.
To try this example, you should have a web server where you put
the binary update.
Modify the constants below to match your configuration.
Created for ArduinoOTA library in February 2020
by Juraj Andrassy
*/
#include <Ethernet.h>
#include <HttpClient.h> // ArduinoHttpClient library
#include <SD.h>
#ifdef ARDUINO_ARCH_SAMD
#include <SDU.h> // prepends to this sketch a 'second stage SD bootloader'
const char* BIN_FILENAME = "UPDATE.BIN"; // expected by the SDU library
#endif
#ifdef ARDUINO_ARCH_AVR
#include <avr/wdt.h> // for self reset
const char* BIN_FILENAME = "FIRMWARE.BIN"; // expected by zevero avr_boot
#endif
const short VERSION = 1;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
#ifndef SDCARD_SS_PIN
#define SDCARD_SS_PIN 4
#endif
#ifdef ARDUINO_SAM_ZERO // M0
#define Serial SerialUSB
#endif
void handleSketchDownload() {
const char* SERVER = "192.168.1.108"; // must be string for HttpClient
const unsigned short SERVER_PORT = 80;
const char* PATH = "/update-v%d.bin";
const unsigned long CHECK_INTERVAL = 5000;
static unsigned long previousMillis;
unsigned long currentMillis = millis();
if (currentMillis - previousMillis < CHECK_INTERVAL)
return;
previousMillis = currentMillis;
EthernetClient transport;
HttpClient client(transport, SERVER, SERVER_PORT);
char buff[32];
snprintf(buff, sizeof(buff), PATH, VERSION + 1);
Serial.print("Check for update file ");
Serial.println(buff);
client.get(buff);
int statusCode = client.responseStatusCode();
Serial.print("Update status code: ");
Serial.println(statusCode);
if (statusCode != 200) {
client.stop();
return;
}
long length = client.contentLength();
if (length == HttpClient::kNoContentLengthHeader) {
client.stop();
Serial.println("Server didn't provide Content-length header. Can't continue with update.");
return;
}
Serial.print("Server returned update file of size ");
Serial.print(length);
Serial.println(" bytes");
File file = SD.open(BIN_FILENAME, O_CREAT | O_WRITE);
if (!file) {
client.stop();
Serial.println("Could not create bin file. Can't continue with update.");
return;
}
byte b;
while (length > 0) {
if (!client.readBytes(&b, 1)) // reading a byte with timeout
break;
file.write(b);
length--;
}
file.close();
client.stop();
if (length > 0) {
SD.remove(BIN_FILENAME);
Serial.print("Timeout downloading update file at ");
Serial.print(length);
Serial.println(" bytes. Can't continue with update.");
return;
}
Serial.println("Update file saved. Reset.");
Serial.flush();
#ifdef __AVR__
wdt_enable(WDTO_15MS);
while (true);
#else
NVIC_SystemReset();
#endif
}
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.print("Sketch version ");
Serial.println(VERSION);
pinMode(SDCARD_SS_PIN, OUTPUT);
digitalWrite(SDCARD_SS_PIN, HIGH); // to disable SD card while Ethernet initializes
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
while (true);
}
Serial.println("Ethernet connected");
Serial.print("Initializing SD card...");
if (!SD.begin(SDCARD_SS_PIN)) {
Serial.println("initialization failed!");
// don't continue:
while (true);
}
Serial.println("initialization done.");
SD.remove(BIN_FILENAME);
}
void loop() {
// check for updates
handleSketchDownload();
// add your normal loop code below ...
}
mais l'IDE donne plein d'erreur:
/Users/XXXXX/Documents/Arduino/sketch_jul04b/sketch_jul04b.ino: In function 'void handleSketchDownload()':
sketch_jul04b:58:51: error: no matching function for call to 'HttpClient::HttpClient(EthernetClient&, const char*&, const short unsigned int&)'
HttpClient client(transport, SERVER, SERVER_PORT);
^
In file included from /Users/XXXXX/Documents/Arduino/sketch_jul04b/sketch_jul04b.ino:19:0:
/Applications/Arduino.app/Contents/Java/libraries/Bridge/src/HttpClient.h:26:5: note: candidate: HttpClient::HttpClient()
HttpClient();
^~~~~~~~~~
/Applications/Arduino.app/Contents/Java/libraries/Bridge/src/HttpClient.h:26:5: note: candidate expects 0 arguments, 3 provided
/Applications/Arduino.app/Contents/Java/libraries/Bridge/src/HttpClient.h:24:7: note: candidate: HttpClient::HttpClient(const HttpClient&)
class HttpClient : public Process {
^~~~~~~~~~
/Applications/Arduino.app/Contents/Java/libraries/Bridge/src/HttpClient.h:24:7: note: candidate expects 1 argument, 3 provided
/Applications/Arduino.app/Contents/Java/libraries/Bridge/src/HttpClient.h:24:7: note: candidate: HttpClient::HttpClient(HttpClient&&)
/Applications/Arduino.app/Contents/Java/libraries/Bridge/src/HttpClient.h:24:7: note: candidate expects 1 argument, 3 provided
sketch_jul04b:68:27: error: 'class HttpClient' has no member named 'responseStatusCode'
int statusCode = client.responseStatusCode();
^~~~~~~~~~~~~~~~~~
sketch_jul04b:72:12: error: 'class HttpClient' has no member named 'stop'
client.stop();
^~~~
sketch_jul04b:76:24: error: 'class HttpClient' has no member named 'contentLength'
long length = client.contentLength();
^~~~~~~~~~~~~
sketch_jul04b:77:29: error: 'kNoContentLengthHeader' is not a member of 'HttpClient'
if (length == HttpClient::kNoContentLengthHeader) {
^~~~~~~~~~~~~~~~~~~~~~
sketch_jul04b:78:12: error: 'class HttpClient' has no member named 'stop'
client.stop();
^~~~
sketch_jul04b:88:12: error: 'class HttpClient' has no member named 'stop'
client.stop();
^~~~
sketch_jul04b:100:10: error: 'class HttpClient' has no member named 'stop'
client.stop();
^~~~
Plusieurs bibliothèque trouvées pour "SD.h"
Utilisé : /Users/XXXXX/Documents/Arduino/libraries/SD
Non utilisé : /Applications/Arduino.app/Contents/Java/libraries/SD
Utilisation de la bibliothèque Ethernet version 2.0.0 dans le dossier: /Applications/Arduino.app/Contents/Java/libraries/Ethernet
Utilisation de la bibliothèque Bridge version 1.7.0 dans le dossier: /Applications/Arduino.app/Contents/Java/libraries/Bridge
Utilisation de la bibliothèque SD version 1.2.4 dans le dossier: /Users/XXXXX/Documents/Arduino/libraries/SD
Utilisation de la bibliothèque SPI version 1.0 dans le dossier: /Users/XXXXX/Library/Arduino15/packages/arduino/hardware/avr/1.8.4/libraries/SPI
exit status 1
no matching function for call to 'HttpClient::HttpClient(EthernetClient&, const char*&, const short unsigned int&)'
