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

System firmware error when trying to make a BLE connection on ESP32-S3 #9614

Open
izmishi opened this issue Sep 11, 2024 · 7 comments
Open

Comments

@izmishi
Copy link

izmishi commented Sep 11, 2024

CircuitPython version

Adafruit CircuitPython 9.2.0-alpha.2350-17-g422eb7eff2-dirty on 2024-08-18; Seeed Xiao ESP32-S3 Sense with ESP32S3

Code/REPL

import _bleio

# dummy address bytes here, but also happens with valid addresses
someAddress = _bleio.Address(b'\x00\x00\x00\x00\x00\x00', 2)
_bleio.adapter.connect(someAddress, timeout=10)

Behavior

Running the code immediately results in an error.

Traceback (most recent call last):
  File "code.py", line 5, in <module>
_bleio.BluetoothError: Unknown system firmware error: 530

Description

On a Seeed Xiao ESP32-S3, when attempting to initiate a bluetooth connection to an already-paired device with a RANDOM_PRIVATE_RESOLVABLE address, an unknown system firmware error (530) occurs.

I've found that the actual address bytes don't matter, only the type (it also happens for RANDOM_PRIVATE_NON_RESOLVABLE, but not PUBLIC or RANDOM_STATIC).

Additional information

I've done a little digging through the CircuitPython source code and I suspect that it's a NimBLE error, in which case it would be an Invalid HCI Command Parameters error (0x212).

It occurs on both 9.1.1 and 9.2.0 alpha.

Running the above code on a Seeed Xiao nRF52840 (CircuitPython 9.0.4) performs as expected (a 'failed to connect' error after 10 seconds):

Traceback (most recent call last):
  File "code.py", line 5, in <module>
_bleio.BluetoothError: Failed to connect: internal error
@izmishi izmishi added the bug label Sep 11, 2024
@tannewt tannewt added the ble label Sep 12, 2024
@tannewt tannewt added this to the Long term milestone Sep 12, 2024
@tannewt
Copy link
Member

tannewt commented Sep 12, 2024

I've done a little digging through the CircuitPython source code and I suspect that it's a NimBLE error, in which case it would be an Invalid HCI Command Parameters error (0x212).

Nice job digging! Maybe we aren't flagging the address correctly internally. Want to see if you can fix it? We're happy to help guide. It's probably not a high priority for us to work on ourselves.

@izmishi
Copy link
Author

izmishi commented Sep 12, 2024

Sure, I can give it a go!

I'll definitely need guidance though

@tannewt
Copy link
Member

tannewt commented Sep 12, 2024

Awesome! Have you gotten it building? There is a tutorial for building here: https://learn.adafruit.com/building-circuitpython

We can answer development questions on Discord in #circuitpython-dev.

@izmishi
Copy link
Author

izmishi commented Sep 13, 2024

I've managed to get it building

@izmishi
Copy link
Author

izmishi commented Sep 15, 2024

What's the next step towards fixing it?

@tannewt
Copy link
Member

tannewt commented Sep 16, 2024

You'll need to sort out why the error is being returned and change the input parameters so it succeeds.

@izmishi
Copy link
Author

izmishi commented Oct 9, 2024

Might it be due to the fact that resolvable addresses haven't been implemented yet?

// TODO: Use a resolvable address if the peer has our key.
CHECK_NIMBLE_ERROR(ble_hs_id_infer_auto(false, &own_addr_type));

This is something I don't have the expertise to implement.

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

2 participants