aioble scan with duration_ms=0 #15684
Unanswered
jef41
asked this question in
Libraries & Drivers
Replies: 1 comment
-
for the record, the below code seems to work without eating memory, but I still don't understand why this while loop and scanner.cancel() are required when duration_ms=0; async def scan_for_ibeacons(bridge_q):
#iBeacon_prefix = b'\x4C\x00\x02\x15'
while True:
#async with aioble_central.scan(duration_ms=2000) as scanner:
async with aioble_central.scan(duration_ms=0) as scanner:
async for result in scanner:
#if result.adv_data and result.adv_data[5:11] == iBeacon_prefix:
await bridge_q.put(result.rssi)
scanner.cancel() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When running an indefinite bluetooth scan (duration_ms=0) I seem to get a constant usage of memory that is not garbage collected. Over a period of about 24 hours this accumulates and leads to a memory error. If I run the scan in a while loop with a fixed duration (duration_ms=2000) I do not see the same issue.
I have been running this minimal sample below on a Raspberry Pi PicoW on the v1.23.0 firmware. It is difficult for me to understand but I think the indefinite scan is consuming 3 bytes per iteration of data received.
It may be that I misunderstand async principles or that I misunderstand the Bluetooth library (or both). Can anyone help me to understand why this happens please? I have tried to intermittently stop and restart the indefinite scan after data is received with the code below, but that seems to make no difference, memory is still consumed;
Running a fixed scan duration_ms=2000 in a while loop seems to work around the issue, but ideally I would like to understand why the minimal sample above consumes memory that is not garbage collected, or how I can track that down. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions