1# BTstack Port for QT with libusb Library (Mac/Linux) 2 3Windows or Embedded (bare metal) platforms not supported yet. 4 5## Compilation 6 7You'll need Qt and [libusb-1.0](http://libusb.info) or higher to be 8installed. 9 10When everything is ready, you can open the provided CMakelists.txt project in Qt Creator and run any of the provided examples. 11See Qt documentation on how to compile on the command line or with other IDEs 12 13## Environment Setup 14 15### Linux 16 17On Linux, the USB Bluetooth dongle is usually not accessible to a regular user. You can either: 18- run the examples as root 19- add a udev rule for your dongle to extend access rights to user processes 20 21To add an udev rule, please create `/etc/udev/rules.d/btstack.rules` and add this 22 23 # Match all devices from CSR 24 SUBSYSTEM=="usb", ATTRS{idVendor}=="0a12", MODE="0666" 25 26 # Match DeLOCK Bluetooth 4.0 dongle 27 SUBSYSTEM=="usb", ATTRS{idVendor}=="0a5c", ATTRS{device}=="21e8", MODE="0666" 28 29 # Match Asus BT400 30 SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", ATTRS{device}=="17cb", MODE="0666" 31 32 # Match Laird BT860 / Cypress Semiconductor CYW20704A2 33 SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{device}=="f901", MODE="0666" 34 35### macOS 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 46Note: if you get this error, 47 48 libusb: warning [darwin_open] USBDeviceOpen: another process has device opened for exclusive access 49 libusb: error [darwin_reset_device] ResetDevice: device not opened for exclusive access 50 51and you didn't start another instance and you didn't assign the USB Controller to a virtual machine, 52macOS uses the plugged-in Bluetooth Controller. Please configure NVRAM as explained and try again after a reboot. 53 54 55## Running the examples 56 57BTstack's HCI USB transport will try to find a suitable Bluetooth module and use it. 58 59On 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. 60 61 $ ./le_counter 62 Packet Log: /tmp/hci_dump.pklg 63 BTstack counter 0001 64 USB Path: 06 65 BTstack up and running on 00:1A:7D:DA:71:13. 66 67If 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. 68 69Example running le_streamer and le_streamer_client in two processes, using Bluetooth dongles at USB path 6 and 4: 70 71 ./le_streamer -u 6 72 Specified USB Path: 06 73 Packet Log: /tmp/hci_dump_6.pklg 74 USB Path: 06 75 BTstack up and running on 00:1A:7D:DA:71:13. 76 To start the streaming, please run the le_streamer_client example on other device, or use some GATT Explorer, e.g. LightBlue, BLExplr. 77 78 $ ./le_streamer_client -u 4 79 Specified USB Path: 04 80 Packet Log: /tmp/hci_dump_4.pklg 81 USB Path: 04 82 BTstack up and running on 00:1A:7D:DA:71:13. 83 Start scanning! 84