add paxcounter config
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
import type { PaxcounterValidation } from "@app/validation/moduleConfig/paxcounter.js";
|
||||||
|
import { DynamicForm } from "@components/Form/DynamicForm.js";
|
||||||
|
import { useDevice } from "@core/stores/deviceStore.js";
|
||||||
|
import { Protobuf } from "@meshtastic/js";
|
||||||
|
|
||||||
|
export const Paxcounter = (): JSX.Element => {
|
||||||
|
const { moduleConfig, setWorkingModuleConfig } = useDevice();
|
||||||
|
|
||||||
|
const onSubmit = (data: PaxcounterValidation) => {
|
||||||
|
setWorkingModuleConfig(
|
||||||
|
new Protobuf.ModuleConfig.ModuleConfig({
|
||||||
|
payloadVariant: {
|
||||||
|
case: "paxcounter",
|
||||||
|
value: data,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DynamicForm<PaxcounterValidation>
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
defaultValues={moduleConfig.paxcounter}
|
||||||
|
fieldGroups={[
|
||||||
|
{
|
||||||
|
label: "Paxcounter Settings",
|
||||||
|
description: "Settings for the Paxcounter module",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: "toggle",
|
||||||
|
name: "enabled",
|
||||||
|
label: "Module Enabled",
|
||||||
|
description: "Enable Paxcounter",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "number",
|
||||||
|
name: "paxcounterUpdateInterval",
|
||||||
|
label: "Update Interval (seconds)",
|
||||||
|
description: "How long to wait between sending paxcounter packets",
|
||||||
|
disabledBy: [
|
||||||
|
{
|
||||||
|
fieldName: "enabled",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -243,6 +243,11 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
|||||||
config.payloadVariant.value;
|
config.payloadVariant.value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "paxcounter": {
|
||||||
|
device.moduleConfig.paxcounter =
|
||||||
|
config.payloadVariant.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { RangeTest } from "@components/PageComponents/ModuleConfig/RangeTest.js"
|
|||||||
import { Serial } from "@components/PageComponents/ModuleConfig/Serial.js";
|
import { Serial } from "@components/PageComponents/ModuleConfig/Serial.js";
|
||||||
import { StoreForward } from "@components/PageComponents/ModuleConfig/StoreForward.js";
|
import { StoreForward } from "@components/PageComponents/ModuleConfig/StoreForward.js";
|
||||||
import { Telemetry } from "@components/PageComponents/ModuleConfig/Telemetry.js";
|
import { Telemetry } from "@components/PageComponents/ModuleConfig/Telemetry.js";
|
||||||
|
import { Paxcounter } from "@components/PageComponents/ModuleConfig/Paxcounter.js";
|
||||||
import {
|
import {
|
||||||
Tabs,
|
Tabs,
|
||||||
TabsContent,
|
TabsContent,
|
||||||
@@ -62,6 +63,10 @@ export const ModuleConfig = (): JSX.Element => {
|
|||||||
label: "Detection Sensor",
|
label: "Detection Sensor",
|
||||||
element: DetectionSensor,
|
element: DetectionSensor,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Paxcounter",
|
||||||
|
element: Paxcounter,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import type { Message } from "@bufbuild/protobuf";
|
||||||
|
import type { Protobuf } from "@meshtastic/js";
|
||||||
|
import { IsBoolean, IsInt } from "class-validator";
|
||||||
|
|
||||||
|
export class PaxcounterValidation
|
||||||
|
implements
|
||||||
|
Omit<Protobuf.ModuleConfig.ModuleConfig_PaxcounterConfig, keyof Message>
|
||||||
|
{
|
||||||
|
@IsBoolean()
|
||||||
|
enabled: boolean;
|
||||||
|
|
||||||
|
@IsInt()
|
||||||
|
paxcounterUpdateInterval: number;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user