Update experimental UDP data output

This commit is contained in:
Sjef Verhoeven PE5PVB
2025-01-26 19:56:47 +01:00
parent a2c9e6f2a7
commit b6ac075875
4 changed files with 78 additions and 34 deletions

View File

@@ -1025,7 +1025,7 @@ void loop() {
while (digitalRead(ROTARY_BUTTON) == LOW) delay(50);
ShowFreq(0);
}
if (wifi) sendUDPlog();
if (wifi) sendUDPlog(true);
autologged = true;
}
TuneUp();
@@ -1078,6 +1078,8 @@ void loop() {
break;
}
}
} else {
if (wifi) sendUDPlog(false);
}
if (millis() >= tuningtimer + 200) rdsflagreset = false;

View File

@@ -95,7 +95,7 @@ static const uint16_t oda_app_ids[] {
0x0000, 0x0093, 0x0BCB, 0x0C24, 0x0CC1, 0x0D45, 0x0D8B, 0x0E2C, 0x0E31, 0x0F87,
0x125F, 0x1BDA, 0x1C5E, 0x1C68, 0x1CB1, 0x1D47, 0x1DC2, 0x1DC5, 0x1E8F, 0x4400,
0x4AA1, 0x4AB7, 0x4BA2, 0x4BD7, 0x4BD8, 0x4C59, 0x4D87, 0x4D95, 0x4D9A, 0x50DD,
0x5757, 0x6363, 0x6365, 0x6552, 0x6A7A, 0x7373, 0xA112, 0xA911, 0xABCE. 0xABCF,
0x5757, 0x6363, 0x6365, 0x6552, 0x6A7A, 0x7373, 0xA112, 0xA911, 0xABCE, 0xABCF,
0xBE22, 0xC350, 0xC3A1, 0xC3B0, 0xC3C3, 0xC4D4, 0xC549, 0xC563, 0xC6A7, 0xC737,
0xCB73, 0xCB97, 0xCC21, 0xCD19, 0xCD46, 0xCD47, 0xCD9E, 0xCE6B, 0xE123, 0xE1C1,
0xE319, 0xE411, 0xE440, 0xE4A6, 0xE5D7, 0xE911, 0xFF70, 0xFF7F, 0xFF80, 0xFF81
@@ -517,7 +517,7 @@ static const char* const oda_app_names[] {
"CITIBUS 1",
"ELECTRABEL-DSM 14",
"CITIBUS 3",
"TokenMe"
"TokenMe",
"RDS-TMC: ALERT-C",
"RDS-TMC: ALERT-C",
"ELECTRABEL-DSM 8",
@@ -530,9 +530,9 @@ static const char* const oda_app_names[] {
"ELECTRABEL-DSM 19",
"ELECTRABEL-DSM 6",
"EAS open protocol",
"Internet connection"
"Internet connection",
"RFT: Station logo",
"RFT: Slideshow"
"RFT: Slideshow",
"RFT: Journaline (work title)"
};

View File

@@ -4,6 +4,8 @@
#include <EEPROM.h>
#include "language.h"
String UDPlogold = "";
void handleRoot() {
fs::File file = SPIFFS.open("/logbook.csv", "r");
if (!file) {
@@ -435,72 +437,112 @@ void printLogbookCSV() {
Serial.println("===== End of logbook.csv =====");
}
void sendUDPlog() {
// Fetch the current date and time as a string
void sendUDPlog(bool scanner_active) {
// Get the current date and time as a string
String currentDateTime = getCurrentDateTime();
// Use a placeholder ("-,-") if the date and time could not be retrieved
// Use a placeholder if the date and time could not be retrieved
if (currentDateTime == "") {
currentDateTime = "-,-";
}
// Prepare the frequency in a formatted string (e.g., "XX.XX MHz")
// Format the frequency, adjusting based on the band and converter settings
int freqInt = (band == BAND_OIRT) ? (int)frequency_OIRT : (int)frequency;
int adjustedFreq = freqInt + (band != BAND_OIRT ? ConverterSet * 100 : 0);
String frequencyFormatted = String(adjustedFreq / 100) + "." +
((adjustedFreq % 100 < 10) ? "0" : "") +
String(adjustedFreq % 100) + " MHz";
String(adjustedFreq % 100);
// Calculate signal strength based on the selected unit
// Calculate signal strength and format it with the selected unit
int SStatusPrint = 0;
if (unit == 0) SStatusPrint = SStatus; // dBμV
else if (unit == 1) SStatusPrint = ((SStatus * 100) + 10875) / 100; // dBf
else if (unit == 2) SStatusPrint = round((float(SStatus) / 10.0 - 10.0 * log10(75) - 90.0) * 10.0); // dBm
// Format the signal strength with appropriate decimal places and unit
String signal = String(SStatusPrint / 10) + "." + String(abs(SStatusPrint % 10));
if (unit == 0) signal += " dBμV";
else if (unit == 1) signal += " dBf";
else if (unit == 2) signal += " dBm";
// Prepare the radio text with station information, including enhanced options if available
// Prepare the radio text with RDS station information and enhanced options
String radioText = String(radio.rds.stationText + " " + radio.rds.stationText32);
if (radio.rds.hasEnhancedRT) {
radioText += " eRT: " + String(radio.rds.enhancedRTtext);
}
// Replace commas in the station name and radio text to avoid CSV conflicts
// Replace commas in the station name and radio text to avoid conflicts in the CSV format
String stationName = radio.rds.stationName;
stationName.replace(",", " ");
String radioTextModified = radioText;
stationName.replace(",", " "); // Replace commas in station name
radioTextModified.replace(",", " "); // Replace commas in radio text
radioTextModified.replace(",", " ");
// Handle ECC, PTY, TA, TP, and Stereo flag
String TA = radio.rds.hasTA ? "" : " ";
String TP = radio.rds.hasTP ? "" : " ";
String Stereo = radio.getStereoStatus() ? "" : " ";
String pty = String(radio.rds.stationTypeCode);
String ECC = "--";
// Extract and format ECC (Extended Country Code) if available
String ECC = "";
if (radio.rds.hasECC) {
char eccBuffer[3]; // Buffer to hold 2-digit hex value + null terminator
snprintf(eccBuffer, sizeof(eccBuffer), "%02X", radio.rds.ECC); // Format ECC as uppercase 2-digit hex
char eccBuffer[3];
snprintf(eccBuffer, sizeof(eccBuffer), "%02X", radio.rds.ECC);
ECC = String(eccBuffer);
}
// Construct the CSV row data
// Extract and format LIC (Language Identifier Code) if available
String LIC = "";
if (radio.rds.hasLIC) {
char licBuffer[3];
snprintf(licBuffer, sizeof(licBuffer), "%02X", radio.rds.LIC);
LIC = String(licBuffer);
}
// Format the list of Alternative Frequencies (AF) if available
String AF = "";
if (radio.rds.hasAF && radio.af_counter > 0) {
for (byte i = 0; i < radio.af_counter; i++) {
AF += String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10) +
(i == radio.af_counter - 1 ? "" : ";");
}
}
// Format Enhanced Other Networks (EON) data if available
String EON = "";
if (radio.eon_counter > 0) {
for (byte i = 0; i < radio.eon_counter; i++) {
EON += String(radio.eon[i].picode) +
(radio.eon[i].ps.length() > 0 ? String(";" + radio.eon[i].ps) : ";") +
(radio.eon[i].mappedfreq > 0 ? String(";" + String(radio.eon[i].mappedfreq / 100) + "." + String((radio.eon[i].mappedfreq % 100) / 10)) : ";") +
(radio.eon[i].mappedfreq2 > 0 ? String(";" + String(radio.eon[i].mappedfreq2 / 100) + "." + String((radio.eon[i].mappedfreq2 % 100) / 10)) : ";") +
(radio.eon[i].mappedfreq3 > 0 ? String(";" + String(radio.eon[i].mappedfreq3 / 100) + "." + String((radio.eon[i].mappedfreq3 % 100) / 10)) : ";") +
(i == radio.eon_counter - 1 ? "" : ";");
}
}
// Extract RT+ (RadioText Plus) content if available
String RTPLUS = "";
if (radio.rds.hasRDSplus) {
RTPLUS += radio.rds.RTContent1 + ";" + radio.rds.RTContent2;
}
// Construct the data row to send via UDP
String row = currentDateTime + "," +
frequencyFormatted + "," +
String(radio.rds.picode).substring(0, 4) + "," +
signal + "," +
Stereo + "," +
TA + "," +
TP + "," +
pty + "," +
String(radio.getStereoStatus()) + "," +
String(radio.rds.hasTA) + "," +
String(radio.rds.hasTP) + "," +
String(radio.rds.hasTMC) + "," +
String(radio.rds.stationTypeCode) + "," +
ECC + "," +
LIC + "," +
stationName + "," +
radioTextModified + "\n";
radioTextModified + "," +
AF + "," +
EON + "," +
RTPLUS + "\n";
Udp.beginPacket(remoteip, 9100);
Udp.print(row);
Udp.endPacket();
// Send the data via UDP if it's new or the scanner is active
if (UDPlogold != row || scanner_active == true) {
Udp.beginPacket(remoteip, 9100);
Udp.print(row);
Udp.endPacket();
UDPlogold = row;
}
}

View File

@@ -35,5 +35,5 @@ String getCurrentDateTime();
bool isDST(time_t t);
void handleLogo();
void printLogbookCSV();
void sendUDPlog();
void sendUDPlog(bool scanner_active);
#endif