test con UTC

This commit is contained in:
richonguzman
2023-06-16 19:49:01 -04:00
parent 3c87e6515a
commit 8e49b29b9f
6 changed files with 96 additions and 4 deletions
+3
View File
@@ -11,6 +11,7 @@
#include "lora_utils.h"
#include "wifi_utils.h"
#include "digi_utils.h"
#include "time_utils.h"
#include "gps_utils.h"
#include "display.h"
#include "utils.h"
@@ -42,6 +43,7 @@ void setup() {
delay(1000);
Utils::setupDiplay();
WIFI_Utils::setup();
TIME_Utils::setup();
LoRa_Utils::setup();
Utils::validateDigiFreqs();
iGateBeaconPacket = GPS_Utils::generateBeacon();
@@ -58,6 +60,7 @@ void loop() {
APRS_IS_Utils::checkStatus();
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0);
while (espClient.connected()) {
TIME_Utils::getDateTime();
Utils::checkDisplayInterval();
Utils::checkBeaconInterval();
APRS_IS_Utils::processLoRaPacket(LoRa_Utils::receivePacket());
+3 -2
View File
@@ -171,7 +171,8 @@ void processAPRSISPacket(String packet) {
lastScreenOn = millis();
delay(500);
espClient.write(queryAnswer.c_str());
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000);
seventhLine = "Callsign = " + Sender;
eigthLine = "TYPE --> QUERY";
}
} else {
Serial.print("Received from APRS-IS : " + packet);
@@ -180,7 +181,7 @@ void processAPRSISPacket(String packet) {
display_toggle(true);
lastScreenOn = millis();
Utils::typeOfPacket(packet);
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, Sender + " -> " + Addressee, eigthLine, 0);
seventhLine = Sender + " -> " + Addressee;
}
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ namespace QUERY_Utils {
String process(String query, String station, String queryOrigin) {
String answer;
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="Help" || query=="help" || query=="?") {
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="HELP" || query=="Help" || query=="help" || query=="?") {
answer = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign";
} else if (query=="?APRSV" || query=="?aprsv" || query=="?Aprsv") {
answer = "CD2RXU_LoRa_iGate 1.2 v" + versionDate;
+75
View File
@@ -0,0 +1,75 @@
#include "time_utils.h"
#include "display.h"
#include "time.h"
extern String firstLine;
extern String secondLine;
extern String thirdLine;
extern String fourthLine;
extern String fifthLine;
extern String sixthLine;
extern String seventhLine;
extern String eigthLine;
namespace TIME_Utils {
void getDateTime() {
struct tm timeinfo;
String year, month, day, hour, minute, seconds;
if(!getLocalTime(&timeinfo)){
Serial.println("Failed to obtain time");
fourthLine = "no time info... restarting";
ESP.restart();
}
year = (String)(timeinfo.tm_year + 1900);
month = (String)(timeinfo.tm_mon+1);
if (month.length() == 1) {
month = "0" + month;
}
day = (String)(timeinfo.tm_mday);
if (day.length() == 1) {
day = "0" + day;
}
hour = (String)(timeinfo.tm_hour);
if (hour == 0) {
hour = "00";
} else if (hour.length() == 1) {
hour = "0" + hour;
}
minute = (String)(timeinfo.tm_min);
if (minute == 0) {
minute = "00";
} else if (minute.length() == 1) {
minute = "0" + minute;
}
seconds = (String)(timeinfo.tm_sec);
if (seconds == 0) {
seconds = "00";
} else if (seconds.length() == 1) {
seconds = "0" + seconds;
}
fourthLine = year + "/" + month + "/" + day + " - " + hour + ":" + minute + ":" + seconds;
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0);
}
void setup() {
const char* ntpServer = "pool.ntp.org";
const long GMT = 0; // for receiving UTC time
const long gmtOffset_sec = GMT*60*60;
const int daylightOffset_sec = 3600;
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
//configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
getDateTime();
}
}
+13
View File
@@ -0,0 +1,13 @@
#ifndef TIME_UTILS_H_
#define TIME_UTILS_H_
#include <Arduino.h>
namespace TIME_Utils {
void getDateTime();
void setup();
}
#endif
+1 -1
View File
@@ -56,7 +56,7 @@ void startWiFi() {
digitalWrite(greenLed,LOW);
Serial.print("Connected as ");
Serial.println(WiFi.localIP());
show_display("", "", " Connected!!", 1000);
show_display("", "", " Connected!!", "" , " loading programs...", 1000);
}
void setup() {