daily_automated

This commit is contained in:
topicchi
2023-03-17 11:59:21 +00:00
parent 252ecca9cf
commit e2f276193e
4496 changed files with 1178007 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
/*
This example polls for sketch updates over Ethernet, sketches
can be updated by selecting a network port from within
the Arduino IDE: Tools -> Port -> Network Ports ...
Circuit:
* W5100, W5200 or W5500 Ethernet shield with SD card attached
created 13 July 2010
by dlf (Metodo2 srl)
modified 31 May 2012
by Tom Igoe
modified 16 January 2017
by Sandeep Mistry
ArduinoOTA version Dec 2018
by Juraj Andrassy
*/
#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>
#include <ArduinoOTA.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
void setup() {
//Initialize serial:
Serial.begin(9600);
while (!Serial);
// setup SD card
Serial.print("Initializing SD card...");
if (!SD.begin(SDCARD_SS_PIN)) {
Serial.println("initialization failed!");
// don't continue:
while (true);
}
Serial.println("initialization done.");
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}
// start the OTEthernet library with SD based storage
SDStorage.setUpdateFileName("FIRMWARE.BIN"); // for https://github.com/zevero/avr_boot/
SDStorage.clear(); // AVR SD bootloaders don't delete the update file
ArduinoOTA.begin(Ethernet.localIP(), "Arduino", "password", SDStorage);
}
void loop() {
// check for updates
ArduinoOTA.poll();
// add your normal loop code below ...
}

View File

@@ -0,0 +1,122 @@
/*
This example downloads sketch update over network.
It doesn't start the OTA upload sever of the ArduinoOTA library,
it only uses the InternalStorage object of the library
to store and apply the downloaded binary file.
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 <ArduinoOTA.h> // only for InternalStorage
#include <Ethernet.h>
#include <ArduinoHttpClient.h>
const short VERSION = 1;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
#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");
if (!InternalStorage.open(length)) {
client.stop();
Serial.println("There is not enough space to store the update. Can't continue with update.");
return;
}
byte b;
while (length > 0) {
if (!client.readBytes(&b, 1)) // reading a byte with timeout
break;
InternalStorage.write(b);
length--;
}
InternalStorage.close();
client.stop();
if (length > 0) {
Serial.print("Timeout downloading update file at ");
Serial.print(length);
Serial.println(" bytes. Can't continue with update.");
return;
}
Serial.println("Sketch update apply and reset.");
Serial.flush();
InternalStorage.apply(); // this doesn't return
}
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.print("Sketch version ");
Serial.println(VERSION);
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");
}
void loop() {
// check for updates
handleSketchDownload();
// add your normal loop code below ...
}

View File

@@ -0,0 +1,151 @@
/*
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 <ArduinoHttpClient.h>
#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 ...
}

View File

@@ -0,0 +1,53 @@
/*
This example polls for sketch updates over Ethernet, sketches
can be updated by selecting a network port from within
the Arduino IDE: Tools -> Port -> Network Ports ...
Circuit:
* W5100, W5200 or W5500 Ethernet shield attached
created 13 July 2010
by dlf (Metodo2 srl)
modified 31 May 2012
by Tom Igoe
modified 16 January 2017
by Sandeep Mistry
Ethernet version August 2018
by Juraj Andrassy
*/
#include <SPI.h>
#include <Ethernet.h>
#include <ArduinoOTA.h>
//#define Serial SerialUSB
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
void setup() {
//Initialize serial:
Serial.begin(9600);
while (!Serial);
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}
// start the OTEthernet library with internal (flash) based storage
ArduinoOTA.begin(Ethernet.localIP(), "Arduino", "password", InternalStorage);
}
void loop() {
// check for updates
ArduinoOTA.poll();
// add your normal loop code below ...
}

View File

@@ -0,0 +1,65 @@
/*
This example polls for sketch updates over Ethernet, sketches
can be updated by selecting a network port from within
the Arduino IDE: Tools -> Port -> Network Ports ...
Circuit:
* W5100, W5200 or W5500 Ethernet shield with SD card attached
created 13 July 2010
by dlf (Metodo2 srl)
modified 31 May 2012
by Tom Igoe
modified 16 January 2017
by Sandeep Mistry
Ethernet version August 2018
by Juraj Andrassy
*/
#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>
#include <ArduinoOTA.h>
#include <SDU.h>
//#define Serial SerialUSB
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
void setup() {
//Initialize serial:
Serial.begin(9600);
while (!Serial);
// setup SD card
Serial.print("Initializing SD card...");
if (!SD.begin(SDCARD_SS_PIN)) {
Serial.println("initialization failed!");
// don't continue:
while (true);
}
Serial.println("initialization done.");
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}
// start the OTEthernet library with SD based storage
ArduinoOTA.begin(Ethernet.localIP(), "Arduino", "password", SDStorage);
}
void loop() {
// check for updates
ArduinoOTA.poll();
// add your normal loop code below ...
}

View File

@@ -0,0 +1,74 @@
/*
This example polls for sketch updates over WiFi module on Serial1,
sketches can be updated by selecting a network port from within
the Arduino IDE: Tools -> Port -> Network Ports ...
created 13 July 2010
by dlf (Metodo2 srl)
modified 31 May 2012
by Tom Igoe
modified 16 January 2017
by Sandeep Mistry
Serial WiFi version December 2019
by Juraj Andrassy
*/
#include <WiFiEspAT.h>
#include <ArduinoOTA.h>
void setup() {
Serial.begin(115200);
while (!Serial);
// initialize Serial1 for communication with the WiFi module
Serial1.begin(115200);
WiFi.init(&Serial1);
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println();
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
// waiting for connection to Wifi network with settings in the WiFi module
Serial.println("Waiting for connection to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print('.');
}
Serial.println();
Serial.println("Connected to WiFi network.");
// start the WiFi OTA library with internal (flash) based storage
ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage);
// you're connected now, so print out the status:
printWifiStatus();
}
void loop() {
// check for WiFi OTA updates
ArduinoOTA.poll();
// add your normal loop code below ...
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}

View File

@@ -0,0 +1,81 @@
/*
This example connects to an WPA encrypted WiFi network.
Then it prints the MAC address of the Wifi shield,
the IP address obtained, and other network details.
It then polls for sketch updates over WiFi, sketches
can be updated by selecting a network port from within
the Arduino IDE: Tools -> Port -> Network Ports ...
Circuit:
* WiFi shield attached
created 13 July 2010
by dlf (Metodo2 srl)
modified 31 May 2012
by Tom Igoe
modified 16 January 2017
by Sandeep Mistry
*/
#include <SPI.h>
#include <WiFiNINA.h>
#include <ArduinoOTA.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
/////// Wifi Settings ///////
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password
int status = WL_IDLE_STATUS;
void setup() {
//Initialize serial:
Serial.begin(9600);
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
}
// start the WiFi OTA library with internal (flash) based storage
ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage);
// you're connected now, so print out the status:
printWifiStatus();
}
void loop() {
// check for WiFi OTA updates
ArduinoOTA.poll();
// add your normal loop code below ...
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}

View File

@@ -0,0 +1,3 @@
#define SECRET_SSID ""
#define SECRET_PASS ""

View File

@@ -0,0 +1,93 @@
/*
This example connects to an WPA encrypted WiFi network.
Then it prints the MAC address of the Wifi shield,
the IP address obtained, and other network details.
It then polls for sketch updates over WiFi, sketches
can be updated by selecting a network port from within
the Arduino IDE: Tools -> Port -> Network Ports ...
Circuit:
* WiFi shield attached
* SD shield attached
created 13 July 2010
by dlf (Metodo2 srl)
modified 31 May 2012
by Tom Igoe
modified 16 January 2017
by Sandeep Mistry
*/
#include <SPI.h>
#include <SD.h>
#include <WiFiNINA.h>
#include <ArduinoOTA.h>
#include <SDU.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
/////// Wifi Settings ///////
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password
int status = WL_IDLE_STATUS;
void setup() {
//Initialize serial:
Serial.begin(9600);
// setup SD card
Serial.print("Initializing SD card...");
if (!SD.begin(SDCARD_SS_PIN)) {
Serial.println("initialization failed!");
// don't continue:
while (true);
}
Serial.println("initialization done.");
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
}
// start the WiFi OTA library with SD based storage
ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", SDStorage);
// you're connected now, so print out the status:
printWifiStatus();
}
void loop() {
// check for WiFi OTA updates
ArduinoOTA.poll();
// add your normal loop code below ...
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}

View File

@@ -0,0 +1,3 @@
#define SECRET_SSID ""
#define SECRET_PASS ""