Skip to content

Commit f3ec9ee

Browse files
committed
CLI: Add firmware version
1 parent f3d0858 commit f3ec9ee

File tree

3 files changed

+48
-13
lines changed

3 files changed

+48
-13
lines changed

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ t_cliResult processCommand(char *cmdBuffer)
263263
// Apply factory defaults, then reset
264264
commandSendExecuteOkResponse(tokens[0], tokens[1]);
265265
factoryReset(false); // We do not have the SD semaphore
266-
return (CLI_OK); //We should never get this far.
266+
return (CLI_OK); // We should never get this far.
267267
}
268268
else
269269
{
@@ -1516,9 +1516,7 @@ void createSettingsString(char *newSettings)
15161516
strncpy(apPlatformPrefix, platformPrefixTable[productVariant], sizeof(apPlatformPrefix));
15171517
stringRecord(newSettings, "platformPrefix", apPlatformPrefix);
15181518

1519-
char apRtkFirmwareVersion[86];
1520-
firmwareVersionGet(apRtkFirmwareVersion, sizeof(apRtkFirmwareVersion), true);
1521-
stringRecord(newSettings, "rtkFirmwareVersion", apRtkFirmwareVersion);
1519+
stringRecord(newSettings, "rtkFirmwareVersion", (char *)printRtkFirmwareVersion());
15221520

15231521
char apGNSSFirmwareVersion[80];
15241522
if (present.gnss_zedf9p)
@@ -2921,13 +2919,19 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
29212919
else if (knownSetting == true)
29222920
return (SETTING_KNOWN);
29232921

2924-
// Report deviceID over CLI - Useful for label generation
2922+
// Report special human-machine-interface settings
29252923
if (strcmp(settingName, "deviceId") == 0)
29262924
{
29272925
writeToString(settingValueStr, (char *)printDeviceId());
29282926
knownSetting = true;
29292927
settingIsString = true;
29302928
}
2929+
else if (strcmp(settingName, "rtkFirmwareVersion") == 0)
2930+
{
2931+
writeToString(settingValueStr, (char *)printRtkFirmwareVersion());
2932+
knownSetting = true;
2933+
settingIsString = true;
2934+
}
29312935

29322936
// Special actions
29332937
else if (strcmp(settingName, "enableRCFirmware") == 0)
@@ -3507,8 +3511,16 @@ const char *commandGetName(int stringIndex, int rtkIndex)
35073511
else if (rtkIndex == COMMAND_PROFILE_NUMBER)
35083512
return "profileNumber";
35093513

3514+
// Display the current firmware version number
3515+
else if (rtkIndex == COMMAND_FIRMWARE_VERSION)
3516+
return "rtkFirmwareVersion";
3517+
35103518
// Display the device ID - used in PointPerfect
3511-
return "deviceId";
3519+
else if (rtkIndex == COMMAND_DEVICE_ID)
3520+
return "deviceId";
3521+
3522+
systemPrintln("commandGetName Error: Uncaught command type");
3523+
return "unknown";
35123524
}
35133525

35143526
// Determine if the setting is available on this platform
@@ -3658,7 +3670,7 @@ bool commandIndexFill(bool usePossibleSettings)
36583670
}
36593671
}
36603672

3661-
// Add the man-machine interface commands to the list
3673+
// Add the human-machine-interface commands to the list
36623674
for (i = 1; i < COMMAND_COUNT; i++)
36633675
commandIndex[commandCount++] = -i;
36643676

@@ -3667,8 +3679,10 @@ bool commandIndexFill(bool usePossibleSettings)
36673679
// If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
36683680
// and all settings will be sorted. Just like the good old days...
36693681

3670-
if (settings.debugSettings)
3682+
if (settings.debugSettings || settings.debugCLI)
36713683
{
3684+
systemPrintf("commandCount %d\r\n", commandCount);
3685+
36723686
if (prioritySettingsEnd > 0)
36733687
systemPrintf("endOfPrioritySettings found at entry %d\r\n", prioritySettingsEnd);
36743688
else
@@ -3714,7 +3728,7 @@ void printAvailableSettings()
37143728
commandList(false, commandIndex[i]);
37153729
}
37163730

3717-
// Below are commands formed specifically for the Man-Machine-Interface
3731+
// Below are commands formed specifically for the Human-Machine-Interface
37183732
// Display the profile name - used in Profiles
37193733
else if (commandIndex[i] >= -MAX_PROFILE_COUNT)
37203734
{
@@ -3736,6 +3750,16 @@ void printAvailableSettings()
37363750
commandSendExecuteListResponse("profileNumber", "uint8_t", settingValue);
37373751
}
37383752

3753+
// Display the current RTK Firmware version
3754+
else if (commandIndex[i] == COMMAND_FIRMWARE_VERSION)
3755+
{
3756+
// Create the settingType based on the length of the firmware version
3757+
char settingType[100];
3758+
snprintf(settingType, sizeof(settingType), "char[%d]", strlen(printRtkFirmwareVersion()));
3759+
3760+
commandSendExecuteListResponse("rtkFirmwareVersion", settingType, printRtkFirmwareVersion());
3761+
}
3762+
37393763
// Display the device ID - used in PointPerfect
37403764
else if (commandIndex[i] == COMMAND_DEVICE_ID)
37413765
{

Firmware/RTK_Everywhere/menuFirmware.ino

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ void firmwareVersionGet(char *buffer, int bufferLength, bool includeDate)
166166
firmwareVersionFormat(FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, buffer, bufferLength, includeDate);
167167
}
168168

169+
// Returns string containing the current version number - ie "v2.0"
170+
const char *printRtkFirmwareVersion()
171+
{
172+
// Create the firmware version string
173+
static char rtkFirmwareVersion[86];
174+
firmwareVersionGet(rtkFirmwareVersion, sizeof(rtkFirmwareVersion), true);
175+
176+
return ((const char *)rtkFirmwareVersion);
177+
}
178+
169179
//----------------------------------------
170180
// Returns true if otaReportedVersion is newer than currentVersion
171181
// Version number comes in as v2.7-Jan 5 2023
@@ -885,7 +895,7 @@ void otaUpdate()
885895
if (otaRequestFirmwareVersionCheck == true)
886896
{
887897
otaRequestFirmwareVersionCheck = false;
888-
898+
889899
if (websocketConnected)
890900
{
891901
char newVersionCSV[40];

Firmware/RTK_Everywhere/settings.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,9 +1209,10 @@ typedef struct
12091209

12101210
#define COMMAND_PROFILE_0_INDEX -1
12111211
#define COMMAND_PROFILE_NUMBER (COMMAND_PROFILE_0_INDEX - MAX_PROFILE_COUNT) // -1 - 8 = -9
1212-
#define COMMAND_DEVICE_ID (COMMAND_PROFILE_NUMBER - 1) // -9 - 1 = -10
1213-
#define COMMAND_UNKNOWN (COMMAND_DEVICE_ID - 1) // -10 - 1 = -11
1214-
#define COMMAND_COUNT (-(COMMAND_UNKNOWN)) // 11
1212+
#define COMMAND_FIRMWARE_VERSION (COMMAND_PROFILE_NUMBER - 1) // -9 - 1 = -10
1213+
#define COMMAND_DEVICE_ID (COMMAND_FIRMWARE_VERSION - 1) // -10 - 1 = -11
1214+
#define COMMAND_UNKNOWN (COMMAND_DEVICE_ID - 1) // -11 - 1 = -12
1215+
#define COMMAND_COUNT (-(COMMAND_UNKNOWN)) // 12
12151216

12161217
// Exit types for processCommand
12171218
typedef enum

0 commit comments

Comments
 (0)