google / bumble

Apache License 2.0
246 stars 70 forks source link

Macbook bluetooth access #97

Closed yakerm closed 1 year ago

yakerm commented 1 year ago

Hello, I would like to know how can I use the library with a Macbook Pro. Directly by using the mac bluetooth Chip (not a dongle). I don't know if you already have implemented this feature. Thank you for your help.

mogenson commented 1 year ago

Although it can be done, there is no public way to setup an HCI transport to the builtin Bluetooth controller on MacOS.

For Bumble on MacOS, the recommendation is to use an external Bluetooth controller over one of the supported transports.

If you're just interested in a Python wrapper over the MacOS CoreBluetooth stack, you could take a look at bleak.

uael commented 1 year ago

You may need to:

# you can see loaded classes with sudo kextstat
sudo kextunload -b com.apple.iokit.CSRBluetoothHostControllerUSBTransport

then you should be able to use it over USB

yakerm commented 1 year ago

Thank you for your feedback. However, I'm using a USB Dongle (TP-LINK UB500). When I try to run on Macbook pro MacOS Apple M1 the example code "run_scanner.py". I have these logs attached, and nothing more happens.

bumble_log.zip

The same example, running on Linux with the TP-LINK, display all BLE devices found around me.

mogenson commented 1 year ago

@uael Interesting find! Does this work for you? I'm unable to unload that kext because: kext is in use or retained. I walked up the tree a little bit trying to unload other Bluetooth related kexts, but could not find one that was not a required dependency.

@yakerm From the logs, it looks like the controller is being setup correctly and has started to scan. Are there nearby BLE devices that are advertising? You could try another example like run_advertiser.py device1.json usb:0. With an BLE phone app like nRF Connect, you should see a device named "Bumble" advertising.

barbibulle commented 1 year ago

@yakerm just be sure, did you configure your mac to not attach the dongle to the macOS Bluetooth stack (see https://google.github.io/bumble/platforms/macos.html). I assume so, but always better to check.

One reason why you may be getting a different result on the mac than on Linux is that some dongles, like the TP-LINK dongle use a Realtek chipset that requires loading a firmware image at init time in order to be fully functional. Until the FW image is loaded, they look like they're working (i.e they respond to the commands) but nothing much happens. Recent versions of the Linux kernel have support for loading this FW image, so it may have been done for you automatically there. But on the mac, that doesn't happen. In fact, see the comments on issue #100 which talks about that, and maybe a solution in the near future.

yakerm commented 1 year ago

Oh... I understand. I did not see the issue #100. Do you have some dongle references also working for mac/windows I can use instead of the TP-Link ? Thank you

uael commented 1 year ago

@mogenson I didn't test that since a very long time and does not have access to a Mac, it may need some additional commands I don't remember..

yakerm commented 1 year ago

Hello, I close this issue. I found a USB BLE dongle that works fine : ASUS USB-BT500 Thank you for your help.