summaryrefslogtreecommitdiffstats
path: root/src/detection/bluetooth/bluetooth_haiku.cpp
blob: 8ed52c5ac55f695d332beccfad3fca62627f800a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
extern "C" {
#include "bluetooth.h"
#include "common/io.h"
}

#include <bluetooth/LocalDevice.h>

const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) {
    using namespace Bluetooth;
    FF_SUPPRESS_IO();

    LocalDevice* dev = LocalDevice::GetLocalDevice();
    if (!dev) {
        return NULL;
    }

    BString devClass;
    dev->GetDeviceClass().DumpDeviceClass(devClass);

    FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *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;
}