11char otaOutcome[21 ] = {0 }; // Modified by otaUpdate(), used to respond to rtkRemoteFirmwareVersion commands
2+ int systemWriteLength = 0 ; // Modified by systemWrite(), used to calculate the size of LIST command for CLI
23
34void menuCommands ()
45{
@@ -266,6 +267,26 @@ t_cliResult processCommand(char *cmdBuffer)
266267 else if (strcmp (tokens[1 ], " LIST" ) == 0 )
267268 {
268269 // Respond with a list of variables, types, and current value
270+
271+ // First calculate the size of the LIST response
272+ PrintEndpoint originalPrintEndpoint = printEndpoint;
273+ printEndpoint = PRINT_ENDPOINT_COUNT;
274+ systemWriteLength = 0 ;
275+ printAvailableSettings ();
276+ printEndpoint = originalPrintEndpoint;
277+
278+ // Use log10 to find the number of digits in systemWriteLength
279+ int systemWriteLengthDigits = floor (log10 (systemWriteLength)) + 1 ;
280+
281+ // Adjust systemWriteLength to include the length of the list entry
282+ systemWriteLength = systemWriteLength + sizeof (" $SPLST,list,int,*2A" ) + systemWriteLengthDigits;
283+
284+ // Print the list entry
285+ char settingValue[6 ]; // 12345
286+ snprintf (settingValue, sizeof (settingValue), " %d" , systemWriteLength);
287+ commandSendExecuteListResponse (" list" , " int" , settingValue);
288+
289+ // Now actually print the list
269290 printAvailableSettings ();
270291 commandSendExecuteOkResponse (tokens[0 ], tokens[1 ]);
271292 return (CLI_OK);
@@ -468,8 +489,22 @@ void commandSendResponse(const char *innerBuffer)
468489
469490 sprintf (responseBuffer, " $%s*%02X\r\n " , innerBuffer, calculatedChecksum);
470491
471- // CLI interactions may come from BLE or serial, respond to both interfaces
472- bluetoothSendCommand (responseBuffer);
492+ // CLI interactions may come from BLE or serial, respond to all interfaces
493+ commandSendAllInterfaces (responseBuffer);
494+ }
495+
496+ // Pass a command string to the all interfaces
497+ void commandSendAllInterfaces (char *rxData)
498+ {
499+ // Direct output to Bluetooth Command
500+ PrintEndpoint originalPrintEndpoint = printEndpoint;
501+
502+ // Don't re-direct if we're doing a count of the print output
503+ if (printEndpoint != PRINT_ENDPOINT_COUNT)
504+ printEndpoint = PRINT_ENDPOINT_ALL;
505+
506+ systemPrint (rxData); // Send command output to BLE, SPP, and Serial
507+ printEndpoint = originalPrintEndpoint;
473508}
474509
475510// Checks structure of command and checksum
@@ -559,8 +594,8 @@ int commandLookupSettingNameSelective(bool inCommands, const char *settingName,
559594 prioritySettingsEnd = findEndOfPrioritySettings ();
560595 // If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
561596
562- // Remove one because while rtkSettingsEntries[] contains detectedGnssReceiver, the command table does not
563- prioritySettingsEnd-- ;
597+ // Adjust prioritySettingsEnd if needed - depending on platform type
598+ prioritySettingsEnd = adjustEndOfPrioritySettings (prioritySettingsEnd) ;
564599
565600 // Loop through the valid command entries - starting at prioritySettingsEnd
566601 for (int i = prioritySettingsEnd; i < commandCount; i++)
@@ -1505,7 +1540,7 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
15051540 }
15061541
15071542 // Check if this setting is read only
1508- if (knownSetting == false )
1543+ if (knownSetting == false )
15091544 {
15101545 const char *table[] = {
15111546 " batteryLevelPercent" ,
@@ -1515,12 +1550,13 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
15151550 " deviceId" ,
15161551 " deviceName" ,
15171552 " gnssModuleInfo" ,
1553+ " list" ,
15181554 " rtkFirmwareVersion" ,
15191555 " rtkRemoteFirmwareVersion" ,
15201556 };
15211557 const int tableEntries = sizeof (table) / sizeof (table[0 ]);
15221558
1523- if (commandCheckListForVariable (settingName, table, tableEntries))
1559+ if (commandCheckListForVariable (settingName, table, tableEntries))
15241560 return (SETTING_KNOWN_READ_ONLY);
15251561 }
15261562
@@ -3747,6 +3783,25 @@ int findEndOfPrioritySettings()
37473783 return prioritySettingsEnd;
37483784}
37493785
3786+ int adjustEndOfPrioritySettings (int prioritySettingsEnd)
3787+ {
3788+ // If prioritySettingsEnd is zero, don't adjust
3789+ if (prioritySettingsEnd == 0 )
3790+ return 0 ;
3791+
3792+ int adjustedPrioritySettingsEnd = prioritySettingsEnd;
3793+
3794+ // Check which of the priority settings are possible on this platform
3795+ // Deduct the ones which are not
3796+ for (int i = 0 ; i < prioritySettingsEnd; i++)
3797+ {
3798+ if (!settingPossibleOnPlatform (i))
3799+ adjustedPrioritySettingsEnd--;
3800+ }
3801+
3802+ return adjustedPrioritySettingsEnd;
3803+ }
3804+
37503805// Allocate and fill the commandIndex table
37513806bool commandIndexFillPossible ()
37523807{
@@ -3824,6 +3879,9 @@ bool commandIndexFill(bool usePossibleSettings)
38243879 // If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
38253880 // and all settings will be sorted. Just like the good old days...
38263881
3882+ // Adjust prioritySettingsEnd if needed - depending on platform type
3883+ prioritySettingsEnd = adjustEndOfPrioritySettings (prioritySettingsEnd);
3884+
38273885 if (settings.debugSettings || settings.debugCLI )
38283886 {
38293887 systemPrintf (" commandCount %d\r\n " , commandCount);
@@ -3937,7 +3995,7 @@ void printAvailableSettings()
39373995 checkBatteryLevels ();
39383996
39393997 // Convert int to string
3940- char batteryLvlStr[4 ] = {0 }; // 104
3998+ char batteryLvlStr[4 ] = {0 }; // 104
39413999 snprintf (batteryLvlStr, sizeof (batteryLvlStr), " %d" , batteryLevelPercent);
39424000
39434001 // Create the settingType based on the length of the firmware version
@@ -3963,7 +4021,7 @@ void printAvailableSettings()
39634021 commandSendExecuteListResponse (" batteryVoltage" , settingType, batteryVoltageStr);
39644022 }
39654023
3966- // Display the current battery charging percent per hour
4024+ // Display the current battery charging percent per hour
39674025 else if (commandIndex[i] == COMMAND_BATTERY_CHARGING_PERCENT)
39684026 {
39694027 checkBatteryLevels ();
@@ -4009,5 +4067,4 @@ void printAvailableSettings()
40094067 commandSendExecuteListResponse (" deviceId" , settingType, printDeviceId ());
40104068 }
40114069 }
4012- systemPrintln ();
40134070}
0 commit comments