mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-03-27 15:14:41 +01:00
make client ready for broadcast function
This commit is contained in:
parent
54b4c1439a
commit
e2ca436e5d
|
|
@ -101,6 +101,12 @@ class BroadcastServer:
|
||||||
self._serverShutdown = False
|
self._serverShutdown = False
|
||||||
self._servePort = servePort
|
self._servePort = servePort
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
if self.isRunning:
|
||||||
|
self.stop()
|
||||||
|
while self.isRunning:
|
||||||
|
pass
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""!Start the broadcast server in a new thread
|
"""!Start the broadcast server in a new thread
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class Packet:
|
||||||
self.set("clientBuildDate", version.date)
|
self.set("clientBuildDate", version.date)
|
||||||
self.set("clientBranch", version.branch)
|
self.set("clientBranch", version.branch)
|
||||||
self.set("inputSource", config["client"]["inputSource"])
|
self.set("inputSource", config["client"]["inputSource"])
|
||||||
self.set("frequency", config["inputSource"]["stick"]["frequency"])
|
self.set("frequency", config["inputSource"]["sdr"]["frequency"])
|
||||||
|
|
||||||
def addServerData(self):
|
def addServerData(self):
|
||||||
"""!Add the server information to the decoded data
|
"""!Add the server information to the decoded data
|
||||||
|
|
|
||||||
24
bw_client.py
24
bw_client.py
|
|
@ -45,6 +45,7 @@ try:
|
||||||
logging.debug("Import BOSWatch modules")
|
logging.debug("Import BOSWatch modules")
|
||||||
from boswatch import configYaml
|
from boswatch import configYaml
|
||||||
from boswatch.network.client import TCPClient
|
from boswatch.network.client import TCPClient
|
||||||
|
from boswatch.network.broadcast import BroadcastClient
|
||||||
from boswatch.decoder.decoder import Decoder
|
from boswatch.decoder.decoder import Decoder
|
||||||
from boswatch.utils import header
|
from boswatch.utils import header
|
||||||
except Exception as e: # pragma: no cover
|
except Exception as e: # pragma: no cover
|
||||||
|
|
@ -71,12 +72,27 @@ try:
|
||||||
|
|
||||||
bwConfig = configYaml.loadConfigFile(paths.CONFIG_PATH + args.config, "clientConfig")
|
bwConfig = configYaml.loadConfigFile(paths.CONFIG_PATH + args.config, "clientConfig")
|
||||||
if bwConfig is None:
|
if bwConfig is None:
|
||||||
logging.exception("cannot load config file")
|
logging.error("cannot load config file")
|
||||||
print("cannot load config file")
|
|
||||||
exit(1) # without config cannot run
|
except Exception as e: # pragma: no cover
|
||||||
|
logging.exception("error occurred")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
# ############################# begin client system
|
||||||
|
try:
|
||||||
|
|
||||||
|
if bwConfig["client"]["useBroadcast"]:
|
||||||
|
broadcastClient = BroadcastClient()
|
||||||
|
if broadcastClient.getConnInfo():
|
||||||
|
ip = broadcastClient.serverIP
|
||||||
|
port = broadcastClient.serverPort
|
||||||
|
else:
|
||||||
|
ip = bwConfig["server"]["ip"]
|
||||||
|
port = bwConfig["server"]["port"]
|
||||||
|
|
||||||
bwClient = TCPClient()
|
bwClient = TCPClient()
|
||||||
if bwClient.connect(bwConfig["server"]["ip"], bwConfig["server"]["port"]):
|
if bwClient.connect(ip, port):
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
for i in range(0, 5):
|
for i in range(0, 5):
|
||||||
|
|
|
||||||
|
|
@ -61,15 +61,8 @@ except Exception as e: # pragma: no cover
|
||||||
|
|
||||||
# Test for the broadcast connection info function
|
# Test for the broadcast connection info function
|
||||||
server = BroadcastServer()
|
server = BroadcastServer()
|
||||||
client = BroadcastClient()
|
|
||||||
server.start()
|
server.start()
|
||||||
print(server.isRunning)
|
|
||||||
client.getConnInfo()
|
|
||||||
print(client.serverIP, client.serverPort)
|
|
||||||
server.stop()
|
|
||||||
print(server.isRunning)
|
|
||||||
time.sleep(2)
|
|
||||||
print(server.isRunning)
|
|
||||||
|
|
||||||
# test for the timer class
|
# test for the timer class
|
||||||
from boswatch.utils.timer import RepeatedTimer
|
from boswatch.utils.timer import RepeatedTimer
|
||||||
|
|
|
||||||
|
|
@ -9,25 +9,22 @@
|
||||||
|
|
||||||
client:
|
client:
|
||||||
name: BW3 Client # name of the BW3 Client instance
|
name: BW3 Client # name of the BW3 Client instance
|
||||||
inputSource: stick # possible is 'stick' or 'audio'
|
inputSource: sdr # atm only 'sdr' is possible
|
||||||
# useBroadcast: yes # use broadcast function to find server
|
useBroadcast: no # use broadcast to find server automatically
|
||||||
|
|
||||||
# atm only one server possible
|
server: # only used if useBroadcast = no
|
||||||
server: # only used if useBroadcast = no
|
|
||||||
name: Server one
|
|
||||||
ip: 127.0.0.1
|
ip: 127.0.0.1
|
||||||
port: 8080
|
port: 8080
|
||||||
|
|
||||||
inputSource:
|
inputSource:
|
||||||
stick:
|
sdr:
|
||||||
device: 0
|
device: 0
|
||||||
frequency: 85.000M
|
frequency: 85.000M
|
||||||
PPMError: 0
|
PPMError: 0
|
||||||
Squelch: 0
|
Squelch: 0
|
||||||
Gain: 100
|
Gain: 100
|
||||||
audio: # not implemented yet
|
|
||||||
|
|
||||||
decoder: # not implemented yet
|
decoder:
|
||||||
fms: yes
|
fms: yes
|
||||||
zvei: yes
|
zvei: yes
|
||||||
poc512: yes
|
poc512: yes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue