test1
This commit is contained in:
parent
e433e375e5
commit
b7ba17d871
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"callsign": "CD2RXU-11",
|
"callsign": "CD2RXU-11",
|
||||||
"stationMode": 4,
|
"stationMode": 2,
|
||||||
"iGateComment": "LoRa_APRS_iGate",
|
"iGateComment": "LoRa_APRS_iGate",
|
||||||
"wifi": {
|
"wifi": {
|
||||||
"AP": [
|
"AP": [
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,4 @@ lib_deps =
|
||||||
ayushsharma82/AsyncElegantOTA@^2.2.7
|
ayushsharma82/AsyncElegantOTA@^2.2.7
|
||||||
ottowinter/ESPAsyncWebServer-esphome@^3.0.0
|
ottowinter/ESPAsyncWebServer-esphome@^3.0.0
|
||||||
esphome/AsyncTCP-esphome@^2.0.0
|
esphome/AsyncTCP-esphome@^2.0.0
|
||||||
mikalhart/TinyGPSPlus @ 1.0.3
|
mikalhart/TinyGPSPlus @ 1.0.3
|
||||||
peterus/esp-logger @ 1.0.0
|
|
||||||
|
|
@ -13,16 +13,13 @@
|
||||||
#include "digi_utils.h"
|
#include "digi_utils.h"
|
||||||
#include "gps_utils.h"
|
#include "gps_utils.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "logger.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
Configuration Config;
|
Configuration Config;
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
|
|
||||||
logging::Logger logger;
|
|
||||||
|
|
||||||
|
String versionDate = "2023.06.13";
|
||||||
String versionDate = "2023.06.12";
|
|
||||||
int myWiFiAPIndex = 0;
|
int myWiFiAPIndex = 0;
|
||||||
int myWiFiAPSize = Config.wifiAPs.size();
|
int myWiFiAPSize = Config.wifiAPs.size();
|
||||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||||
|
|
@ -39,8 +36,6 @@ std::vector<String> lastHeardStation_temp;
|
||||||
|
|
||||||
String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket;
|
String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket;
|
||||||
|
|
||||||
// agregar automatic restart cada X horas?
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
pinMode(greenLed, OUTPUT);
|
pinMode(greenLed, OUTPUT);
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ void sendNewPacket(const String &typeOfMessage, const String &newPacket) {
|
||||||
LoRa.write((const uint8_t *)newPacket.c_str(), newPacket.length());
|
LoRa.write((const uint8_t *)newPacket.c_str(), newPacket.length());
|
||||||
LoRa.endPacket();
|
LoRa.endPacket();
|
||||||
digitalWrite(greenLed,LOW);
|
digitalWrite(greenLed,LOW);
|
||||||
|
SYSLOG_Utils::log("LoRa Tx", newPacket,0,0,0);
|
||||||
Serial.print("---> LoRa Packet Tx : ");
|
Serial.print("---> LoRa Packet Tx : ");
|
||||||
Serial.println(newPacket);
|
Serial.println(newPacket);
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +68,7 @@ String receivePacket() {
|
||||||
loraPacket += (char)inChar;
|
loraPacket += (char)inChar;
|
||||||
}
|
}
|
||||||
if (Config.syslog.active && (stationMode==1 || stationMode==2)) {
|
if (Config.syslog.active && (stationMode==1 || stationMode==2)) {
|
||||||
SYSLOG_Utils::processPacket(loraPacket, LoRa.packetRssi(), LoRa.packetSnr(), LoRa.packetFrequencyError());
|
SYSLOG_Utils::log("LoRa Rx", loraPacket, LoRa.packetRssi(), LoRa.packetSnr(), LoRa.packetFrequencyError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return loraPacket;
|
return loraPacket;
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,58 @@
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
#include <WiFi.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "syslog_utils.h"
|
#include "syslog_utils.h"
|
||||||
#include "gps_utils.h"
|
#include "gps_utils.h"
|
||||||
#include "logger.h"
|
|
||||||
|
|
||||||
extern Configuration Config;
|
extern Configuration Config;
|
||||||
extern logging::Logger logger;
|
extern int stationMode;
|
||||||
|
|
||||||
|
WiFiUDP udpClient;
|
||||||
|
|
||||||
namespace SYSLOG_Utils {
|
namespace SYSLOG_Utils {
|
||||||
|
|
||||||
void processPacket(String packet, int rssi, float snr, int freqError) {
|
void log(String type, String packet, int rssi, float snr, int freqError) {
|
||||||
String syslogPacket;
|
String syslogPacket = "ESP32 LoRa [APRS] - ";
|
||||||
syslogPacket = packet.substring(3,packet.indexOf(">")) + " / TIME / ";
|
if (Config.syslog.active && (stationMode==1 || stationMode==2)) {
|
||||||
syslogPacket += packet.substring(packet.indexOf(">")+1,packet.indexOf(",")) + " / ";
|
if (type == "APRSIS Tx") {
|
||||||
if (packet.indexOf("WIDE1-1") > 10) {
|
if (packet.indexOf(":>") > 10) {
|
||||||
syslogPacket += "WIDE1-1 / ";
|
syslogPacket += type + " - StartUp STATUS - " + packet.substring(packet.indexOf(":>")+2);
|
||||||
} else {
|
}
|
||||||
syslogPacket += " _ / ";
|
} else if (type == "LoRa Rx") {
|
||||||
|
if (packet.indexOf("::") > 10) {
|
||||||
|
syslogPacket += type + " - MESSAGE - " + packet.substring(3,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf("::")+2);
|
||||||
|
} else if (packet.indexOf(":!") > 10 || packet.indexOf(":=") > 10) {
|
||||||
|
syslogPacket += type + " - GPS - " + packet.substring(3,packet.indexOf(">")) + " / " + packet.substring(packet.indexOf(">")+1,packet.indexOf(",")) + " / ";
|
||||||
|
if (packet.indexOf("WIDE1-1") > 10) {
|
||||||
|
syslogPacket += "WIDE1-1 / ";
|
||||||
|
} else {
|
||||||
|
syslogPacket += "_ / ";
|
||||||
|
}
|
||||||
|
syslogPacket += String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz / " + GPS_Utils::getDistance(packet);
|
||||||
|
} else {
|
||||||
|
syslogPacket += type + " - " + packet;
|
||||||
|
}
|
||||||
|
} else if (type == "LoRa Tx") {
|
||||||
|
if (packet.indexOf("RFONLY") > 10) {
|
||||||
|
syslogPacket += type + " - RFONLY - " + packet.substring(packet.indexOf("::")+2);
|
||||||
|
} else if (packet.indexOf("::") > 10) {
|
||||||
|
syslogPacket += type + " - MESSAGE - " + packet.substring(0,packet.indexOf(">")) + " ---> " + packet.substring(packet.indexOf("::")+2);
|
||||||
|
} else {
|
||||||
|
syslogPacket += type + " - " + packet;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
syslogPacket = "ERROR - Error in Syslog Packet";
|
||||||
|
}
|
||||||
|
udpClient.beginPacket(Config.syslog.server.c_str(), Config.syslog.port);
|
||||||
|
udpClient.write((const uint8_t*)syslogPacket.c_str(), syslogPacket.length());
|
||||||
|
udpClient.endPacket();
|
||||||
}
|
}
|
||||||
syslogPacket += String(rssi) + "dBm / " + String(snr) + "dB / " + String(freqError) + "Hz / ";
|
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", (syslogPacket + GPS_Utils::getDistance(packet)).c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
if (Config.syslog.active && (stationMode==1 || stationMode==2)) {
|
||||||
// ver hostname "ESP32 LoRa APRS iGate" ?
|
udpClient.begin(WiFi.localIP(), 0);
|
||||||
if (Config.syslog.active) {
|
|
||||||
logger.setSyslogServer(Config.syslog.server, Config.syslog.port, "ESP32 LoRa APRS iGate");
|
|
||||||
Serial.println("Syslog Server (" + Config.syslog.server + ") connected!\n");
|
Serial.println("Syslog Server (" + Config.syslog.server + ") connected!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace SYSLOG_Utils {
|
namespace SYSLOG_Utils {
|
||||||
|
|
||||||
void processPacket(String packet, int rssi, float snr, int freqError) ;
|
void log(String type ,String packet, int rssi, float snr, int freqError);
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include "syslog_utils.h"
|
||||||
#include "pins_config.h"
|
#include "pins_config.h"
|
||||||
#include "wifi_utils.h"
|
#include "wifi_utils.h"
|
||||||
#include "lora_utils.h"
|
#include "lora_utils.h"
|
||||||
|
|
@ -34,7 +35,8 @@ void processStatus() {
|
||||||
if (stationMode==1 || stationMode==2) {
|
if (stationMode==1 || stationMode==2) {
|
||||||
delay(1000);
|
delay(1000);
|
||||||
status += ",qAC:>https://github.com/richonguzman/LoRa_APRS_iGate";
|
status += ",qAC:>https://github.com/richonguzman/LoRa_APRS_iGate";
|
||||||
espClient.write((status + "\n").c_str());
|
espClient.write((status + "\n").c_str());
|
||||||
|
SYSLOG_Utils::log("APRSIS Tx", status,0,0,0);
|
||||||
} else {
|
} else {
|
||||||
delay(5000);
|
delay(5000);
|
||||||
status += ":>https://github.com/richonguzman/LoRa_APRS_iGate";
|
status += ":>https://github.com/richonguzman/LoRa_APRS_iGate";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue