mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
'Refactored by Sourcery'
This commit is contained in:
parent
e7e113df28
commit
5c64491bca
1 changed files with 8 additions and 7 deletions
15
tnc/tci.py
15
tnc/tci.py
|
@ -36,12 +36,13 @@ class TCI:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"[TCI] Starting TCI thread!", ip=self.hostname, port=self.port
|
"[TCI] Starting TCI thread!", ip=self.hostname, port=self.port
|
||||||
)
|
)
|
||||||
self.ws = websocket.WebSocketApp("ws://" + self.hostname + ":" + self.port,
|
self.ws = websocket.WebSocketApp(
|
||||||
on_open=self.on_open,
|
f"ws://{self.hostname}:{self.port}",
|
||||||
on_message=self.on_message,
|
on_open=self.on_open,
|
||||||
on_error=self.on_error,
|
on_message=self.on_message,
|
||||||
on_close=self.on_close
|
on_error=self.on_error,
|
||||||
)
|
on_close=self.on_close,
|
||||||
|
)
|
||||||
|
|
||||||
self.ws.run_forever(reconnect=5) # Set dispatcher to automatic reconnection, 5 second reconnect delay if con>
|
self.ws.run_forever(reconnect=5) # Set dispatcher to automatic reconnection, 5 second reconnect delay if con>
|
||||||
#rel.signal(2, rel.abort) # Keyboard Interrupt
|
#rel.signal(2, rel.abort) # Keyboard Interrupt
|
||||||
|
@ -55,7 +56,7 @@ class TCI:
|
||||||
self.ws.send('AUDIO_STREAM_SAMPLES:1200;')
|
self.ws.send('AUDIO_STREAM_SAMPLES:1200;')
|
||||||
self.ws.send('audio_start:0;')
|
self.ws.send('audio_start:0;')
|
||||||
|
|
||||||
if len(message) == 576 or len(message) == 2464 or len(message) == 4160:
|
if len(message) in {576, 2464, 4160}:
|
||||||
# audio received
|
# audio received
|
||||||
receiver = message[:4]
|
receiver = message[:4]
|
||||||
sample_rate = int.from_bytes(message[4:8], "little")
|
sample_rate = int.from_bytes(message[4:8], "little")
|
||||||
|
|
Loading…
Reference in a new issue