2025-02-16 20:37:21 +08:00
|
|
|
extern "C" {
|
|
|
|
|
#include "bluetooth.h"
|
2026-01-06 09:48:38 +08:00
|
|
|
#include "common/io.h"
|
2025-02-16 20:37:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include <bluetooth/LocalDevice.h>
|
|
|
|
|
|
2026-04-09 16:20:59 +08:00
|
|
|
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) {
|
2025-02-16 20:37:21 +08:00
|
|
|
using namespace Bluetooth;
|
2025-02-16 21:39:34 +08:00
|
|
|
FF_SUPPRESS_IO();
|
|
|
|
|
|
2025-02-16 20:37:21 +08:00
|
|
|
LocalDevice* dev = LocalDevice::GetLocalDevice();
|
2026-03-29 09:28:49 +08:00
|
|
|
if (!dev) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2025-02-16 20:37:21 +08:00
|
|
|
|
|
|
|
|
BString devClass;
|
|
|
|
|
dev->GetDeviceClass().DumpDeviceClass(devClass);
|
|
|
|
|
|
|
|
|
|
FFBluetoothResult* device = (FFBluetoothResult*) ffListAdd(devices);
|
|
|
|
|
ffStrbufInitS(&device->name, dev->GetFriendlyName());
|
|
|
|
|
ffStrbufInitS(&device->address, bdaddrUtils::ToString(dev->GetBluetoothAddress()).String());
|
|
|
|
|
ffStrbufInitS(&device->type, devClass.String());
|
|
|
|
|
device->battery = 0;
|
|
|
|
|
device->connected = true;
|
|
|
|
|
|
|
|
|
|
// TODO: more devices?
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|