update to namespaced protobufs

This commit is contained in:
Sacha Weatherstone
2024-01-03 14:22:18 +10:00
parent a4a5061171
commit 8641c150dd
53 changed files with 568 additions and 572 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ export const DeviceNameDialog = ({
const onSubmit = handleSubmit((data) => {
connection?.setOwner(
new Protobuf.User({
new Protobuf.Mesh.User({
...myNode?.user,
...data,
}),
+9 -7
View File
@@ -19,7 +19,7 @@ import { useEffect, useState } from "react";
export interface ImportDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
loraConfig?: Protobuf.Config_LoRaConfig;
loraConfig?: Protobuf.Config.Config_LoRaConfig;
}
export const ImportDialog = ({
@@ -27,7 +27,7 @@ export const ImportDialog = ({
onOpenChange,
}: ImportDialogProps): JSX.Element => {
const [QRCodeURL, setQRCodeURL] = useState<string>("");
const [channelSet, setChannelSet] = useState<Protobuf.ChannelSet>();
const [channelSet, setChannelSet] = useState<Protobuf.AppOnly.ChannelSet>();
const [validURL, setValidURL] = useState<boolean>(false);
const { connection } = useDevice();
@@ -39,7 +39,9 @@ export const ImportDialog = ({
.replace(/-/g, "+")
.replace(/_/g, "/");
try {
setChannelSet(Protobuf.ChannelSet.fromBinary(toByteArray(paddedString)));
setChannelSet(
Protobuf.AppOnly.ChannelSet.fromBinary(toByteArray(paddedString)),
);
setValidURL(true);
} catch (error) {
setValidURL(false);
@@ -50,12 +52,12 @@ export const ImportDialog = ({
const apply = () => {
channelSet?.settings.map((ch, index) => {
connection?.setChannel(
new Protobuf.Channel({
new Protobuf.Channel.Channel({
index,
role:
index === 0
? Protobuf.Channel_Role.PRIMARY
: Protobuf.Channel_Role.SECONDARY,
? Protobuf.Channel.Channel_Role.PRIMARY
: Protobuf.Channel.Channel_Role.SECONDARY,
settings: ch,
}),
);
@@ -63,7 +65,7 @@ export const ImportDialog = ({
if (channelSet?.loraConfig) {
connection?.setConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "lora",
value: channelSet.loraConfig,
+6 -6
View File
@@ -18,8 +18,8 @@ import { QRCode } from "react-qrcode-logo";
export interface QRDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
loraConfig?: Protobuf.Config_LoRaConfig;
channels: Map<Types.ChannelNumber, Protobuf.Channel>;
loraConfig?: Protobuf.Config.Config_LoRaConfig;
channels: Map<Types.ChannelNumber, Protobuf.Channel.Channel>;
}
export const QRDialog = ({
@@ -37,9 +37,9 @@ export const QRDialog = ({
const channelsToEncode = allChannels
.filter((ch) => selectedChannels.includes(ch.index))
.map((channel) => channel.settings)
.filter((ch): ch is Protobuf.ChannelSettings => !!ch);
const encoded = new Protobuf.ChannelSet(
new Protobuf.ChannelSet({
.filter((ch): ch is Protobuf.Channel.ChannelSettings => !!ch);
const encoded = new Protobuf.AppOnly.ChannelSet(
new Protobuf.AppOnly.ChannelSet({
loraConfig,
settings: channelsToEncode,
}),
@@ -69,7 +69,7 @@ export const QRDialog = ({
<Label>
{channel.settings?.name.length
? channel.settings.name
: channel.role === Protobuf.Channel_Role.PRIMARY
: channel.role === Protobuf.Channel.Channel_Role.PRIMARY
? "Primary"
: `Channel: ${channel.index}`}
</Label>
+3 -3
View File
@@ -6,7 +6,7 @@ import { Protobuf } from "@meshtastic/js";
import { fromByteArray, toByteArray } from "base64-js";
export interface SettingsPanelProps {
channel: Protobuf.Channel;
channel: Protobuf.Channel.Channel;
}
export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
@@ -14,7 +14,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
const { toast } = useToast();
const onSubmit = (data: ChannelValidation) => {
const channel = new Protobuf.Channel({
const channel = new Protobuf.Channel.Channel({
...data,
settings: {
...data.settings,
@@ -55,7 +55,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
description:
"Device telemetry is sent over PRIMARY. Only one PRIMARY allowed",
properties: {
enumValue: Protobuf.Channel_Role,
enumValue: Protobuf.Channel.Channel_Role,
},
},
{
@@ -8,7 +8,7 @@ export const Bluetooth = (): JSX.Element => {
const onSubmit = (data: BluetoothValidation) => {
setWorkingConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "bluetooth",
value: data,
@@ -43,7 +43,7 @@ export const Bluetooth = (): JSX.Element => {
},
],
properties: {
enumValue: Protobuf.Config_BluetoothConfig_PairingMode,
enumValue: Protobuf.Config.Config_BluetoothConfig_PairingMode,
formatEnumName: true,
},
},
@@ -56,7 +56,8 @@ export const Bluetooth = (): JSX.Element => {
{
fieldName: "mode",
selector:
Protobuf.Config_BluetoothConfig_PairingMode.FIXED_PIN,
Protobuf.Config.Config_BluetoothConfig_PairingMode
.FIXED_PIN,
invert: true,
},
{
@@ -8,7 +8,7 @@ export const Device = (): JSX.Element => {
const onSubmit = (data: DeviceValidation) => {
setWorkingConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "device",
value: data,
@@ -32,7 +32,7 @@ export const Device = (): JSX.Element => {
label: "Role",
description: "What role the device performs on the mesh",
properties: {
enumValue: Protobuf.Config_DeviceConfig_Role,
enumValue: Protobuf.Config.Config_DeviceConfig_Role,
formatEnumName: true,
},
},
@@ -67,7 +67,7 @@ export const Device = (): JSX.Element => {
label: "Rebroadcast Mode",
description: "How to handle rebroadcasting",
properties: {
enumValue: Protobuf.Config_DeviceConfig_RebroadcastMode,
enumValue: Protobuf.Config.Config_DeviceConfig_RebroadcastMode,
formatEnumName: true,
},
},
@@ -8,7 +8,7 @@ export const Display = (): JSX.Element => {
const onSubmit = (data: DisplayValidation) => {
setWorkingConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "display",
value: data,
@@ -41,7 +41,8 @@ export const Display = (): JSX.Element => {
label: "GPS Display Units",
description: "Coordinate display format",
properties: {
enumValue: Protobuf.Config_DisplayConfig_GpsCoordinateFormat,
enumValue:
Protobuf.Config.Config_DisplayConfig_GpsCoordinateFormat,
},
},
{
@@ -68,7 +69,7 @@ export const Display = (): JSX.Element => {
label: "Display Units",
description: "Display metric or imperial units",
properties: {
enumValue: Protobuf.Config_DisplayConfig_DisplayUnits,
enumValue: Protobuf.Config.Config_DisplayConfig_DisplayUnits,
formatEnumName: true,
},
},
@@ -78,7 +79,7 @@ export const Display = (): JSX.Element => {
label: "OLED Type",
description: "Type of OLED screen attached to the device",
properties: {
enumValue: Protobuf.Config_DisplayConfig_OledType,
enumValue: Protobuf.Config.Config_DisplayConfig_OledType,
},
},
{
@@ -87,7 +88,7 @@ export const Display = (): JSX.Element => {
label: "Display Mode",
description: "Screen layout variant",
properties: {
enumValue: Protobuf.Config_DisplayConfig_DisplayMode,
enumValue: Protobuf.Config.Config_DisplayConfig_DisplayMode,
formatEnumName: true,
},
},
@@ -8,7 +8,7 @@ export const LoRa = (): JSX.Element => {
const onSubmit = (data: LoRaValidation) => {
setWorkingConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "lora",
value: data,
@@ -32,7 +32,7 @@ export const LoRa = (): JSX.Element => {
label: "Region",
description: "Sets the region for your node",
properties: {
enumValue: Protobuf.Config_LoRaConfig_RegionCode,
enumValue: Protobuf.Config.Config_LoRaConfig_RegionCode,
},
},
{
@@ -70,7 +70,7 @@ export const LoRa = (): JSX.Element => {
},
],
properties: {
enumValue: Protobuf.Config_LoRaConfig_ModemPreset,
enumValue: Protobuf.Config.Config_LoRaConfig_ModemPreset,
formatEnumName: true,
},
},
@@ -8,12 +8,12 @@ export const Network = (): JSX.Element => {
const onSubmit = (data: NetworkValidation) => {
setWorkingConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "network",
value: {
...data,
ipv4Config: new Protobuf.Config_NetworkConfig_IpV4Config(
ipv4Config: new Protobuf.Config.Config_NetworkConfig_IpV4Config(
data.ipv4Config,
),
},
@@ -83,7 +83,7 @@ export const Network = (): JSX.Element => {
label: "Address Mode",
description: "Address assignment selection",
properties: {
enumValue: Protobuf.Config_NetworkConfig_AddressMode,
enumValue: Protobuf.Config.Config_NetworkConfig_AddressMode,
},
},
{
@@ -94,7 +94,8 @@ export const Network = (): JSX.Element => {
disabledBy: [
{
fieldName: "addressMode",
selector: Protobuf.Config_NetworkConfig_AddressMode.DHCP,
selector:
Protobuf.Config.Config_NetworkConfig_AddressMode.DHCP,
},
],
},
@@ -106,7 +107,8 @@ export const Network = (): JSX.Element => {
disabledBy: [
{
fieldName: "addressMode",
selector: Protobuf.Config_NetworkConfig_AddressMode.DHCP,
selector:
Protobuf.Config.Config_NetworkConfig_AddressMode.DHCP,
},
],
},
@@ -118,7 +120,8 @@ export const Network = (): JSX.Element => {
disabledBy: [
{
fieldName: "addressMode",
selector: Protobuf.Config_NetworkConfig_AddressMode.DHCP,
selector:
Protobuf.Config.Config_NetworkConfig_AddressMode.DHCP,
},
],
},
@@ -130,7 +133,8 @@ export const Network = (): JSX.Element => {
disabledBy: [
{
fieldName: "addressMode",
selector: Protobuf.Config_NetworkConfig_AddressMode.DHCP,
selector:
Protobuf.Config.Config_NetworkConfig_AddressMode.DHCP,
},
],
},
@@ -8,7 +8,7 @@ export const Position = (): JSX.Element => {
const onSubmit = (data: PositionValidation) => {
setWorkingConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "position",
value: data,
@@ -52,7 +52,7 @@ export const Position = (): JSX.Element => {
label: "Position Flags",
description: "Configuration options for Position messages",
properties: {
enumValue: Protobuf.Config_PositionConfig_PositionFlags,
enumValue: Protobuf.Config.Config_PositionConfig_PositionFlags,
},
},
{
@@ -8,7 +8,7 @@ export const Power = (): JSX.Element => {
const onSubmit = (data: PowerValidation) => {
setWorkingConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "power",
value: data,
@@ -4,7 +4,7 @@ import { useAppStore } from "@core/stores/appStore.js";
import { useDeviceStore } from "@core/stores/deviceStore.js";
import { subscribeAll } from "@core/subscriptions.js";
import { randId } from "@core/utils/randId.js";
import { Constants, IBLEConnection } from "@meshtastic/js";
import { Constants, BleConnection } from "@meshtastic/js";
import { useCallback, useEffect, useState } from "react";
export const BLE = (): JSX.Element => {
@@ -24,7 +24,7 @@ export const BLE = (): JSX.Element => {
const id = randId();
const device = addDevice(id);
setSelectedDevice(id);
const connection = new IBLEConnection(id);
const connection = new BleConnection(id);
await connection.connect({
device: bleDevice,
});
@@ -6,7 +6,7 @@ import { useAppStore } from "@core/stores/appStore.js";
import { useDeviceStore } from "@core/stores/deviceStore.js";
import { subscribeAll } from "@core/subscriptions.js";
import { randId } from "@core/utils/randId.js";
import { IHTTPConnection } from "@meshtastic/js";
import { HttpConnection } from "@meshtastic/js";
import { Controller, useForm, useWatch } from "react-hook-form";
export const HTTP = (): JSX.Element => {
@@ -36,7 +36,7 @@ export const HTTP = (): JSX.Element => {
const id = randId();
const device = addDevice(id);
setSelectedDevice(id);
const connection = new IHTTPConnection(id);
const connection = new HttpConnection(id);
// TODO: Promise never resolves
await connection.connect({
address: data.ip,
@@ -4,7 +4,7 @@ import { useAppStore } from "@core/stores/appStore.js";
import { useDeviceStore } from "@core/stores/deviceStore.js";
import { subscribeAll } from "@core/subscriptions.js";
import { randId } from "@core/utils/randId.js";
import { ISerialConnection } from "@meshtastic/js";
import { SerialConnection } from "@meshtastic/js";
import { useCallback, useEffect, useState } from "react";
export const Serial = (): JSX.Element => {
@@ -30,7 +30,7 @@ export const Serial = (): JSX.Element => {
const id = randId();
const device = addDevice(id);
setSelectedDevice(id);
const connection = new ISerialConnection(id);
const connection = new SerialConnection(id);
await connection
.connect({
port,
@@ -10,7 +10,7 @@ import {
export interface MessageProps {
lastMsgSameUser: boolean;
message: MessageWithState;
sender?: Protobuf.NodeInfo;
sender?: Protobuf.Mesh.NodeInfo;
}
export const Message = ({
@@ -8,7 +8,7 @@ export const AmbientLighting = (): JSX.Element => {
const onSubmit = (data: AmbientLightingValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "ambientLighting",
value: data,
@@ -8,7 +8,7 @@ export const Audio = (): JSX.Element => {
const onSubmit = (data: AudioValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "audio",
value: data,
@@ -44,7 +44,8 @@ export const Audio = (): JSX.Element => {
label: "Bitrate",
description: "Bitrate to use for audio encoding",
properties: {
enumValue: Protobuf.ModuleConfig_AudioConfig_Audio_Baud,
enumValue:
Protobuf.ModuleConfig.ModuleConfig_AudioConfig_Audio_Baud,
},
},
{
@@ -8,7 +8,7 @@ export const CannedMessage = (): JSX.Element => {
const onSubmit = (data: CannedMessageValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "cannedMessage",
value: data,
@@ -63,7 +63,8 @@ export const CannedMessage = (): JSX.Element => {
description: "Select input event.",
properties: {
enumValue:
Protobuf.ModuleConfig_CannedMessageConfig_InputEventChar,
Protobuf.ModuleConfig
.ModuleConfig_CannedMessageConfig_InputEventChar,
},
},
{
@@ -73,7 +74,8 @@ export const CannedMessage = (): JSX.Element => {
description: "Select input event.",
properties: {
enumValue:
Protobuf.ModuleConfig_CannedMessageConfig_InputEventChar,
Protobuf.ModuleConfig
.ModuleConfig_CannedMessageConfig_InputEventChar,
},
},
{
@@ -83,7 +85,8 @@ export const CannedMessage = (): JSX.Element => {
description: "Select input event",
properties: {
enumValue:
Protobuf.ModuleConfig_CannedMessageConfig_InputEventChar,
Protobuf.ModuleConfig
.ModuleConfig_CannedMessageConfig_InputEventChar,
},
},
{
@@ -8,7 +8,7 @@ export const DetectionSensor = (): JSX.Element => {
const onSubmit = (data: DetectionSensorValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "detectionSensor",
value: data,
@@ -8,7 +8,7 @@ export const ExternalNotification = (): JSX.Element => {
const onSubmit = (data: ExternalNotificationValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "externalNotification",
value: data,
@@ -1,14 +1,14 @@
import { useDevice } from "@app/core/stores/deviceStore.js";
import type { MQTTValidation } from "@app/validation/moduleConfig/mqtt.js";
import type { MqttValidation } from "@app/validation/moduleConfig/mqtt.js";
import { DynamicForm } from "@components/Form/DynamicForm.js";
import { Protobuf } from "@meshtastic/js";
export const MQTT = (): JSX.Element => {
const { moduleConfig, setWorkingModuleConfig } = useDevice();
const onSubmit = (data: MQTTValidation) => {
const onSubmit = (data: MqttValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "mqtt",
value: data,
@@ -18,7 +18,7 @@ export const MQTT = (): JSX.Element => {
};
return (
<DynamicForm<MQTTValidation>
<DynamicForm<MqttValidation>
onSubmit={onSubmit}
defaultValues={moduleConfig.mqtt}
fieldGroups={[
@@ -8,7 +8,7 @@ export const NeighborInfo = (): JSX.Element => {
const onSubmit = (data: NeighborInfoValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "neighborInfo",
value: data,
@@ -8,7 +8,7 @@ export const RangeTest = (): JSX.Element => {
const onSubmit = (data: RangeTestValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "rangeTest",
value: data,
@@ -8,7 +8,7 @@ export const Serial = (): JSX.Element => {
const onSubmit = (data: SerialValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "serial",
value: data,
@@ -78,7 +78,8 @@ export const Serial = (): JSX.Element => {
},
],
properties: {
enumValue: Protobuf.ModuleConfig_SerialConfig_Serial_Baud,
enumValue:
Protobuf.ModuleConfig.ModuleConfig_SerialConfig_Serial_Baud,
},
},
{
@@ -109,7 +110,8 @@ export const Serial = (): JSX.Element => {
},
],
properties: {
enumValue: Protobuf.ModuleConfig_SerialConfig_Serial_Mode,
enumValue:
Protobuf.ModuleConfig.ModuleConfig_SerialConfig_Serial_Mode,
formatEnumName: true,
},
},
@@ -8,7 +8,7 @@ export const StoreForward = (): JSX.Element => {
const onSubmit = (data: StoreForwardValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "storeForward",
value: data,
@@ -8,7 +8,7 @@ export const Telemetry = (): JSX.Element => {
const onSubmit = (data: TelemetryValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
new Protobuf.ModuleConfig.ModuleConfig({
payloadVariant: {
case: "telemetry",
value: data,