adafruit / adafruit/Adafruit_CircuitPython_BLE

ValueError on BLERadio.start_scan() and ble_detailed_scan.py

Open
#141 5 comments 3 reactions 1 assignee Claimed by @tannewt View on GitHub
Dominant language
Python
Stars
138
Forks
58
PR merge metrics
No merged PRs in 30d

Description

I tried running `ble_detailed_scan.py` and get the following error:

```
scanning
Traceback (most recent call last):
File "code.py", line 14, in
File "adafruit_ble/__init__.py", line 250, in start_scan
ValueError: Prefix buffer must be on the heap
```

I _think_ the error happens because the example scans for both services advertisements and any advertisement:

https://github.com/adafruit/Adafruit_CircuitPython_BLE/blob/4eca28e6407f511d5051fd608a238a9d8b40d783/examples/ble_detailed_scan.py#L18

which the causes the prefixes buffer to be empty:

https://github.com/adafruit/Adafruit_CircuitPython_BLE/blob/4eca28e6407f511d5051fd608a238a9d8b40d783/adafruit_ble/__init__.py#L244-L248

That seems to trigger the error here:

https://github.com/adafruit/circuitpython/blob/0dfb7a9a2da1444ebca4b8fff0b88795afede895/shared-bindings/_bleio/Adapter.c#L348-L355

I managed to get the example to work by either removing `Advertisement` from the scan_start() call, or commenting out the prefix check in `_bleio/Adapter.c`.

What I'm not sure about is the relevant code doesn't seem to have changed in the last 1.5 years. I'm using CircuitPython from the latest git commit on the micro:bit v2, so perhaps something weird is happening with my setup. But I thought I would open this issue just in case either something is wrong,.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.