make client ready for broadcast function

This commit is contained in:
Bastian Schroll 2019-02-27 12:08:55 +01:00
parent 54b4c1439a
commit e2ca436e5d
5 changed files with 33 additions and 21 deletions

View file

@ -101,6 +101,12 @@ class BroadcastServer:
self._serverShutdown = False
self._servePort = servePort
def __del__(self):
if self.isRunning:
self.stop()
while self.isRunning:
pass
def start(self):
"""!Start the broadcast server in a new thread

View file

@ -80,7 +80,7 @@ class Packet:
self.set("clientBuildDate", version.date)
self.set("clientBranch", version.branch)
self.set("inputSource", config["client"]["inputSource"])
self.set("frequency", config["inputSource"]["stick"]["frequency"])
self.set("frequency", config["inputSource"]["sdr"]["frequency"])
def addServerData(self):
"""!Add the server information to the decoded data

View file

@ -45,6 +45,7 @@ try:
logging.debug("Import BOSWatch modules")
from boswatch import configYaml
from boswatch.network.client import TCPClient
from boswatch.network.broadcast import BroadcastClient
from boswatch.decoder.decoder import Decoder
from boswatch.utils import header
except Exception as e: # pragma: no cover
@ -71,12 +72,27 @@ try:
bwConfig = configYaml.loadConfigFile(paths.CONFIG_PATH + args.config, "clientConfig")
if bwConfig is None:
logging.exception("cannot load config file")
print("cannot load config file")
exit(1) # without config cannot run
logging.error("cannot load config file")
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()
if bwClient.connect(bwConfig["server"]["ip"], bwConfig["server"]["port"]):
if bwClient.connect(ip, port):
while 1:
for i in range(0, 5):

View file

@ -61,15 +61,8 @@ except Exception as e: # pragma: no cover
# Test for the broadcast connection info function
server = BroadcastServer()
client = BroadcastClient()
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
from boswatch.utils.timer import RepeatedTimer

View file

@ -9,25 +9,22 @@
client:
name: BW3 Client # name of the BW3 Client instance
inputSource: stick # possible is 'stick' or 'audio'
# useBroadcast: yes # use broadcast function to find server
inputSource: sdr # atm only 'sdr' is possible
useBroadcast: no # use broadcast to find server automatically
# atm only one server possible
server: # only used if useBroadcast = no
name: Server one
server: # only used if useBroadcast = no
ip: 127.0.0.1
port: 8080
inputSource:
stick:
sdr:
device: 0
frequency: 85.000M
PPMError: 0
Squelch: 0
Gain: 100
audio: # not implemented yet
decoder: # not implemented yet
decoder:
fms: yes
zvei: yes
poc512: yes