diff --git a/owrx/controllers/settings/reporting.py b/owrx/controllers/settings/reporting.py index 9d8ac852..ba5ff9ba 100644 --- a/owrx/controllers/settings/reporting.py +++ b/owrx/controllers/settings/reporting.py @@ -95,12 +95,12 @@ class ReportingController(SettingsFormController): "MQTT settings", CheckboxInput( "mqtt_enabled", - "Enable publishing decodes to MQTT", + "Enable publishing reports to MQTT", ), TextInput( "mqtt_host", "Broker address", - infotext="Addresss of the MQTT broker to send decodes to (address[:port])", + infotext="Addresss of the MQTT broker to send reports to (address[:port])", validator=AddressAndOptionalPortValidator(), ), TextInput( @@ -125,7 +125,7 @@ class ReportingController(SettingsFormController): TextInput( "mqtt_topic", "MQTT topic", - infotext="MQTT topic to publish decodes to (default: openwebrx/decodes)", + infotext="MQTT topic to publish reports to (default: openwebrx)", converter=OptionalConverter(), ), ) diff --git a/owrx/reporting/mqtt.py b/owrx/reporting/mqtt.py index 003b1700..628d6267 100644 --- a/owrx/reporting/mqtt.py +++ b/owrx/reporting/mqtt.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) class MqttReporter(Reporter): - DEFAULT_TOPIC = "openwebrx/decodes" + DEFAULT_TOPIC = "openwebrx" def __init__(self): pm = Config.get() diff --git a/owrx/source/__init__.py b/owrx/source/__init__.py index fb637c1d..d9c9b299 100644 --- a/owrx/source/__init__.py +++ b/owrx/source/__init__.py @@ -17,8 +17,10 @@ from owrx.form.input.converter import Converter, OptionalConverter, IntConverter from owrx.form.input.device import GainInput, SchedulerInput, WaterfallLevelsInput from owrx.form.input.validator import RequiredValidator, Range, RangeValidator, RangeListValidator from owrx.form.section import OptionalSection +from owrx.reporting import ReportingEngine from owrx.feature import FeatureDetector from owrx.log import LogPipe, HistoryHandler +from datetime import datetime from typing import List from enum import Enum @@ -274,6 +276,17 @@ class SdrSource(ABC): profile_name = self.getProfiles()[profile_id]["name"] self.logger.debug("activating profile \"%s\" for \"%s\"", profile_name, self.getName()) self.profileCarousel.switch(profile_id) + # Report profile changes + ReportingEngine.getSharedInstance().spot({ + "mode" : "RX", + "timestamp" : round(datetime.now().timestamp() * 1000), + "source_id" : self.id, + "source" : self.getName(), + "profile_id" : profile_id, + "profile" : profile_name, + "freq" : self.props["center_freq"], + "samplerate" : self.props["samp_rate"] + }) except KeyError: self.logger.warning("invalid profile %s for sdr %s. ignoring", profile_id, self.getId()) @@ -566,8 +579,18 @@ class SdrSource(ABC): return self.state def setState(self, state: SdrSourceState): + # Drop out if state has not changed if state == self.state: return + # Report state changes + ReportingEngine.getSharedInstance().spot({ + "mode" : "RX", + "timestamp" : round(datetime.now().timestamp() * 1000), + "source_id" : self.id, + "source" : self.getName(), + "state" : str(state) + }) + # Update state and broadcast to clients self.state = state for c in self.clients.copy(): c.onStateChange(state)