"""
"""

import logging
import os

from auracast.auracast_config import AuracastGlobalConfig, AuracastBigConfig, AuracastQosRobust
from auracast.multicast import broadcast, run_async


if __name__ == "__main__":
    logging.basicConfig(
        level=os.environ.get("LOG_LEVEL", logging.INFO),
        format="%(module)s.py:%(lineno)d %(levelname)s: %(message)s",
    )

    # Ensure relative audio paths like in AuracastBigConfig work (./auracast/...) from src/auracast/
    os.chdir(os.path.join(os.path.dirname(__file__), "../../auracast"))

    # Start from default global config
    config = AuracastGlobalConfig()

    # Use same QoS profile as multicast main
    config.qos_config = AuracastQosRobust()

    # Transport similar to multicast main; adjust if needed for your setup
    # config.transport = "auto"  # let multicast auto-detect
    config.transport = "serial:/dev/ttyAMA3,1000000,rtscts"  # Raspberry Pi default

    # Stereo BIG with 2 BISes (FRONT_LEFT + FRONT_RIGHT)
    big = AuracastBigConfig()
    big.random_address = "F1:F1:F2:F3:F4:F5"
    big.audio_source = "file:./testdata/announcement_es_stereo.wav"
    big.id = 12
    big.num_bis = 2  # stereo: 2 BISes

    run_async(
        broadcast(
            config,
            [big],
        )
    )
