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

Bluetooth device settings don't take effect when expected #5996

Open
jaustin opened this issue Oct 16, 2024 · 3 comments
Open

Bluetooth device settings don't take effect when expected #5996

jaustin opened this issue Oct 16, 2024 · 3 comments

Comments

@jaustin
Copy link
Collaborator

jaustin commented Oct 16, 2024

Describe the bug
I am building a bluetooth project that needs to be 'open security' (no pairing required)
Image

There's a very strange inconsistency with when this setting actually gets applied. For example, if I build after changing the setting, initially the micro:bit behaviour doesn't change. After I do some set of things I can't identify the significance of, I get the new pairing settings
For example, in one case I had an extension that used bluetooth:
Image
In this configuration, the 'open' pairing was not taking effect
By adding the 'accelerometer service' (which had already been initialised in 'setup as input micro:bit', so this was a duplicate) and then downloading the code to my micro:bit the behaviour changed

To Reproduce
Here's a reproducer that works for me without my custom extension:

  • create a new MakeCode project
  • Add bluetooth extension (but leave all settings as normal)
  • Use https://googlechrome.github.io/samples/web-bluetooth/device-info.html?namePrefix=BBC+micro%3Abit to verify that the device is visible in the Bluetooth dialog pairing mode, but not in 'normal' mode [this is expected]
  • You can skip these steps, but they were my way of verifying that the right CODAL config where Bluetooth is enabled, not radio, had been applied
    • bond from phone, confirm this works
    • flash from phone - no need to enter pairing mode
      • IE: bluetooth extensions is working right
  • Change project settings in MakeCode to 'no pairing required', save
  • Download code to micro:bit
  • use https://googlechrome.github.io/samples/web-bluetooth/device-info.html?namePrefix=BBC+micro%3Abit to verify that the device is visible in the Bluetooth dialog pairing mode, but not in 'normal' mode [this is NOT expected]
    • micro:bit is NOT visible when not in pairing mode, but the open setting means it should be
  • Add any block from the Bluetooth library, redownload
    • Still not visible. (this is weird because in my previous case with my extension, this change DID make the micro:bit visible)
  • Add data logging extension, redownload:
  • Test in the same page, but the micro:bit is now visible even when not in pairing mode.

My expectation is that as soon as I toggle that setting, the next time I flash the micro:bit the setting will be applied
I also don't understand what is causing/triggering the rebuild for it to work

CC @martinwork perhaps you've seen this @microbit-carlos has some theories!

@martinwork
Copy link
Contributor

@jaustin @microbit-carlos Related: #5416 (comment)

@microbit-carlos
Copy link
Collaborator

As Martin has mentioned in #5416 (comment), I've also experienced this when changing extension versions or yotta config flags inside the pxt.json file, changes that should trigger a cloud rebuild often take several attempts to trigger.
Sometimes it helps if I add a C++ extension to the project (or remove it), or adding more yotta flags with random names (so that it doesn't affect anything important), and sometimes it helps if I exit the project by going to the Makecode home page and then reopen it.

@microbit-carlos
Copy link
Collaborator

@abchatra Just to clarify, that while this does affect Bluetooth, it is not an issue with Bluetooth itself. The main issue is that changes to the pxt.json file are not applied until an "additional trigger" (like adding extensions, closing and reopening the project, or sometimes making multiple changes to the pxt.json file) somehow forces MakeCode to recompile with the right settings.

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

No branches or pull requests

4 participants