make multicast with 2 broadcasters work
This commit is contained in:
@@ -84,7 +84,7 @@ async def create_device(config: auracast_config.AuracastGlobalConfig) -> AsyncGe
|
||||
name=config.device_name,
|
||||
address=config.auracast_device_address,
|
||||
keystore='JsonKeyStore',
|
||||
le_simultaneous_enabled=True #TODO: needed ?
|
||||
#le_simultaneous_enabled=True #TODO: needed ?
|
||||
)
|
||||
|
||||
device = bumble.device.Device.from_config_with_hci(
|
||||
@@ -113,7 +113,6 @@ def run_async(async_command: Coroutine) -> None:
|
||||
)
|
||||
|
||||
PKGS_COUNT = 0
|
||||
ADVERTISING_INTERVAL_SLOWDOWN_FACTOR = 2
|
||||
|
||||
async def run_broadcast(
|
||||
global_config : auracast_config.AuracastGlobalConfig,
|
||||
@@ -168,6 +167,9 @@ async def run_broadcast(
|
||||
le_audio.Metadata.Entry(
|
||||
tag=le_audio.Metadata.Tag.PROGRAM_INFO, data=conf.broadcast_program_info.encode()
|
||||
),
|
||||
le_audio.Metadata.Entry(
|
||||
tag=le_audio.Metadata.Tag.BROADCAST_NAME, data=conf.broadcast_name.encode()
|
||||
),
|
||||
]
|
||||
),
|
||||
bis=[
|
||||
@@ -184,12 +186,13 @@ async def run_broadcast(
|
||||
logging.info('Setup Advertising')
|
||||
bigs[f'big{i}']['broadcast_audio_announcement'] = bap.BroadcastAudioAnnouncement(conf.broadcast_id)
|
||||
advertising_set = await device.create_advertising_set(
|
||||
random_address=conf.broadcast_random_address,
|
||||
advertising_parameters=bumble.device.AdvertisingParameters(
|
||||
advertising_event_properties=bumble.device.AdvertisingEventProperties(
|
||||
is_connectable=False
|
||||
),
|
||||
primary_advertising_interval_min=100*ADVERTISING_INTERVAL_SLOWDOWN_FACTOR,
|
||||
primary_advertising_interval_max=200*ADVERTISING_INTERVAL_SLOWDOWN_FACTOR,
|
||||
primary_advertising_interval_min=100,
|
||||
primary_advertising_interval_max=200,
|
||||
advertising_sid=i
|
||||
# TODO: use 2mbit phy
|
||||
),
|
||||
@@ -202,8 +205,8 @@ async def run_broadcast(
|
||||
)
|
||||
),
|
||||
periodic_advertising_parameters=bumble.device.PeriodicAdvertisingParameters(
|
||||
periodic_advertising_interval_min=80*ADVERTISING_INTERVAL_SLOWDOWN_FACTOR,
|
||||
periodic_advertising_interval_max=160*ADVERTISING_INTERVAL_SLOWDOWN_FACTOR,
|
||||
periodic_advertising_interval_min=80,
|
||||
periodic_advertising_interval_max=160,
|
||||
),
|
||||
periodic_advertising_data=bigs[f'big{i}']['basic_audio_announcement'].get_advertising_data(),
|
||||
auto_restart=True,
|
||||
@@ -243,20 +246,22 @@ async def run_broadcast(
|
||||
logging.info("Broadcasting...")
|
||||
def on_packet_complete(event):
|
||||
global PKGS_COUNT
|
||||
#for val in bigs.values(): # loop over bigs
|
||||
#frame = next(val['frames_iterator'] )
|
||||
#val['big'].bis_links[0].write(frame)
|
||||
#global pkgs_count
|
||||
PKGS_COUNT = PKGS_COUNT + 1
|
||||
|
||||
event_handle = event.connection_handles[0]
|
||||
|
||||
if PKGS_COUNT < LOOP_FINITE_PKGS or LOOP_FINITE_PKGS == -1 :
|
||||
frame = next(bigs[f'big0']['frames_iterator'] )
|
||||
bigs[f'big0']['big'].bis_links[0].write(frame)
|
||||
bigs[f'big1']['big'].bis_links[0].write(frame)
|
||||
|
||||
|
||||
for big in bigs.values():
|
||||
if big['big'].bis_links[0].handle == event_handle:
|
||||
frame = next(big['frames_iterator'] )
|
||||
big['big'].bis_links[0].write(frame)
|
||||
|
||||
device.host.on('hci_number_of_completed_packets_event', on_packet_complete)
|
||||
|
||||
on_packet_complete('') # Send the first packet, to get the event loop running
|
||||
# Send the first packet for each big, to get the event loop running
|
||||
for big in bigs.values():
|
||||
frame = next(big['frames_iterator'] )
|
||||
big['big'].bis_links[0].write(frame)
|
||||
|
||||
while True:
|
||||
await asyncio.sleep(1)
|
||||
@@ -278,7 +283,7 @@ def broadcast(global_conf: auracast_config.AuracastGlobalConfig, big_conf: List[
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
global_conf = auracast_config.global_base_config
|
||||
|
||||
@@ -291,9 +296,13 @@ if __name__ == "__main__":
|
||||
|
||||
bigs = [
|
||||
auracast_config.broadcast_de,
|
||||
auracast_config.broadcast_en
|
||||
auracast_config.broadcast_en,
|
||||
#auracast_config.broadcast_fr,
|
||||
]
|
||||
global_conf.octets_per_frame=60# 48kbps@24kHz
|
||||
#global_conf.auracast_sampling_rate_hz = 16000
|
||||
#global_conf.octets_per_frame = 40 # 32kbps@16kHz
|
||||
|
||||
|
||||
|
||||
broadcast(
|
||||
global_conf,
|
||||
|
||||
Reference in New Issue
Block a user