122029648SMatthias Ringwald# BTstack Port for FreeBSD Systems 222029648SMatthias Ringwald 322029648SMatthias Ringwald## Overview 422029648SMatthias RingwaldThis port assumes that FreeBSD provides an ng_hci netgraph node for a connected Bluetooth Controller. 522029648SMatthias RingwaldIn most cases, these are Bluetooth USB dongles or built-in Bluetooth Controller connected via USB. 622029648SMatthias Ringwald 722029648SMatthias RingwaldFor Bluetooth Controllers connected via UART, the POSX-H4 port might be a better option als 822029648SMatthias Ringwald 922029648SMatthias Ringwald## Implementation details 1022029648SMatthias RingwaldIn FreeBSD 13.2, the hci node is connected to a l2cap node and a btsock_hci_raw node. In order to take control, this 1122029648SMatthias Ringwaldport create a custom netgraph ng_socket node and connect to the 'acl' and 'raw' hooks of the hci node. The OS Bluetooth 1222029648SMatthias Ringwaldfunctionality will be interrupted. 1322029648SMatthias Ringwald 1422029648SMatthias Ringwald## Compilation 1522029648SMatthias Ringwald 16*8e0bef02SMatthias RingwaldBTstack's FeeeBSD port does not have additional dependencies. To compile the cmake project with Make 1722029648SMatthias Ringwald 1822029648SMatthias Ringwald mkdir build 1922029648SMatthias Ringwald cd build 2022029648SMatthias Ringwald cmake .. 2122029648SMatthias Ringwald make 2222029648SMatthias Ringwald 2322029648SMatthias Ringwaldor using Ninja: 2422029648SMatthias Ringwald 25*8e0bef02SMatthias Ringwald mkdir build 26*8e0bef02SMatthias Ringwald cd build 27*8e0bef02SMatthias Ringwald cmake -G Ninja .. 2822029648SMatthias Ringwald ninja 2922029648SMatthias Ringwald 3022029648SMatthias Ringwald## Running the examples 3122029648SMatthias Ringwald 3222029648SMatthias RingwaldAs the port needs to reconfigure the Bluetooth netgraph node, it needs to run with root privileges. 3322029648SMatthias RingwaldIt tries to connect to 'ubt0hci' by default. If your Bluetooth Controller is different, you can select it with '-u node' 3422029648SMatthias RingwaldOn start, BTstack prints the path to the packet log and prints the information on the detected Buetooth Controller. 3522029648SMatthias Ringwald 3622029648SMatthias Ringwald $ sudo gatt_counter 3722029648SMatthias Ringwald Packet Log: /tmp/hci_dump.pklg 3822029648SMatthias Ringwald BTstack counter 0001 3922029648SMatthias Ringwald BTstack up and running on 00:1A:7D:DA:71:13. 4022029648SMatthias Ringwald 4122029648SMatthias Ringwald## ToDO 4222029648SMatthias Ringwald- drop privileges after startup 4322029648SMatthias Ringwald- auto-detect ng_hci node 4422029648SMatthias Ringwald- support for profiles that require SCO: HFP & HSP 45