forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Milestone
Description
CircuitPython version
Adafruit CircuitPython 9.1.0-rc.0 on 2024-07-09; Adafruit Feather ESP32S3 No PSRAM with ESP32S3Code/REPL
import board
import keypad
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
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
COLUMNS = 3
ROWS = 4
keys = keypad.KeyMatrix(
row_pins=(board.D12, board.D11, board.D10, board.D9),
column_pins=(board.A0, board.A1, board.A2),
columns_to_anodes=False,
)
# connect to BLE
hid = HIDService()
device_info = DeviceInfoService(software_revision=adafruit_ble.__version__,
manufacturer="Adafruit Industries")
advertisement = ProvideServicesAdvertisement(hid)
# Advertise as "Keyboard" (0x03C1) icon when pairing
# https://www.bluetooth.com/specifications/assigned-numbers/
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "BLE ESP32-S3 MacroPad"
# make a keyboard
kbd = Keyboard(hid.devices)
ble = adafruit_ble.BLERadio()
if not ble.connected:
print("advertising")
ble.start_advertising(advertisement, scan_response)
else:
print("already connected")
print(ble.connections)
while True:
while not ble.connected:
pass
while ble.connected:
key_event = keys.events.get()
if key_event:
if key_event.pressed:
kbd.press(Keycode.SPACE)
if key_event.released:
kbd.release_all()
ble.start_advertising(advertisement)Behavior
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
advertising
The Feather advertises the BLE connection and it appears as a device. When the connection is initiated, the Feather thinks that a connection is achieved. However, on the host device it will appear as still connecting (Windows) and eventually fail out or will show as connected but will not be shown as an active device (Mac). A keypress is never able to be sent.
Description
No response
Additional information
i also tried it without the keypad part of the code, but the same behavior occurred:
import board
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
# connect to BLE
hid = HIDService()
device_info = DeviceInfoService(software_revision=adafruit_ble.__version__,
manufacturer="Adafruit Industries")
advertisement = ProvideServicesAdvertisement(hid)
# Advertise as "Keyboard" (0x03C1) icon when pairing
# https://www.bluetooth.com/specifications/assigned-numbers/
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "BLE ESP32-S3 MacroPad"
# make a keyboard
kbd = Keyboard(hid.devices)
ble = adafruit_ble.BLERadio()
if not ble.connected:
print("advertising")
ble.start_advertising(advertisement, scan_response)
else:
print("already connected")
print(ble.connections)
while True:
while not ble.connected:
pass
while ble.connected:
print("connected")
time.sleep(5)
ble.start_advertising(advertisement)
Reactions are currently unavailable