From 7e1216ed8c4d7becd651d84394fc7e509cb8c201 Mon Sep 17 00:00:00 2001 From: hhvrc Date: Mon, 18 Nov 2024 02:16:09 +0100 Subject: [PATCH] Renamed "device" to "hub" --- .../WifiNetworkEventHandler.ts | 16 ++++----- frontend/src/lib/MessageHandlers/index.ts | 16 ++++----- .../src/lib/components/GpioPinSelector.svelte | 17 +++++++-- frontend/src/lib/components/WiFiList.svelte | 22 ++++++++---- .../lib/components/modals/WiFiDetails.svelte | 23 ++++++++---- .../{DeviceStateStore.ts => HubStateStore.ts} | 8 ++--- frontend/src/lib/stores/index.ts | 2 +- .../lib/types/{DeviceState.ts => HubState.ts} | 2 +- frontend/src/lib/types/index.ts | 2 +- frontend/src/routes/+page.svelte | 29 ++++++++++++--- include/http/JsonAPI.h | 14 ++++---- include/serialization/JsonAPI.h | 8 ++--- include/wifi/WiFiManager.h | 14 ++++---- src/GatewayClient.cpp | 2 +- src/GatewayConnectionManager.cpp | 14 ++++---- src/http/JsonAPI.cpp | 21 ++++++----- src/serial/command_handlers/factoryreset.cpp | 8 +++-- src/serialization/JsonAPI.cpp | 36 +++++++++++-------- 18 files changed, 157 insertions(+), 97 deletions(-) rename frontend/src/lib/stores/{DeviceStateStore.ts => HubStateStore.ts} (94%) rename frontend/src/lib/types/{DeviceState.ts => HubState.ts} (94%) diff --git a/frontend/src/lib/MessageHandlers/WifiNetworkEventHandler.ts b/frontend/src/lib/MessageHandlers/WifiNetworkEventHandler.ts index 9b5268c5..bd918226 100644 --- a/frontend/src/lib/MessageHandlers/WifiNetworkEventHandler.ts +++ b/frontend/src/lib/MessageHandlers/WifiNetworkEventHandler.ts @@ -1,7 +1,7 @@ import { WifiNetworkEvent } from '$lib/_fbs/open-shock/serialization/local/wifi-network-event'; import { WifiNetwork as FbsWifiNetwork } from '$lib/_fbs/open-shock/serialization/types/wifi-network'; import { WifiNetworkEventType } from '$lib/_fbs/open-shock/serialization/types/wifi-network-event-type'; -import { DeviceStateStore } from '$lib/stores'; +import { HubStateStore } from '$lib/stores'; import { toastDelegator } from '$lib/stores/ToastDelegator'; import type { WiFiNetwork } from '$lib/types/WiFiNetwork'; import type { MessageHandler } from '.'; @@ -27,7 +27,7 @@ function handleDiscoveredEvent(fbsNetwork: FbsWifiNetwork) { saved: fbsNetwork.saved(), }; - DeviceStateStore.setWifiNetwork(network); + HubStateStore.setWifiNetwork(network); } function handleUpdatedEvent(fbsNetwork: FbsWifiNetwork) { const ssid = fbsNetwork.ssid(); @@ -47,7 +47,7 @@ function handleUpdatedEvent(fbsNetwork: FbsWifiNetwork) { saved: fbsNetwork.saved(), }; - DeviceStateStore.setWifiNetwork(network); + HubStateStore.setWifiNetwork(network); } function handleLostEvent(fbsNetwork: FbsWifiNetwork) { const bssid = fbsNetwork.bssid(); @@ -57,7 +57,7 @@ function handleLostEvent(fbsNetwork: FbsWifiNetwork) { return; } - DeviceStateStore.removeWifiNetwork(bssid); + HubStateStore.removeWifiNetwork(bssid); } function handleSavedEvent(fbsNetwork: FbsWifiNetwork) { const ssid = fbsNetwork.ssid(); @@ -68,7 +68,7 @@ function handleSavedEvent(fbsNetwork: FbsWifiNetwork) { return; } - DeviceStateStore.updateWifiNetwork(bssid, (network) => { + HubStateStore.updateWifiNetwork(bssid, (network) => { network.saved = true; return network; }); @@ -87,7 +87,7 @@ function handleRemovedEvent(fbsNetwork: FbsWifiNetwork) { return; } - DeviceStateStore.updateWifiNetwork(bssid, (network) => { + HubStateStore.updateWifiNetwork(bssid, (network) => { network.saved = false; return network; }); @@ -106,7 +106,7 @@ function handleConnectedEvent(fbsNetwork: FbsWifiNetwork) { return; } - DeviceStateStore.setWifiConnectedBSSID(bssid); + HubStateStore.setWifiConnectedBSSID(bssid); toastDelegator.trigger({ message: 'WiFi network connected: ' + ssid, @@ -122,7 +122,7 @@ function handleDisconnectedEvent(fbsNetwork: FbsWifiNetwork) { return; } - DeviceStateStore.setWifiConnectedBSSID(null); + HubStateStore.setWifiConnectedBSSID(null); toastDelegator.trigger({ message: 'WiFi network disconnected: ' + ssid, diff --git a/frontend/src/lib/MessageHandlers/index.ts b/frontend/src/lib/MessageHandlers/index.ts index 808c54b8..ecb19354 100644 --- a/frontend/src/lib/MessageHandlers/index.ts +++ b/frontend/src/lib/MessageHandlers/index.ts @@ -4,7 +4,7 @@ import { HubToLocalMessagePayload } from '$lib/_fbs/open-shock/serialization/loc import { ReadyMessage } from '$lib/_fbs/open-shock/serialization/local/ready-message'; import { WifiScanStatusMessage } from '$lib/_fbs/open-shock/serialization/local/wifi-scan-status-message'; import { ByteBuffer } from 'flatbuffers'; -import { DeviceStateStore } from '$lib/stores'; +import { HubStateStore } from '$lib/stores'; import { SerializeWifiScanCommand } from '$lib/Serializers/WifiScanCommand'; import { toastDelegator } from '$lib/stores/ToastDelegator'; import { SetRfTxPinCommandResult } from '$lib/_fbs/open-shock/serialization/local/set-rf-tx-pin-command-result'; @@ -33,9 +33,9 @@ PayloadHandlers[HubToLocalMessagePayload.ReadyMessage] = (cli, msg) => { const payload = new ReadyMessage(); msg.payload(payload); - console.log('[WS] Connected to device, poggies: ', payload.poggies()); + console.log('[WS] Connected to hub, poggies: ', payload.poggies()); - DeviceStateStore.update((store) => { + HubStateStore.update((store) => { store.wifiConnectedBSSID = payload.connectedWifi()?.bssid() || null; store.accountLinked = payload.accountLinked(); store.config = mapConfig(payload.config()); @@ -50,7 +50,7 @@ PayloadHandlers[HubToLocalMessagePayload.ReadyMessage] = (cli, msg) => { store.gpioValidOutputs = gpioValidOutputs; } - console.log('[WS] Updated device state store: ', store); + console.log('[WS] Updated hub state store: ', store); return store; }); @@ -80,7 +80,7 @@ PayloadHandlers[HubToLocalMessagePayload.WifiScanStatusMessage] = (cli, msg) => const payload = new WifiScanStatusMessage(); msg.payload(payload); - DeviceStateStore.setWifiScanStatus(payload.status()); + HubStateStore.setWifiScanStatus(payload.status()); }; PayloadHandlers[HubToLocalMessagePayload.WifiNetworkEvent] = WifiNetworkEventHandler; @@ -135,7 +135,7 @@ PayloadHandlers[HubToLocalMessagePayload.SetRfTxPinCommandResult] = (cli, msg) = const result = payload.result(); if (result == SetGPIOResultCode.Success) { - DeviceStateStore.setRfTxPin(payload.pin()); + HubStateStore.setRfTxPin(payload.pin()); toastDelegator.trigger({ message: 'Changed RF TX pin to: ' + payload.pin(), background: 'bg-green-500', @@ -168,7 +168,7 @@ PayloadHandlers[HubToLocalMessagePayload.SetEstopEnabledCommandResult] = (cli, m const success = payload.success(); if (success) { - DeviceStateStore.setEstopEnabled(payload.enabled()); + HubStateStore.setEstopEnabled(payload.enabled()); toastDelegator.trigger({ message: 'Changed EStop enabled to: ' + enabled, background: 'bg-green-500', @@ -189,7 +189,7 @@ PayloadHandlers[HubToLocalMessagePayload.SetEstopPinCommandResult] = (cli, msg) if (result == SetGPIOResultCode.Success) { const gpioPin = payload.gpioPin(); - DeviceStateStore.setEstopGpioPin(gpioPin); + HubStateStore.setEstopGpioPin(gpioPin); toastDelegator.trigger({ message: 'Changed EStop pin to: ' + gpioPin, background: 'bg-green-500', diff --git a/frontend/src/lib/components/GpioPinSelector.svelte b/frontend/src/lib/components/GpioPinSelector.svelte index 6c5d1766..e7256b3c 100644 --- a/frontend/src/lib/components/GpioPinSelector.svelte +++ b/frontend/src/lib/components/GpioPinSelector.svelte @@ -1,5 +1,5 @@