ohmu
·
2026-10-15
1extern "C" {
2#include "bluetooth.h"
3#include "common/io.h"
4}
5
6#include <bluetooth/LocalDevice.h>
7
8const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) {
9 // The local adapter's device class is a BR/EDR concept and the adapter is the only device this
10 // backend has, so a Low Energy-only configuration leaves the list empty.
11 if (!(options->showType & FF_BLUETOOTH_DEVICE_TYPE_CLASSIC_BIT)) {
12 return nullptr;
13 }
14
15 using namespace Bluetooth;
16 FF_SUPPRESS_IO();
17
18 LocalDevice* dev = LocalDevice::GetLocalDevice();
19 if (!dev) {
20 return nullptr;
21 }
22
23 BString devClass;
24 dev->GetDeviceClass().DumpDeviceClass(devClass);
25
26 FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices);
27 ffStrbufInitS(&device->name, dev->GetFriendlyName());
28 ffStrbufInitS(&device->address, bdaddrUtils::ToString(dev->GetBluetoothAddress()).String());
29 ffStrbufInitS(&device->type, devClass.String());
30 device->deviceType = FF_BLUETOOTH_DEVICE_TYPE_CLASSIC_BIT; // The local adapter's device class is a BR/EDR concept
31 device->battery = 0;
32 device->signalQuality = -DBL_MAX;
33 device->connected = true;
34
35 // TODO: more devices?
36
37 return nullptr;
38}