Skip to content

Commit fb9a460

Browse files
committed
feat(frontend): add ethernet support
1 parent 3bbc51e commit fb9a460

File tree

9 files changed

+637
-0
lines changed

9 files changed

+637
-0
lines changed

docs/stores.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ It exposes the following properties you can subscribe to:
6464
| `$telemetry.download_ota.status` | `String` | Status of OTA |
6565
| `$telemetry.download_ota.progress` | `Number` | Progress of OTA |
6666
| `$telemetry.download_ota.error` | `String` | Error Message of OTA |
67+
| `$telemetry.ethernet.connected` | `Boolean` | Connection status of the ethernet interface |
6768

6869
## Analytics
6970

interface/src/lib/stores/telemetry.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { writable } from 'svelte/store';
22
import type { RSSI } from '../types/models';
33
import type { Battery } from '../types/models';
44
import type { DownloadOTA } from '../types/models';
5+
import type { Ethernet } from '../types/models';
56

67
let telemetry_data = {
78
rssi: {
@@ -17,6 +18,9 @@ let telemetry_data = {
1718
status: 'none',
1819
progress: 0,
1920
error: ''
21+
},
22+
ethernet: {
23+
connected: false
2024
}
2125
};
2226

@@ -49,6 +53,12 @@ function createTelemetry() {
4953
...telemetry_data,
5054
download_ota: { status: data.status, progress: data.progress, error: data.error }
5155
}));
56+
},
57+
setEthernet: (data: Ethernet) => {
58+
update((telemetry_data) => ({
59+
...telemetry_data,
60+
ethernet: { connected: data.connected }
61+
}));
5262
}
5363
};
5464
}

interface/src/lib/types/models.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,29 @@ export type MQTTSettings = {
148148
clean_session: boolean;
149149
message_interval_ms: number;
150150
};
151+
152+
153+
export type Ethernet = {
154+
connected: boolean;
155+
};
156+
157+
export type EthernetStatus = {
158+
connected: boolean;
159+
local_ip: string;
160+
mac_address: string;
161+
subnet_mask: string;
162+
gateway_ip?: string;
163+
dns_ip_1?: string;
164+
dns_ip_2?: string;
165+
link_speed?: number;
166+
};
167+
168+
export type EthernetSettings = {
169+
hostname: string;
170+
static_ip_config: boolean;
171+
local_ip?: string;
172+
subnet_mask?: string;
173+
gateway_ip?: string;
174+
dns_ip_1?: string;
175+
dns_ip_2?: string;
176+
};

interface/src/routes/+layout.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import type { RSSI } from '$lib/types/models';
2121
import type { Battery } from '$lib/types/models';
2222
import type { DownloadOTA } from '$lib/types/models';
23+
import type { Ethernet } from '$lib/types/models';
2324
2425
interface Props {
2526
data: LayoutData;
@@ -60,6 +61,7 @@
6061
if (page.data.features.analytics) socket.on('analytics', handleAnalytics);
6162
if (page.data.features.battery) socket.on('battery', handleBattery);
6263
if (page.data.features.download_firmware) socket.on('otastatus', handleOAT);
64+
if (page.data.features.ethernet) socket.on('ethernet', handleEthernet);
6365
};
6466
6567
const removeEventListeners = () => {
@@ -70,6 +72,7 @@
7072
socket.off('notification', handleNotification);
7173
socket.off('battery', handleBattery);
7274
socket.off('otastatus', handleOAT);
75+
socket.off('ethernet', handleEthernet);
7376
};
7477
7578
async function validateUser(userdata: userProfile) {
@@ -130,6 +133,10 @@
130133
131134
const handleOAT = (data: DownloadOTA) => telemetry.setDownloadOTA(data);
132135
136+
const handleEthernet = (data: Ethernet) => {
137+
telemetry.setEthernet(data);
138+
};
139+
133140
let menuOpen = $state(false);
134141
</script>
135142

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script lang="ts">
2+
import type { PageData } from './$types';
3+
import Ethernet from './Ethernet.svelte';
4+
5+
interface Props {
6+
data: PageData;
7+
}
8+
9+
let { data }: Props = $props();
10+
</script>
11+
12+
<div
13+
class="mx-0 my-1 flex flex-col space-y-4
14+
sm:mx-8 sm:my-8"
15+
>
16+
<Ethernet />
17+
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { PageLoad } from './$types';
2+
3+
export const load = (async () => {
4+
return {
5+
title: 'Ethernet'
6+
};
7+
}) satisfies PageLoad;

0 commit comments

Comments
 (0)