adafruit / Adafruit_CircuitPython_BLE

Bluetooth Low Energy (BLE) library for CircuitPython
MIT License
124 stars 57 forks source link

Set up an on-board HCI adapter automatically #99

Closed dhalbert closed 4 years ago

dhalbert commented 4 years ago

Goes with https://github.com/adafruit/circuitpython/pull/3310.

Add code to initialize a Bluetooth HCI adapter. The current pins should work for the on-board adapter on Metro M4 AirLift, PyPortals, and PyBadge AirLift. That is, all you need is:

ble = BLERadio()

For an offboard AirLift breakout, the kind of code below works for now. We can think about changing this API to pass the pins to BLERadio(). I haven't thought about this API in detail yet.

import _bleio
import board

hci.esp32_hci_init(
    esp_reset=board.D12,
    esp_gpio0=board.D10,
    esp_busy=board.D11,
    esp_cs=board.D13,
    esp_tx=board.TX,
    esp_rx=board.RX,
    debug=True)

# Must use initialized adapter explicitly.
ble = BLERadio(_bleio.adapter)
dhalbert commented 4 years ago

Closing to replace with updated PR.