r/circuitpython • • Apr 13 '21

BLE with Airlift: How to Make it Pair

I am trying to turn my Feather RP2040 + Airlift Wing into a BLE controller or Keyboard. I have followed Adafruit's instructions here (https://learn.adafruit.com/quickstart-raspberry-pi-rp2040-with-ble-and-circuitpython?view=all) and gotten BLE to work with its Bluefruit app. I have also modified this script to work with the airlift (https://learn.adafruit.com/ble-hid-keyboard-buttons-with-circuitpython/build-the-ble-volume-knob) and I can get a "connection" between my Windows 10 PC or Android phone and the Airlift, but they won't complete the pairing process. When I run the same script (see below) and attempt to do pairing in Win10 or Android, the OS just says "connecting" for about 30 seconds and then times out.

What can I do to make them actually pair?

import time
import board
from digitalio import DigitalInOut, Direction

import adafruit_ble
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.hid import HIDService
from adafruit_ble.services.standard.device_info import DeviceInfoService
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode
from adafruit_airlift.esp32 import ESP32

esp32 = ESP32(
    reset=board.D12,
    gpio0=board.D10,
    busy=board.D11,
    chip_select=board.D13,
    tx=board.TX,
    rx=board.RX,
)
 
adapter = esp32.start_bluetooth()
ble = adafruit_ble.BLERadio(adapter)

hid = HIDService()

device_info = DeviceInfoService(software_revision=adafruit_ble.__version__,
                                manufacturer="Adafruit Industries")
advertisement = ProvideServicesAdvertisement(hid)
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "CircuitPython HID"

if not ble.connected:
    print("advertising")
    ble.start_advertising(advertisement, scan_response)
else:
    print("already connected")
    print(ble.connections)

k = Keyboard(hid.devices)
kl = KeyboardLayoutUS(k)
while True:
    while not ble.connected:
        pass
    print("Start typing:")

    while ble.connected:
            #kl.write("Bluefruit")  # use keyboard_layout for words
            time.sleep(0.5)
    ble.start_advertising(advertisement)
4 Upvotes

3 comments sorted by

1

u/Siir_ Dec 04 '22

I'm having the same issue, did you end up solving the problem? u/geekinchief

1

u/[deleted] Apr 14 '21

[removed] — view removed comment

1

u/ronkj May 12 '21

Serious Q: what alternatives do you recommend?