Skip to content

Commit 3d3fc44

Browse files
committed
Make sure that UI actually can display values from backplane
1 parent 726ce97 commit 3d3fc44

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

ui/src/App.svelte

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
130130
onMount(() => {
131131
applyUrlParameters();
132-
connectMqtt(mqttAddress);
132+
connectMqtt(mqttAddress || undefined);
133133
if (mockMqtt) {
134134
startSineWaveMqttGenerator({ intervalMs: 3000, channel: mqttChannel });
135135
}
@@ -196,13 +196,17 @@
196196
// Subscribe to MQTT data changes
197197
$: {
198198
const data = getDataByPacket($mqttData) as Record<string, unknown>;
199-
const prefix = getChannelPayload(data, mqttChannel);
200-
if (prefix) {
199+
// Channel-based lookup (mock: gsw/{channel}/{packetType} → object) falls back to
200+
// direct packet-name lookup (real: gsw/{PacketName}/{field} → scalar).
201+
const lookup = getChannelPayload(data, mqttChannel) ?? data;
202+
203+
const gnsscoordinates = getObjectCaseInsensitive(lookup, "gnsscoordinates");
204+
const powermodule = getObjectCaseInsensitive(lookup, "powermodule");
205+
const receiverstats = getObjectCaseInsensitive(lookup, "receiverstats");
206+
const sensormodule = getObjectCaseInsensitive(lookup, "sensormodule");
207+
208+
if (gnsscoordinates || powermodule || receiverstats || sensormodule) {
201209
lastTransmission = Date.now();
202-
const gnsscoordinates = getObjectCaseInsensitive(prefix, "gnsscoordinates");
203-
const powermodule = getObjectCaseInsensitive(prefix, "powermodule");
204-
const receiverstats = getObjectCaseInsensitive(prefix, "receiverstats");
205-
const sensormodule = getObjectCaseInsensitive(prefix, "sensormodule");
206210
207211
const latitude = getNumberCaseInsensitive(gnsscoordinates, "latitude");
208212
const longitude = getNumberCaseInsensitive(gnsscoordinates, "longitude");
@@ -215,10 +219,10 @@
215219
battCurrent = getNumberCaseInsensitive(powermodule, "CURR_BATT");
216220
battVoltage = getNumberCaseInsensitive(powermodule, "VOLT_BATT");
217221
receiverSnr = getNumberCaseInsensitive(receiverstats, "SNR", "RCV_SNR", "snr");
218-
temperature = getNumberCaseInsensitive(sensormodule, "temperature");
219-
accelX = getNumberCaseInsensitive(sensormodule, "ACCEL_X", "ADX_ACCEL_X", "LSM_ACCEL_X");
220-
accelY = getNumberCaseInsensitive(sensormodule, "ACCEL_Y", "ADX_ACCEL_Y", "LSM_ACCEL_Y");
221-
accelZ = getNumberCaseInsensitive(sensormodule, "ACCEL_Z", "ADX_ACCEL_Z", "LSM_ACCEL_Z");
222+
temperature = getNumberCaseInsensitive(sensormodule, "temperature", "TEMP_BMP388", "TEMP_MS5611", "TEMP_TMP117");
223+
accelX = getNumberCaseInsensitive(sensormodule, "accel_x", "ACCEL_X", "ADX_ACCEL_X", "LSM_ACCEL_X");
224+
accelY = getNumberCaseInsensitive(sensormodule, "accel_y", "ACCEL_Y", "ADX_ACCEL_Y", "LSM_ACCEL_Y");
225+
accelZ = getNumberCaseInsensitive(sensormodule, "accel_z", "ACCEL_Z", "ADX_ACCEL_Z", "LSM_ACCEL_Z");
222226
}
223227
}
224228
</script>

0 commit comments

Comments
 (0)