1*22029648SMatthias Ringwald# BTstack Port for FreeBSD Systems 2*22029648SMatthias Ringwald 3*22029648SMatthias Ringwald## Overview 4*22029648SMatthias RingwaldThis port assumes that FreeBSD provides an ng_hci netgraph node for a connected Bluetooth Controller. 5*22029648SMatthias RingwaldIn most cases, these are Bluetooth USB dongles or built-in Bluetooth Controller connected via USB. 6*22029648SMatthias Ringwald 7*22029648SMatthias RingwaldFor Bluetooth Controllers connected via UART, the POSX-H4 port might be a better option als 8*22029648SMatthias Ringwald 9*22029648SMatthias Ringwald## Implementation details 10*22029648SMatthias 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 11*22029648SMatthias Ringwaldport create a custom netgraph ng_socket node and connect to the 'acl' and 'raw' hooks of the hci node. The OS Bluetooth 12*22029648SMatthias Ringwaldfunctionality will be interrupted. 13*22029648SMatthias Ringwald 14*22029648SMatthias Ringwald## Compilation 15*22029648SMatthias Ringwald 16*22029648SMatthias RingwaldBTstack's FeeeBSD port does not have additional dependencies. To compile the cmake project with make 17*22029648SMatthias Ringwald 18*22029648SMatthias Ringwald mkdir build 19*22029648SMatthias Ringwald cd build 20*22029648SMatthias Ringwald cmake .. 21*22029648SMatthias Ringwald make 22*22029648SMatthias Ringwald 23*22029648SMatthias Ringwaldor using Ninja: 24*22029648SMatthias Ringwald 25*22029648SMatthias Ringwald mkdir ninja 26*22029648SMatthias Ringwald cd ninja 27*22029648SMatthias Ringwald cmake .. 28*22029648SMatthias Ringwald ninja 29*22029648SMatthias Ringwald 30*22029648SMatthias Ringwald## Running the examples 31*22029648SMatthias Ringwald 32*22029648SMatthias RingwaldAs the port needs to reconfigure the Bluetooth netgraph node, it needs to run with root privileges. 33*22029648SMatthias RingwaldIt tries to connect to 'ubt0hci' by default. If your Bluetooth Controller is different, you can select it with '-u node' 34*22029648SMatthias RingwaldOn start, BTstack prints the path to the packet log and prints the information on the detected Buetooth Controller. 35*22029648SMatthias Ringwald 36*22029648SMatthias Ringwald $ sudo gatt_counter 37*22029648SMatthias Ringwald Packet Log: /tmp/hci_dump.pklg 38*22029648SMatthias Ringwald BTstack counter 0001 39*22029648SMatthias Ringwald BTstack up and running on 00:1A:7D:DA:71:13. 40*22029648SMatthias Ringwald 41*22029648SMatthias Ringwald## ToDO 42*22029648SMatthias Ringwald- drop privileges after startup 43*22029648SMatthias Ringwald- auto-detect ng_hci node 44*22029648SMatthias Ringwald- support for profiles that require SCO: HFP & HSP 45