refractoring to use ghe global config.py

This commit is contained in:
2024-12-19 16:28:52 +01:00
parent 5d2f0f4fdf
commit 56b942ce39
6 changed files with 61 additions and 65 deletions

View File

@@ -1,20 +1,16 @@
import serial
import time
import logging as log
import os
import serial
from ..config import SAMPLING_RATE_HZ, LANG_CONFIG
PRESET = f'{SAMPLING_RATE_HZ//1000}_2_1'
BROADCAST_CONFIG = {}
SAMPLING_RATE_KHZ = 16
FRAME_DUR_MS = 10
PRESET = f'{SAMPLING_RATE_KHZ}_2_1'
for i, d in enumerate(list(LANG_CONFIG.items())):
key, val = d
BROADCAST_CONFIG[i] = os.path.basename(val["file"])
if SAMPLING_RATE_KHZ == 8:
BITRATE_KBPS = 16
elif SAMPLING_RATE_KHZ == 16:
BITRATE_KBPS = 32
elif SAMPLING_RATE_KHZ == 24:
BITRATE_KBPS = 48
else:
raise NotImplemented()
def write_to_serial_read_respone(port, cmd, timeout = 2):
# Initialize serial connection
@@ -68,19 +64,12 @@ def gen_broadcast_config_cmd(preset, broadcast_config: dict):
cmds.append(f"nac preset {preset} {ch}")
cmds.append(f"nac broadcast_name broadcast{ch} {ch}")
cmds.append(f"nac file select_play_once {file_name} {ch} 0 0")
cmds.append(f"nac file select_play_once {file_name}.lc3 {ch} 0 0")
cmds.append(f"nac num_bises 1 {ch} 0")
return cmds
# TODO: Advertising interval wird ungelmäßig bei mehr als 3 broadcasts 10ms -> 1s< bei 24kHz sampling rate
BROADCAST_CONFIG = {
0: f"announcement_{SAMPLING_RATE_KHZ}_{FRAME_DUR_MS}_{BITRATE_KBPS}_de.lc3",
1: f"announcement_{SAMPLING_RATE_KHZ}_{FRAME_DUR_MS}_{BITRATE_KBPS}_en.lc3",
2: f"announcement_{SAMPLING_RATE_KHZ}_{FRAME_DUR_MS}_{BITRATE_KBPS}_fr.lc3",
#3: f"announcement_{SAMPLING_RATE_KHZ}_{FRAME_DUR_MS}_{BITRATE_KBPS}_es.lc3",
#4: f"announcement_{SAMPLING_RATE_KHZ}_{FRAME_DUR_MS}_{BITRATE_KBPS}_it.lc3"
}
def broadcaster_config():