micropython / micropython/micropython-lib
aioble: Connecting to the Apple Media Service (Pico-W)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Description
Hi,
I'm trying to use a Pi Pico W to connect to the Apple Media Service, but I'm running into a few issues.
async def connectBLE():
connection = await aioble.advertise(
_ADV_INTERVAL_MS,
name="AMS",
services=[_AMS_UUID],
appearance=0,
manufacturer=(0xABCD, b"1234"),
)
print("Connection from", connection.device)
return connection
_AMS_UUID = bluetooth.UUID("89D3502B-0F36-433A-8EF4-C502AD55F8DC")
_AMS_ENTITY_UPDATE = bluetooth.UUID("2F7CABCE-808D-411F-9A0C-BB92BA96C102")
_ADV_INTERVAL_MS = const(250000)
async def main():
ams_service = aioble.Service(_AMS_UUID)
aioble.register_services(ams_service)
connection = await connectBLE()
ams_service = await connection.service(_AMS_UUID)
ams_entity_update_characteristic = await ams_service.characteristic(
_AMS_ENTITY_UPDATE
)
await ams_entity_update_characteristic.subscribe(notify=True)
This'll connect, find the services, characteristics but then throws:
Traceback (most recent call last):
File "<stdin>", line 160, in <module>
File "uasyncio/core.py", line 1, in run
File "uasyncio/core.py", line 1, in run_until_complete
File "uasyncio/core.py", line 1, in run_until_complete
File "<stdin>", line 139, in main
File "aioble/client.py", line 430, in subscribe
File "aioble/client.py", line 295, in write
GattError: 5
On the .subscribe(notify=True) bit, not sure how / if I can look up the GattError: 5 bit for more info?
There is a CircuitPython implementation here, https://docs.circuitpython.org/projects/ble_apple_media/en/latest/index.html
Which uses a "Service Solicitation" advertisement - what's the method for constructing that in aioble? I'm guessing custom adv_data & resp_data but I'm unsure of the format, etc.
That implementation also pairs to the connecting device, but when I insert a await connection.pair() I get
Traceback (most recent call last):
File "<stdin>", line 161, in <module>
File "uasyncio/core.py", line 1, in run
File "uasyncio/core.py", line 1, in run_until_complete
File "uasyncio/core.py", line 1, in run_until_complete
File "<stdin>", line 124, in main
File "<stdin>", line 99, in connectBLE
File "aioble/device.py", line 256, in pair
File "aioble/security.py", line 171, in pair
ValueError: unknown config param
Which I guess is due to the Pico-W implementation not (currently?) supporting something in ble.config(bond=bond, le_secure=le_secure, mitm=mitm, io=io)
Thanks
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.
Research direction
Start with aioble/client.py around subscribe() and write(), then inspect aioble/device.py and aioble/security.py around pair() and the BLE configuration parameters. Compare those paths with the linked CircuitPython Apple Media Service implementation and the Pico-W BLE capabilities. Done means the supported advertising, subscription, and pairing requirements are established, with any necessary aioble changes clearly scoped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100