adafruit / Adafruit_CircuitPython_BLE

Bluetooth Low Energy (BLE) library for CircuitPython
MIT License
127 stars 58 forks source link

PyPortal start_scan(): NotImplementedError #161

Closed jhfoo closed 2 years ago

jhfoo commented 2 years ago

Here's what I did on my PyPortal:

  1. Referenced this doc to upgrade ESP32 firmware to 1.7.4: https://learn.adafruit.com/adafruit-pyp ... python-ble
  2. Referenced this doc for BLE scanning: https://docs.circuitpython.org/projects ... mples.html
  3. Upgraded CircuitPython to 7.2.5

Here's my code:

esp32 = ESP32()
Esp32Adapter = esp32.start_bluetooth()
ble = BLERadio(Esp32Adapter)
for advert in ble.start_scan():
  addr = advert.address
  print(addr, advert)

When running the code I get this error:

Traceback (most recent call last):
  File "code.py", line 117, in <module>
  File "adafruit_ble/__init__.py", line 250, in start_scan
NotImplementedError:

Can someone confirm if BLE is expected to work on PyPortal, or is there a mistake in my code?

dhalbert commented 2 years ago

As mentioned here: https://learn.adafruit.com/adafruit-pyportal/circuitpython-ble

Currently the AirLift support for CircuitPython only provides BLE peripheral support. BLE central is under development. So you cannot connect to BLE devices like Heart Rate monitors, etc., but you can act as a BLE peripheral yourself.

As a BLE peripheral, you cannot scan. You can only scan if you can act as a BLE central. You can scan if you use an nRF52840 board, which can be both a central and peripheral.

jhfoo commented 2 years ago

Thanks for the clarification.