Your code doesn't do anything with the scan IRQ.
Code: Select all
def _irq(self, event, data):
if event == _IRQ_SCAN_RESULT:
addr_type, addr, adv_type, rssi, adv_data = data
return data
Code: Select all
def _irq(self, event, data):
if event == _IRQ_SCAN_RESULT:
addr_type, addr, adv_type, rssi, adv_data = data
print("Scan result: {}/{} {} {} {}", addr_type, hexlify(addr, ":"), adv_type, rssi, hexlify(adv_data))
Also be aware that the memory used for the address and adv_data is owned by bluetooth, so you need to copy it if you're going to reference it later. See the second paragraph of https://docs.micropython.org/en/latest/ ... th.BLE.irq
I would recommend taking a look at aioble -- it makes using Bluetooth much simpler.
https://github.com/micropython/micropyt ... oth/aioble
Here's a simple scanner with aioble:
Code: Select all
async with aioble.scan() as scanner:
async for result in scanner:
if result.name():
print(result, result.name(), result.rssi, result.services())