Skip to content

Commit 9569999

Browse files
committed
CLI: Add gets for battery stats, deviceName,
1 parent 9b03afc commit 9569999

File tree

2 files changed

+103
-10
lines changed

2 files changed

+103
-10
lines changed

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 95 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,6 +2970,22 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
29702970
settingIsString = true;
29712971
}
29722972
}
2973+
else if (strcmp(settingName, "bluetoothId") == 0)
2974+
{
2975+
// Get the last two digits of Bluetooth MAC
2976+
char macAddress[5];
2977+
snprintf(macAddress, sizeof(macAddress), "%02X%02X", btMACAddress[4], btMACAddress[5]);
2978+
2979+
writeToString(settingValueStr, macAddress);
2980+
knownSetting = true;
2981+
settingIsString = true;
2982+
}
2983+
else if (strcmp(settingName, "deviceName") == 0)
2984+
{
2985+
writeToString(settingValueStr, (char *)productDisplayNames[productVariant]);
2986+
knownSetting = true;
2987+
settingIsString = true;
2988+
}
29732989
else if (strcmp(settingName, "deviceId") == 0)
29742990
{
29752991
writeToString(settingValueStr, (char *)printDeviceId());
@@ -3011,19 +3027,20 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
30113027
else if (strcmp(settingName, "batteryLevelPercent") == 0)
30123028
{
30133029
checkBatteryLevels();
3014-
writeToString(settingValueStr, batteryLevelPercent);
3030+
writeToString(settingValueStr, batteryLevelPercent, 0);
30153031
knownSetting = true;
3032+
settingIsString = true;
30163033
}
30173034
else if (strcmp(settingName, "batteryVoltage") == 0)
30183035
{
30193036
checkBatteryLevels();
3020-
writeToString(settingValueStr, batteryVoltage);
3037+
writeToString(settingValueStr, batteryVoltage, 2);
30213038
knownSetting = true;
30223039
}
30233040
else if (strcmp(settingName, "batteryChargingPercentPerHour") == 0)
30243041
{
30253042
checkBatteryLevels();
3026-
writeToString(settingValueStr, batteryChargingPercentPerHour);
3043+
writeToString(settingValueStr, batteryChargingPercentPerHour, 0);
30273044
knownSetting = true;
30283045
}
30293046

@@ -3596,11 +3613,27 @@ const char *commandGetName(int stringIndex, int rtkIndex)
35963613
else if (rtkIndex == COMMAND_GNSS_MODULE_INFO)
35973614
return "gnssModuleInfo";
35983615

3616+
// Display the current battery level as a percent
3617+
else if (rtkIndex == COMMAND_BATTERY_LEVEL_PERCENT)
3618+
return "batteryLevelPercent";
3619+
3620+
// Display the current battery level as a percent
3621+
else if (rtkIndex == COMMAND_BATTERY_VOLTAGE)
3622+
return "batteryVoltage";
3623+
3624+
// Display the current battery charging percent per hour
3625+
else if (rtkIndex == COMMAND_BATTERY_CHARGING_PERCENT)
3626+
return "batteryChargingPercentPerHour";
3627+
35993628
// Display the last four characters of the Bluetooth MAC address
36003629
else if (rtkIndex == COMMAND_BLUETOOTH_ID)
36013630
return "bluetoothId";
36023631

3603-
// Display the device ID - used in PointPerfect
3632+
// Display the device Name
3633+
else if (rtkIndex == COMMAND_DEVICE_NAME)
3634+
return "deviceName";
3635+
3636+
// Display the device ID
36043637
else if (rtkIndex == COMMAND_DEVICE_ID)
36053638
return "deviceId";
36063639

@@ -3871,7 +3904,55 @@ void printAvailableSettings()
38713904
commandSendExecuteListResponse("gnssModuleInfo", settingType, printGnssModuleInfo());
38723905
}
38733906

3874-
// Display the current RTK Firmware version
3907+
// Display the current battery level as a percent
3908+
else if (commandIndex[i] == COMMAND_BATTERY_LEVEL_PERCENT)
3909+
{
3910+
checkBatteryLevels();
3911+
3912+
// Convert int to string
3913+
char batteryLvlStr[4] = {0}; //104
3914+
snprintf(batteryLvlStr, sizeof(batteryLvlStr), "%d", batteryLevelPercent);
3915+
3916+
// Create the settingType based on the length of the firmware version
3917+
char settingType[100];
3918+
snprintf(settingType, sizeof(settingType), "char[%d]", strlen(batteryLvlStr));
3919+
3920+
commandSendExecuteListResponse("batteryLevelPercent", settingType, batteryLvlStr);
3921+
}
3922+
3923+
// Display the current battery voltage
3924+
else if (commandIndex[i] == COMMAND_BATTERY_VOLTAGE)
3925+
{
3926+
checkBatteryLevels();
3927+
3928+
// Convert int to string
3929+
char batteryVoltageStr[6] = {0}; // 11.25
3930+
snprintf(batteryVoltageStr, sizeof(batteryVoltageStr), "%0.2f", batteryVoltage);
3931+
3932+
// Create the settingType based on the length of the firmware version
3933+
char settingType[100];
3934+
snprintf(settingType, sizeof(settingType), "char[%d]", strlen(batteryVoltageStr));
3935+
3936+
commandSendExecuteListResponse("batteryVoltage", settingType, batteryVoltageStr);
3937+
}
3938+
3939+
// Display the current battery charging percent per hour
3940+
else if (commandIndex[i] == COMMAND_BATTERY_CHARGING_PERCENT)
3941+
{
3942+
checkBatteryLevels();
3943+
3944+
// Convert int to string
3945+
char batteryChargingPercentStr[3] = {0}; // 45
3946+
snprintf(batteryChargingPercentStr, sizeof(batteryChargingPercentStr), "%0.0f", batteryChargingPercentStr);
3947+
3948+
// Create the settingType based on the length of the firmware version
3949+
char settingType[100];
3950+
snprintf(settingType, sizeof(settingType), "char[%d]", strlen(batteryChargingPercentStr));
3951+
3952+
commandSendExecuteListResponse("batteryChargingPercentPerHour", settingType, batteryChargingPercentStr);
3953+
}
3954+
3955+
// Display the last four characters of the Bluetooth MAC
38753956
else if (commandIndex[i] == COMMAND_BLUETOOTH_ID)
38763957
{
38773958
// Get the last two digits of Bluetooth MAC
@@ -3885,7 +3966,15 @@ void printAvailableSettings()
38853966
commandSendExecuteListResponse("bluetoothId", settingType, macAddress);
38863967
}
38873968

3888-
// Display the device ID - used in PointPerfect
3969+
// Display the device name
3970+
else if (commandIndex[i] == COMMAND_DEVICE_NAME)
3971+
{
3972+
char settingType[100];
3973+
snprintf(settingType, sizeof(settingType), "char[%d]", strlen(productDisplayNames[productVariant]));
3974+
commandSendExecuteListResponse("deviceName", settingType, productDisplayNames[productVariant]);
3975+
}
3976+
3977+
// Display the device ID
38893978
else if (commandIndex[i] == COMMAND_DEVICE_ID)
38903979
{
38913980
char settingType[100];

Firmware/RTK_Everywhere/settings.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,10 +1213,14 @@ typedef struct
12131213
#define COMMAND_REMOTE_FIRMWARE_VERSION (COMMAND_FIRMWARE_VERSION - 1) // -10 - 1 = -11
12141214
#define COMMAND_ENABLE_RC_FIRMWARE (COMMAND_REMOTE_FIRMWARE_VERSION - 1) // -11 - 1 = -12
12151215
#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
1216+
#define COMMAND_BATTERY_LEVEL_PERCENT (COMMAND_GNSS_MODULE_INFO - 1) // -13 - 1 = -14
1217+
#define COMMAND_BATTERY_VOLTAGE (COMMAND_BATTERY_LEVEL_PERCENT - 1) // -13 - 1 = -14
1218+
#define COMMAND_BATTERY_CHARGING_PERCENT (COMMAND_BATTERY_VOLTAGE - 1) // -13 - 1 = -14
1219+
#define COMMAND_BLUETOOTH_ID (COMMAND_BATTERY_CHARGING_PERCENT - 1) // -13 - 1 = -14
1220+
#define COMMAND_DEVICE_NAME (COMMAND_BLUETOOTH_ID - 1) // -14 - 1 = -15
1221+
#define COMMAND_DEVICE_ID (COMMAND_DEVICE_NAME - 1) // -15 - 1 = -16
1222+
#define COMMAND_UNKNOWN (COMMAND_DEVICE_ID - 1) // -16 - 1 = -17
1223+
#define COMMAND_COUNT (-(COMMAND_UNKNOWN)) // 17
12201224

12211225
// Exit types for processCommand
12221226
typedef enum

0 commit comments

Comments
 (0)