1
1
char 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
2
3
3
4
void menuCommands ()
4
5
{
@@ -266,6 +267,26 @@ t_cliResult processCommand(char *cmdBuffer)
266
267
else if (strcmp (tokens[1 ], " LIST" ) == 0 )
267
268
{
268
269
// 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
269
290
printAvailableSettings ();
270
291
commandSendExecuteOkResponse (tokens[0 ], tokens[1 ]);
271
292
return (CLI_OK);
@@ -468,8 +489,22 @@ void commandSendResponse(const char *innerBuffer)
468
489
469
490
sprintf (responseBuffer, " $%s*%02X\r\n " , innerBuffer, calculatedChecksum);
470
491
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;
473
508
}
474
509
475
510
// Checks structure of command and checksum
@@ -559,8 +594,8 @@ int commandLookupSettingNameSelective(bool inCommands, const char *settingName,
559
594
prioritySettingsEnd = findEndOfPrioritySettings ();
560
595
// If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
561
596
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) ;
564
599
565
600
// Loop through the valid command entries - starting at prioritySettingsEnd
566
601
for (int i = prioritySettingsEnd; i < commandCount; i++)
@@ -1505,7 +1540,7 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
1505
1540
}
1506
1541
1507
1542
// Check if this setting is read only
1508
- if (knownSetting == false )
1543
+ if (knownSetting == false )
1509
1544
{
1510
1545
const char *table[] = {
1511
1546
" batteryLevelPercent" ,
@@ -1515,12 +1550,13 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
1515
1550
" deviceId" ,
1516
1551
" deviceName" ,
1517
1552
" gnssModuleInfo" ,
1553
+ " list" ,
1518
1554
" rtkFirmwareVersion" ,
1519
1555
" rtkRemoteFirmwareVersion" ,
1520
1556
};
1521
1557
const int tableEntries = sizeof (table) / sizeof (table[0 ]);
1522
1558
1523
- if (commandCheckListForVariable (settingName, table, tableEntries))
1559
+ if (commandCheckListForVariable (settingName, table, tableEntries))
1524
1560
return (SETTING_KNOWN_READ_ONLY);
1525
1561
}
1526
1562
@@ -3747,6 +3783,25 @@ int findEndOfPrioritySettings()
3747
3783
return prioritySettingsEnd;
3748
3784
}
3749
3785
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
+
3750
3805
// Allocate and fill the commandIndex table
3751
3806
bool commandIndexFillPossible ()
3752
3807
{
@@ -3824,6 +3879,9 @@ bool commandIndexFill(bool usePossibleSettings)
3824
3879
// If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
3825
3880
// and all settings will be sorted. Just like the good old days...
3826
3881
3882
+ // Adjust prioritySettingsEnd if needed - depending on platform type
3883
+ prioritySettingsEnd = adjustEndOfPrioritySettings (prioritySettingsEnd);
3884
+
3827
3885
if (settings.debugSettings || settings.debugCLI )
3828
3886
{
3829
3887
systemPrintf (" commandCount %d\r\n " , commandCount);
@@ -3937,7 +3995,7 @@ void printAvailableSettings()
3937
3995
checkBatteryLevels ();
3938
3996
3939
3997
// Convert int to string
3940
- char batteryLvlStr[4 ] = {0 }; // 104
3998
+ char batteryLvlStr[4 ] = {0 }; // 104
3941
3999
snprintf (batteryLvlStr, sizeof (batteryLvlStr), " %d" , batteryLevelPercent);
3942
4000
3943
4001
// Create the settingType based on the length of the firmware version
@@ -3963,7 +4021,7 @@ void printAvailableSettings()
3963
4021
commandSendExecuteListResponse (" batteryVoltage" , settingType, batteryVoltageStr);
3964
4022
}
3965
4023
3966
- // Display the current battery charging percent per hour
4024
+ // Display the current battery charging percent per hour
3967
4025
else if (commandIndex[i] == COMMAND_BATTERY_CHARGING_PERCENT)
3968
4026
{
3969
4027
checkBatteryLevels ();
@@ -4009,5 +4067,4 @@ void printAvailableSettings()
4009
4067
commandSendExecuteListResponse (" deviceId" , settingType, printDeviceId ());
4010
4068
}
4011
4069
}
4012
- systemPrintln ();
4013
4070
}
0 commit comments