You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.0 KiB
73 lines
2.0 KiB
import type { BluetoothValidation } from "@app/validation/config/bluetooth.js";
|
|
import { useDevice } from "@core/stores/deviceStore.js";
|
|
import { Protobuf } from "@meshtastic/meshtasticjs";
|
|
import { DynamicForm } from "@components/Form/DynamicForm.js";
|
|
|
|
export const Bluetooth = (): JSX.Element => {
|
|
const { config, setWorkingConfig } = useDevice();
|
|
|
|
const onSubmit = (data: BluetoothValidation) => {
|
|
setWorkingConfig(
|
|
new Protobuf.Config({
|
|
payloadVariant: {
|
|
case: "bluetooth",
|
|
value: data
|
|
}
|
|
})
|
|
);
|
|
};
|
|
|
|
return (
|
|
<DynamicForm<BluetoothValidation>
|
|
onSubmit={onSubmit}
|
|
defaultValues={config.bluetooth}
|
|
fieldGroups={[
|
|
{
|
|
label: "Bluetooth Settings",
|
|
description: "Settings for the Bluetooth module",
|
|
fields: [
|
|
{
|
|
type: "toggle",
|
|
name: "enabled",
|
|
label: "Enabled",
|
|
description: "Enable or disable Bluetooth"
|
|
},
|
|
{
|
|
type: "select",
|
|
name: "mode",
|
|
label: "Pairing mode",
|
|
description: "Pin selection behaviour.",
|
|
disabledBy: [
|
|
{
|
|
fieldName: "enabled"
|
|
}
|
|
],
|
|
properties: {
|
|
enumValue: Protobuf.Config_BluetoothConfig_PairingMode,
|
|
formatEnumName: true
|
|
}
|
|
},
|
|
{
|
|
type: "number",
|
|
name: "fixedPin",
|
|
label: "Pin",
|
|
description: "Pin to use when pairing",
|
|
disabledBy: [
|
|
{
|
|
fieldName: "mode",
|
|
selector:
|
|
Protobuf.Config_BluetoothConfig_PairingMode.FIXED_PIN,
|
|
invert: true
|
|
},
|
|
{
|
|
fieldName: "enabled"
|
|
}
|
|
],
|
|
properties: {}
|
|
}
|
|
]
|
|
}
|
|
]}
|
|
/>
|
|
);
|
|
};
|
|
|