Bluetooth (Windows): tidy; update module description

This commit is contained in:
李通洲
2024-07-27 23:53:17 +08:00
parent 2cc94ee095
commit ce648e9e44
2 changed files with 15 additions and 20 deletions
+12 -17
View File
@@ -15,18 +15,16 @@ const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothResult */)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindNextDevice)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindDeviceClose)
BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = {
BLUETOOTH_DEVICE_INFO btdi = {
.dwSize = sizeof(btdi)
};
HBLUETOOTH_DEVICE_FIND hFind = ffBluetoothFindFirstDevice(&(BLUETOOTH_DEVICE_SEARCH_PARAMS) {
.fReturnConnected = TRUE,
.fReturnRemembered = TRUE,
.fReturnAuthenticated = TRUE,
.fReturnUnknown = TRUE,
.dwSize = sizeof(btsp)
};
BLUETOOTH_DEVICE_INFO btdi = {
.dwSize = sizeof(btdi)
};
HBLUETOOTH_DEVICE_FIND hFind = ffBluetoothFindFirstDevice(&btsp, &btdi);
.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS)
}, &btdi);
if(!hFind)
{
if (GetLastError() == ERROR_NO_MORE_ITEMS)
@@ -37,21 +35,18 @@ const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothResult */)
do {
FFBluetoothResult* device = ffListAdd(devices);
ffStrbufInit(&device->name);
ffStrbufInit(&device->address);
ffStrbufInit(&device->type);
device->battery = 0;
device->connected = !!btdi.fConnected;
ffStrbufSetWS(&device->name, btdi.szName);
ffStrbufAppendF(&device->address, "%02x:%02x:%02x:%02x:%02x:%02x",
ffStrbufInitWS(&device->name, btdi.szName);
ffStrbufInitF(&device->address, "%02x:%02x:%02x:%02x:%02x:%02x",
btdi.Address.rgBytes[0],
btdi.Address.rgBytes[1],
btdi.Address.rgBytes[2],
btdi.Address.rgBytes[3],
btdi.Address.rgBytes[4],
btdi.Address.rgBytes[5]);
ffStrbufInit(&device->type);
device->battery = 0;
device->connected = !!btdi.fConnected;
//https://btprodspecificationrefs.blob.core.windows.net/assigned-numbers/Assigned%20Number%20Types/Assigned%20Numbers.pdf
if(BitTest(&btdi.ulClassofDevice, 13))
+3 -3
View File
@@ -178,8 +178,8 @@ void ffGenerateBluetoothJsonResult(FF_MAYBE_UNUSED FFBluetoothOptions* options,
void ffPrintBluetoothHelpFormat(void)
{
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTH_MODULE_NAME, "{1} ({4})", FF_BLUETOOTH_NUM_FORMAT_ARGS, ((const char* []) {
"Name - name",
"Address - address",
"Name - device name",
"Address - remote device address",
"Type - type",
"Battery percentage number - battery-percentage",
"Is connected - connected",
@@ -192,7 +192,7 @@ void ffInitBluetoothOptions(FFBluetoothOptions* options)
ffOptionInitModuleBaseInfo(
&options->moduleInfo,
FF_BLUETOOTH_MODULE_NAME,
"List bluetooth devices",
"List (connected) bluetooth devices",
ffParseBluetoothCommandOptions,
ffParseBluetoothJsonObject,
ffPrintBluetooth,