Adaptions for new bumble version

This commit is contained in:
2025-02-19 09:37:35 +01:00
parent 3eb32663c3
commit 692f35d27a
2 changed files with 28 additions and 28 deletions
+1
View File
@@ -31,6 +31,7 @@ class AuracastGlobalConfig:
octets_per_frame: int = 60 #48kbps@24kHz # bitrate = octets_per_frame * 8 / frame len
frame_duration_us: int = 10000
presentation_delay_us: int = 40000
debug: bool = False
@dataclass
class AuracastBigConfig:
+27 -28
View File
@@ -95,7 +95,7 @@ def run_async(async_command: Coroutine) -> None:
color('!!! An error occurred while executing the command:', 'red'), message
)
ADVERTISING_SLOWDOWN_FACTOR=1
ADVERTISING_SLOWDOWN_FACTOR=1.25
async def run_broadcast(
global_config : auracast_config.AuracastGlobalConfig,
big_config: List[auracast_config.AuracastBigConfig]
@@ -183,7 +183,7 @@ async def run_broadcast(
primary_advertising_phy=hci.Phy.LE_1M, # 2m phy config throws error - because for primary advertising channels, 1mbit is only supported
secondary_advertising_phy=hci.Phy.LE_2M, # this is the secondary advertising beeing send on non advertising channels (extendend advertising)
#advertising_tx_power= # tx power in dbm (max 20)
secondary_advertising_max_skip=10,
#secondary_advertising_max_skip=10,
),
advertising_data=(
bigs[f'big{i}']['broadcast_audio_announcement'].get_advertising_data()
@@ -228,18 +228,17 @@ async def run_broadcast(
)
bigs[f'big{i}']['big'] = big
iso_queues = [
bumble.device.IsoPacketStream(big.bis_links[0], 64),
#bumble.device.IsoPacketStream(big.bis_links[1], 64), # right channel
]
logging.info('Setup ISO Data Path')
for queue in iso_queues:
await queue.iso_link.setup_data_path(
direction=queue.iso_link.Direction.HOST_TO_CONTROLLER
for bis_link in big.bis_links:
await bis_link.setup_data_path(
direction=bis_link.Direction.HOST_TO_CONTROLLER
)
bigs[f'big{i}']['iso_queues'] = iso_queues
iso_queue =bumble.device.IsoPacketStream(big.bis_links[0], 64),
logging.info('Setup ISO Data Path')
bigs[f'big{i}']['iso_queues'] = iso_queue
logging.debug(f'big{i} parameters are:')
logging.debug('%s', pprint.pformat(vars(big)))
@@ -250,7 +249,7 @@ async def run_broadcast(
logging.info("Broadcasting...")
def on_flow():
data_packet_queue = iso_queues[0].data_packet_queue
data_packet_queue = iso_queue.data_packet_queue
print(
f'\rPACKETS: pending={data_packet_queue.pending}, '
f'queued={data_packet_queue.queued}, '
@@ -258,21 +257,20 @@ async def run_broadcast(
end='',
)
bigs[f'big{0}']['iso_queues'][0].data_packet_queue.on('flow', on_flow)
async def streamer(queue, iterator):
if global_conf.debug:
bigs[f'big{0}']['iso_queues'][0].data_packet_queue.on('flow', on_flow)
async def streamer(bigs):
while True:
frame = next(iterator)
await queue[0].write(frame)
for big in bigs.values():
# write one frame to each queue
frame = next(big['frames_iterator'])
await big['iso_queues'][0].write(frame)
streams = []
for big in bigs.values():
streams.append(
asyncio.create_task(
streamer(big['iso_queues'], big['frames_iterator'])
)
)
stream = streamer(bigs)
await stream # running endlessly
await asyncio.wait(streams)
print("Done.")
@@ -303,11 +301,11 @@ if __name__ == "__main__":
#global_conf.transport='serial:/dev/serial/by-id/usb-SEGGER_J-Link_001050076061-if02,1000000,rtscts' # transport for nrf53dk
#global_conf.transport='serial:/dev/serial/by-id/usb-SEGGER_J-Link_001057705357-if02,1000000,rtscts' # transport for nrf54l15dk
global_conf.transport='serial:/dev/serial/by-id/usb-SEGGER_J-Link_001057705357-if02,1000000,rtscts' # transport for nrf54l15dk
global_conf.transport='serial:/dev/serial/by-id/usb-ZEPHYR_Zephyr_HCI_UART_sample_81BD14B8D71B5662-if00,115200,rtscts' #nrf52dongle hci_uart usb cdc
#global_conf.transport='serial:/dev/serial/by-id/usb-ZEPHYR_Zephyr_HCI_UART_sample_81BD14B8D71B5662-if00,115200,rtscts' #nrf52dongle hci_uart usb cdc
# global_conf.transport='usb:2fe3:000b' #nrf52dongle hci_usb #TODO: iso packet over usb seems not to be supported
# global_conf.transport='usb:2fe3:000b' #nrf52dongle hci_usb # TODO: iso packet over usb not supported
#global_conf.qos_config = auracast_config.qos_config_mono_medium_rel
global_conf.qos_config = auracast_config.qos_config_mono_high_rel
@@ -326,6 +324,7 @@ if __name__ == "__main__":
global_conf.auracast_sampling_rate_hz = 16000
global_conf.octets_per_frame = 40 # 32kbps@16kHz
#global_conf.debug = True
# TODO: How can we use other iso interval than 10ms ?(medium or low rel) ? - nrf53audio receiver repports I2S tx underrun
broadcast(