Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let me know if kaspersmicrobit works on macOS! #5

Open
janickr opened this issue Mar 26, 2023 · 5 comments
Open

Let me know if kaspersmicrobit works on macOS! #5

janickr opened this issue Mar 26, 2023 · 5 comments

Comments

@janickr
Copy link
Owner

janickr commented Mar 26, 2023

I don't have a mac to test kaspersmicrobit on. Let me know in a comment if it works!
First upgrade to the latest version:

$  pip install --upgrade kaspersmicrobit  

Please mention:

  • the version of your micro:bit
  • the python version you used
  • if you used "No pairing required" or "JustWorks pairing"
@RyanNorge
Copy link

Work for me with the provided hex file right out of the box! No pairing or anything else required.
However, it didn't work with my own MakeCode project. I'll start a separate issue for that.

Micro:bit version 2.0
Python version 3.11.7
MacBook Pro M1 (so Apple Silicon, not Intel)

One thing I can say is that the "JustWorks" is most likely not going to work on Mac. This is not possible in Bleak (or probably any other library), as per their docs...
https://bleak.readthedocs.io/en/latest/backends/macos.html
"There is also no pairing functionality implemented in macOS right now, since it does not seem to be any explicit pairing methods in the COre Bluetooth."

Great looking project, even if I can't under the doc strings. Thanks for this super helpful tool :)
Anything special you'd like me to check for you?

@RyanNorge
Copy link

Sorry, ignore the thing about opening up a new issue. Now I'm able to 2 different MakeCode projects no problem.

I think it was probably an error on my part. Since I can't recreate the problem I'm going to assume that I didn't turn it on and off again like you suggested in the documentation.

BTW if anyone finds this in the future and is having trouble getting their own project running, make sure you read the excellent documentation for it here...
https://kaspersmicrobit.readthedocs.io/en/stable/makecode-bluetooth/create-a-makecode-project-without-pairing/

@janickr
Copy link
Owner Author

janickr commented Feb 18, 2024

Hi @RyanNorge,
This is awesome! Thanks for taking the time to log this!
I'll update the compatibility table in the readme.

The docstrings are in dutch because I started this package for my son. Maybe I'll translate them and generate localized apidocs in the future.

Thanks for bringing that sentence from the bleak docs to my attention. I'm not 100% sure about this but I believe this refers to bluetooth pairing initiated by bleak. This method is not used by kaspermicrobit for the "JustWorks" scenario, instead kaspersmicrobit relies on the microbit being paired manually by the user in the os. So maybe there is still a chance that this too works. It would be great if you feel like it and you could If you have some time to test the "JustWorks" pairing on your device:

Feel no obligation, I'm already really happy you posted your experience with the "no pairing required" method. Also, it will probably be difficult for me to provide support in case it doesn't work because I cannot test it on macos myself.

Have a great weekend!

@RyanNorge
Copy link

No problem, happy to help! I think it's really great that you built/maintain this package. They made it pretty easy to set things up on the micro:bit, thanks for making things a bit easier on the laptop side. So nice you could help your kid with his project :)

I'm not able to get the bluetooth pairing to work. The micro:bit just doesn't show up in the list of bluetooth devices I can connect to. I'm using the .hex file you provide in the readme on GitHub.

I spent a little time looking at this, and it looks like the bluetooth pairing must be done manually by the user. A program pair automatically, and it can't prompt the user to pair, so if it's not on the list then there's not an obvious way to do it. I can see it and read from it as an unpaired device though.

I have the same thing with another bluetooth device I have, where I can read and write but I've never been able to pair. I see other people have had similar problems, my guess is it's just one of those Apple things...

As for the test file, it was a little hit and miss. Here is the output using your supplied hex file, I just took out the bluetooth address and serial number...

Platform: macOS-14.3.1-arm64-arm-64bit
Python version: 3.11.7

Bluetooth address: XXXXXXXX

Service.GENERIC_ACCESS not found

Service.DEVICE_INFORMATION available
Model # : BBC micro:bit V2.0
Serial # : XXXXXXXX
Firmware revision: unknown

Service.ACCELEROMETER available
data: AccelerometerData(x=40, y=140, z=-1040)

Service.BUTTON available
Button a: 0
Button b: 0

Service.LED available

Service.TEMPERATURE available
The temperature is now: 20

Service.UART not found

Service.IO_PIN not found

Service.MAGNETOMETER not found

Service.EVENT not found

@janickr
Copy link
Owner Author

janickr commented Feb 23, 2024

Thanks for spending your time on this!

Kaspersmicrobit never pairs automatically, you'll always have to do it manually in the OS (there is a page for win and one for linux on the documentation site). I know of the methods in bleak to do this but after playing with that in the past I could not always get reproducible results. So if it works after manually pairing in MacOS, that's great!

About the hit&miss on the test file: was that because you expected some services to be available but they weren't or was it because of other reasons? On the download page there is only one hex file with all services enabled (others enable only a subset because of memory limitations) so maybe you had the one with the accelerometer - buttons - led - temperature subset?

Have a great day!

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

No branches or pull requests

2 participants