wip
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
"imports": {
|
"imports": {
|
||||||
|
"@meshtastic/core": "jsr:@meshtastic/core@^2.6.2",
|
||||||
|
"@meshtastic/js": "jsr:@meshtastic/js@^2.3.4",
|
||||||
|
"@meshtastic/transport-http": "jsr:@meshtastic/transport-http@^0.2.1",
|
||||||
|
"@meshtastic/transport-web-bluetooth": "jsr:@meshtastic/transport-web-bluetooth@^0.1.1",
|
||||||
|
"@meshtastic/transport-web-serial": "jsr:@meshtastic/transport-web-serial@^0.2.1",
|
||||||
"@app/": "./src/",
|
"@app/": "./src/",
|
||||||
"@pages/": "./src/pages/",
|
"@pages/": "./src/pages/",
|
||||||
"@components/": "./src/components/",
|
"@components/": "./src/components/",
|
||||||
|
|||||||
+1
-4
@@ -35,10 +35,6 @@
|
|||||||
"homepage": "https://meshtastic.org",
|
"homepage": "https://meshtastic.org",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@bufbuild/protobuf": "^2.2.3",
|
"@bufbuild/protobuf": "^2.2.3",
|
||||||
"@meshtastic/core": "npm:@jsr/meshtastic__core@2.6.0-0",
|
|
||||||
"@meshtastic/js": "npm:@jsr/meshtastic__js@2.6.0-0",
|
|
||||||
"@meshtastic/transport-http": "npm:@jsr/meshtastic__transport-http",
|
|
||||||
"@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial",
|
|
||||||
"@noble/curves": "^1.8.1",
|
"@noble/curves": "^1.8.1",
|
||||||
"@radix-ui/react-accordion": "^1.2.3",
|
"@radix-ui/react-accordion": "^1.2.3",
|
||||||
"@radix-ui/react-checkbox": "^1.1.4",
|
"@radix-ui/react-checkbox": "^1.1.4",
|
||||||
@@ -74,6 +70,7 @@
|
|||||||
"react-qrcode-logo": "^3.0.0",
|
"react-qrcode-logo": "^3.0.0",
|
||||||
"rfc4648": "^1.5.4",
|
"rfc4648": "^1.5.4",
|
||||||
"vite-plugin-node-polyfills": "^0.23.0",
|
"vite-plugin-node-polyfills": "^0.23.0",
|
||||||
|
"zod": "^3.24.2",
|
||||||
"zustand": "5.0.3"
|
"zustand": "5.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -10,13 +10,14 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@components/UI/Select.tsx";
|
} from "@components/UI/Select.tsx";
|
||||||
import { useController, type FieldValues } from "react-hook-form";
|
import { useController, type FieldValues } from "react-hook-form";
|
||||||
import { computeHeadingLevel } from "@core/utils/test.tsx";
|
|
||||||
|
|
||||||
export interface SelectFieldProps<T> extends BaseFormBuilderProps<T> {
|
export interface SelectFieldProps<T> extends BaseFormBuilderProps<T> {
|
||||||
type: "select";
|
type: "select";
|
||||||
selectChange?: (e: string, name: string) => void;
|
selectChange?: (e: string, name: string) => void;
|
||||||
validate?: (newValue: string) => Promise<boolean>;
|
validate?: (newValue: string) => Promise<boolean>;
|
||||||
|
defaultValue?: string;
|
||||||
properties: BaseFormBuilderProps<T>["properties"] & {
|
properties: BaseFormBuilderProps<T>["properties"] & {
|
||||||
|
defaultValue?: T;
|
||||||
enumValue: {
|
enumValue: {
|
||||||
[s: string]: string | number;
|
[s: string]: string | number;
|
||||||
};
|
};
|
||||||
@@ -38,11 +39,15 @@ export function SelectInput<T extends FieldValues>({
|
|||||||
disabled,
|
disabled,
|
||||||
field,
|
field,
|
||||||
}: GenericFormElementProps<T, SelectFieldProps<T>>) {
|
}: GenericFormElementProps<T, SelectFieldProps<T>>) {
|
||||||
|
// Get default value and set it
|
||||||
|
const defaultValue = field.properties.defaultValue ?? field.defaultValue;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
field: { value, onChange, ...rest },
|
field: { value, onChange, ...rest },
|
||||||
} = useController({
|
} = useController({
|
||||||
name: field.name,
|
name: field.name,
|
||||||
control,
|
control,
|
||||||
|
defaultValue: defaultValue ? defaultValue.toString() : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { enumValue, formatEnumName, ...remainingProperties } = field.properties;
|
const { enumValue, formatEnumName, ...remainingProperties } = field.properties;
|
||||||
@@ -70,12 +75,12 @@ export function SelectInput<T extends FieldValues>({
|
|||||||
onChange(Number.parseInt(newValue));
|
onChange(Number.parseInt(newValue));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
onValueChange={handleValueChange}
|
onValueChange={handleValueChange}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={value?.toString()}
|
value={value?.toString()}
|
||||||
|
defaultValue={defaultValue?.toString()}
|
||||||
{...remainingProperties}
|
{...remainingProperties}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { NetworkValidation } from "@app/validation/config/network.tsx";
|
import type { NetworkValidation } from "@app/validation/config/network.ts";
|
||||||
import { create } from "@bufbuild/protobuf";
|
import { create } from "@bufbuild/protobuf";
|
||||||
import { DynamicForm } from "@components/Form/DynamicForm.tsx";
|
import { DynamicForm } from "@components/Form/DynamicForm.tsx";
|
||||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||||
@@ -12,6 +12,9 @@ export const Network = () => {
|
|||||||
const { config, setWorkingConfig } = useDevice();
|
const { config, setWorkingConfig } = useDevice();
|
||||||
|
|
||||||
const onSubmit = (data: NetworkValidation) => {
|
const onSubmit = (data: NetworkValidation) => {
|
||||||
|
|
||||||
|
console.log("Network data", data);
|
||||||
|
|
||||||
setWorkingConfig(
|
setWorkingConfig(
|
||||||
create(Protobuf.Config.ConfigSchema, {
|
create(Protobuf.Config.ConfigSchema, {
|
||||||
payloadVariant: {
|
payloadVariant: {
|
||||||
@@ -21,7 +24,7 @@ export const Network = () => {
|
|||||||
ipv4Config: create(
|
ipv4Config: create(
|
||||||
Protobuf.Config.Config_NetworkConfig_IpV4ConfigSchema,
|
Protobuf.Config.Config_NetworkConfig_IpV4ConfigSchema,
|
||||||
{
|
{
|
||||||
ip: convertIpAddressToInt(data.ipv4Config.ip) ?? 0,
|
ip: convertIpAddressToInt(data?.ipv4Config?.ip) ?? 0,
|
||||||
gateway: convertIpAddressToInt(data.ipv4Config.gateway) ?? 0,
|
gateway: convertIpAddressToInt(data.ipv4Config.gateway) ?? 0,
|
||||||
subnet: convertIpAddressToInt(data.ipv4Config.subnet) ?? 0,
|
subnet: convertIpAddressToInt(data.ipv4Config.subnet) ?? 0,
|
||||||
dns: convertIpAddressToInt(data.ipv4Config.dns) ?? 0,
|
dns: convertIpAddressToInt(data.ipv4Config.dns) ?? 0,
|
||||||
@@ -165,6 +168,22 @@ export const Network = () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "UDP Config",
|
||||||
|
description: "UDP over Mesh configuration",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: "select",
|
||||||
|
name: "enabledProtocols",
|
||||||
|
label: "Mesh via UDP enabled",
|
||||||
|
properties: {
|
||||||
|
enumValue:
|
||||||
|
Protobuf.Config.Config_NetworkConfig_ProtocolFlags,
|
||||||
|
formatEnumName: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "NTP Config",
|
label: "NTP Config",
|
||||||
description: "NTP configuration",
|
description: "NTP configuration",
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
export function convertIntToIpAddress(int: number): string {
|
export function convertIntToIpAddress(int: number): string {
|
||||||
return `${int & 0xff}.${(int >> 8) & 0xff}.${(int >> 16) & 0xff}.${
|
return `${int & 0xff}.${(int >> 8) & 0xff}.${(int >> 16) & 0xff}.${(int >> 24) & 0xff
|
||||||
(int >> 24) & 0xff
|
}`;
|
||||||
}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertIpAddressToInt(ip: string): number | null {
|
export function convertIpAddressToInt(ip: string): number | undefined {
|
||||||
|
if (!ip) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
ip
|
ip
|
||||||
.split(".")
|
.split(".")
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
|
|
||||||
export class NetworkValidation
|
export class NetworkValidation
|
||||||
implements
|
implements
|
||||||
Omit<Protobuf.Config.Config_NetworkConfig, keyof Message | "ipv4Config"> {
|
Omit<Protobuf.Config.Config_NetworkConfig, keyof Message | "ipv4Config"> {
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
wifiEnabled: boolean;
|
wifiEnabled: boolean;
|
||||||
|
|
||||||
@@ -34,6 +34,9 @@ export class NetworkValidation
|
|||||||
|
|
||||||
ipv4Config: NetworkValidationIpV4Config;
|
ipv4Config: NetworkValidationIpV4Config;
|
||||||
|
|
||||||
|
@IsEnum(Protobuf.Config.Config_NetworkConfig_EnabledProtocols)
|
||||||
|
enabledProtocols: Protobuf.Config.Config_NetworkConfig_ProtocolFlags;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
rsyslogServer: string;
|
rsyslogServer: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user