Skip to content

Commit 7edb87f

Browse files
committed
Resolve #769. Add settings.geographicRegion. Delete settings.LBandFreq
1 parent 34e047d commit 7edb87f

File tree

5 files changed

+91
-27
lines changed

5 files changed

+91
-27
lines changed

Firmware/RTK_Surveyor/AP-Config/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,19 @@
10291029
</span>
10301030
</div>
10311031

1032+
<div id="geographicRegionDropdown">
1033+
<label for="geographicRegion">Geographic Region:</label>
1034+
<select name="geographicRegion" id="geographicRegion" class="form-dropdown mb-2">
1035+
<option value="0">US</option>
1036+
<option value="1">EU</option>
1037+
</select>
1038+
<span class="tt" data-bs-placement="right"
1039+
title="Select your geographic region. This defines the default L-Band frequency. Default: US">
1040+
<span class="icon-info-circle text-primary ms-2"></span>
1041+
</span>
1042+
<br>
1043+
</div>
1044+
10321045
<div id="ppSettingsConfig">
10331046
<div class="form-check mt-3">
10341047
<label class="form-check-label" for="autoKeyRenewal">Auto Key Renewal </label>

Firmware/RTK_Surveyor/Form.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ void createSettingsString(char *newSettings)
802802
stringRecord(newSettings, "pointPerfectDeviceProfileToken", settings.pointPerfectDeviceProfileToken);
803803
stringRecord(newSettings, "enablePointPerfectCorrections", settings.enablePointPerfectCorrections);
804804
stringRecord(newSettings, "autoKeyRenewal", settings.autoKeyRenewal);
805+
stringRecord(newSettings, "geographicRegion", settings.geographicRegion);
805806

806807
// External PPS/Triggers
807808
stringRecord(newSettings, "enableExternalPulse", settings.enableExternalPulse);
@@ -1385,6 +1386,9 @@ void updateSettingWithValue(const char *settingName, const char *settingValueStr
13851386
else if (strcmp(settingName, "autoFirmwareCheckMinutes") == 0)
13861387
settings.autoFirmwareCheckMinutes = settingValueBool;
13871388

1389+
else if (strcmp(settingName, "geographicRegion") == 0)
1390+
settings.geographicRegion = settingValue;
1391+
13881392
// Unused variables - read to avoid errors
13891393
else if (strcmp(settingName, "measurementRateSec") == 0)
13901394
{

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ void recordSystemSettingsToFile(File *settingsFile)
277277
settingsFile->printf("%s=%d\r\n", "debugPpCertificate", settings.debugPpCertificate);
278278

279279
settingsFile->printf("%s=%d\r\n", "updateZEDSettings", settings.updateZEDSettings);
280-
settingsFile->printf("%s=%d\r\n", "LBandFreq", settings.LBandFreq);
281280
settingsFile->printf("%s=%d\r\n", "enableLogging", settings.enableLogging);
282281
settingsFile->printf("%s=%d\r\n", "enableARPLogging", settings.enableARPLogging);
283282
settingsFile->printf("%s=%d\r\n", "ARPLoggingInterval_s", settings.ARPLoggingInterval_s);
@@ -451,6 +450,8 @@ void recordSystemSettingsToFile(File *settingsFile)
451450
settingsFile->printf("%s=%d\r\n", "enableZedUsb", settings.enableZedUsb);
452451
settingsFile->printf("%s=%d\r\n", "debugWiFiConfig", settings.debugWiFiConfig);
453452

453+
settingsFile->printf("%s=%d\r\n", "geographicRegion", settings.geographicRegion);
454+
454455
// Add new settings above <------------------------------------------------------------>
455456
}
456457

@@ -1089,8 +1090,6 @@ bool parseLine(char *str, Settings *settings)
10891090
if (settings->updateZEDSettings != d)
10901091
settings->updateZEDSettings = true; // If there is a discrepancy, push ZED reconfig
10911092
}
1092-
else if (strcmp(settingName, "LBandFreq") == 0)
1093-
settings->LBandFreq = d;
10941093
else if (strcmp(settingName, "timeZoneHours") == 0)
10951094
settings->timeZoneHours = d;
10961095
else if (strcmp(settingName, "timeZoneMinutes") == 0)
@@ -1377,6 +1376,9 @@ bool parseLine(char *str, Settings *settings)
13771376
else if (strcmp(settingName, "debugWiFiConfig") == 0)
13781377
settings->debugWiFiConfig = d;
13791378

1379+
else if (strcmp(settingName, "geographicRegion") == 0)
1380+
settings->geographicRegion = d;
1381+
13801382
// Add new settings above
13811383
//<------------------------------------------------------------>
13821384

Firmware/RTK_Surveyor/menuPP.ino

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,44 +1148,47 @@ void beginLBand()
11481148
theGNSS.checkCallbacks(); // Process any callbacks: ie, eventTriggerReceived
11491149
}
11501150

1151+
uint32_t LBandFreq;
11511152
// If we have a fix, check which frequency to use
11521153
if (fixType == 2 || fixType == 3 || fixType == 4 || fixType == 5) // 2D, 3D, 3D+DR, or Time
11531154
{
1154-
if ((longitude > -125 && longitude < -67) && (latitude > -90 && latitude < 90))
1155+
int r = 0; // Step through each geographic region
1156+
for (; r < numRegionalAreas; r++)
11551157
{
1156-
if (settings.debugLBand == true)
1157-
systemPrintln("Setting L-Band to US");
1158-
settings.LBandFreq = 1556290000; // We are in US band
1159-
}
1160-
else if ((longitude > -25 && longitude < 70) && (latitude > -90 && latitude < 90))
1161-
{
1162-
if (settings.debugLBand == true)
1163-
systemPrintln("Setting L-Band to EU");
1164-
settings.LBandFreq = 1545260000; // We are in EU band
1158+
if ((longitude >= Regional_Information_Table[r].area.lonWest)
1159+
&& (longitude <= Regional_Information_Table[r].area.lonEast)
1160+
&& (latitude >= Regional_Information_Table[r].area.latSouth)
1161+
&& (latitude <= Regional_Information_Table[r].area.latNorth))
1162+
{
1163+
LBandFreq = Regional_Information_Table[r].frequency;
1164+
if (settings.debugLBand == true)
1165+
systemPrintf("Setting L-Band frequency to %s (%dHz)\r\n", Regional_Information_Table[r].name, LBandFreq);
1166+
break;
1167+
}
11651168
}
1166-
else
1169+
if (r == numRegionalAreas) // Geographic region not found
11671170
{
1168-
systemPrintln("Error: Unknown band area. Defaulting to US band.");
1169-
settings.LBandFreq = 1556290000; // Default to US
1171+
LBandFreq = Regional_Information_Table[settings.geographicRegion].frequency;
1172+
systemPrintf("Error: Unknown L-Band geographic region. Using %s (%dHz)\r\n", Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
11701173
}
1171-
recordSystemSettings();
11721174
}
11731175
else
11741176
{
1177+
LBandFreq = Regional_Information_Table[settings.geographicRegion].frequency;
11751178
if (settings.debugLBand == true)
1176-
systemPrintln("No fix available for L-Band frequency determination");
1179+
systemPrintf("No fix available for L-Band geographic region determination. Using %s (%dHz)\r\n", Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
11771180
}
11781181

11791182
bool response = true;
11801183
response &= i2cLBand.newCfgValset();
1181-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_CENTER_FREQUENCY, settings.LBandFreq); // Default 1539812500 Hz
1182-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_SEARCH_WINDOW, 2200); // Default 2200 Hz
1183-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_SERVICE_ID, 0); // Default 1
1184-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_SERVICE_ID, 21845); // Default 50821
1185-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_DATA_RATE, 2400); // Default 2400 bps
1186-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_DESCRAMBLER, 1); // Default 1
1187-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_DESCRAMBLER_INIT, 26969); // Default 23560
1188-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_PRESCRAMBLING, 0); // Default 0
1184+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_CENTER_FREQUENCY, LBandFreq); // Default 1539812500 Hz
1185+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_SEARCH_WINDOW, 2200); // Default 2200 Hz
1186+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_SERVICE_ID, 0); // Default 1
1187+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_SERVICE_ID, 21845); // Default 50821
1188+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_DATA_RATE, 2400); // Default 2400 bps
1189+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_DESCRAMBLER, 1); // Default 1
1190+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_DESCRAMBLER_INIT, 26969); // Default 23560
1191+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_PRESCRAMBLING, 0); // Default 0
11891192
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_UNIQUE_WORD, 16238547128276412563ull);
11901193
response &=
11911194
i2cLBand.addCfgValset(UBLOX_CFG_MSGOUT_UBX_RXM_PMP_UART1, 0); // Diasable UBX-RXM-PMP on UART1. Not used.
@@ -1268,6 +1271,9 @@ void menuPointPerfect()
12681271

12691272
systemPrintln("k) Manual Key Entry");
12701273

1274+
systemPrint("g) Geographic Region: ");
1275+
systemPrintln(Regional_Information_Table[settings.geographicRegion].name);
1276+
12711277
systemPrintln("x) Exit");
12721278

12731279
byte incoming = getCharacterNumber();
@@ -1346,6 +1352,12 @@ void menuPointPerfect()
13461352
{
13471353
menuPointPerfectKeys();
13481354
}
1355+
else if (incoming == 'g')
1356+
{
1357+
settings.geographicRegion++;
1358+
if (settings.geographicRegion >= numRegionalAreas)
1359+
settings.geographicRegion = 0;
1360+
}
13491361
else if (incoming == 'x')
13501362
break;
13511363
else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_EMPTY)

Firmware/RTK_Surveyor/settings.h

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,38 @@ const ubxCmd ubxCommands[] = {
853853

854854
#define MAX_UBX_CMD (sizeof(ubxCommands) / sizeof(ubxCmd))
855855

856+
// Regional Support
857+
// Do we want the user to be able to specify which region they are in?
858+
// Or do we want to figure it out based on position?
859+
// If we define a simple 'square' area for each region, we can do both.
860+
// Note: the best way to obtain the L-Band frequencies would be from the MQTT /pp/frequencies/Lb topic.
861+
// But it is easier to record them here, in case we don't have access to MQTT...
862+
// Note: the key distribution topic is provided during ZTP. We don't need to record it here.
863+
864+
typedef struct
865+
{
866+
const double latNorth; // Degrees
867+
const double latSouth; // Degrees
868+
const double lonEast; // Degrees
869+
const double lonWest; // Degrees
870+
} Regional_Area;
871+
872+
typedef struct
873+
{
874+
const char *name; // As defined in the ZTP subscriptions description: EU, US, KR, AU, Japan
875+
const char *topicRegion; // As used in the corrections topic path
876+
const Regional_Area area;
877+
const uint32_t frequency; // L-Band frequency, Hz, if supported. 0 if not supported
878+
} Regional_Information;
879+
880+
const Regional_Information Regional_Information_Table[] =
881+
{
882+
{ "US", "us", { 50.0, 25.0, -60.0, -125.0}, 1556290000 },
883+
{ "EU", "eu", { 72.0, 36.0, 32.0, -11.0}, 1545260000 },
884+
// Note: we only include regions with L-Band coverage. AU, KR and Japan are not included here.
885+
};
886+
const int numRegionalAreas = sizeof(Regional_Information_Table) / sizeof(Regional_Information_Table[0]);
887+
856888
// This is all the settings that can be set on RTK Surveyor. It's recorded to NVM and the config file.
857889
typedef struct
858890
{
@@ -941,7 +973,6 @@ typedef struct
941973

942974
uint64_t lastKeyAttempt = 0; // Epoch time of last attempt at obtaining keys
943975
bool updateZEDSettings = true; // When in doubt, update the ZED with current settings
944-
uint32_t LBandFreq = 1556290000; // Default to US band
945976

946977
bool debugPpCertificate = false; // Debug Point Perfect certificate management
947978

@@ -1120,6 +1151,8 @@ typedef struct
11201151

11211152
bool debugWiFiConfig = false;
11221153

1154+
int geographicRegion = 0; // Default to US - first entry in Regional_Information_Table
1155+
11231156
// Add new settings above <------------------------------------------------------------>
11241157

11251158
} Settings;

0 commit comments

Comments
 (0)