Skip to content

Comments

Use bleak instead of bluepy#44

Open
deric wants to merge 5 commits intokawasaki:masterfrom
deric:bleak
Open

Use bleak instead of bluepy#44
deric wants to merge 5 commits intokawasaki:masterfrom
deric:bleak

Conversation

@deric
Copy link

@deric deric commented Mar 1, 2025

Use bleak for Bluetooth communication, which seems to be maintained (unlike bluepy).

Moreover this PR adds Intelino support.

Screenshot_20250302_130108
Screenshot_20250302_130157

In order to test this, you can use:

pip3 install 'git+https://github.com/deric/pyscrlink.git'@bleak --upgrade

Beta testers welcomed 🙂

@kawasaki
Copy link
Owner

kawasaki commented Mar 8, 2025

@deric This work looks great :) But I'm still busy on other works... I will try to find my time slots to take a look, hopefully next month.

@kawasaki
Copy link
Owner

kawasaki commented May 2, 2025

I gave the @deric 's bleak implementation a try. I used my microbit, and tried to connect scratch microbit extension. The bleak implementation missed a couple of points for microbit below:

  1. Device matching with service UUID
  2. "read" method

I quickly changed the code to support these two, but still I faced a failure at the startNotification step. Bleak reported "BleakDBusError: [org.bluez.Error.NotPermitted] Write not permitted". I'm not sure how to resolve it, and will need time for it. If anyone has advice, it will be appreciated.

@kawasaki
Copy link
Owner

kawasaki commented May 2, 2025

I was able to avoid the error "Write not permitted" by changing self.client.write_gatt_char() argument "response" value from "True" to "False". With this, I was able to connect to microbit with Scratch :)

However, while I was operating my microbit from scratch, the connection between the microbit and Scratch suddenly got lost. The debug log indicates that the notifications from microbit suddenly stops, then Scratch shutdown the connection (the microbit extension does it when it does not receive notifications from microbit for 4500 ms). Then next challenge is this sudden notification stop. The Bleak debug log with BLEAK_LOGGING=1 does not look providing any clues. It might be required to dig into Bleak, D-bus and bluetoothd to solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants