From 45edcafb066fcaf2282424509afbe578f04fc844 Mon Sep 17 00:00:00 2001 From: Josh Wu Date: Wed, 27 Sep 2023 23:30:26 +0800 Subject: [PATCH] SCO: A loopback example --- examples/run_hfp_gateway.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/run_hfp_gateway.py b/examples/run_hfp_gateway.py index 13a2ed93..5cb3eb3d 100644 --- a/examples/run_hfp_gateway.py +++ b/examples/run_hfp_gateway.py @@ -31,6 +31,7 @@ from bumble.core import ( BT_BR_EDR_TRANSPORT, ) from bumble import rfcomm, hfp +from bumble.hci import HCI_SynchronousDataPacket from bumble.sdp import ( Client as SDP_Client, DataElement, @@ -197,6 +198,13 @@ async def main(): print('@@@ Disconnected from RFCOMM server') return + def on_sco(connection_handle: int, packet: HCI_SynchronousDataPacket): + # Reset packet and loopback + packet.packet_status = 0 + device.host.send_hci_packet(packet) + + device.host.on('sco_packet', on_sco) + # Protocol loop (just for testing at this point) protocol = hfp.HfpProtocol(session) while True: