Skip to content

Commit

Permalink
update to namespaced protobufs
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaw committed Jan 3, 2024
1 parent a4a5061 commit 8641c15
Show file tree
Hide file tree
Showing 53 changed files with 568 additions and 572 deletions.
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meshtastic-web",
"version": "2.2.16-0",
"version": "2.2.17-0",
"type": "module",
"description": "Meshtastic web client",
"license": "GPL-3.0-only",
Expand All @@ -20,8 +20,9 @@
},
"homepage": "https://meshtastic.org",
"dependencies": {
"@bufbuild/protobuf": "^1.6.0",
"@emeraldpay/hashicon-react": "^0.5.2",
"@meshtastic/js": "2.2.16-0",
"@meshtastic/js": "2.2.17-4",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
Expand All @@ -41,10 +42,10 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"clsx": "^2.1.0",
"cmdk": "^0.2.0",
"immer": "^10.0.3",
"lucide-react": "^0.302.0",
"lucide-react": "^0.303.0",
"mapbox-gl": "npm:empty-npm-package@^1.0.0",
"maplibre-gl": "3.6.2",
"react": "^18.2.0",
Expand All @@ -59,9 +60,10 @@
"zustand": "4.4.7"
},
"devDependencies": {
"@buf/meshtastic_protobufs.bufbuild_es": "1.6.0-20231227193150-3f9c1dfd2a29.1",
"@types/chrome": "^0.0.254",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"@types/node": "^20.10.6",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@types/w3c-web-serial": "^1.0.6",
"@types/web-bluetooth": "^0.0.20",
Expand All @@ -70,7 +72,7 @@
"biome": "^0.3.3",
"gzipper": "^7.2.0",
"postcss": "^8.4.32",
"rollup-plugin-visualizer": "^5.11.0",
"rollup-plugin-visualizer": "^5.12.0",
"tailwindcss": "^3.4.0",
"tar": "^6.2.0",
"tslib": "^2.6.2",
Expand Down
674 changes: 341 additions & 333 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/Dialog/DeviceNameDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const DeviceNameDialog = ({

const onSubmit = handleSubmit((data) => {
connection?.setOwner(
new Protobuf.User({
new Protobuf.Mesh.User({
...myNode?.user,
...data,
}),
Expand Down
16 changes: 9 additions & 7 deletions src/components/Dialog/ImportDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ 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 = ({
open,
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();
Expand All @@ -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);
Expand All @@ -50,20 +52,20 @@ 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,
}),
);
});

if (channelSet?.loraConfig) {
connection?.setConfig(
new Protobuf.Config({
new Protobuf.Config.Config({
payloadVariant: {
case: "lora",
value: channelSet.loraConfig,
Expand Down
12 changes: 6 additions & 6 deletions src/components/Dialog/QRDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand All @@ -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,
}),
Expand Down Expand Up @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions src/components/PageComponents/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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 => {
const { connection, addChannel } = useDevice();
const { toast } = useToast();

const onSubmit = (data: ChannelValidation) => {
const channel = new Protobuf.Channel({
const channel = new Protobuf.Channel.Channel({
...data,
settings: {
...data.settings,
Expand Down Expand Up @@ -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,
},
},
{
Expand Down
7 changes: 4 additions & 3 deletions src/components/PageComponents/Config/Bluetooth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -43,7 +43,7 @@ export const Bluetooth = (): JSX.Element => {
},
],
properties: {
enumValue: Protobuf.Config_BluetoothConfig_PairingMode,
enumValue: Protobuf.Config.Config_BluetoothConfig_PairingMode,
formatEnumName: true,
},
},
Expand All @@ -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,
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/components/PageComponents/Config/Device.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
},
Expand Down Expand Up @@ -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,
},
},
Expand Down
11 changes: 6 additions & 5 deletions src/components/PageComponents/Config/Display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
},
{
Expand All @@ -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,
},
},
Expand All @@ -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,
},
},
{
Expand All @@ -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,
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/PageComponents/Config/LoRa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
},
{
Expand Down Expand Up @@ -70,7 +70,7 @@ export const LoRa = (): JSX.Element => {
},
],
properties: {
enumValue: Protobuf.Config_LoRaConfig_ModemPreset,
enumValue: Protobuf.Config.Config_LoRaConfig_ModemPreset,
formatEnumName: true,
},
},
Expand Down
18 changes: 11 additions & 7 deletions src/components/PageComponents/Config/Network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
},
Expand Down Expand Up @@ -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,
},
},
{
Expand All @@ -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,
},
],
},
Expand All @@ -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,
},
],
},
Expand All @@ -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,
},
],
},
Expand All @@ -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,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/PageComponents/Config/Position.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageComponents/Config/Power.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 8641c15

Please sign in to comment.