fixed explorer publishing

This commit is contained in:
DJ2LS 2023-11-19 12:31:56 +01:00
parent 129b7f6029
commit 225af9e8b5
4 changed files with 10 additions and 10 deletions

View file

@ -15,8 +15,9 @@ import structlog
log = structlog.get_logger("explorer")
class explorer():
def __init__(self, config, states):
def __init__(self, app, config, states):
self.config = config
self.app = app
self.states = states
self.explorer_url = "https://api.freedata.app/explorer.php"
self.publish_interval = 120
@ -39,7 +40,7 @@ class explorer():
band = "USB"
callsign = str(self.config['STATION']['mycall'])
gridsquare = str(self.config['STATION']['mygrid'])
version = str(self.states.modem_version)
version = str(self.app.MODEM_VERSION)
bandwidth = str(self.config['MODEM']['enable_low_bandwidth_mode'])
beacon = str(self.states.is_beacon_running)
strength = str(self.states.radio_strength)

View file

@ -16,9 +16,11 @@ app = Flask(__name__)
CORS(app)
CORS(app, resources={r"/*": {"origins": "*"}})
sock = Sock(app)
app.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 5}
print(app.config)
print(app.config['SOCK_SERVER_OPTIONS'])
app.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 10}
# define global MODEM_VERSION
app.MODEM_VERSION = "0.12.0-alpha"
# set config file to use
def set_config():
if 'FREEDATA_CONFIG' in os.environ:
@ -62,6 +64,7 @@ def index():
return api_response({'name': 'FreeDATA API',
'description': '',
'api_version': 1,
'modem_version': app.MODEM_VERSION,
'license': 'GPL3.0',
'documentation': 'https://wiki.freedata.app',
})
@ -198,7 +201,6 @@ def transmit_sock_data_worker(client_list, event_queue):
client_list.remove(client)
def sock_watchdog(sock, client_list, event_queue):
event_queue.put(json.dumps({"freedata-message": "hello-client"}))

View file

@ -27,7 +27,7 @@ class SM:
# optionally start explorer module
if self.config['STATION']['enable_explorer']:
explorer.explorer(self.config, self.states)
explorer.explorer(self.app, self.config, self.states)
def runner(self):
while True:

View file

@ -3,8 +3,6 @@ import ujson as json
class STATES:
def __init__(self, statequeue):
self.modem_version = 0.0
# state related settings
self.statequeue = statequeue
self.newstate = None
@ -67,7 +65,6 @@ class STATES:
def getAsJSON(self, isChangedState):
msgtype = "state-change"
if (not isChangedState):
msgtype = "state"