summaryrefslogtreecommitdiffstats
path: root/src/detection/bluetooth/bluetooth_bsd.c
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/bluetooth/bluetooth_bsd.c
Add the files
Diffstat (limited to 'src/detection/bluetooth/bluetooth_bsd.c')
-rw-r--r--src/detection/bluetooth/bluetooth_bsd.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/detection/bluetooth/bluetooth_bsd.c b/src/detection/bluetooth/bluetooth_bsd.c
new file mode 100644
index 0000000..db9f23c
--- /dev/null
+++ b/src/detection/bluetooth/bluetooth_bsd.c
@@ -0,0 +1,30 @@
+#include "bluetooth.h"
+
+#define L2CAP_SOCKET_CHECKED
+#include <bluetooth.h>
+
+static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* devices) {
+ FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices);
+ ffStrbufInitS(&device->name,
+#if __FreeBSD__
+ bt_devremote_name_gen(dev->devname, &dev->bdaddr)
+#else
+ dev->devname
+#endif
+ );
+ ffStrbufInitS(&device->address, bt_ntoa(&dev->bdaddr, NULL));
+ ffStrbufUpperCase(&device->address);
+ ffStrbufInit(&device->type);
+ device->battery = 0;
+ device->connected = true;
+ return 0;
+}
+
+const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) {
+ // struct hostent* ent = bt_gethostent();
+ if (bt_devenum((void*) enumDev, devices) < 0) {
+ return "bt_devenum() failed";
+ }
+
+ return NULL;
+}