FreeDATA/modem/state_manager.py

26 lines
798 B
Python
Raw Normal View History

2023-11-12 18:56:15 +00:00
import ujson as json
class STATES:
def __init__(self, statequeue):
self.statequeue = statequeue
self.channel_busy = False
self.channel_busy_slot = [False, False, False, False, False]
self.is_codec2_traffic = False
2023-11-12 18:56:15 +00:00
self.is_modem_running = False
2023-11-12 22:22:53 +00:00
self.is_beacon_running = False
2023-11-13 17:11:55 +00:00
self.audio_dbfs = 0
2023-11-12 22:22:53 +00:00
def set(self, key, value):
setattr(self, key, value)
self.statequeue.put(self.getAsJSON())
def getAsJSON(self):
2023-11-12 18:56:15 +00:00
return json.dumps({
"freedata-message": "state-change",
"channel_busy": self.channel_busy,
2023-11-12 18:56:15 +00:00
"is_codec2_traffic": self.is_codec2_traffic,
"is_modem_running": self.is_modem_running,
2023-11-12 22:22:53 +00:00
"is_beacon_running": self.is_beacon_running,
2023-11-12 18:56:15 +00:00
})