micropython / micropython/micropython-lib
aioble: Connecting to the Apple Media Service (Pico-W)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 2.9k
- Forks
- 1.1k
- Ø Merge
- 7 T. 6 Std.
- Gemergte PRs (30 T.)
- 3
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in aioble/client.py bei subscribe() und write(), untersuche dann aioble/device.py und aioble/security.py im Umfeld von pair() und den BLE-Konfigurationsparametern. Vergleiche diese Pfade mit der verknüpften CircuitPython Apple Media Service-Implementierung und den BLE-Funktionen des Pico-W. Die Aufgabe ist erledigt, wenn die Anforderungen für unterstütztes Advertising, Subscriptions und Pairing festgelegt sind und alle erforderlichen aioble-Änderungen klar abgegrenzt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- embedded-iot
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100