Send DX scan results to rabbitears.info map for North America

This commit is contained in:
Russell Dwarshuis
2024-08-30 08:46:41 -04:00
parent 64eeb5dfe5
commit c77a84c0d4
4 changed files with 93 additions and 6 deletions
+67
View File
@@ -1,6 +1,7 @@
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include <WiFiClient.h>
#include <HTTPClient.h>
#include <EEPROM.h>
#include <Wire.h>
#include <math.h>
@@ -214,6 +215,7 @@ byte spispeed;
char buff[16];
char eonpicodeold[20][6];
char programTypePrevious[18];
char rabbitearstime[100][21];
const uint8_t* currentFont = nullptr;
float vPerold;
int ActiveColor;
@@ -308,6 +310,8 @@ String PIold;
String PSold;
String ptynold = " ";
String PTYold;
String RabbitearsPassword;
String RabbitearsUser;
String rds_clock;
String rds_clockold;
String RDSSPYRDS;
@@ -326,6 +330,7 @@ String XDRGTKRDS;
String XDRGTKRDSold;
uint16_t BW;
uint16_t MStatus;
uint16_t rabbitearspi[100]; // first is for 88.1, 2nd 88.3, etc. to 107.9 MHz
uint16_t SWMIBandPos;
uint16_t SWMIBandPosold;
uint16_t USN;
@@ -481,6 +486,8 @@ void setup() {
frequency_AIR = EEPROM.readUInt(EE_UINT16_FREQUENCY_AIR);
#endif
XDRGTK_key = EEPROM.readString(EE_STRING_XDRGTK_KEY);
RabbitearsUser = EEPROM.readString(EE_STRING_RABBITEARSUSER);
RabbitearsPassword = EEPROM.readString(EE_STRING_RABBITEARSPASSWORD);
usesquelch = EEPROM.readByte(EE_BYTE_USESQUELCH);
showmodulation = EEPROM.readByte(EE_BYTE_SHOWMODULATION);
amnb = EEPROM.readByte(EE_BYTE_AM_NB);
@@ -880,6 +887,13 @@ void loop() {
}
delay(100);
radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
if (RabbitearsUser.length() && RabbitearsPassword.length() && region == REGION_US && radio.rds.correctPI != 0 && frequency >= 8810 && frequency <= 10790 && !(frequency % 10) && ((frequency/10) % 2)) {
byte i = (frequency / 10 - 881) / 2;
if (!rabbitearspi[i]) {
rabbitearspi[i] = radio.rds.correctPI;
rtc.getTime("%FT%TZ").toCharArray(rabbitearstime[i],21); // ISO8601 format like 2024-08-24T12:52:00Z
}
}
if (!initdxscan) {
switch (scancancel) {
case CORRECTPI: if (RDSstatus && radio.rds.correctPI != 0) cancelDXScan(); break;
@@ -3900,6 +3914,22 @@ void TuneUp() {
if (fmdefaultstepsize == 2 && stepsize == 0 && frequency == 8795) frequency = 8790;
if (frequency >= (HighEdgeSet * 10) + 1) {
if (scandxmode && RabbitearsUser.length() && RabbitearsPassword.length()) {
byte i = 0;
bool hasreport = false;
for(i=0; i<100; i++) {
if (rabbitearspi[i]) {
hasreport = true;
break;
}
}
if (hasreport) {
rabbitearssend();
for (i=0; i< 100; i++) {
rabbitearspi[i] = 0;
}
}
}
frequency = LowEdgeSet * 10;
if (fmdefaultstepsize == 2 && stepsize == 0 && frequency == 8750) frequency = 8775;
if (edgebeep) EdgeBeeper();
@@ -4238,6 +4268,8 @@ void DefaultSettings(byte userhardwaremodel) {
EEPROM.writeUInt(EE_UINT16_FREQUENCY_AIR, 135350);
#endif
EEPROM.writeString(EE_STRING_XDRGTK_KEY, "password");
EEPROM.writeString(EE_STRING_RABBITEARSUSER, "");
EEPROM.writeString(EE_STRING_RABBITEARSPASSWORD, "");
if (userhardwaremodel == BASE_ILI9341) EEPROM.writeByte(EE_BYTE_USESQUELCH, 1); else EEPROM.writeByte(EE_BYTE_USESQUELCH, 0);
EEPROM.writeByte(EE_BYTE_SHOWMODULATION, 1);
EEPROM.writeByte(EE_BYTE_AM_NB, 0);
@@ -4546,6 +4578,10 @@ void endMenu() {
void startFMDXScan() {
initdxscan = true;
for(byte i=0; i<100; i++) {
rabbitearspi[i] = 0;
rabbitearstime[i][0] = 0;
}
if (menu) endMenu();
if (afscreen || advancedRDS) BuildDisplay();
@@ -4581,6 +4617,37 @@ void startFMDXScan() {
if (XDRGTKUSB || XDRGTKTCP) DataPrint("J1\n");
}
void rabbitearssend () {
if(WiFi.status() != WL_CONNECTED) return;
String RabbitearsURL = "http://rabbitears.info/tvdx/fm_spot";
WiFiClient RabbitearsClient;
HTTPClient http;
byte i;
String json = String("{\"tuner_key\":\"");
json += RabbitearsUser;
json += String("\",\"password\":\"");
json += RabbitearsPassword;
json += String("\",");
json += String("\"signal\":{");
for (i=0; i <100; i++) {
if (rabbitearspi[i]) {
json += String("\"");
json += String((i*2+881)*100000);
json += String("\":{\"time\":\"");
json += String(rabbitearstime[i]);
json += String("\",\"pi_code\":");
json += String(rabbitearspi[i]);
json += String("},");
}
}
json.remove(json.length()-1); // remove trailing comma
json += String("}}");
http.begin(RabbitearsClient,RabbitearsURL.c_str());
http.addHeader("Content-Type", "application/json");
http.POST(json);
http.end();
}
void setAutoSpeedSPI() {
switch (frequency / 10) {
case 875 ... 877: tft.setSPISpeed(28); break;
+7 -5
View File
@@ -209,9 +209,9 @@
#define EE_CHECKBYTE_VALUE 10 // 0 ~ 255,add new entry, change for new value
#define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
#ifdef HAS_AIR_BAND
#define EE_TOTAL_CNT 2236 // Total occupied eeprom bytes
#define EE_TOTAL_CNT 2258 // Total occupied eeprom bytes
#else
#define EE_TOTAL_CNT 2230 // Total occupied eeprom bytes
#define EE_TOTAL_CNT 2253 // Total occupied eeprom bytes
#endif
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte
@@ -320,9 +320,11 @@
#define EE_BYTE_MEMSTOPPOS 2227
#define EE_BYTE_MEMPIONLY 2228
#define EE_BYTE_MEMDOUBLEPI 2229
#define EE_STRING_RABBITEARSUSER 2230
#define EE_STRING_RABBITEARSPASSWORD 2241
#ifdef HAS_AIR_BAND
#define EE_BYTE_AIRSTEPSIZE 2230
#define EE_UINT16_FREQUENCY_AIR 2231
#define EE_BYTE_AIRSTEPSIZE 2252
#define EE_UINT16_FREQUENCY_AIR 2253
#endif
// End of EEPROM index defines
@@ -678,4 +680,4 @@ static const uint16_t openradiologo[] PROGMEM = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xbdf7, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffdf, 0x39c7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x42e6, 0x76ef, 0xa6cf, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x7ecf, 0x5be9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xce59, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xef5d, 0x3186, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x9492, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5367, 0x76ef, 0x9e6e, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x1962, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x31a6, 0xef7d, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xef5d, 0x4228, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xad75, 0xf7be, 0xffff, 0xffff, 0xffff, 0xffff, 0xef7d, 0x94b2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2183, 0x5be8, 0x76ef, 0x95ed, 0x9e8f, 0xa6ef, 0xa730, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0xa730, 0xa6f0, 0x9e8f, 0x962e, 0x76ef, 0x76ef, 0x3aa5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4208, 0xd6ba, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xd6ba, 0x2965, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
};
};
+17 -1
View File
@@ -4455,17 +4455,33 @@ void DoMenu() {
tftPrint(0, "http://192.168.4.1", 155, 174, PrimaryColor, PrimaryColorSmooth, 16);
char key [9];
XDRGTK_key.toCharArray(key, 9);
char rabbitearsuser [9];
RabbitearsUser.toCharArray(rabbitearsuser, 9);
char rabbitearspw [9];
RabbitearsPassword.toCharArray(rabbitearspw, 9);
UpdateFonts(1);
WiFiConnectParam XDRGTK_key_text("Set XDRGTK Password: (max 8 characters)");
WiFiConnectParam XDRGTK_key_input("XDRGTK_key", "Password", key, 9);
WiFiConnectParam RabbitearsUser_text("Set rabbitears.info live bandscan user ID");
WiFiConnectParam RabbitearsUser_input("RabbitearsUser", "ID", rabbitearsuser, 9);
WiFiConnectParam RabbitearsPassword_text("Set rabbitears.info password");
WiFiConnectParam RabbitearsPassword_input("RabbitearsPassword", "Password", rabbitearspw, 9);
if (!setWiFiConnectParam) {
wc.addParameter(&XDRGTK_key_text);
wc.addParameter(&XDRGTK_key_input);
wc.addParameter(&RabbitearsUser_text);
wc.addParameter(&RabbitearsUser_input);
wc.addParameter(&RabbitearsPassword_text);
wc.addParameter(&RabbitearsPassword_input);
setWiFiConnectParam = true;
}
wc.startConfigurationPortal(AP_WAIT);
XDRGTK_key = XDRGTK_key_input.getValue();
RabbitearsUser = RabbitearsUser_input.getValue();
RabbitearsPassword = RabbitearsPassword_input.getValue();
EEPROM.writeString(EE_STRING_XDRGTK_KEY, XDRGTK_key);
EEPROM.writeString(EE_STRING_RABBITEARSUSER, RabbitearsUser);
EEPROM.writeString(EE_STRING_RABBITEARSPASSWORD, RabbitearsPassword);
EEPROM.commit();
UpdateFonts(0);
wifi = true;
@@ -4728,4 +4744,4 @@ String removeNewline(String inputString) {
}
}
return outputString;
}
}
+2
View File
@@ -196,6 +196,8 @@ extern String rds_clockold;
extern String stationIDold;
extern String stationStateold;
extern String XDRGTK_key;
extern String RabbitearsUser;
extern String RabbitearsPassword;
extern unsigned int ConverterSet;
extern unsigned int HighEdgeSet;
extern unsigned int LowEdgeSet;