Skip to content

Commit c99731f

Browse files
committed
Add more commands to CLI. Use wifiConnectTimeout setting for OTA.
Remove commands that do not need to be exposed in the CLI.
1 parent c5b98b6 commit c99731f

File tree

3 files changed

+102
-48
lines changed

3 files changed

+102
-48
lines changed

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,29 +1547,7 @@ void createSettingsString(char *newSettings)
15471547
stringRecord(newSettings, "platformPrefix", apPlatformPrefix);
15481548

15491549
stringRecord(newSettings, "rtkFirmwareVersion", (char *)printRtkFirmwareVersion());
1550-
1551-
char apGNSSFirmwareVersion[80];
1552-
if (present.gnss_zedf9p)
1553-
{
1554-
snprintf(apGNSSFirmwareVersion, sizeof(apGNSSFirmwareVersion), "ZED-F9P Firmware: %s ID: %s",
1555-
gnssFirmwareVersion, gnssUniqueId);
1556-
}
1557-
else if (present.gnss_um980)
1558-
{
1559-
snprintf(apGNSSFirmwareVersion, sizeof(apGNSSFirmwareVersion), "UM980 Firmware: %s ID: %s", gnssFirmwareVersion,
1560-
gnssUniqueId);
1561-
}
1562-
else if (present.gnss_mosaicX5)
1563-
{
1564-
snprintf(apGNSSFirmwareVersion, sizeof(apGNSSFirmwareVersion), "mosaic-X5 Firmware: %s ID: %s",
1565-
gnssFirmwareVersion, gnssUniqueId);
1566-
}
1567-
else if (present.gnss_lg290p)
1568-
{
1569-
snprintf(apGNSSFirmwareVersion, sizeof(apGNSSFirmwareVersion), "LG290P Firmware: %s ID: %s",
1570-
gnssFirmwareVersion, gnssUniqueId);
1571-
}
1572-
stringRecord(newSettings, "gnssFirmwareVersion", apGNSSFirmwareVersion);
1550+
stringRecord(newSettings, "gnssFirmwareVersion", (char *)printGnssModuleInfo());
15731551
stringRecord(newSettings, "gnssFirmwareVersionInt", gnssFirmwareVersionInt);
15741552

15751553
char apDeviceBTID[30];
@@ -2964,7 +2942,8 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
29642942
}
29652943
else if (strcmp(settingName, "rtkRemoteFirmwareVersion") == 0)
29662944
{
2967-
// otaUpdate() is synchronous and called from loop() so we respond here with OK, then go check the firmware version
2945+
// otaUpdate() is synchronous and called from loop() so we respond here with OK, then go check the firmware
2946+
// version
29682947
writeToString(settingValueStr, (char *)"OK");
29692948
knownSetting = true;
29702949

@@ -2980,6 +2959,13 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
29802959
writeToString(settingValueStr, enableRCFirmware);
29812960
knownSetting = true;
29822961
}
2962+
else if (strcmp(settingName, "gnssModuleInfo") == 0)
2963+
{
2964+
writeToString(settingValueStr, (char *)printGnssModuleInfo());
2965+
knownSetting = true;
2966+
settingIsString = true;
2967+
}
2968+
29832969
else if (strcmp(settingName, "batteryLevelPercent") == 0)
29842970
{
29852971
checkBatteryLevels();
@@ -3560,6 +3546,18 @@ const char *commandGetName(int stringIndex, int rtkIndex)
35603546
else if (rtkIndex == COMMAND_REMOTE_FIRMWARE_VERSION)
35613547
return "rtkRemoteFirmwareVersion";
35623548

3549+
// Allow release candidate firmware to be installed
3550+
else if (rtkIndex == COMMAND_ENABLE_RC_FIRMWARE)
3551+
return "enableRCFirmware";
3552+
3553+
// Display the current GNSS firmware version number
3554+
else if (rtkIndex == COMMAND_GNSS_MODULE_INFO)
3555+
return "gnssModuleInfo";
3556+
3557+
// Display the last four characters of the Bluetooth MAC address
3558+
else if (rtkIndex == COMMAND_BLUETOOTH_ID)
3559+
return "bluetoothId";
3560+
35633561
// Display the device ID - used in PointPerfect
35643562
else if (rtkIndex == COMMAND_DEVICE_ID)
35653563
return "deviceId";
@@ -3805,13 +3803,46 @@ void printAvailableSettings()
38053803
commandSendExecuteListResponse("rtkFirmwareVersion", settingType, printRtkFirmwareVersion());
38063804
}
38073805

3808-
// Display the current RTK Firmware version
3806+
// Display the latest remote RTK Firmware version
38093807
else if (commandIndex[i] == COMMAND_REMOTE_FIRMWARE_VERSION)
38103808
{
3811-
// Report the avialable command but without data. That requires the user issue separate SPGET.
3809+
// Report the available command but without data. That requires the user issue separate SPGET.
38123810
commandSendExecuteListResponse("rtkRemoteFirmwareVersion", "char[21]", "NotYetRetreived");
38133811
}
38143812

3813+
// Allow beta firmware release candidates
3814+
else if (commandIndex[i] == COMMAND_ENABLE_RC_FIRMWARE)
3815+
{
3816+
if (enableRCFirmware)
3817+
commandSendExecuteListResponse("enableRCFirmware", "bool", "true");
3818+
else
3819+
commandSendExecuteListResponse("enableRCFirmware", "bool", "false");
3820+
}
3821+
3822+
// Display the current RTK Firmware version
3823+
else if (commandIndex[i] == COMMAND_GNSS_MODULE_INFO)
3824+
{
3825+
// Create the settingType based on the length of the firmware version
3826+
char settingType[100];
3827+
snprintf(settingType, sizeof(settingType), "char[%d]", strlen(printGnssModuleInfo()));
3828+
3829+
commandSendExecuteListResponse("gnssModuleInfo", settingType, printGnssModuleInfo());
3830+
}
3831+
3832+
// Display the current RTK Firmware version
3833+
else if (commandIndex[i] == COMMAND_BLUETOOTH_ID)
3834+
{
3835+
// Get the last two digits of Bluetooth MAC
3836+
char macAddress[5];
3837+
snprintf(macAddress, sizeof(macAddress), "%02X%02X", btMACAddress[4], btMACAddress[5]);
3838+
3839+
// Create the settingType based on the length of the MAC
3840+
char settingType[100];
3841+
snprintf(settingType, sizeof(settingType), "char[%d]", strlen(macAddress));
3842+
3843+
commandSendExecuteListResponse("bluetoothId", settingType, macAddress);
3844+
}
3845+
38153846
// Display the device ID - used in PointPerfect
38163847
else if (commandIndex[i] == COMMAND_DEVICE_ID)
38173848
{

Firmware/RTK_Everywhere/menuFirmware.ino

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,26 @@ const char *printRtkFirmwareVersion()
176176
return ((const char *)rtkFirmwareVersion);
177177
}
178178

179+
// Returns a string containing the module model, firmware, and ID. Similar to gnss->printModuleInfo()
180+
const char *printGnssModuleInfo()
181+
{
182+
static char gnssModuleInfo[80];
183+
char gnssMfg[10];
184+
if (present.gnss_zedf9p)
185+
strncpy(gnssMfg, "ZED-F9P", sizeof(gnssMfg));
186+
else if (present.gnss_um980)
187+
strncpy(gnssMfg, "UM980", sizeof(gnssMfg));
188+
else if (present.gnss_mosaicX5)
189+
strncpy(gnssMfg, "mosaic-X5", sizeof(gnssMfg));
190+
else if (present.gnss_lg290p)
191+
strncpy(gnssMfg, "LG290P", sizeof(gnssMfg));
192+
193+
snprintf(gnssModuleInfo, sizeof(gnssModuleInfo), "%s Firmware: %s ID: %s", gnssMfg, gnssFirmwareVersion,
194+
gnssUniqueId);
195+
196+
return ((const char *)gnssModuleInfo);
197+
}
198+
179199
//----------------------------------------
180200
// Returns true if otaReportedVersion is newer than currentVersion
181201
// Version number comes in as v2.7-Jan 5 2023
@@ -854,7 +874,7 @@ void otaUpdate()
854874
otaSetState(OTA_STATE_GET_FIRMWARE_VERSION);
855875
}
856876

857-
else if ((millis() - connectTimer) > (10 * MILLISECONDS_IN_A_SECOND))
877+
else if ((millis() - connectTimer) > settings.wifiConnectTimeoutMs)
858878
{
859879
if (settings.debugFirmwareUpdate)
860880
systemPrintln("Firmware update failed to connect to network");
@@ -873,14 +893,14 @@ void otaUpdate()
873893
if (bluetoothCommandIsConnected())
874894
{
875895
// Report failure to the CLI
876-
if(otaRequestFirmwareUpdate)
877-
commandSendExecuteErrorResponse((char *)"SPEXE", (char *)"UPDATEFIRMWARE", (char *)"No Internet");
878-
else if(otaRequestFirmwareVersionCheck)
879-
commandSendErrorResponse((char *)"SPGET", (char *)"rtkRemoteFirmwareVersion", (char *)"No Internet");
896+
if (otaRequestFirmwareUpdate)
897+
commandSendExecuteErrorResponse((char *)"SPEXE", (char *)"UPDATEFIRMWARE",
898+
(char *)"No Internet");
899+
else if (otaRequestFirmwareVersionCheck)
900+
commandSendErrorResponse((char *)"SPGET", (char *)"rtkRemoteFirmwareVersion",
901+
(char *)"No Internet");
880902
otaUpdateStop();
881903
}
882-
883-
884904
}
885905
break;
886906

Firmware/RTK_Everywhere/settings.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ struct Settings
10681068
{"", ""},
10691069
{"", ""},
10701070
};
1071-
uint32_t wifiConnectTimeoutMs = 20000; // Wait this long for a WiFiMulti connection
1071+
uint32_t wifiConnectTimeoutMs = 10000; // Wait this long for a WiFiMulti connection
10721072

10731073
bool outputTipAltitude = false; // If enabled, subtract the pole length and APC from the GNSS receiver's reported altitude
10741074

@@ -1211,9 +1211,12 @@ typedef struct
12111211
#define COMMAND_PROFILE_NUMBER (COMMAND_PROFILE_0_INDEX - MAX_PROFILE_COUNT) // -1 - 8 = -9
12121212
#define COMMAND_FIRMWARE_VERSION (COMMAND_PROFILE_NUMBER - 1) // -9 - 1 = -10
12131213
#define COMMAND_REMOTE_FIRMWARE_VERSION (COMMAND_FIRMWARE_VERSION - 1) // -10 - 1 = -11
1214-
#define COMMAND_DEVICE_ID (COMMAND_REMOTE_FIRMWARE_VERSION - 1) // -11 - 1 = -12
1215-
#define COMMAND_UNKNOWN (COMMAND_DEVICE_ID - 1) // -12 - 1 = -13
1216-
#define COMMAND_COUNT (-(COMMAND_UNKNOWN)) // 13
1214+
#define COMMAND_ENABLE_RC_FIRMWARE (COMMAND_REMOTE_FIRMWARE_VERSION - 1) // -11 - 1 = -12
1215+
#define COMMAND_GNSS_MODULE_INFO (COMMAND_ENABLE_RC_FIRMWARE - 1) // -12 - 1 = -13
1216+
#define COMMAND_BLUETOOTH_ID (COMMAND_GNSS_MODULE_INFO - 1) // -13 - 1 = -14
1217+
#define COMMAND_DEVICE_ID (COMMAND_BLUETOOTH_ID - 1) // -14 - 1 = -15
1218+
#define COMMAND_UNKNOWN (COMMAND_DEVICE_ID - 1) // -15 - 1 = -16
1219+
#define COMMAND_COUNT (-(COMMAND_UNKNOWN)) // 16
12171220

12181221
// Exit types for processCommand
12191222
typedef enum
@@ -1534,15 +1537,15 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
15341537
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.bluetoothInterruptsCore, "bluetoothInterruptsCore", },
15351538
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.btReadTaskCore, "btReadTaskCore", },
15361539
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.btReadTaskPriority, "btReadTaskPriority", },
1537-
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.debugMalloc, "debugMalloc", },
1540+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.debugMalloc, "debugMalloc", },
15381541
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.enableHeapReport, "enableHeapReport", },
15391542
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.enablePrintIdleTime, "enablePrintIdleTime", },
15401543
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.enablePsram, "enablePsram", },
15411544
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.enableTaskReports, "enableTaskReports", },
15421545
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.gnssReadTaskCore, "gnssReadTaskCore", },
15431546
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.gnssReadTaskPriority, "gnssReadTaskPriority", },
15441547
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.gnssUartInterruptsCore, "gnssUartInterruptsCore", },
1545-
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.haltOnPanic, "haltOnPanic", },
1548+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.haltOnPanic, "haltOnPanic", },
15461549
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.handleGnssDataTaskCore, "handleGnssDataTaskCore", },
15471550
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.handleGnssDataTaskPriority, "handleGnssDataTaskPriority", },
15481551
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.i2cInterruptsCore, "i2cInterruptsCore", },
@@ -1561,7 +1564,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
15611564
// Point Perfect
15621565
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.autoKeyRenewal, "autoKeyRenewal", },
15631566
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.debugPpCertificate, "debugPpCertificate", },
1564-
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _int, 0, & settings.geographicRegion, "geographicRegion", },
1567+
{ 1, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _int, 0, & settings.geographicRegion, "geographicRegion", },
15651568
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint64_t, 0, & settings.lastKeyAttempt, "lastKeyAttempt", },
15661569
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint16_t, 0, & settings.lbandFixTimeout_seconds, "lbandFixTimeout", },
15671570
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, tCharArry, sizeof(settings.pointPerfectBrokerHost), & settings.pointPerfectBrokerHost, "pointPerfectBrokerHost", },
@@ -1683,9 +1686,9 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
16831686
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.tcpOverWiFiStation, "tcpOverWiFiStation", },
16841687

16851688
// Time Zone
1686-
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _int8_t, 0, & settings.timeZoneHours, "timeZoneHours", },
1687-
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _int8_t, 0, & settings.timeZoneMinutes, "timeZoneMinutes", },
1688-
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _int8_t, 0, & settings.timeZoneSeconds, "timeZoneSeconds", },
1689+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _int8_t, 0, & settings.timeZoneHours, "timeZoneHours", },
1690+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _int8_t, 0, & settings.timeZoneMinutes, "timeZoneMinutes", },
1691+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _int8_t, 0, & settings.timeZoneSeconds, "timeZoneSeconds", },
16891692

16901693
// F
16911694
// a
@@ -1755,14 +1758,14 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
17551758
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.wifiChannel, "wifiChannel", },
17561759
{ 1, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.wifiConfigOverAP, "wifiConfigOverAP", },
17571760
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, ALL, 1, tWiFiNet, MAX_WIFI_NETWORKS, & settings.wifiNetworks, "wifiNetwork_", },
1758-
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint32_t, 0, & settings.wifiConnectTimeoutMs, "wifiConnectTimeoutMs", },
1761+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint32_t, 0, & settings.wifiConnectTimeoutMs, "wifiConnectTimeoutMs", },
17591762

17601763
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.outputTipAltitude, "outputTipAltitude", },
17611764

17621765
// Localized distribution
1763-
{ 1, 1, 0, 1, 1, 0, 1, 1, 1, ALL, 1, _bool, 0, & settings.useLocalizedDistribution, "useLocalizedDistribution", },
1764-
{ 1, 1, 0, 1, 1, 0, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.localizedDistributionTileLevel, "localizedDistributionTileLevel", },
1765-
{ 1, 1, 0, 1, 1, 0, 1, 1, 1, ALL, 1, _bool, 0, & settings.useAssistNow, "useAssistNow", },
1766+
{ 1, 0, 0, 1, 1, 0, 1, 1, 1, ALL, 1, _bool, 0, & settings.useLocalizedDistribution, "useLocalizedDistribution", },
1767+
{ 1, 0, 0, 1, 1, 0, 1, 1, 1, ALL, 1, _uint8_t, 0, & settings.localizedDistributionTileLevel, "localizedDistributionTileLevel", },
1768+
{ 1, 0, 0, 1, 1, 0, 1, 1, 1, ALL, 1, _bool, 0, & settings.useAssistNow, "useAssistNow", },
17661769

17671770
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.requestKeyUpdate, "requestKeyUpdate", },
17681771

@@ -1798,7 +1801,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
17981801
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.debugSettings, "debugSettings", },
17991802
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.enableNtripCaster, "enableNtripCaster", },
18001803
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.baseCasterOverride, "baseCasterOverride", },
1801-
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.debugCLI, "debugCLI", },
1804+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.debugCLI, "debugCLI", },
18021805

18031806

18041807
// Add new settings to appropriate group above or create new group

0 commit comments

Comments
 (0)