small adaptions in multicast client and server
This commit is contained in:
@@ -15,13 +15,8 @@ def stop_audio():
|
|||||||
response = requests.post(f"{BASE_URL}/stop_audio")
|
response = requests.post(f"{BASE_URL}/stop_audio")
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def send_audio():
|
def send_audio(data_dict):
|
||||||
test_audio_data = { # TODO: investigate further whats the best way to actually transfer the data
|
response = requests.post(f"{BASE_URL}/stream_lc3", json=data_dict)
|
||||||
"broadcast_de": read_lc3_file('src/auracast/testdata/announcement_de_10_16_32.lc3').decode('latin-1'),
|
|
||||||
"broadcast_en": read_lc3_file('src/auracast/testdata/announcement_en_10_16_32.lc3').decode('latin-1')
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.post(f"{BASE_URL}/stream_lc3", json=test_audio_data)
|
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def get_status():
|
def get_status():
|
||||||
@@ -29,6 +24,11 @@ def get_status():
|
|||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
test_audio_data = { # TODO: investigate further whats the best way to actually transfer the data
|
||||||
|
"broadcast_deu": read_lc3_file('src/auracast/testdata/announcement_de_10_16_32.lc3').decode('latin-1'),
|
||||||
|
"broadcast_eng": read_lc3_file('src/auracast/testdata/announcement_en_10_16_32.lc3').decode('latin-1')
|
||||||
|
}
|
||||||
|
|
||||||
print("Getting status:", get_status())
|
print("Getting status:", get_status())
|
||||||
print("Initializing server:", initialize())
|
print("Initializing server:", initialize())
|
||||||
print("Getting status:", get_status())
|
print("Getting status:", get_status())
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
|
import logging as log
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
from quart import Quart, request, jsonify # TODO: evalute if classic flask should be used instead
|
from quart import Quart, request, jsonify
|
||||||
from auracast import multicast_control
|
from auracast import multicast_control
|
||||||
from auracast import auracast_config
|
from auracast import auracast_config
|
||||||
|
|
||||||
app = Quart(__name__)
|
app = Quart(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: redo this with fastapi, transfer whole radio config on init
|
||||||
|
|
||||||
# Initialize the multicaster instance globally
|
# Initialize the multicaster instance globally
|
||||||
global_conf = auracast_config.global_base_config
|
global_conf = auracast_config.AuracastGlobalConfig()
|
||||||
|
|
||||||
#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
|
||||||
|
|
||||||
big_conf = { # TODO: use another dataclass for this to be able to iterate over the names
|
big_conf = { # TODO: use another dataclass for this to be able to iterate over the names
|
||||||
'broadcast_de': auracast_config.AuracastBigConfigDe(),
|
'deu': auracast_config.AuracastBigConfigDe(),
|
||||||
'broadcast_en': auracast_config.AuracastBigConfigEn(),
|
'eng': auracast_config.AuracastBigConfigEn(),
|
||||||
'broadcast_fr': auracast_config.AuracastBigConfigFr(),
|
'fra': auracast_config.AuracastBigConfigFr(),
|
||||||
#auracast_config.broadcast_es,
|
#auracast_config.broadcast_es,
|
||||||
#auracast_config.broadcast_it,
|
#auracast_config.broadcast_it,
|
||||||
}
|
}
|
||||||
@@ -60,8 +65,8 @@ async def send_audio():
|
|||||||
"""Streams pre-coded LC3 audio.
|
"""Streams pre-coded LC3 audio.
|
||||||
# post data in the format
|
# post data in the format
|
||||||
{
|
{
|
||||||
broadcast_de: b''
|
broadcast_deu: b''
|
||||||
broadcast_fr: b''
|
broadcast_fra: b''
|
||||||
|
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -69,6 +74,7 @@ async def send_audio():
|
|||||||
try:
|
try:
|
||||||
for key, val in big_conf.items(): #TODO: loop over caster.big_conf directly
|
for key, val in big_conf.items(): #TODO: loop over caster.big_conf directly
|
||||||
if key in post_data:
|
if key in post_data:
|
||||||
|
log.info('Received a send audio request for %s', key)
|
||||||
val.audio_source = post_data[key].encode('latin-1')
|
val.audio_source = post_data[key].encode('latin-1')
|
||||||
else:
|
else:
|
||||||
val.audio_source = b''
|
val.audio_source = b''
|
||||||
@@ -90,4 +96,8 @@ async def get_status():
|
|||||||
return jsonify({"status": status}), 200
|
return jsonify({"status": status}), 200
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
log.basicConfig(
|
||||||
|
level=log.INFO,
|
||||||
|
format='%(module)s.py:%(lineno)d %(levelname)s: %(message)s'
|
||||||
|
)
|
||||||
app.run(host='0.0.0.0', port=5000, debug=True)
|
app.run(host='0.0.0.0', port=5000, debug=True)
|
||||||
Reference in New Issue
Block a user