1808a498cSMatthias Ringwald# BTstack Port for POSIX Systems with libusb Library 2304b2f4dSMatthias Ringwald 3808a498cSMatthias Ringwald## Compilation 4304b2f4dSMatthias RingwaldThe quickest way to try BTstack is on a Linux or OS X system with an 5304b2f4dSMatthias Ringwaldadditional USB Bluetooth dongle. It requires 6304b2f4dSMatthias Ringwald[pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/) 7304b2f4dSMatthias Ringwaldand [libusb-1.0](http://libusb.info) or higher to be 8304b2f4dSMatthias Ringwaldinstalled. 9304b2f4dSMatthias Ringwald 10808a498cSMatthias RingwaldOn a recent Debian-based system, all you need is: 11808a498cSMatthias Ringwald 12808a498cSMatthias Ringwald apt-get install gcc git libusb-1.0 pkg-config 13808a498cSMatthias Ringwald 14808a498cSMatthias Ringwald 15808a498cSMatthias RingwaldWhen everything is ready, you compile all examples with: 16808a498cSMatthias Ringwald 17808a498cSMatthias Ringwald make 18808a498cSMatthias Ringwald 19808a498cSMatthias Ringwald## Environment 20808a498cSMatthias Ringwald 21808a498cSMatthias RingwaldOn Linux, the USB Bluetooth dongle is usually not accessible to a regular user. You can either: 22304b2f4dSMatthias Ringwald- run the examples as root 23304b2f4dSMatthias Ringwald- add a udev rule for your dongle to extend access rights to user processes 24304b2f4dSMatthias Ringwald 25304b2f4dSMatthias RingwaldTo add an udev rule, please create `/etc/udev/rules.d/btstack.rules` and add this 26304b2f4dSMatthias Ringwald 27304b2f4dSMatthias Ringwald # Match all devices from CSR 28304b2f4dSMatthias Ringwald SUBSYSTEM=="usb", ATTRS{idVendor}=="0a12", MODE="0666" 29304b2f4dSMatthias Ringwald 30304b2f4dSMatthias Ringwald # Match DeLOCK Bluetooth 4.0 dongle 31304b2f4dSMatthias Ringwald SUBSYSTEM=="usb", ATTRS{idVendor}=="0a5c", ATTRS{device}=="21e8", MODE="0666" 32304b2f4dSMatthias Ringwald 33304b2f4dSMatthias Ringwald # Match Asus BT400 34304b2f4dSMatthias Ringwald SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", ATTRS{device}=="17cb", MODE="0666" 35304b2f4dSMatthias Ringwald 36*425c3bbdSMatthias Ringwald # Match Laird BT860 / Cypress Semiconductor CYW20704A2 37*425c3bbdSMatthias Ringwald SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{device}=="f901", MODE="0666" 38*425c3bbdSMatthias Ringwald 39808a498cSMatthias Ringwald 40808a498cSMatthias RingwaldOn macOS, the OS will try to use a plugged-in Bluetooth Controller if one is available. 41808a498cSMatthias RingwaldIt's best to to tell the OS to always use the internal Bluetooth Contoller. 42808a498cSMatthias Ringwald 43808a498cSMatthias RingwaldFor this, execute: 44304b2f4dSMatthias Ringwald 45304b2f4dSMatthias Ringwald sudo nvram bluetoothHostControllerSwitchBehavior=never 46304b2f4dSMatthias Ringwald 47c7558746SMatthias Ringwaldand then reboot to activate the change. 48c7558746SMatthias Ringwald 49808a498cSMatthias Ringwald## Running the examples 50808a498cSMatthias Ringwald 51808a498cSMatthias RingwaldBTstack's HCI USB transport will try to find a suitable Bluetooth module and use it. 52808a498cSMatthias Ringwald 53808a498cSMatthias RingwaldOn 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. 54808a498cSMatthias Ringwald 55808a498cSMatthias Ringwald $ ./le_counter 56808a498cSMatthias Ringwald Packet Log: /tmp/hci_dump.pklg 57808a498cSMatthias Ringwald BTstack counter 0001 58808a498cSMatthias Ringwald USB Path: 06 59808a498cSMatthias Ringwald BTstack up and running on 00:1A:7D:DA:71:13. 60808a498cSMatthias Ringwald 61808a498cSMatthias RingwaldIf 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. 62808a498cSMatthias Ringwald 63808a498cSMatthias RingwaldExample running le_streamer and le_streamer_client in two processes, using Bluetooth dongles at USB path 6 and 4: 64808a498cSMatthias Ringwald 65808a498cSMatthias Ringwald ./le_streamer -u 6 66808a498cSMatthias Ringwald Specified USB Path: 06 67808a498cSMatthias Ringwald Packet Log: /tmp/hci_dump_6.pklg 68808a498cSMatthias Ringwald USB Path: 06 69808a498cSMatthias Ringwald BTstack up and running on 00:1A:7D:DA:71:13. 70808a498cSMatthias Ringwald To start the streaming, please run the le_streamer_client example on other device, or use some GATT Explorer, e.g. LightBlue, BLExplr. 71808a498cSMatthias Ringwald 72808a498cSMatthias Ringwald $ ./le_streamer_client -u 4 73808a498cSMatthias Ringwald Specified USB Path: 04 74808a498cSMatthias Ringwald Packet Log: /tmp/hci_dump_4.pklg 75808a498cSMatthias Ringwald USB Path: 04 76808a498cSMatthias Ringwald BTstack up and running on 00:1A:7D:DA:71:13. 77808a498cSMatthias Ringwald Start scanning! 78