1# BTstack Port for POSIX Systems with libusb Library 2 3## Compilation 4The quickest way to try BTstack is on a Linux or OS X system with an 5additional USB Bluetooth dongle. It requires 6[pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/) 7and [libusb-1.0](http://libusb.info) or higher to be 8installed. 9 10On a recent Debian-based system, all you need is: 11 12 apt-get install gcc git libusb-1.0 pkg-config 13 14 15When everything is ready, you compile all examples with: 16 17 make 18 19## Environment 20 21On Linux, the USB Bluetooth dongle is usually not accessible to a regular user. You can either: 22- run the examples as root 23- add a udev rule for your dongle to extend access rights to user processes 24 25To add an udev rule, please create `/etc/udev/rules.d/btstack.rules` and add this 26 27 # Match all devices from CSR 28 SUBSYSTEM=="usb", ATTRS{idVendor}=="0a12", MODE="0666" 29 30 # Match DeLOCK Bluetooth 4.0 dongle 31 SUBSYSTEM=="usb", ATTRS{idVendor}=="0a5c", ATTRS{device}=="21e8", MODE="0666" 32 33 # Match Asus BT400 34 SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", ATTRS{device}=="17cb", MODE="0666" 35 36 37On macOS, the OS will try to use a plugged-in Bluetooth Controller if one is available. 38It's best to to tell the OS to always use the internal Bluetooth Contoller. 39 40For this, execute: 41 42 sudo nvram bluetoothHostControllerSwitchBehavior=never 43 44and then reboot to activate the change. 45 46## Running the examples 47 48BTstack's HCI USB transport will try to find a suitable Bluetooth module and use it. 49 50On start, BTstack will try to find a suitable Bluetooth module. It will also print the path to the packet log as well as the USB path. 51 52 $ ./le_counter 53 Packet Log: /tmp/hci_dump.pklg 54 BTstack counter 0001 55 USB Path: 06 56 BTstack up and running on 00:1A:7D:DA:71:13. 57 58If you want to run multiple examples at the same time, it helps to fix the path to the used Bluetooth module by passing -u usb-path to the executable. 59 60Example running le_streamer and le_streamer_client in two processes, using Bluetooth dongles at USB path 6 and 4: 61 62 ./le_streamer -u 6 63 Specified USB Path: 06 64 Packet Log: /tmp/hci_dump_6.pklg 65 USB Path: 06 66 BTstack up and running on 00:1A:7D:DA:71:13. 67 To start the streaming, please run the le_streamer_client example on other device, or use some GATT Explorer, e.g. LightBlue, BLExplr. 68 69 $ ./le_streamer_client -u 4 70 Specified USB Path: 04 71 Packet Log: /tmp/hci_dump_4.pklg 72 USB Path: 04 73 BTstack up and running on 00:1A:7D:DA:71:13. 74 Start scanning! 75