"Why am I unable to read the keyboard input?"
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- embedded-iot
Research direction
Start with the pasted asyncio.run(main()) entry point and reproduce the connection and read loop. Inspect the BLE HID service and characteristic identifiers shown in the example; done means the reason keyboard input cannot be read is established and a verified correction is identified.
Written by the indexing model from the issue text.
Description
import aioble
import asyncio
import bluetooth
async def scan_bluetooth():
print("Starting BLE scan...")
async with aioble.scan(
duration_ms=10000, # 扫描 10 秒
interval_us=300000, # 间隔 300 毫秒
window_us=300000, # 窗口 300 毫秒
active=True # 主动请求额外数据
) as scanner:
async for result in scanner:
name = result.name() or "Unknown"
addr = result.device.addr_hex()
rssi = result.rssi
services = result.services()
if "0d:f9:6d:6a:75:c9" in addr:
print("找到此设备")
print(result.services)
return result.device
return None
async def main():
device = await scan_bluetooth()
if not device:
print("未找到设备")
return
try:
print(f"正在连接 {device.addr_hex()}...")
connection = await device.connect(timeout_ms=2000) # 设置连接超时
print("连接成功",connection)
except asyncio.TimeoutError:
print("连接超时")
except Exception as e:
print(f"连接失败: {e}")
async with connection:
try:
hid_service=0x1812
key_input=0x2A4D
mouse_input=0x2A33
ser=bluetooth.UUID(hid_service)
char=bluetooth.UUID(key_input)
hid_service = await connection.service(ser)
print(hid_service)
hid_characteristic = await hid_service.characteristic(char)
print(hid_characteristic)
except asyncio.TimeoutError:
print("Timeout discovering services/characteristics")
return
while True:
# 尝试读取特征的值
data = await hid_characteristic.read()
print("Received key input data:", data)
运行主程序
asyncio.run(main())
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from micropython/micropython-lib
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Difficulty 1/5 Under an hour Newbie friendliness 72/100
micropython/micropython-lib#943 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
micropython/micropython-lib#931 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
micropython/micropython-lib#795 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#762 ·
All issues in micropython/micropython-lib
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·