You've already forked TEF6686_ESP32
Extended UDP protocol
This commit is contained in:
@@ -171,6 +171,7 @@ byte BWsetFM;
|
||||
byte BWsetRecall;
|
||||
byte BWtemp;
|
||||
byte charwidth = 8;
|
||||
byte chipmodel;
|
||||
byte hardwaremodel;
|
||||
byte ContrastSet;
|
||||
byte CurrentSkin;
|
||||
@@ -862,19 +863,23 @@ void setup() {
|
||||
if (lowByte(device) == 14) {
|
||||
fullsearchrds = false;
|
||||
fmsi = false;
|
||||
chipmodel = 0;
|
||||
tft.fillRect(152, 230, 16, 6, PrimaryColor);
|
||||
tftPrint(0, "TEF6686 Lithio", 160, 172, ActiveColor, ActiveColorSmooth, 28);
|
||||
} else if (lowByte(device) == 1) {
|
||||
fullsearchrds = true;
|
||||
chipmodel = 1;
|
||||
tft.fillRect(152, 230, 16, 6, PrimaryColor);
|
||||
tftPrint(0, "TEF6687 Lithio FMSI", 160, 172, ActiveColor, ActiveColorSmooth, 28);
|
||||
} else if (lowByte(device) == 9) {
|
||||
fullsearchrds = false;
|
||||
chipmodel = 2;
|
||||
fmsi = false;
|
||||
tft.fillRect(152, 230, 16, 6, PrimaryColor);
|
||||
tftPrint(0, "TEF6688 Lithio DR", 160, 172, ActiveColor, ActiveColorSmooth, 28);
|
||||
} else if (lowByte(device) == 3) {
|
||||
fullsearchrds = true;
|
||||
chipmodel = 3;
|
||||
tft.fillRect(152, 230, 16, 6, PrimaryColor);
|
||||
tftPrint(0, "TEF6689 Lithio FMSI DR", 160, 172, ActiveColor, ActiveColorSmooth, 28);
|
||||
} else {
|
||||
|
||||
@@ -9,52 +9,80 @@ void Communication() {
|
||||
if (!menu) {
|
||||
if (wifi) {
|
||||
int packetSize = Udp.parsePacket();
|
||||
if (packetSize) {
|
||||
char packetBuffer[packetSize];
|
||||
if (packetSize > 0) {
|
||||
char packetBuffer[packetSize + 1]; // +1 for null terminator
|
||||
Udp.read(packetBuffer, packetSize);
|
||||
packetBuffer[packetSize] = '\0'; // Ensure valid string
|
||||
Udp.endPacket();
|
||||
|
||||
String packet = String(packetBuffer);
|
||||
if (strcmp(packetBuffer, "from=StationList;freq=?;bandwidth=?") == 0) {
|
||||
|
||||
if (packet.equals("from=StationList;freq=?;bandwidth=?")) {
|
||||
ShowFreq(0);
|
||||
} else {
|
||||
externaltune = true;
|
||||
int symPos = packet.indexOf("freq=");
|
||||
String stlfreq = packet.substring(symPos + 5, packetSize);
|
||||
return;
|
||||
}
|
||||
|
||||
externaltune = true;
|
||||
|
||||
if (packet.charAt(0) == '*') {
|
||||
if (afscreen) BuildAdvancedRDS();
|
||||
char command = packet.charAt(1);
|
||||
switch (command) {
|
||||
case 'U':
|
||||
case 'D':
|
||||
tunemode = TUNE_MAN;
|
||||
ShowTuneMode();
|
||||
if (command == 'U') TuneUp(); else TuneDown();
|
||||
ShowFreq(0);
|
||||
break;
|
||||
|
||||
case 'S': if (!scandxmode) startFMDXScan(); break;
|
||||
case 'E': if (scandxmode) cancelDXScan(); break;
|
||||
|
||||
case 'R': radio.clearRDS(fullsearchrds); break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int symPos = packet.indexOf("freq=");
|
||||
|
||||
if (symPos != -1) {
|
||||
String stlfreq = packet.substring(symPos + 5);
|
||||
int freqValue = stlfreq.toInt();
|
||||
|
||||
if (afscreen) BuildAdvancedRDS();
|
||||
|
||||
if ((stlfreq.toInt()) / 10000 > (TEF == 205 ? 6400 : 6500) && (stlfreq.toInt()) / 10000 < 10800) {
|
||||
unsigned int tempfreq = (stlfreq.toInt()) / 10000;
|
||||
unsigned int tempfreq;
|
||||
if ((freqValue / 10000) > (TEF == 205 ? 6400 : 6500) && (freqValue / 10000) < 10800) {
|
||||
tempfreq = freqValue / 10000;
|
||||
if (scandxmode) cancelDXScan();
|
||||
|
||||
if (tempfreq >= FREQ_FM_OIRT_START && tempfreq <= FREQ_FM_OIRT_END) {
|
||||
if (band != BAND_OIRT) {
|
||||
band = BAND_OIRT;
|
||||
frequency_OIRT = tempfreq;
|
||||
SelectBand();
|
||||
}
|
||||
radio.SetFreq(frequency_OIRT);
|
||||
} else {
|
||||
if (band != BAND_FM) {
|
||||
band = BAND_FM;
|
||||
frequency = tempfreq;
|
||||
SelectBand();
|
||||
}
|
||||
}
|
||||
if (band == BAND_OIRT) {
|
||||
frequency_OIRT = tempfreq;
|
||||
radio.SetFreq(frequency_OIRT);
|
||||
} else {
|
||||
frequency = tempfreq;
|
||||
radio.SetFreq(frequency);
|
||||
}
|
||||
}
|
||||
|
||||
if ((stlfreq.toInt()) / 1000 > 144 && (stlfreq.toInt()) / 1000 < 27000) {
|
||||
if ((freqValue / 1000) > 144 && (freqValue / 1000) < 27000) {
|
||||
tempfreq = freqValue / 1000;
|
||||
if (scandxmode) cancelDXScan();
|
||||
if (afscreen || advancedRDS) {
|
||||
BuildDisplay();
|
||||
SelectBand();
|
||||
ScreensaverTimerReopen();
|
||||
}
|
||||
unsigned int tempfreq = (stlfreq.toInt()) / 1000;
|
||||
|
||||
if (tempfreq >= FREQ_LW_LOW_EDGE_MIN && tempfreq <= FREQ_LW_HIGH_EDGE_MAX) {
|
||||
frequency_LW = tempfreq;
|
||||
if (band != BAND_LW) {
|
||||
@@ -84,6 +112,7 @@ void Communication() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
radio.clearRDS(fullsearchrds);
|
||||
ShowFreq(0);
|
||||
store = true;
|
||||
|
||||
@@ -54,6 +54,7 @@ extern byte scanhold;
|
||||
extern byte stepsize;
|
||||
extern byte subnetclient;
|
||||
extern byte TEF;
|
||||
extern byte tunemode;
|
||||
extern char buff[16];
|
||||
extern int ActiveColor;
|
||||
extern int ActiveColorSmooth;
|
||||
@@ -154,4 +155,7 @@ extern void handleRoot();
|
||||
extern void handleDownloadCSV();
|
||||
extern void handleLogo();
|
||||
extern void Infoboxprint(const char* input);
|
||||
extern void TuneUp();
|
||||
extern void TuneDown();
|
||||
extern void ShowTuneMode();
|
||||
#endif
|
||||
@@ -535,6 +535,15 @@ void sendUDPlog() {
|
||||
}
|
||||
}
|
||||
|
||||
// set Chipmodel
|
||||
String CHIP = "";
|
||||
switch (chipmodel) {
|
||||
case 0: CHIP = "TEF6686"; break;
|
||||
case 1: CHIP = "TEF6687"; break;
|
||||
case 2: CHIP = "TEF6688"; break;
|
||||
case 3: CHIP = "TEF6689"; break;
|
||||
}
|
||||
|
||||
// Extract RT+ (RadioText Plus) content if available
|
||||
String RTPLUS = "";
|
||||
if (radio.rds.hasRDSplus) {
|
||||
@@ -542,7 +551,10 @@ void sendUDPlog() {
|
||||
}
|
||||
|
||||
// Construct the data row to send via UDP
|
||||
String row = currentDateTime + "," +
|
||||
String row = CHIP + "," +
|
||||
VERSION + "," +
|
||||
String(scandxmode) + "," +
|
||||
currentDateTime + "," +
|
||||
frequencyFormatted + "," +
|
||||
String(radio.rds.picode).substring(0, 4) + "," +
|
||||
signal + "," +
|
||||
@@ -561,7 +573,7 @@ void sendUDPlog() {
|
||||
|
||||
// Send the data via UDP if it's new
|
||||
if (UDPlogold != row) {
|
||||
IPAddress broadcastIP = makeBroadcastAddress(remoteip);
|
||||
IPAddress broadcastIP = makeBroadcastAddress(remoteip);
|
||||
Udp.beginPacket(broadcastIP, 9100);
|
||||
Udp.print(row);
|
||||
Udp.endPacket();
|
||||
@@ -570,6 +582,6 @@ void sendUDPlog() {
|
||||
}
|
||||
|
||||
IPAddress makeBroadcastAddress(IPAddress ip) {
|
||||
// Assuming a typical subnet mask of 255.255.255.0
|
||||
return IPAddress(ip[0], ip[1], ip[2], 255);
|
||||
// Assuming a typical subnet mask of 255.255.255.0
|
||||
return IPAddress(ip[0], ip[1], ip[2], 255);
|
||||
}
|
||||
@@ -12,7 +12,9 @@ extern bool autoDST;
|
||||
extern bool clockampm;
|
||||
extern bool NTPupdated;
|
||||
extern bool rtcset;
|
||||
extern bool scandxmode;
|
||||
extern byte band;
|
||||
extern byte chipmodel;
|
||||
extern byte language;
|
||||
extern byte unit;
|
||||
extern int16_t SStatus;
|
||||
|
||||
Reference in New Issue
Block a user