mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2025-12-06 07:42:00 +01:00
OTA update added
This commit is contained in:
parent
ff2325ced2
commit
4d5dc32d69
|
|
@ -2,6 +2,7 @@
|
||||||
#include <WiFiMulti.h>
|
#include <WiFiMulti.h>
|
||||||
#include <NTPClient.h>
|
#include <NTPClient.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
|
#include <ArduinoOTA.h>
|
||||||
#include <APRS-IS.h>
|
#include <APRS-IS.h>
|
||||||
#include <APRS-Decoder.h>
|
#include <APRS-Decoder.h>
|
||||||
#include <LoRa.h>
|
#include <LoRa.h>
|
||||||
|
|
@ -25,6 +26,7 @@ void setup()
|
||||||
Serial.println("[INFO] LoRa APRS iGate by OE5BPA (Peter Buchegger)");
|
Serial.println("[INFO] LoRa APRS iGate by OE5BPA (Peter Buchegger)");
|
||||||
show_display_2("OE5BPA", "LoRa APRS iGate", "by Peter Buchegger", 2000);
|
show_display_2("OE5BPA", "LoRa APRS iGate", "by Peter Buchegger", 2000);
|
||||||
|
|
||||||
|
WiFi.setHostname("LoRa_APRS_iGate");
|
||||||
WiFiMulti.addAP(WIFI_NAME, WIFI_KEY);
|
WiFiMulti.addAP(WIFI_NAME, WIFI_KEY);
|
||||||
Serial.print("[INFO] Waiting for WiFi");
|
Serial.print("[INFO] Waiting for WiFi");
|
||||||
show_display_1("INFO", "Waiting for WiFi");
|
show_display_1("INFO", "Waiting for WiFi");
|
||||||
|
|
@ -40,6 +42,34 @@ void setup()
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
show_display_3("INFO", "WiFi connected", "IP: ", WiFi.localIP().toString(), 2000);
|
show_display_3("INFO", "WiFi connected", "IP: ", WiFi.localIP().toString(), 2000);
|
||||||
|
|
||||||
|
ArduinoOTA
|
||||||
|
.onStart([]()
|
||||||
|
{
|
||||||
|
String type;
|
||||||
|
if (ArduinoOTA.getCommand() == U_FLASH)
|
||||||
|
type = "sketch";
|
||||||
|
else // U_SPIFFS
|
||||||
|
type = "filesystem";
|
||||||
|
Serial.println("Start updating " + type);
|
||||||
|
})
|
||||||
|
.onEnd([]()
|
||||||
|
{
|
||||||
|
Serial.println("\nEnd");
|
||||||
|
})
|
||||||
|
.onProgress([](unsigned int progress, unsigned int total)
|
||||||
|
{
|
||||||
|
Serial.printf("Progress: %u%%\r\n", (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();
|
||||||
|
|
||||||
Serial.println("[INFO] Set SPI pins!");
|
Serial.println("[INFO] Set SPI pins!");
|
||||||
SPI.begin(SCK, MISO, MOSI, SS);
|
SPI.begin(SCK, MISO, MOSI, SS);
|
||||||
LoRa.setPins(SS, RST, DIO0);
|
LoRa.setPins(SS, RST, DIO0);
|
||||||
|
|
@ -75,6 +105,7 @@ void setup()
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
timeClient.update();
|
timeClient.update();
|
||||||
|
ArduinoOTA.handle();
|
||||||
if(WiFiMulti.run() != WL_CONNECTED)
|
if(WiFiMulti.run() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
Serial.println("[ERROR] WiFi not connected!");
|
Serial.println("[ERROR] WiFi not connected!");
|
||||||
|
|
@ -89,7 +120,7 @@ void loop()
|
||||||
Serial.print(" on port: ");
|
Serial.print(" on port: ");
|
||||||
Serial.println(PORT);
|
Serial.println(PORT);
|
||||||
//show_display_3("INFO", "Connecting to server", SERVER, PORT, 2000);
|
//show_display_3("INFO", "Connecting to server", SERVER, PORT, 2000);
|
||||||
show_display_1("INFO", "Connecting to server", 2000);
|
show_display_1("INFO", "Connecting to server");
|
||||||
if(!aprs_is.connect(SERVER, PORT, FILTER))
|
if(!aprs_is.connect(SERVER, PORT, FILTER))
|
||||||
{
|
{
|
||||||
Serial.println("[ERROR] Connection failed.");
|
Serial.println("[ERROR] Connection failed.");
|
||||||
|
|
@ -102,7 +133,7 @@ void loop()
|
||||||
}
|
}
|
||||||
if(next_update == timeClient.getMinutes() || next_update == -1)
|
if(next_update == timeClient.getMinutes() || next_update == -1)
|
||||||
{
|
{
|
||||||
show_display_1(call, "Broadcast to Server...", 2000);
|
show_display_1(call, "Broadcast to Server...");
|
||||||
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
||||||
aprs_is.sendMessage(BROADCAST_MESSAGE);
|
aprs_is.sendMessage(BROADCAST_MESSAGE);
|
||||||
next_update = (timeClient.getMinutes() + BROADCAST_TIMEOUT) % 60;
|
next_update = (timeClient.getMinutes() + BROADCAST_TIMEOUT) % 60;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue