Compare commits
202 commits
docker-imp
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8dc7cdb811 | |||
| b9ed0914d4 | |||
| fc4fff532a | |||
| e22b835114 | |||
| d452e8b3ad | |||
| 720f3b1529 | |||
| 8c54e71efc | |||
| 6e6bb22a9c | |||
| c090352c32 | |||
| 7a57d252dd | |||
| 8bb4d9d9dd | |||
| 33c24d9fe6 | |||
| a0181b8e0f | |||
| 360694842c | |||
|
|
8fd6730e0d | ||
|
|
1748079708 | ||
|
|
4a4b5fb7f3 | ||
|
|
dc9a45a62a | ||
|
|
f3154cb97b | ||
|
|
57c10383e2 | ||
|
|
f690bb65a7 | ||
|
|
f79ff5b7e4 | ||
|
|
71d32d1cd0 | ||
|
|
556dde517b | ||
|
|
1333447398 | ||
|
|
58d71c8c74 | ||
|
|
57dce4f099 | ||
|
|
3cfb7e7dff | ||
|
|
db4008d86a | ||
|
|
d9aaeb4479 | ||
|
|
6deefed3f7 | ||
|
|
8ef35660ea | ||
|
|
cbbde6c50a | ||
|
|
ef7053d243 | ||
|
|
a49c1b73ea | ||
|
|
9d0ade01a4 | ||
|
|
42b9e304e1 | ||
|
|
87a3da812a | ||
|
|
3441fb2475 | ||
|
|
f7fbb38961 | ||
|
|
aadd038880 | ||
|
|
328fb3e842 | ||
|
|
53728e4528 | ||
|
|
4927ab9920 | ||
|
|
cc07bfdaba | ||
|
|
8fd496c59d | ||
|
|
7a86783ba4 | ||
|
|
8575d87c18 | ||
|
|
b107e6489a | ||
|
|
e7afce1f3b | ||
|
|
c5f7690f0e | ||
|
|
32204a554d | ||
|
|
221aed8e97 | ||
|
|
737eeb3120 | ||
|
|
1fd9f1c737 | ||
|
|
da7809fd75 | ||
|
|
57d962ae89 | ||
|
|
3cf7c9479e | ||
|
|
998259042b | ||
|
|
9eae1d21b6 | ||
|
|
7d63cac3b9 | ||
|
|
0ffbf5e895 | ||
|
|
2d20bf293e | ||
|
|
f09cf5596a | ||
|
|
6682131cf1 | ||
|
|
7df3908c4b | ||
|
|
4d2ad549db | ||
|
|
b2473b419a | ||
|
|
f470b1b1b1 | ||
|
|
e8f796c5ad | ||
|
|
9d60cb07e0 | ||
|
|
c0c30d189d | ||
|
|
6ccdfc7d4b | ||
|
|
151fabece0 | ||
|
|
f08b225a82 | ||
|
|
e12252f585 | ||
|
|
a7b147d3ac | ||
|
|
4d9c591aea | ||
|
|
b762972ff3 | ||
|
|
8851bbc375 | ||
|
|
435788bda0 | ||
|
|
fe520b50b1 | ||
|
|
b1755d4b73 | ||
|
|
02529b8b5f | ||
|
|
5358bb8928 | ||
|
|
0be80d4177 | ||
|
|
2fd0e9c016 | ||
|
|
42d25add06 | ||
|
|
e4b9585d12 | ||
|
|
f1103748e6 | ||
|
|
07c3cc2c0d | ||
|
|
dff6ed035a | ||
|
|
a9e749a336 | ||
|
|
ce8adb88a4 | ||
|
|
41bafcaaff | ||
|
|
35d1fdbc6f | ||
|
|
63af2fbf9c | ||
|
|
c777a7bce2 | ||
|
|
5984b8b243 | ||
|
|
1ee526caf7 | ||
|
|
a7b99c3027 | ||
|
|
b668892248 | ||
|
|
0053b9f774 | ||
|
|
435c122c21 | ||
|
|
c5028f911f | ||
|
|
7fee84de77 | ||
|
|
162f8da79c | ||
|
|
ca9d1d9de0 | ||
|
|
8eb5c695f0 | ||
|
|
e11367544d | ||
|
|
cbcbeb9a22 | ||
|
|
4c745123c1 | ||
|
|
800dcfef78 | ||
|
|
e27f92d5c6 | ||
|
|
772faa550b | ||
|
|
a716d401a9 | ||
|
|
aeeb95554b | ||
|
|
bc78a0b0e3 | ||
|
|
aa57eb543f | ||
|
|
d5993aebb8 | ||
|
|
2b2ca982a0 | ||
|
|
d685826f15 | ||
|
|
91f98a6a09 | ||
|
|
3452efb1b7 | ||
|
|
54e83e5cdd | ||
|
|
d3ac48f044 | ||
|
|
24b90f6710 | ||
|
|
a77518facf | ||
|
|
c36a797967 | ||
|
|
5c83393cb1 | ||
|
|
5c0a7db8c6 | ||
|
|
201ba0d399 | ||
|
|
b31d10d434 | ||
|
|
96cc1ad1d5 | ||
|
|
ce2121d964 | ||
|
|
0c5b330681 | ||
|
|
2d1dd6fbb2 | ||
|
|
9e17347a7a | ||
|
|
6619e42bad | ||
|
|
e95bac1063 | ||
|
|
3eed255eb4 | ||
|
|
2bc82ae7a3 | ||
|
|
9d7a60efa5 | ||
|
|
8c064ac6e6 | ||
|
|
b3bb02fede | ||
|
|
11f5898996 | ||
|
|
17be3cb6a9 | ||
|
|
d95af37be5 | ||
|
|
e30fb12aa8 | ||
|
|
6691df73f5 | ||
|
|
9b69d0ce27 | ||
|
|
cf3f053e12 | ||
|
|
305f091142 | ||
|
|
4d1bdba6e0 | ||
|
|
6210f04ea5 | ||
|
|
99e31d8692 | ||
|
|
55cbdb63ba | ||
|
|
c251c5adb8 | ||
|
|
189c89a7ca | ||
|
|
8b84a3a91c | ||
|
|
6cd07fe314 | ||
|
|
fac5a91829 | ||
|
|
2fbaab81c5 | ||
|
|
bfb845ac37 | ||
|
|
274f0b8efa | ||
|
|
c8f322f012 | ||
|
|
f35a8876f9 | ||
|
|
af2a663dab | ||
|
|
342c8dc87a | ||
|
|
ff8bb07f7f | ||
|
|
9411c9e4cc | ||
|
|
7ab62a9968 | ||
|
|
a3c4667f34 | ||
|
|
700ee298c4 | ||
|
|
4c6bccc058 | ||
|
|
cdcefee641 | ||
|
|
6e9d425bda | ||
|
|
984771925f | ||
|
|
cadc78d1d4 | ||
|
|
fd36e1b0a2 | ||
|
|
c3c92b47f1 | ||
|
|
48e25dd352 | ||
|
|
708451b027 | ||
|
|
37e54c76a6 | ||
|
|
b319115fd2 | ||
|
|
1eb0b7eeea | ||
|
|
67fc07d326 | ||
|
|
24df50889d | ||
|
|
1f93c8eb9e | ||
|
|
566b8d6086 | ||
|
|
2b6156ff07 | ||
|
|
3c12e5fbe9 | ||
|
|
ec8093a1ca | ||
|
|
55c7a45060 | ||
|
|
471d8dded6 | ||
|
|
045008a9df | ||
|
|
fd50a4adeb | ||
|
|
efdf5f850d | ||
|
|
15bd3ebdc8 | ||
|
|
a73d858ebd | ||
|
|
af92253092 | ||
|
|
7e5a026987 |
|
|
@ -1,2 +1,3 @@
|
|||
.env
|
||||
node_modules
|
||||
.git
|
||||
|
|
|
|||
13
.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '20:00'
|
||||
open-pull-requests-limit: 10
|
||||
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "protobufs"]
|
||||
path = src/protobufs
|
||||
url = https://github.com/meshtastic/protobufs.git
|
||||
29
Dockerfile
|
|
@ -1,10 +1,29 @@
|
|||
FROM node:lts-alpine
|
||||
FROM node:lts-alpine AS build
|
||||
|
||||
RUN apk add --no-cache openssl
|
||||
|
||||
# add project files to /app
|
||||
ADD ./ /app
|
||||
WORKDIR /app
|
||||
|
||||
# install node dependencies
|
||||
RUN npm install
|
||||
# Copy only package files and install deps
|
||||
# This layer will be cached as long as package*.json don't change
|
||||
COPY package*.json package-lock.json* ./
|
||||
RUN --mount=type=cache,target=/root/.npm npm ci --omit=dev
|
||||
|
||||
# Copy the rest of your source
|
||||
COPY . .
|
||||
|
||||
# Pre-generate prisma client
|
||||
RUN node_modules/.bin/prisma generate
|
||||
|
||||
FROM node:lts-alpine
|
||||
|
||||
RUN apk add --no-cache openssl
|
||||
|
||||
USER node:node
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=build --chown=node:node /app .
|
||||
|
||||
|
||||
EXPOSE 8080
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ git clone https://github.com/liamcottle/meshtastic-map
|
|||
cd meshtastic-map
|
||||
```
|
||||
|
||||
Install Meshtastic protobufs definitions
|
||||
```
|
||||
git clone https://github.com/meshtastic/protobufs src/protobufs
|
||||
```
|
||||
|
||||
Install NodeJS dependencies
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -30,6 +30,18 @@ services:
|
|||
DATABASE_URL: "mysql://root:password@database:3306/meshtastic-map?connection_limit=100"
|
||||
MAP_OPTS: "" # add any custom index.js options here
|
||||
|
||||
# publishes mqtt packets via websocket
|
||||
meshtastic-ws:
|
||||
container_name: meshtastic-ws
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
command: /app/docker/ws.sh
|
||||
ports:
|
||||
- 8081:8081/tcp
|
||||
environment:
|
||||
WS_OPTS: ""
|
||||
|
||||
# runs the database to store everything from mqtt
|
||||
database:
|
||||
container_name: database
|
||||
|
|
|
|||
5
docker/ws.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Starting websocket publisher"
|
||||
exec node src/ws.js ${WS_OPTS}
|
||||
|
||||
4998
package-lock.json
generated
20
package.json
|
|
@ -9,16 +9,18 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@prisma/client": "^5.11.0",
|
||||
"command-line-args": "^5.2.1",
|
||||
"command-line-usage": "^7.0.1",
|
||||
"compression": "^1.7.4",
|
||||
"express": "^4.18.3",
|
||||
"mqtt": "^5.3.6",
|
||||
"protobufjs": "^7.2.6"
|
||||
"@prisma/client": "^6.16.2",
|
||||
"command-line-args": "^6.0.1",
|
||||
"command-line-usage": "^7.0.3",
|
||||
"compression": "^1.8.1",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^5.2.1",
|
||||
"mqtt": "^5.14.1",
|
||||
"protobufjs": "^7.5.4",
|
||||
"ws": "^8.18.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^29.7.0",
|
||||
"prisma": "^5.10.2"
|
||||
"jest": "^30.1.3",
|
||||
"prisma": "^6.16.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `nodes` ADD COLUMN `ok_to_mqtt` BOOLEAN NULL;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `service_envelopes` ADD COLUMN `portnum` INTEGER NULL;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `service_envelopes` ADD COLUMN `packet_id` BIGINT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `service_envelopes_packet_id_idx` ON `service_envelopes`(`packet_id`);
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE `battery_stats` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`recorded_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`avg_battery_level` DECIMAL(5, 2) NULL,
|
||||
|
||||
INDEX `battery_stats_recorded_at_idx`(`recorded_at`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `channel_utilization_stats` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`recorded_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`avg_channel_utilization` DECIMAL(65, 30) NULL,
|
||||
|
||||
INDEX `channel_utilization_stats_recorded_at_idx`(`recorded_at`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE `name_history` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`node_id` BIGINT NOT NULL,
|
||||
`long_name` VARCHAR(191) NOT NULL,
|
||||
`short_name` VARCHAR(191) NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
INDEX `name_history_node_id_idx`(`node_id`),
|
||||
INDEX `name_history_long_name_idx`(`long_name`),
|
||||
INDEX `name_history_created_at_idx`(`created_at`),
|
||||
INDEX `name_history_updated_at_idx`(`updated_at`),
|
||||
UNIQUE INDEX `name_history_node_id_long_name_short_name_key`(`node_id`, `long_name`, `short_name`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `nodes` ADD COLUMN `is_backbone` BOOLEAN NULL;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `nodes` ADD COLUMN `is_unmessagable` BOOLEAN NULL,
|
||||
ADD COLUMN `public_key` VARCHAR(191) NULL;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `nodes` ADD COLUMN `max_hops` INTEGER NULL;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `nodes` ADD COLUMN `channel_id` VARCHAR(191) NULL;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `channel_utilization_stats` ADD COLUMN `channel_id` VARCHAR(191) NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `channel_utilization_stats_channel_id_idx` ON `channel_utilization_stats`(`channel_id`);
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `text_messages` ADD COLUMN `ok_to_mqtt` BOOLEAN NULL;
|
||||
23
prisma/migrations/20260106151912_add_edges/migration.sql
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE `edges` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`from_node_id` BIGINT NOT NULL,
|
||||
`to_node_id` BIGINT NOT NULL,
|
||||
`snr` INTEGER NOT NULL,
|
||||
`from_latitude` INTEGER NULL,
|
||||
`from_longitude` INTEGER NULL,
|
||||
`to_latitude` INTEGER NULL,
|
||||
`to_longitude` INTEGER NULL,
|
||||
`packet_id` BIGINT NOT NULL,
|
||||
`channel_id` VARCHAR(191) NULL,
|
||||
`gateway_id` BIGINT NULL,
|
||||
`source` VARCHAR(191) NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
INDEX `edges_from_node_id_idx`(`from_node_id`),
|
||||
INDEX `edges_to_node_id_idx`(`to_node_id`),
|
||||
INDEX `edges_created_at_idx`(`created_at`),
|
||||
INDEX `edges_from_node_id_to_node_id_idx`(`from_node_id`, `to_node_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
|
@ -21,6 +21,8 @@ model Node {
|
|||
hardware_model Int
|
||||
role Int
|
||||
is_licensed Boolean?
|
||||
public_key String?
|
||||
is_unmessagable Boolean?
|
||||
|
||||
firmware_version String?
|
||||
region Int?
|
||||
|
|
@ -51,6 +53,12 @@ model Node {
|
|||
// this column tracks when an mqtt gateway node uplinked a packet
|
||||
mqtt_connection_state_updated_at DateTime?
|
||||
|
||||
ok_to_mqtt Boolean?
|
||||
is_backbone Boolean?
|
||||
max_hops Int?
|
||||
|
||||
channel_id String?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
|
||||
|
|
@ -202,6 +210,8 @@ model ServiceEnvelope {
|
|||
gateway_id BigInt?
|
||||
to BigInt
|
||||
from BigInt
|
||||
portnum Int?
|
||||
packet_id BigInt?
|
||||
protobuf Bytes
|
||||
|
||||
created_at DateTime @default(now())
|
||||
|
|
@ -210,6 +220,7 @@ model ServiceEnvelope {
|
|||
@@index(created_at)
|
||||
@@index(updated_at)
|
||||
@@index(gateway_id)
|
||||
@@index(packet_id)
|
||||
@@map("service_envelopes")
|
||||
}
|
||||
|
||||
|
|
@ -228,6 +239,7 @@ model TextMessage {
|
|||
rx_snr Decimal?
|
||||
rx_rssi Int?
|
||||
hop_limit Int?
|
||||
ok_to_mqtt Boolean?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
|
|
@ -296,3 +308,67 @@ model Waypoint {
|
|||
@@index(gateway_id)
|
||||
@@map("waypoints")
|
||||
}
|
||||
|
||||
model NameHistory {
|
||||
id BigInt @id @default(autoincrement())
|
||||
node_id BigInt
|
||||
long_name String
|
||||
short_name String
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
|
||||
@@index(node_id)
|
||||
@@index(long_name)
|
||||
|
||||
@@index(created_at)
|
||||
@@index(updated_at)
|
||||
@@map("name_history")
|
||||
|
||||
// We only want to keep track of unique name and node_id combinations
|
||||
@@unique([node_id, long_name, short_name])
|
||||
}
|
||||
|
||||
model BatteryStats {
|
||||
id BigInt @id @default(autoincrement())
|
||||
recorded_at DateTime? @default(now())
|
||||
avg_battery_level Decimal? @db.Decimal(5, 2)
|
||||
|
||||
@@index([recorded_at])
|
||||
@@map("battery_stats")
|
||||
}
|
||||
|
||||
model ChannelUtilizationStats {
|
||||
id BigInt @id @default(autoincrement())
|
||||
recorded_at DateTime? @default(now())
|
||||
avg_channel_utilization Decimal?
|
||||
channel_id String?
|
||||
|
||||
@@index([channel_id])
|
||||
@@index([recorded_at])
|
||||
@@map("channel_utilization_stats")
|
||||
}
|
||||
|
||||
model Edge {
|
||||
id BigInt @id @default(autoincrement())
|
||||
from_node_id BigInt
|
||||
to_node_id BigInt
|
||||
snr Int
|
||||
from_latitude Int?
|
||||
from_longitude Int?
|
||||
to_latitude Int?
|
||||
to_longitude Int?
|
||||
packet_id BigInt
|
||||
channel_id String?
|
||||
gateway_id BigInt?
|
||||
source String
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
|
||||
@@index(from_node_id)
|
||||
@@index(to_node_id)
|
||||
@@index(created_at)
|
||||
@@index([from_node_id, to_node_id])
|
||||
@@map("edges")
|
||||
}
|
||||
BIN
screenshot.png
|
Before Width: | Height: | Size: 270 KiB After Width: | Height: | Size: 5.4 MiB |
|
|
@ -1,6 +1,7 @@
|
|||
// node src/admin.js --purge-node-id 123
|
||||
// node src/admin.js --purge-node-id '!AABBCCDD'
|
||||
|
||||
require('./utils/logger');
|
||||
const commandLineArgs = require("command-line-args");
|
||||
const commandLineUsage = require("command-line-usage");
|
||||
|
||||
|
|
|
|||
397
src/index.js
|
|
@ -1,9 +1,13 @@
|
|||
require('./utils/logger');
|
||||
const path = require('path');
|
||||
const express = require('express');
|
||||
const compression = require('compression');
|
||||
const protobufjs = require("protobufjs");
|
||||
const commandLineArgs = require("command-line-args");
|
||||
const commandLineUsage = require("command-line-usage");
|
||||
const cors = require('cors');
|
||||
|
||||
const statsRoutes = require('./stats.js');
|
||||
|
||||
// create prisma db client
|
||||
const { PrismaClient } = require("@prisma/client");
|
||||
|
|
@ -52,7 +56,7 @@ const port = options["port"] ?? 8080;
|
|||
|
||||
// load protobufs
|
||||
const root = new protobufjs.Root();
|
||||
root.resolvePath = (origin, target) => path.join(__dirname, "protos", target);
|
||||
root.resolvePath = (origin, target) => path.join(__dirname, "protobufs", target);
|
||||
root.loadSync('meshtastic/mqtt.proto');
|
||||
const HardwareModel = root.lookupEnum("HardwareModel");
|
||||
const Role = root.lookupEnum("Config.DeviceConfig.Role");
|
||||
|
|
@ -76,6 +80,9 @@ const app = express();
|
|||
// enable compression
|
||||
app.use(compression());
|
||||
|
||||
// Apply CORS only to API routes
|
||||
app.use('/api', cors());
|
||||
|
||||
// serve files inside the public folder from /
|
||||
app.use('/', express.static(path.join(__dirname, 'public')));
|
||||
|
||||
|
|
@ -83,6 +90,9 @@ app.get('/', async (req, res) => {
|
|||
res.sendFile(path.join(__dirname, 'public/index.html'));
|
||||
});
|
||||
|
||||
// stats API in separate file
|
||||
app.use('/api/v1/stats', statsRoutes);
|
||||
|
||||
app.get('/api', async (req, res) => {
|
||||
|
||||
const links = [
|
||||
|
|
@ -137,6 +147,23 @@ app.get('/api', async (req, res) => {
|
|||
"path": "/api/v1/nodes/:nodeId/traceroutes",
|
||||
"description": "Trace routes for a meshtastic node",
|
||||
},
|
||||
{
|
||||
"path": "/api/v1/traceroutes",
|
||||
"description": "Recent traceroute edges across all nodes",
|
||||
"params": {
|
||||
"time_from": "Only include traceroutes updated after this unix timestamp (milliseconds)",
|
||||
"time_to": "Only include traceroutes updated before this unix timestamp (milliseconds)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/api/v1/connections",
|
||||
"description": "Aggregated edges between nodes from traceroutes",
|
||||
"params": {
|
||||
"node_id": "Only include connections involving this node id",
|
||||
"time_from": "Only include edges created after this unix timestamp (milliseconds)",
|
||||
"time_to": "Only include edges created before this unix timestamp (milliseconds)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/api/v1/nodes/:nodeId/position-history",
|
||||
"description": "Position history for a meshtastic node",
|
||||
|
|
@ -202,6 +229,10 @@ app.get('/api/v1/nodes', async (req, res) => {
|
|||
where: {
|
||||
role: role,
|
||||
hardware_model: hardwareModel,
|
||||
// Since we removed retention; only include nodes that have been updated in the last 30 days
|
||||
updated_at: {
|
||||
gte: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) // within last 30 days
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -557,6 +588,313 @@ app.get('/api/v1/nodes/:nodeId/traceroutes', async (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
// Aggregated recent traceroute edges (global), filtered by updated_at
|
||||
// Returns deduplicated edges with the latest SNR and timestamp.
|
||||
// GET /api/v1/nodes/traceroutes?time_from=...&time_to=...
|
||||
app.get('/api/v1/traceroutes', async (req, res) => {
|
||||
try {
|
||||
|
||||
const timeFrom = req.query.time_from ? parseInt(req.query.time_from) : undefined;
|
||||
const timeTo = req.query.time_to ? parseInt(req.query.time_to) : undefined;
|
||||
|
||||
// Pull recent traceroutes within the time window. We only want replies (want_response=false)
|
||||
// and those that were actually gated to MQTT (gateway_id not null)
|
||||
const traces = await prisma.traceRoute.findMany({
|
||||
where: {
|
||||
want_response: false,
|
||||
gateway_id: { not: null },
|
||||
updated_at: {
|
||||
gte: timeFrom ? new Date(timeFrom) : undefined,
|
||||
lte: timeTo ? new Date(timeTo) : undefined,
|
||||
},
|
||||
},
|
||||
orderBy: { id: 'desc' },
|
||||
take: 5000, // cap to keep response bounded; UI can page/adjust time window if needed
|
||||
});
|
||||
|
||||
// Normalize JSON fields that may be strings (depending on driver)
|
||||
const normalized = traces.map((t) => {
|
||||
const trace = { ...t };
|
||||
if (typeof trace.route === 'string') {
|
||||
try { trace.route = JSON.parse(trace.route); } catch(_) {}
|
||||
}
|
||||
if (typeof trace.route_back === 'string') {
|
||||
try { trace.route_back = JSON.parse(trace.route_back); } catch(_) {}
|
||||
}
|
||||
if (typeof trace.snr_towards === 'string') {
|
||||
try { trace.snr_towards = JSON.parse(trace.snr_towards); } catch(_) {}
|
||||
}
|
||||
if (typeof trace.snr_back === 'string') {
|
||||
try { trace.snr_back = JSON.parse(trace.snr_back); } catch(_) {}
|
||||
}
|
||||
return trace;
|
||||
});
|
||||
|
||||
// Build edges from both forward (towards) and reverse (back) paths.
|
||||
// Forward path: to → route[] → from, using snr_towards
|
||||
// Reverse path: from → route_back[] → to, using snr_back
|
||||
const edgeKey = (a, b) => `${String(a)}->${String(b)}`;
|
||||
const edges = new Map();
|
||||
|
||||
function upsertEdgesFromPath(trace, pathNodes, pathSnrs) {
|
||||
for (let i = 0; i < pathNodes.length - 1; i++) {
|
||||
const hopFrom = pathNodes[i];
|
||||
const hopTo = pathNodes[i + 1];
|
||||
const snr = typeof (pathSnrs && pathSnrs[i]) === 'number' ? pathSnrs[i] : null;
|
||||
|
||||
// Skip edges without SNR data
|
||||
if (snr === null) continue;
|
||||
|
||||
const key = edgeKey(hopFrom, hopTo);
|
||||
const existing = edges.get(key);
|
||||
if (!existing) {
|
||||
edges.set(key, {
|
||||
from: hopFrom,
|
||||
to: hopTo,
|
||||
snr: snr,
|
||||
updated_at: trace.updated_at,
|
||||
channel_id: trace.channel_id ?? null,
|
||||
gateway_id: trace.gateway_id ?? null,
|
||||
traceroute_from: trace.from, // original initiator
|
||||
traceroute_to: trace.to, // original target
|
||||
});
|
||||
} else if (new Date(trace.updated_at) > new Date(existing.updated_at)) {
|
||||
existing.snr = snr;
|
||||
existing.updated_at = trace.updated_at;
|
||||
existing.channel_id = trace.channel_id ?? existing.channel_id;
|
||||
existing.gateway_id = trace.gateway_id ?? existing.gateway_id;
|
||||
existing.traceroute_from = trace.from;
|
||||
existing.traceroute_to = trace.to;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const tr of normalized) {
|
||||
// Forward path
|
||||
const forwardPath = [];
|
||||
if (tr.to != null) forwardPath.push(Number(tr.to));
|
||||
if (Array.isArray(tr.route)) {
|
||||
for (const hop of tr.route) {
|
||||
if (hop != null) forwardPath.push(Number(hop));
|
||||
}
|
||||
}
|
||||
if (tr.from != null) forwardPath.push(Number(tr.from));
|
||||
const forwardSnrs = Array.isArray(tr.snr_towards) ? tr.snr_towards : [];
|
||||
upsertEdgesFromPath(tr, forwardPath, forwardSnrs);
|
||||
|
||||
// Reverse path
|
||||
const reversePath = [];
|
||||
if (tr.from != null) reversePath.push(Number(tr.from));
|
||||
if (Array.isArray(tr.route_back)) {
|
||||
for (const hop of tr.route_back) {
|
||||
if (hop != null) reversePath.push(Number(hop));
|
||||
}
|
||||
}
|
||||
if (tr.to != null) reversePath.push(Number(tr.to));
|
||||
const reverseSnrs = Array.isArray(tr.snr_back) ? tr.snr_back : [];
|
||||
upsertEdgesFromPath(tr, reversePath, reverseSnrs);
|
||||
}
|
||||
|
||||
res.json({
|
||||
traceroute_edges: Array.from(edges.values()),
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).json({
|
||||
message: "Something went wrong, try again later.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Aggregated edges endpoint
|
||||
// GET /api/v1/connections?node_id=...&time_from=...&time_to=...
|
||||
app.get('/api/v1/connections', async (req, res) => {
|
||||
try {
|
||||
const nodeId = req.query.node_id ? parseInt(req.query.node_id) : undefined;
|
||||
const timeFrom = req.query.time_from ? parseInt(req.query.time_from) : undefined;
|
||||
const timeTo = req.query.time_to ? parseInt(req.query.time_to) : undefined;
|
||||
|
||||
// Query edges from database
|
||||
const edges = await prisma.edge.findMany({
|
||||
where: {
|
||||
created_at: {
|
||||
...(timeFrom && { gte: new Date(timeFrom) }),
|
||||
...(timeTo && { lte: new Date(timeTo) }),
|
||||
},
|
||||
// Only include edges where both nodes have positions
|
||||
from_latitude: { not: null },
|
||||
from_longitude: { not: null },
|
||||
to_latitude: { not: null },
|
||||
to_longitude: { not: null },
|
||||
// If node_id is provided, filter edges where either from_node_id or to_node_id matches
|
||||
...(nodeId !== undefined && {
|
||||
OR: [
|
||||
{ from_node_id: nodeId },
|
||||
{ to_node_id: nodeId },
|
||||
],
|
||||
}),
|
||||
},
|
||||
orderBy: [
|
||||
{ created_at: 'desc' },
|
||||
{ packet_id: 'desc' },
|
||||
],
|
||||
});
|
||||
|
||||
// Collect all unique node IDs from edges
|
||||
const nodeIds = new Set();
|
||||
for (const edge of edges) {
|
||||
nodeIds.add(edge.from_node_id);
|
||||
nodeIds.add(edge.to_node_id);
|
||||
}
|
||||
|
||||
// Fetch current positions for all nodes
|
||||
const nodes = await prisma.node.findMany({
|
||||
where: {
|
||||
node_id: { in: Array.from(nodeIds) },
|
||||
},
|
||||
select: {
|
||||
node_id: true,
|
||||
latitude: true,
|
||||
longitude: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Create a map of current node positions
|
||||
const nodePositions = new Map();
|
||||
for (const node of nodes) {
|
||||
nodePositions.set(node.node_id, {
|
||||
latitude: node.latitude,
|
||||
longitude: node.longitude,
|
||||
});
|
||||
}
|
||||
|
||||
// Filter edges: only include edges where both nodes are still at the same location
|
||||
const validEdges = edges.filter(edge => {
|
||||
const fromCurrentPos = nodePositions.get(edge.from_node_id);
|
||||
const toCurrentPos = nodePositions.get(edge.to_node_id);
|
||||
|
||||
// Skip if either node doesn't exist or doesn't have a current position
|
||||
if (!fromCurrentPos || !toCurrentPos ||
|
||||
fromCurrentPos.latitude === null || fromCurrentPos.longitude === null ||
|
||||
toCurrentPos.latitude === null || toCurrentPos.longitude === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if stored positions match current positions
|
||||
const fromMatches = fromCurrentPos.latitude === edge.from_latitude &&
|
||||
fromCurrentPos.longitude === edge.from_longitude;
|
||||
const toMatches = toCurrentPos.latitude === edge.to_latitude &&
|
||||
toCurrentPos.longitude === edge.to_longitude;
|
||||
|
||||
return fromMatches && toMatches;
|
||||
});
|
||||
|
||||
// Normalize node pairs: always use min/max to treat A->B and B->A as same connection
|
||||
const connectionsMap = new Map();
|
||||
|
||||
for (const edge of validEdges) {
|
||||
const nodeA = edge.from_node_id < edge.to_node_id ? edge.from_node_id : edge.to_node_id;
|
||||
const nodeB = edge.from_node_id < edge.to_node_id ? edge.to_node_id : edge.from_node_id;
|
||||
const key = `${nodeA}-${nodeB}`;
|
||||
|
||||
if (!connectionsMap.has(key)) {
|
||||
connectionsMap.set(key, {
|
||||
node_a: nodeA,
|
||||
node_b: nodeB,
|
||||
direction_ab: [], // A -> B edges
|
||||
direction_ba: [], // B -> A edges
|
||||
});
|
||||
}
|
||||
|
||||
const connection = connectionsMap.get(key);
|
||||
const isAB = edge.from_node_id === nodeA;
|
||||
|
||||
// Add edge to appropriate direction
|
||||
if (isAB) {
|
||||
connection.direction_ab.push({
|
||||
snr: edge.snr,
|
||||
snr_db: edge.snr / 4, // Convert to dB
|
||||
created_at: edge.created_at,
|
||||
packet_id: edge.packet_id,
|
||||
source: edge.source,
|
||||
});
|
||||
} else {
|
||||
connection.direction_ba.push({
|
||||
snr: edge.snr,
|
||||
snr_db: edge.snr / 4,
|
||||
created_at: edge.created_at,
|
||||
packet_id: edge.packet_id,
|
||||
source: edge.source,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Aggregate each connection
|
||||
const connections = Array.from(connectionsMap.values()).map(conn => {
|
||||
// Deduplicate edges by packet_id for each direction (keep first occurrence, which is most recent)
|
||||
const dedupeByPacketId = (edges) => {
|
||||
const seen = new Set();
|
||||
return edges.filter(edge => {
|
||||
if (seen.has(edge.packet_id)) {
|
||||
return false;
|
||||
}
|
||||
seen.add(edge.packet_id);
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
const deduplicatedAB = dedupeByPacketId(conn.direction_ab);
|
||||
const deduplicatedBA = dedupeByPacketId(conn.direction_ba);
|
||||
|
||||
// Calculate average SNR for A->B (using deduplicated edges)
|
||||
const avgSnrAB = deduplicatedAB.length > 0
|
||||
? deduplicatedAB.reduce((sum, e) => sum + e.snr_db, 0) / deduplicatedAB.length
|
||||
: null;
|
||||
|
||||
// Calculate average SNR for B->A (using deduplicated edges)
|
||||
const avgSnrBA = deduplicatedBA.length > 0
|
||||
? deduplicatedBA.reduce((sum, e) => sum + e.snr_db, 0) / deduplicatedBA.length
|
||||
: null;
|
||||
|
||||
// Get last 5 edges for each direction (already sorted by created_at DESC, packet_id DESC, now deduplicated)
|
||||
const last5AB = deduplicatedAB.slice(0, 5);
|
||||
const last5BA = deduplicatedBA.slice(0, 5);
|
||||
|
||||
// Determine worst average SNR
|
||||
const worstAvgSnrDb = [avgSnrAB, avgSnrBA]
|
||||
.filter(v => v !== null)
|
||||
.reduce((min, val) => val < min ? val : min, Infinity);
|
||||
|
||||
return {
|
||||
node_a: conn.node_a,
|
||||
node_b: conn.node_b,
|
||||
direction_ab: {
|
||||
avg_snr_db: avgSnrAB,
|
||||
last_5_edges: last5AB,
|
||||
total_count: deduplicatedAB.length, // Use deduplicated count
|
||||
},
|
||||
direction_ba: {
|
||||
avg_snr_db: avgSnrBA,
|
||||
last_5_edges: last5BA,
|
||||
total_count: deduplicatedBA.length, // Use deduplicated count
|
||||
},
|
||||
worst_avg_snr_db: worstAvgSnrDb !== Infinity ? worstAvgSnrDb : null,
|
||||
};
|
||||
}).filter(conn => conn.worst_avg_snr_db !== null); // Only return connections with at least one direction
|
||||
|
||||
res.json({
|
||||
connections: connections,
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).json({
|
||||
message: "Something went wrong, try again later.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/v1/nodes/:nodeId/position-history', async (req, res) => {
|
||||
try {
|
||||
|
||||
|
|
@ -646,42 +984,6 @@ app.get('/api/v1/nodes/:nodeId/position-history', async (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
app.get('/api/v1/stats/hardware-models', async (req, res) => {
|
||||
try {
|
||||
|
||||
// get nodes from db
|
||||
const results = await prisma.node.groupBy({
|
||||
by: ['hardware_model'],
|
||||
orderBy: {
|
||||
_count: {
|
||||
hardware_model: 'desc',
|
||||
},
|
||||
},
|
||||
_count: {
|
||||
hardware_model: true,
|
||||
},
|
||||
});
|
||||
|
||||
const hardwareModelStats = results.map((result) => {
|
||||
return {
|
||||
count: result._count.hardware_model,
|
||||
hardware_model: result.hardware_model,
|
||||
hardware_model_name: HardwareModel.valuesById[result.hardware_model] ?? "UNKNOWN",
|
||||
};
|
||||
});
|
||||
|
||||
res.json({
|
||||
hardware_model_stats: hardwareModelStats,
|
||||
});
|
||||
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
res.status(500).json({
|
||||
message: "Something went wrong, try again later.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/v1/text-messages', async (req, res) => {
|
||||
try {
|
||||
|
||||
|
|
@ -808,8 +1110,29 @@ app.get('/api/v1/waypoints', async (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
// start express server
|
||||
const listener = app.listen(port, () => {
|
||||
const port = listener.address().port;
|
||||
console.log(`Server running at http://127.0.0.1:${port}`);
|
||||
});
|
||||
|
||||
// Graceful shutdown handlers
|
||||
function gracefulShutdown(signal) {
|
||||
console.log(`Received ${signal}. Starting graceful shutdown...`);
|
||||
|
||||
// Stop accepting new connections
|
||||
listener.close(async (err) => {
|
||||
console.log('HTTP server closed');
|
||||
await prisma.$disconnect();
|
||||
console.log('Database connections closed');
|
||||
console.log('Graceful shutdown completed');
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
// Handle SIGTERM (Docker, systemd, etc.)
|
||||
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
|
||||
|
||||
// Handle SIGINT (Ctrl+C)
|
||||
process.on('SIGINT', () => gracefulShutdown('SIGINT'));
|
||||
|
|
|
|||
324
src/mqtt.js
|
|
@ -1,3 +1,4 @@
|
|||
require('./utils/logger');
|
||||
const crypto = require("crypto");
|
||||
const path = require("path");
|
||||
const mqtt = require("mqtt");
|
||||
|
|
@ -222,6 +223,7 @@ const collectNeighbourInfo = options["collect-neighbour-info"] ?? false;
|
|||
const collectMapReports = options["collect-map-reports"] ?? false;
|
||||
const decryptionKeys = options["decryption-keys"] ?? [
|
||||
"1PG7OiApB1nwvP+rz05pAQ==", // add default "AQ==" decryption key
|
||||
"PjG/mVAqnannyvqmuYAwd0LZa1AV+wkcUQlacmexEXY=", // Årsta mesh? länkad av [x/0!] divideByZero i meshen
|
||||
];
|
||||
const dropPacketsNotOkToMqtt = options["drop-packets-not-ok-to-mqtt"] ?? false;
|
||||
const dropPortnumsWithoutBitfield = options["drop-portnums-without-bitfield"] ?? null;
|
||||
|
|
@ -249,7 +251,7 @@ const client = mqtt.connect(mqttBrokerUrl, {
|
|||
|
||||
// load protobufs
|
||||
const root = new protobufjs.Root();
|
||||
root.resolvePath = (origin, target) => path.join(__dirname, "protos", target);
|
||||
root.resolvePath = (origin, target) => path.join(__dirname, "protobufs", target);
|
||||
root.loadSync('meshtastic/mqtt.proto');
|
||||
const Data = root.lookupType("Data");
|
||||
const ServiceEnvelope = root.lookupType("ServiceEnvelope");
|
||||
|
|
@ -262,8 +264,9 @@ const User = root.lookupType("User");
|
|||
const Waypoint = root.lookupType("Waypoint");
|
||||
|
||||
// run automatic purge if configured
|
||||
let purgeInterval = null;
|
||||
if(purgeIntervalSeconds){
|
||||
setInterval(async () => {
|
||||
purgeInterval = setInterval(async () => {
|
||||
await purgeUnheardNodes();
|
||||
await purgeOldDeviceMetrics();
|
||||
await purgeOldEnvironmentMetrics();
|
||||
|
|
@ -740,6 +743,13 @@ client.on("message", async (topic, message) => {
|
|||
|
||||
}
|
||||
|
||||
// check if bitfield is available, then set ok-to-mqtt
|
||||
// else leave undefined to let Prisma ignore it.
|
||||
let isOkToMqtt
|
||||
if(bitfield != null){
|
||||
isOkToMqtt = Boolean(bitfield & BITFIELD_OK_TO_MQTT_MASK);
|
||||
}
|
||||
|
||||
// create service envelope in db
|
||||
if(collectServiceEnvelopes){
|
||||
try {
|
||||
|
|
@ -750,6 +760,8 @@ client.on("message", async (topic, message) => {
|
|||
gateway_id: envelope.gatewayId ? convertHexIdToNumericId(envelope.gatewayId) : null,
|
||||
to: envelope.packet.to,
|
||||
from: envelope.packet.from,
|
||||
portnum: portnum,
|
||||
packet_id: envelope.packet.id,
|
||||
protobuf: message,
|
||||
},
|
||||
});
|
||||
|
|
@ -814,6 +826,7 @@ client.on("message", async (topic, message) => {
|
|||
rx_snr: envelope.packet.rxSnr,
|
||||
rx_rssi: envelope.packet.rxRssi,
|
||||
hop_limit: envelope.packet.hopLimit,
|
||||
ok_to_mqtt: isOkToMqtt,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
@ -935,6 +948,19 @@ client.on("message", async (topic, message) => {
|
|||
hardware_model: user.hwModel,
|
||||
is_licensed: user.isLicensed === true,
|
||||
role: user.role,
|
||||
is_unmessagable: user.isUnmessagable,
|
||||
ok_to_mqtt: isOkToMqtt,
|
||||
max_hops: envelope.packet.hopStart,
|
||||
channel_id: envelope.channelId,
|
||||
|
||||
firmware_version: '<2.5.0',
|
||||
...(user.publicKey != '' && {
|
||||
firmware_version: '>2.5.0',
|
||||
public_key: user.publicKey?.toString("base64"),
|
||||
}),
|
||||
...(user.isUnmessagable != null && {
|
||||
firmware_version: '>2.6.8',
|
||||
}),
|
||||
},
|
||||
update: {
|
||||
long_name: user.longName,
|
||||
|
|
@ -942,12 +968,57 @@ client.on("message", async (topic, message) => {
|
|||
hardware_model: user.hwModel,
|
||||
is_licensed: user.isLicensed === true,
|
||||
role: user.role,
|
||||
is_unmessagable: user.isUnmessagable,
|
||||
ok_to_mqtt: isOkToMqtt,
|
||||
max_hops: envelope.packet.hopStart,
|
||||
channel_id: envelope.channelId,
|
||||
|
||||
firmware_version: '<2.5.0',
|
||||
...(user.publicKey != '' && {
|
||||
firmware_version: '>2.5.0',
|
||||
public_key: user.publicKey?.toString("base64"),
|
||||
}),
|
||||
...(user.isUnmessagable != null && {
|
||||
firmware_version: '>2.6.8',
|
||||
}),
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// Ignore MySQL error 1020 "Record has changed since last read" - this is a race condition
|
||||
// that occurs when multiple packets arrive concurrently for the same node
|
||||
const errorMessage = e.message || String(e);
|
||||
if (!errorMessage.includes('Record has changed since last read')) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Keep track of the names a node has been using.
|
||||
try {
|
||||
await prisma.NameHistory.upsert({
|
||||
where: {
|
||||
node_id_long_name_short_name: {
|
||||
node_id: envelope.packet.from,
|
||||
long_name: user.longName,
|
||||
short_name: user.shortName,
|
||||
}
|
||||
},
|
||||
create: {
|
||||
node_id: envelope.packet.from,
|
||||
long_name: user.longName,
|
||||
short_name: user.shortName,
|
||||
},
|
||||
update: {
|
||||
updated_at: new Date(),
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
// Ignore MySQL error 1020 "Record has changed since last read" - this is a race condition
|
||||
// that occurs when multiple packets arrive concurrently for the same node
|
||||
const errorMessage = e.message || String(e);
|
||||
if (!errorMessage.includes('Record has changed since last read')) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(portnum === 8) {
|
||||
|
|
@ -1023,6 +1094,70 @@ client.on("message", async (topic, message) => {
|
|||
console.error(e);
|
||||
}
|
||||
|
||||
// Extract edges from neighbour info
|
||||
try {
|
||||
const toNodeId = envelope.packet.from;
|
||||
const neighbors = neighbourInfo.neighbors || [];
|
||||
const packetId = envelope.packet.id;
|
||||
const channelId = envelope.channelId;
|
||||
const gatewayId = envelope.gatewayId ? convertHexIdToNumericId(envelope.gatewayId) : null;
|
||||
const edgesToCreate = [];
|
||||
|
||||
for(const neighbour of neighbors) {
|
||||
// Skip if no node ID
|
||||
if(!neighbour.nodeId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip if SNR is invalid (0 or null/undefined)
|
||||
// Note: SNR can be negative, so we check for 0 specifically
|
||||
if(neighbour.snr === 0 || neighbour.snr == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const fromNodeId = neighbour.nodeId;
|
||||
const snr = neighbour.snr;
|
||||
|
||||
// Fetch node positions from Node table
|
||||
const [fromNode, toNode] = await Promise.all([
|
||||
prisma.node.findUnique({
|
||||
where: { node_id: fromNodeId },
|
||||
select: { latitude: true, longitude: true },
|
||||
}),
|
||||
prisma.node.findUnique({
|
||||
where: { node_id: toNodeId },
|
||||
select: { latitude: true, longitude: true },
|
||||
}),
|
||||
]);
|
||||
|
||||
// Create edge record
|
||||
edgesToCreate.push({
|
||||
from_node_id: fromNodeId,
|
||||
to_node_id: toNodeId,
|
||||
snr: snr,
|
||||
from_latitude: fromNode?.latitude ?? null,
|
||||
from_longitude: fromNode?.longitude ?? null,
|
||||
to_latitude: toNode?.latitude ?? null,
|
||||
to_longitude: toNode?.longitude ?? null,
|
||||
packet_id: packetId,
|
||||
channel_id: channelId,
|
||||
gateway_id: gatewayId,
|
||||
source: "NEIGHBORINFO_APP",
|
||||
});
|
||||
}
|
||||
|
||||
// Bulk insert edges
|
||||
if(edgesToCreate.length > 0) {
|
||||
await prisma.edge.createMany({
|
||||
data: edgesToCreate,
|
||||
skipDuplicates: true, // Skip if exact duplicate exists
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
// Log error but don't crash - edge extraction is non-critical
|
||||
console.error("Error extracting edges from neighbour info:", e);
|
||||
}
|
||||
|
||||
// don't store all neighbour infos, but we want to update the existing node above
|
||||
if(!collectNeighbourInfo){
|
||||
return;
|
||||
|
|
@ -1265,6 +1400,160 @@ client.on("message", async (topic, message) => {
|
|||
console.error(e);
|
||||
}
|
||||
|
||||
// Extract edges from traceroute (only for response packets)
|
||||
if(!envelope.packet.decoded.wantResponse) {
|
||||
try {
|
||||
const route = routeDiscovery.route || [];
|
||||
const snrTowards = routeDiscovery.snrTowards || [];
|
||||
const originNodeId = envelope.packet.to;
|
||||
const destinationNodeId = envelope.packet.from;
|
||||
const packetId = envelope.packet.id;
|
||||
const channelId = envelope.channelId;
|
||||
const gatewayId = envelope.gatewayId ? convertHexIdToNumericId(envelope.gatewayId) : null;
|
||||
|
||||
// Determine number of edges: route.length + 1
|
||||
const numEdges = route.length + 1;
|
||||
const edgesToCreate = [];
|
||||
|
||||
// Extract edges from the route path
|
||||
for(let i = 0; i < numEdges; i++) {
|
||||
// Get SNR for this edge
|
||||
if(i >= snrTowards.length) {
|
||||
// Array length mismatch - skip this edge
|
||||
continue;
|
||||
}
|
||||
|
||||
const snr = snrTowards[i];
|
||||
|
||||
// Skip if SNR is -128 (no SNR recorded)
|
||||
if(snr === -128) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine from_node and to_node
|
||||
let fromNodeId, toNodeId;
|
||||
|
||||
if(route.length === 0) {
|
||||
// Empty route: direct connection (to -> from)
|
||||
fromNodeId = originNodeId;
|
||||
toNodeId = destinationNodeId;
|
||||
} else if(i === 0) {
|
||||
// First edge: origin -> route[0]
|
||||
fromNodeId = originNodeId;
|
||||
toNodeId = route[0];
|
||||
} else if(i === route.length) {
|
||||
// Last edge: route[route.length-1] -> destination
|
||||
fromNodeId = route[route.length - 1];
|
||||
toNodeId = destinationNodeId;
|
||||
} else {
|
||||
// Middle edge: route[i-1] -> route[i]
|
||||
fromNodeId = route[i - 1];
|
||||
toNodeId = route[i];
|
||||
}
|
||||
|
||||
// Fetch node positions from Node table
|
||||
const [fromNode, toNode] = await Promise.all([
|
||||
prisma.node.findUnique({
|
||||
where: { node_id: fromNodeId },
|
||||
select: { latitude: true, longitude: true },
|
||||
}),
|
||||
prisma.node.findUnique({
|
||||
where: { node_id: toNodeId },
|
||||
select: { latitude: true, longitude: true },
|
||||
}),
|
||||
]);
|
||||
|
||||
// Create edge record (skip if nodes don't exist, but still create edge with null positions)
|
||||
edgesToCreate.push({
|
||||
from_node_id: fromNodeId,
|
||||
to_node_id: toNodeId,
|
||||
snr: snr,
|
||||
from_latitude: fromNode?.latitude ?? null,
|
||||
from_longitude: fromNode?.longitude ?? null,
|
||||
to_latitude: toNode?.latitude ?? null,
|
||||
to_longitude: toNode?.longitude ?? null,
|
||||
packet_id: packetId,
|
||||
channel_id: channelId,
|
||||
gateway_id: gatewayId,
|
||||
source: "TRACEROUTE_APP",
|
||||
});
|
||||
}
|
||||
|
||||
// Extract edges from route_back path
|
||||
const routeBack = routeDiscovery.routeBack || [];
|
||||
const snrBack = routeDiscovery.snrBack || [];
|
||||
|
||||
if(routeBack.length > 0) {
|
||||
// Number of edges in route_back equals route_back.length
|
||||
for(let i = 0; i < routeBack.length; i++) {
|
||||
// Get SNR for this edge
|
||||
if(i >= snrBack.length) {
|
||||
// Array length mismatch - skip this edge
|
||||
continue;
|
||||
}
|
||||
|
||||
const snr = snrBack[i];
|
||||
|
||||
// Skip if SNR is -128 (no SNR recorded)
|
||||
if(snr === -128) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine from_node and to_node
|
||||
let fromNodeId, toNodeId;
|
||||
|
||||
if(i === 0) {
|
||||
// First edge: from -> route_back[0]
|
||||
fromNodeId = destinationNodeId; // 'from' in the packet
|
||||
toNodeId = routeBack[0];
|
||||
} else {
|
||||
// Subsequent edges: route_back[i-1] -> route_back[i]
|
||||
fromNodeId = routeBack[i - 1];
|
||||
toNodeId = routeBack[i];
|
||||
}
|
||||
|
||||
// Fetch node positions from Node table
|
||||
const [fromNode, toNode] = await Promise.all([
|
||||
prisma.node.findUnique({
|
||||
where: { node_id: fromNodeId },
|
||||
select: { latitude: true, longitude: true },
|
||||
}),
|
||||
prisma.node.findUnique({
|
||||
where: { node_id: toNodeId },
|
||||
select: { latitude: true, longitude: true },
|
||||
}),
|
||||
]);
|
||||
|
||||
// Create edge record
|
||||
edgesToCreate.push({
|
||||
from_node_id: fromNodeId,
|
||||
to_node_id: toNodeId,
|
||||
snr: snr,
|
||||
from_latitude: fromNode?.latitude ?? null,
|
||||
from_longitude: fromNode?.longitude ?? null,
|
||||
to_latitude: toNode?.latitude ?? null,
|
||||
to_longitude: toNode?.longitude ?? null,
|
||||
packet_id: packetId,
|
||||
channel_id: channelId,
|
||||
gateway_id: gatewayId,
|
||||
source: "TRACEROUTE_APP",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Bulk insert edges
|
||||
if(edgesToCreate.length > 0) {
|
||||
await prisma.edge.createMany({
|
||||
data: edgesToCreate,
|
||||
skipDuplicates: true, // Skip if exact duplicate exists
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
// Log error but don't crash - edge extraction is non-critical
|
||||
console.error("Error extracting edges from traceroute:", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if(portnum === 73) {
|
||||
|
|
@ -1369,6 +1658,7 @@ client.on("message", async (topic, message) => {
|
|||
|| portnum === 0 // ignore UNKNOWN_APP
|
||||
|| portnum === 1 // ignore TEXT_MESSAGE_APP
|
||||
|| portnum === 5 // ignore ROUTING_APP
|
||||
|| portnum === 6 // ignore ADMIN_APP
|
||||
|| portnum === 34 // ignore PAXCOUNTER_APP
|
||||
|| portnum === 65 // ignore STORE_FORWARD_APP
|
||||
|| portnum === 66 // ignore RANGE_TEST_APP
|
||||
|
|
@ -1385,6 +1675,32 @@ client.on("message", async (topic, message) => {
|
|||
}
|
||||
|
||||
} catch(e) {
|
||||
// ignore errors
|
||||
console.log("error", e);
|
||||
}
|
||||
});
|
||||
|
||||
// Graceful shutdown handlers
|
||||
function gracefulShutdown(signal) {
|
||||
console.log(`Received ${signal}. Starting graceful shutdown...`);
|
||||
|
||||
// Clear the purge interval if it exists
|
||||
if(purgeInterval) {
|
||||
clearInterval(purgeInterval);
|
||||
console.log('Purge interval cleared');
|
||||
}
|
||||
|
||||
// Close MQTT client
|
||||
client.end(false, async () => {
|
||||
console.log('MQTT client disconnected');
|
||||
await prisma.$disconnect();
|
||||
console.log('Database connections closed');
|
||||
console.log('Graceful shutdown completed');
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
// Handle SIGTERM (Docker, systemd, etc.)
|
||||
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
|
||||
|
||||
// Handle SIGINT (Ctrl+C)
|
||||
process.on('SIGINT', () => gracefulShutdown('SIGINT'));
|
||||
|
|
|
|||
1
src/protobufs
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit c2e45a3fc9cda6aedb72ad3b5b88fcccfa78073e
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
*AdminMessage.payload_variant anonymous_oneof:true
|
||||
|
||||
*AdminMessage.set_canned_message_module_messages max_size:201
|
||||
*AdminMessage.get_canned_message_module_messages_response max_size:201
|
||||
*AdminMessage.delete_file_request max_size:201
|
||||
|
||||
*AdminMessage.set_ringtone_message max_size:231
|
||||
*AdminMessage.get_ringtone_response max_size:231
|
||||
|
||||
*HamParameters.call_sign max_size:8
|
||||
*HamParameters.short_name max_size:6
|
||||
*NodeRemoteHardwarePinsResponse.node_remote_hardware_pins max_count:16
|
||||
|
|
@ -1,364 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
import "meshtastic/channel.proto";
|
||||
import "meshtastic/config.proto";
|
||||
import "meshtastic/connection_status.proto";
|
||||
import "meshtastic/deviceonly.proto";
|
||||
import "meshtastic/mesh.proto";
|
||||
import "meshtastic/module_config.proto";
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "AdminProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* This message is handled by the Admin module and is responsible for all settings/channel read/write operations.
|
||||
* This message is used to do settings operations to both remote AND local nodes.
|
||||
* (Prior to 1.2 these operations were done via special ToRadio operations)
|
||||
*/
|
||||
message AdminMessage {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
enum ConfigType {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
DEVICE_CONFIG = 0;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
POSITION_CONFIG = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
POWER_CONFIG = 2;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
NETWORK_CONFIG = 3;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
DISPLAY_CONFIG = 4;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
LORA_CONFIG = 5;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
BLUETOOTH_CONFIG = 6;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
enum ModuleConfigType {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
MQTT_CONFIG = 0;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
SERIAL_CONFIG = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
EXTNOTIF_CONFIG = 2;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
STOREFORWARD_CONFIG = 3;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
RANGETEST_CONFIG = 4;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
TELEMETRY_CONFIG = 5;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
CANNEDMSG_CONFIG = 6;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
AUDIO_CONFIG = 7;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
REMOTEHARDWARE_CONFIG = 8;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
NEIGHBORINFO_CONFIG = 9;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
AMBIENTLIGHTING_CONFIG = 10;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
DETECTIONSENSOR_CONFIG = 11;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
PAXCOUNTER_CONFIG = 12;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
oneof payload_variant {
|
||||
/*
|
||||
* Send the specified channel in the response to this message
|
||||
* NOTE: This field is sent with the channel index + 1 (to ensure we never try to send 'zero' - which protobufs treats as not present)
|
||||
*/
|
||||
uint32 get_channel_request = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
Channel get_channel_response = 2;
|
||||
|
||||
/*
|
||||
* Send the current owner data in the response to this message.
|
||||
*/
|
||||
bool get_owner_request = 3;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
User get_owner_response = 4;
|
||||
|
||||
/*
|
||||
* Ask for the following config data to be sent
|
||||
*/
|
||||
ConfigType get_config_request = 5;
|
||||
|
||||
/*
|
||||
* Send the current Config in the response to this message.
|
||||
*/
|
||||
Config get_config_response = 6;
|
||||
|
||||
/*
|
||||
* Ask for the following config data to be sent
|
||||
*/
|
||||
ModuleConfigType get_module_config_request = 7;
|
||||
|
||||
/*
|
||||
* Send the current Config in the response to this message.
|
||||
*/
|
||||
ModuleConfig get_module_config_response = 8;
|
||||
|
||||
/*
|
||||
* Get the Canned Message Module messages in the response to this message.
|
||||
*/
|
||||
bool get_canned_message_module_messages_request = 10;
|
||||
|
||||
/*
|
||||
* Get the Canned Message Module messages in the response to this message.
|
||||
*/
|
||||
string get_canned_message_module_messages_response = 11;
|
||||
|
||||
/*
|
||||
* Request the node to send device metadata (firmware, protobuf version, etc)
|
||||
*/
|
||||
bool get_device_metadata_request = 12;
|
||||
|
||||
/*
|
||||
* Device metadata response
|
||||
*/
|
||||
DeviceMetadata get_device_metadata_response = 13;
|
||||
|
||||
/*
|
||||
* Get the Ringtone in the response to this message.
|
||||
*/
|
||||
bool get_ringtone_request = 14;
|
||||
|
||||
/*
|
||||
* Get the Ringtone in the response to this message.
|
||||
*/
|
||||
string get_ringtone_response = 15;
|
||||
|
||||
/*
|
||||
* Request the node to send it's connection status
|
||||
*/
|
||||
bool get_device_connection_status_request = 16;
|
||||
|
||||
/*
|
||||
* Device connection status response
|
||||
*/
|
||||
DeviceConnectionStatus get_device_connection_status_response = 17;
|
||||
|
||||
/*
|
||||
* Setup a node for licensed amateur (ham) radio operation
|
||||
*/
|
||||
HamParameters set_ham_mode = 18;
|
||||
|
||||
/*
|
||||
* Get the mesh's nodes with their available gpio pins for RemoteHardware module use
|
||||
*/
|
||||
bool get_node_remote_hardware_pins_request = 19;
|
||||
|
||||
/*
|
||||
* Respond with the mesh's nodes with their available gpio pins for RemoteHardware module use
|
||||
*/
|
||||
NodeRemoteHardwarePinsResponse get_node_remote_hardware_pins_response = 20;
|
||||
|
||||
/*
|
||||
* Enter (UF2) DFU mode
|
||||
* Only implemented on NRF52 currently
|
||||
*/
|
||||
bool enter_dfu_mode_request = 21;
|
||||
|
||||
/*
|
||||
* Delete the file by the specified path from the device
|
||||
*/
|
||||
string delete_file_request = 22;
|
||||
|
||||
/*
|
||||
* Set the owner for this node
|
||||
*/
|
||||
User set_owner = 32;
|
||||
|
||||
/*
|
||||
* Set channels (using the new API).
|
||||
* A special channel is the "primary channel".
|
||||
* The other records are secondary channels.
|
||||
* Note: only one channel can be marked as primary.
|
||||
* If the client sets a particular channel to be primary, the previous channel will be set to SECONDARY automatically.
|
||||
*/
|
||||
Channel set_channel = 33;
|
||||
|
||||
/*
|
||||
* Set the current Config
|
||||
*/
|
||||
Config set_config = 34;
|
||||
|
||||
/*
|
||||
* Set the current Config
|
||||
*/
|
||||
ModuleConfig set_module_config = 35;
|
||||
|
||||
/*
|
||||
* Set the Canned Message Module messages text.
|
||||
*/
|
||||
string set_canned_message_module_messages = 36;
|
||||
|
||||
/*
|
||||
* Set the ringtone for ExternalNotification.
|
||||
*/
|
||||
string set_ringtone_message = 37;
|
||||
|
||||
/*
|
||||
* Remove the node by the specified node-num from the NodeDB on the device
|
||||
*/
|
||||
uint32 remove_by_nodenum = 38;
|
||||
|
||||
/*
|
||||
* Begins an edit transaction for config, module config, owner, and channel settings changes
|
||||
* This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings)
|
||||
*/
|
||||
bool begin_edit_settings = 64;
|
||||
|
||||
/*
|
||||
* Commits an open transaction for any edits made to config, module config, owner, and channel settings
|
||||
*/
|
||||
bool commit_edit_settings = 65;
|
||||
|
||||
/*
|
||||
* Tell the node to reboot into the OTA Firmware in this many seconds (or <0 to cancel reboot)
|
||||
* Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth.
|
||||
*/
|
||||
int32 reboot_ota_seconds = 95;
|
||||
|
||||
/*
|
||||
* This message is only supported for the simulator Portduino build.
|
||||
* If received the simulator will exit successfully.
|
||||
*/
|
||||
bool exit_simulator = 96;
|
||||
|
||||
/*
|
||||
* Tell the node to reboot in this many seconds (or <0 to cancel reboot)
|
||||
*/
|
||||
int32 reboot_seconds = 97;
|
||||
|
||||
/*
|
||||
* Tell the node to shutdown in this many seconds (or <0 to cancel shutdown)
|
||||
*/
|
||||
int32 shutdown_seconds = 98;
|
||||
|
||||
/*
|
||||
* Tell the node to factory reset, all device settings will be returned to factory defaults.
|
||||
*/
|
||||
int32 factory_reset = 99;
|
||||
|
||||
/*
|
||||
* Tell the node to reset the nodedb.
|
||||
*/
|
||||
int32 nodedb_reset = 100;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Parameters for setting up Meshtastic for ameteur radio usage
|
||||
*/
|
||||
message HamParameters {
|
||||
/*
|
||||
* Amateur radio call sign, eg. KD2ABC
|
||||
*/
|
||||
string call_sign = 1;
|
||||
|
||||
/*
|
||||
* Transmit power in dBm at the LoRA transceiver, not including any amplification
|
||||
*/
|
||||
int32 tx_power = 2;
|
||||
|
||||
/*
|
||||
* The selected frequency of LoRA operation
|
||||
* Please respect your local laws, regulations, and band plans.
|
||||
* Ensure your radio is capable of operating of the selected frequency before setting this.
|
||||
*/
|
||||
float frequency = 3;
|
||||
|
||||
/*
|
||||
* Optional short name of user
|
||||
*/
|
||||
string short_name = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Response envelope for node_remote_hardware_pins
|
||||
*/
|
||||
message NodeRemoteHardwarePinsResponse {
|
||||
/*
|
||||
* Nodes and their respective remote hardware GPIO pins
|
||||
*/
|
||||
repeated NodeRemoteHardwarePin node_remote_hardware_pins = 1;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
*ChannelSet.settings max_count:8
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
import "meshtastic/channel.proto";
|
||||
import "meshtastic/config.proto";
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "AppOnlyProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* This is the most compact possible representation for a set of channels.
|
||||
* It includes only one PRIMARY channel (which must be first) and
|
||||
* any SECONDARY channels.
|
||||
* No DISABLED channels are included.
|
||||
* This abstraction is used only on the the 'app side' of the world (ie python, javascript and android etc) to show a group of Channels as a (long) URL
|
||||
*/
|
||||
message ChannelSet {
|
||||
/*
|
||||
* Channel list with settings
|
||||
*/
|
||||
repeated ChannelSettings settings = 1;
|
||||
|
||||
/*
|
||||
* LoRa config
|
||||
*/
|
||||
Config.LoRaConfig lora_config = 2;
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
*Contact.callsign max_size:120
|
||||
*Contact.device_callsign max_size:120
|
||||
*Status.battery int_size:8
|
||||
*PLI.course int_size:16
|
||||
*GeoChat.message max_size:200
|
||||
*GeoChat.to max_size:120
|
||||
|
|
@ -1,251 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "ATAKProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
/*
|
||||
* Packets for the official ATAK Plugin
|
||||
*/
|
||||
message TAKPacket
|
||||
{
|
||||
/*
|
||||
* Are the payloads strings compressed for LoRA transport?
|
||||
*/
|
||||
bool is_compressed = 1;
|
||||
/*
|
||||
* The contact / callsign for ATAK user
|
||||
*/
|
||||
Contact contact = 2;
|
||||
/*
|
||||
* The group for ATAK user
|
||||
*/
|
||||
Group group = 3;
|
||||
/*
|
||||
* The status of the ATAK EUD
|
||||
*/
|
||||
Status status = 4;
|
||||
/*
|
||||
* The payload of the packet
|
||||
*/
|
||||
oneof payload_variant {
|
||||
/*
|
||||
* TAK position report
|
||||
*/
|
||||
PLI pli = 5;
|
||||
/*
|
||||
* ATAK GeoChat message
|
||||
*/
|
||||
GeoChat chat = 6;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ATAK GeoChat message
|
||||
*/
|
||||
message GeoChat {
|
||||
/*
|
||||
* The text message
|
||||
*/
|
||||
string message = 1;
|
||||
|
||||
/*
|
||||
* Uid recipient of the message
|
||||
*/
|
||||
optional string to = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* ATAK Group
|
||||
* <__group role='Team Member' name='Cyan'/>
|
||||
*/
|
||||
message Group {
|
||||
/*
|
||||
* Role of the group member
|
||||
*/
|
||||
MemberRole role = 1;
|
||||
/*
|
||||
* Team (color)
|
||||
* Default Cyan
|
||||
*/
|
||||
Team team = 2;
|
||||
}
|
||||
|
||||
enum Team {
|
||||
/*
|
||||
* Unspecifed
|
||||
*/
|
||||
Unspecifed_Color = 0;
|
||||
/*
|
||||
* White
|
||||
*/
|
||||
White = 1;
|
||||
/*
|
||||
* Yellow
|
||||
*/
|
||||
Yellow = 2;
|
||||
/*
|
||||
* Orange
|
||||
*/
|
||||
Orange = 3;
|
||||
/*
|
||||
* Magenta
|
||||
*/
|
||||
Magenta = 4;
|
||||
/*
|
||||
* Red
|
||||
*/
|
||||
Red = 5;
|
||||
/*
|
||||
* Maroon
|
||||
*/
|
||||
Maroon = 6;
|
||||
/*
|
||||
* Purple
|
||||
*/
|
||||
Purple = 7;
|
||||
/*
|
||||
* Dark Blue
|
||||
*/
|
||||
Dark_Blue = 8;
|
||||
/*
|
||||
* Blue
|
||||
*/
|
||||
Blue = 9;
|
||||
/*
|
||||
* Cyan
|
||||
*/
|
||||
Cyan = 10;
|
||||
/*
|
||||
* Teal
|
||||
*/
|
||||
Teal = 11;
|
||||
/*
|
||||
* Green
|
||||
*/
|
||||
Green = 12;
|
||||
/*
|
||||
* Dark Green
|
||||
*/
|
||||
Dark_Green = 13;
|
||||
/*
|
||||
* Brown
|
||||
*/
|
||||
Brown = 14;
|
||||
}
|
||||
|
||||
/*
|
||||
* Role of the group member
|
||||
*/
|
||||
enum MemberRole {
|
||||
/*
|
||||
* Unspecifed
|
||||
*/
|
||||
Unspecifed = 0;
|
||||
/*
|
||||
* Team Member
|
||||
*/
|
||||
TeamMember = 1;
|
||||
/*
|
||||
* Team Lead
|
||||
*/
|
||||
TeamLead = 2;
|
||||
/*
|
||||
* Headquarters
|
||||
*/
|
||||
HQ = 3;
|
||||
/*
|
||||
* Airsoft enthusiast
|
||||
*/
|
||||
Sniper = 4;
|
||||
/*
|
||||
* Medic
|
||||
*/
|
||||
Medic = 5;
|
||||
/*
|
||||
* ForwardObserver
|
||||
*/
|
||||
ForwardObserver = 6;
|
||||
/*
|
||||
* Radio Telephone Operator
|
||||
*/
|
||||
RTO = 7;
|
||||
/*
|
||||
* Doggo
|
||||
*/
|
||||
K9 = 8;
|
||||
}
|
||||
|
||||
/*
|
||||
* ATAK EUD Status
|
||||
* <status battery='100' />
|
||||
*/
|
||||
message Status {
|
||||
/*
|
||||
* Battery level
|
||||
*/
|
||||
uint32 battery = 1;
|
||||
}
|
||||
/*
|
||||
* ATAK Contact
|
||||
* <contact endpoint='0.0.0.0:4242:tcp' phone='+12345678' callsign='FALKE'/>
|
||||
*/
|
||||
message Contact {
|
||||
/*
|
||||
* Callsign
|
||||
*/
|
||||
string callsign = 1;
|
||||
|
||||
/*
|
||||
* Device callsign
|
||||
*/
|
||||
string device_callsign = 2;
|
||||
/*
|
||||
* IP address of endpoint in integer form (0.0.0.0 default)
|
||||
*/
|
||||
// fixed32 enpoint_address = 3;
|
||||
/*
|
||||
* Port of endpoint (4242 default)
|
||||
*/
|
||||
// uint32 endpoint_port = 4;
|
||||
/*
|
||||
* Phone represented as integer
|
||||
* Terrible practice, but we really need the wire savings
|
||||
*/
|
||||
// uint32 phone = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Position Location Information from ATAK
|
||||
*/
|
||||
message PLI {
|
||||
/*
|
||||
* The new preferred location encoding, multiply by 1e-7 to get degrees
|
||||
* in floating point
|
||||
*/
|
||||
sfixed32 latitude_i = 1;
|
||||
|
||||
/*
|
||||
* The new preferred location encoding, multiply by 1e-7 to get degrees
|
||||
* in floating point
|
||||
*/
|
||||
sfixed32 longitude_i = 2;
|
||||
|
||||
/*
|
||||
* Altitude (ATAK prefers HAE)
|
||||
*/
|
||||
int32 altitude = 3;
|
||||
|
||||
/*
|
||||
* Speed
|
||||
*/
|
||||
uint32 speed = 4;
|
||||
|
||||
/*
|
||||
* Course in degrees
|
||||
*/
|
||||
uint32 course = 5;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
*CannedMessageModuleConfig.messages max_size:201
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "CannedMessageConfigProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* Canned message module configuration.
|
||||
*/
|
||||
message CannedMessageModuleConfig {
|
||||
/*
|
||||
* Predefined messages for canned message module separated by '|' characters.
|
||||
*/
|
||||
string messages = 1;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
*Channel.index int_size:8
|
||||
|
||||
# 256 bit or 128 bit psk key
|
||||
*ChannelSettings.psk max_size:32
|
||||
*ChannelSettings.name max_size:12
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "ChannelProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* This information can be encoded as a QRcode/url so that other users can configure
|
||||
* their radio to join the same channel.
|
||||
* A note about how channel names are shown to users: channelname-X
|
||||
* poundsymbol is a prefix used to indicate this is a channel name (idea from @professr).
|
||||
* Where X is a letter from A-Z (base 26) representing a hash of the PSK for this
|
||||
* channel - so that if the user changes anything about the channel (which does
|
||||
* force a new PSK) this letter will also change. Thus preventing user confusion if
|
||||
* two friends try to type in a channel name of "BobsChan" and then can't talk
|
||||
* because their PSKs will be different.
|
||||
* The PSK is hashed into this letter by "0x41 + [xor all bytes of the psk ] modulo 26"
|
||||
* This also allows the option of someday if people have the PSK off (zero), the
|
||||
* users COULD type in a channel name and be able to talk.
|
||||
* FIXME: Add description of multi-channel support and how primary vs secondary channels are used.
|
||||
* FIXME: explain how apps use channels for security.
|
||||
* explain how remote settings and remote gpio are managed as an example
|
||||
*/
|
||||
message ChannelSettings {
|
||||
/*
|
||||
* Deprecated in favor of LoraConfig.channel_num
|
||||
*/
|
||||
uint32 channel_num = 1 [deprecated = true];
|
||||
|
||||
/*
|
||||
* A simple pre-shared key for now for crypto.
|
||||
* Must be either 0 bytes (no crypto), 16 bytes (AES128), or 32 bytes (AES256).
|
||||
* A special shorthand is used for 1 byte long psks.
|
||||
* These psks should be treated as only minimally secure,
|
||||
* because they are listed in this source code.
|
||||
* Those bytes are mapped using the following scheme:
|
||||
* `0` = No crypto
|
||||
* `1` = The special "default" channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0x01}
|
||||
* `2` through 10 = The default channel key, except with 1 through 9 added to the last byte.
|
||||
* Shown to user as simple1 through 10
|
||||
*/
|
||||
bytes psk = 2;
|
||||
|
||||
/*
|
||||
* A SHORT name that will be packed into the URL.
|
||||
* Less than 12 bytes.
|
||||
* Something for end users to call the channel
|
||||
* If this is the empty string it is assumed that this channel
|
||||
* is the special (minimally secure) "Default"channel.
|
||||
* In user interfaces it should be rendered as a local language translation of "X".
|
||||
* For channel_num hashing empty string will be treated as "X".
|
||||
* Where "X" is selected based on the English words listed above for ModemPreset
|
||||
*/
|
||||
string name = 3;
|
||||
|
||||
/*
|
||||
* Used to construct a globally unique channel ID.
|
||||
* The full globally unique ID will be: "name.id" where ID is shown as base36.
|
||||
* Assuming that the number of meshtastic users is below 20K (true for a long time)
|
||||
* the chance of this 64 bit random number colliding with anyone else is super low.
|
||||
* And the penalty for collision is low as well, it just means that anyone trying to decrypt channel messages might need to
|
||||
* try multiple candidate channels.
|
||||
* Any time a non wire compatible change is made to a channel, this field should be regenerated.
|
||||
* There are a small number of 'special' globally known (and fairly) insecure standard channels.
|
||||
* Those channels do not have a numeric id included in the settings, but instead it is pulled from
|
||||
* a table of well known IDs.
|
||||
* (see Well Known Channels FIXME)
|
||||
*/
|
||||
fixed32 id = 4;
|
||||
|
||||
/*
|
||||
* If true, messages on the mesh will be sent to the *public* internet by any gateway ndoe
|
||||
*/
|
||||
bool uplink_enabled = 5;
|
||||
|
||||
/*
|
||||
* If true, messages seen on the internet will be forwarded to the local mesh.
|
||||
*/
|
||||
bool downlink_enabled = 6;
|
||||
|
||||
/*
|
||||
* Per-channel module settings.
|
||||
*/
|
||||
ModuleSettings module_settings = 7;
|
||||
}
|
||||
|
||||
/*
|
||||
* This message is specifically for modules to store per-channel configuration data.
|
||||
*/
|
||||
message ModuleSettings {
|
||||
/*
|
||||
* Bits of precision for the location sent in position packets.
|
||||
*/
|
||||
uint32 position_precision = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* A pair of a channel number, mode and the (sharable) settings for that channel
|
||||
*/
|
||||
message Channel {
|
||||
/*
|
||||
* How this channel is being used (or not).
|
||||
* Note: this field is an enum to give us options for the future.
|
||||
* In particular, someday we might make a 'SCANNING' option.
|
||||
* SCANNING channels could have different frequencies and the radio would
|
||||
* occasionally check that freq to see if anything is being transmitted.
|
||||
* For devices that have multiple physical radios attached, we could keep multiple PRIMARY/SCANNING channels active at once to allow
|
||||
* cross band routing as needed.
|
||||
* If a device has only a single radio (the common case) only one channel can be PRIMARY at a time
|
||||
* (but any number of SECONDARY channels can't be sent received on that common frequency)
|
||||
*/
|
||||
enum Role {
|
||||
/*
|
||||
* This channel is not in use right now
|
||||
*/
|
||||
DISABLED = 0;
|
||||
|
||||
/*
|
||||
* This channel is used to set the frequency for the radio - all other enabled channels must be SECONDARY
|
||||
*/
|
||||
PRIMARY = 1;
|
||||
|
||||
/*
|
||||
* Secondary channels are only used for encryption/decryption/authentication purposes.
|
||||
* Their radio settings (freq etc) are ignored, only psk is used.
|
||||
*/
|
||||
SECONDARY = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* The index of this channel in the channel table (from 0 to MAX_NUM_CHANNELS-1)
|
||||
* (Someday - not currently implemented) An index of -1 could be used to mean "set by name",
|
||||
* in which case the target node will find and set the channel by settings.name.
|
||||
*/
|
||||
int32 index = 1;
|
||||
|
||||
/*
|
||||
* The new settings, or NULL to disable that channel
|
||||
*/
|
||||
ChannelSettings settings = 2;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
Role role = 3;
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
*DeviceProfile.long_name max_size:40
|
||||
*DeviceProfile.short_name max_size:5
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
import "meshtastic/localonly.proto";
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "ClientOnlyProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* This abstraction is used to contain any configuration for provisioning a node on any client.
|
||||
* It is useful for importing and exporting configurations.
|
||||
*/
|
||||
message DeviceProfile {
|
||||
/*
|
||||
* Long name for the node
|
||||
*/
|
||||
optional string long_name = 1;
|
||||
|
||||
/*
|
||||
* Short name of the node
|
||||
*/
|
||||
optional string short_name = 2;
|
||||
|
||||
/*
|
||||
* The url of the channels from our node
|
||||
*/
|
||||
optional string channel_url = 3;
|
||||
|
||||
/*
|
||||
* The Config of the node
|
||||
*/
|
||||
optional LocalConfig config = 4;
|
||||
|
||||
/*
|
||||
* The ModuleConfig of the node
|
||||
*/
|
||||
optional LocalModuleConfig module_config = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* A heartbeat message is sent by a node to indicate that it is still alive.
|
||||
* This is currently only needed to keep serial connections alive.
|
||||
*/
|
||||
message Heartbeat {
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
*NetworkConfig.wifi_ssid max_size:33
|
||||
*NetworkConfig.wifi_psk max_size:65
|
||||
*NetworkConfig.ntp_server max_size:33
|
||||
*NetworkConfig.rsyslog_server max_size:33
|
||||
|
||||
# Max of three ignored nodes for our testing
|
||||
*LoRaConfig.ignore_incoming max_count:3
|
||||
|
||||
*LoRaConfig.tx_power int_size:8
|
||||
*LoRaConfig.bandwidth int_size:16
|
||||
*LoRaConfig.coding_rate int_size:8
|
||||
*LoRaConfig.channel_num int_size:16
|
||||
|
||||
*PowerConfig.device_battery_ina_address int_size:8
|
||||
|
|
@ -1,986 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "ConfigProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
message Config {
|
||||
/*
|
||||
* Configuration
|
||||
*/
|
||||
message DeviceConfig {
|
||||
/*
|
||||
* Defines the device's role on the Mesh network
|
||||
*/
|
||||
enum Role {
|
||||
/*
|
||||
* Description: App connected or stand alone messaging device.
|
||||
* Technical Details: Default Role
|
||||
*/
|
||||
CLIENT = 0;
|
||||
/*
|
||||
* Description: Device that does not forward packets from other devices.
|
||||
*/
|
||||
CLIENT_MUTE = 1;
|
||||
|
||||
/*
|
||||
* Description: Infrastructure node for extending network coverage by relaying messages. Visible in Nodes list.
|
||||
* Technical Details: Mesh packets will prefer to be routed over this node. This node will not be used by client apps.
|
||||
* The wifi radio and the oled screen will be put to sleep.
|
||||
* This mode may still potentially have higher power usage due to it's preference in message rebroadcasting on the mesh.
|
||||
*/
|
||||
ROUTER = 2;
|
||||
|
||||
/*
|
||||
* Description: Combination of both ROUTER and CLIENT. Not for mobile devices.
|
||||
*/
|
||||
ROUTER_CLIENT = 3;
|
||||
|
||||
/*
|
||||
* Description: Infrastructure node for extending network coverage by relaying messages with minimal overhead. Not visible in Nodes list.
|
||||
* Technical Details: Mesh packets will simply be rebroadcasted over this node. Nodes configured with this role will not originate NodeInfo, Position, Telemetry
|
||||
* or any other packet type. They will simply rebroadcast any mesh packets on the same frequency, channel num, spread factor, and coding rate.
|
||||
*/
|
||||
REPEATER = 4;
|
||||
|
||||
/*
|
||||
* Description: Broadcasts GPS position packets as priority.
|
||||
* Technical Details: Position Mesh packets will be prioritized higher and sent more frequently by default.
|
||||
* When used in conjunction with power.is_power_saving = true, nodes will wake up,
|
||||
* send position, and then sleep for position.position_broadcast_secs seconds.
|
||||
*/
|
||||
TRACKER = 5;
|
||||
|
||||
/*
|
||||
* Description: Broadcasts telemetry packets as priority.
|
||||
* Technical Details: Telemetry Mesh packets will be prioritized higher and sent more frequently by default.
|
||||
* When used in conjunction with power.is_power_saving = true, nodes will wake up,
|
||||
* send environment telemetry, and then sleep for telemetry.environment_update_interval seconds.
|
||||
*/
|
||||
SENSOR = 6;
|
||||
|
||||
/*
|
||||
* Description: Optimized for ATAK system communication and reduces routine broadcasts.
|
||||
* Technical Details: Used for nodes dedicated for connection to an ATAK EUD.
|
||||
* Turns off many of the routine broadcasts to favor CoT packet stream
|
||||
* from the Meshtastic ATAK plugin -> IMeshService -> Node
|
||||
*/
|
||||
TAK = 7;
|
||||
|
||||
/*
|
||||
* Description: Device that only broadcasts as needed for stealth or power savings.
|
||||
* Technical Details: Used for nodes that "only speak when spoken to"
|
||||
* Turns all of the routine broadcasts but allows for ad-hoc communication
|
||||
* Still rebroadcasts, but with local only rebroadcast mode (known meshes only)
|
||||
* Can be used for clandestine operation or to dramatically reduce airtime / power consumption
|
||||
*/
|
||||
CLIENT_HIDDEN = 8;
|
||||
|
||||
/*
|
||||
* Description: Broadcasts location as message to default channel regularly for to assist with device recovery.
|
||||
* Technical Details: Used to automatically send a text message to the mesh
|
||||
* with the current position of the device on a frequent interval:
|
||||
* "I'm lost! Position: lat / long"
|
||||
*/
|
||||
LOST_AND_FOUND = 9;
|
||||
|
||||
/*
|
||||
* Description: Enables automatic TAK PLI broadcasts and reduces routine broadcasts.
|
||||
* Technical Details: Turns off many of the routine broadcasts to favor ATAK CoT packet stream
|
||||
* and automatic TAK PLI (position location information) broadcasts.
|
||||
* Uses position module configuration to determine TAK PLI broadcast interval.
|
||||
*/
|
||||
TAK_TRACKER = 10;
|
||||
|
||||
/*
|
||||
* Description: Will always rebroadcast packets, but will do so after all other modes.
|
||||
* Technical Details: Used for router nodes that are intended to provide additional coverage
|
||||
* in areas not already covered by other routers, or to bridge around problematic terrain,
|
||||
* but should not be given priority over other routers in order to avoid unnecessaraily
|
||||
* consuming hops.
|
||||
*/
|
||||
ROUTER_LATE = 11;
|
||||
}
|
||||
|
||||
/*
|
||||
* Defines the device's behavior for how messages are rebroadcast
|
||||
*/
|
||||
enum RebroadcastMode {
|
||||
/*
|
||||
* Default behavior.
|
||||
* Rebroadcast any observed message, if it was on our private channel or from another mesh with the same lora params.
|
||||
*/
|
||||
ALL = 0;
|
||||
|
||||
/*
|
||||
* Same as behavior as ALL but skips packet decoding and simply rebroadcasts them.
|
||||
* Only available in Repeater role. Setting this on any other roles will result in ALL behavior.
|
||||
*/
|
||||
ALL_SKIP_DECODING = 1;
|
||||
|
||||
/*
|
||||
* Ignores observed messages from foreign meshes that are open or those which it cannot decrypt.
|
||||
* Only rebroadcasts message on the nodes local primary / secondary channels.
|
||||
*/
|
||||
LOCAL_ONLY = 2;
|
||||
|
||||
/*
|
||||
* Ignores observed messages from foreign meshes like LOCAL_ONLY,
|
||||
* but takes it step further by also ignoring messages from nodenums not in the node's known list (NodeDB)
|
||||
*/
|
||||
KNOWN_ONLY = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the role of node
|
||||
*/
|
||||
Role role = 1;
|
||||
|
||||
/*
|
||||
* Disabling this will disable the SerialConsole by not initilizing the StreamAPI
|
||||
*/
|
||||
bool serial_enabled = 2;
|
||||
|
||||
/*
|
||||
* By default we turn off logging as soon as an API client connects (to keep shared serial link quiet).
|
||||
* Set this to true to leave the debug log outputting even when API is active.
|
||||
*/
|
||||
bool debug_log_enabled = 3;
|
||||
|
||||
/*
|
||||
* For boards without a hard wired button, this is the pin number that will be used
|
||||
* Boards that have more than one button can swap the function with this one. defaults to BUTTON_PIN if defined.
|
||||
*/
|
||||
uint32 button_gpio = 4;
|
||||
|
||||
/*
|
||||
* For boards without a PWM buzzer, this is the pin number that will be used
|
||||
* Defaults to PIN_BUZZER if defined.
|
||||
*/
|
||||
uint32 buzzer_gpio = 5;
|
||||
|
||||
/*
|
||||
* Sets the role of node
|
||||
*/
|
||||
RebroadcastMode rebroadcast_mode = 6;
|
||||
|
||||
/*
|
||||
* Send our nodeinfo this often
|
||||
* Defaults to 900 Seconds (15 minutes)
|
||||
*/
|
||||
uint32 node_info_broadcast_secs = 7;
|
||||
|
||||
/*
|
||||
* Treat double tap interrupt on supported accelerometers as a button press if set to true
|
||||
*/
|
||||
bool double_tap_as_button_press = 8;
|
||||
|
||||
/*
|
||||
* If true, device is considered to be "managed" by a mesh administrator
|
||||
* Clients should then limit available configuration and administrative options inside the user interface
|
||||
*/
|
||||
bool is_managed = 9;
|
||||
|
||||
/*
|
||||
* Disables the triple-press of user button to enable or disable GPS
|
||||
*/
|
||||
bool disable_triple_click = 10;
|
||||
}
|
||||
|
||||
/*
|
||||
* Position Config
|
||||
*/
|
||||
message PositionConfig {
|
||||
/*
|
||||
* Bit field of boolean configuration options, indicating which optional
|
||||
* fields to include when assembling POSITION messages.
|
||||
* Longitude, latitude, altitude, speed, heading, and DOP
|
||||
* are always included (also time if GPS-synced)
|
||||
* NOTE: the more fields are included, the larger the message will be -
|
||||
* leading to longer airtime and a higher risk of packet loss
|
||||
*/
|
||||
enum PositionFlags {
|
||||
/*
|
||||
* Required for compilation
|
||||
*/
|
||||
UNSET = 0x0000;
|
||||
|
||||
/*
|
||||
* Include an altitude value (if available)
|
||||
*/
|
||||
ALTITUDE = 0x0001;
|
||||
|
||||
/*
|
||||
* Altitude value is MSL
|
||||
*/
|
||||
ALTITUDE_MSL = 0x0002;
|
||||
|
||||
/*
|
||||
* Include geoidal separation
|
||||
*/
|
||||
GEOIDAL_SEPARATION = 0x0004;
|
||||
|
||||
/*
|
||||
* Include the DOP value ; PDOP used by default, see below
|
||||
*/
|
||||
DOP = 0x0008;
|
||||
|
||||
/*
|
||||
* If POS_DOP set, send separate HDOP / VDOP values instead of PDOP
|
||||
*/
|
||||
HVDOP = 0x0010;
|
||||
|
||||
/*
|
||||
* Include number of "satellites in view"
|
||||
*/
|
||||
SATINVIEW = 0x0020;
|
||||
|
||||
/*
|
||||
* Include a sequence number incremented per packet
|
||||
*/
|
||||
SEQ_NO = 0x0040;
|
||||
|
||||
/*
|
||||
* Include positional timestamp (from GPS solution)
|
||||
*/
|
||||
TIMESTAMP = 0x0080;
|
||||
|
||||
/*
|
||||
* Include positional heading
|
||||
* Intended for use with vehicle not walking speeds
|
||||
* walking speeds are likely to be error prone like the compass
|
||||
*/
|
||||
HEADING = 0x0100;
|
||||
|
||||
/*
|
||||
* Include positional speed
|
||||
* Intended for use with vehicle not walking speeds
|
||||
* walking speeds are likely to be error prone like the compass
|
||||
*/
|
||||
SPEED = 0x0200;
|
||||
}
|
||||
|
||||
enum GpsMode {
|
||||
/*
|
||||
* GPS is present but disabled
|
||||
*/
|
||||
DISABLED = 0;
|
||||
|
||||
/*
|
||||
* GPS is present and enabled
|
||||
*/
|
||||
ENABLED = 1;
|
||||
|
||||
/*
|
||||
* GPS is not present on the device
|
||||
*/
|
||||
NOT_PRESENT = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* We should send our position this often (but only if it has changed significantly)
|
||||
* Defaults to 15 minutes
|
||||
*/
|
||||
uint32 position_broadcast_secs = 1;
|
||||
|
||||
/*
|
||||
* Adaptive position braoadcast, which is now the default.
|
||||
*/
|
||||
bool position_broadcast_smart_enabled = 2;
|
||||
|
||||
/*
|
||||
* If set, this node is at a fixed position.
|
||||
* We will generate GPS position updates at the regular interval, but use whatever the last lat/lon/alt we have for the node.
|
||||
* The lat/lon/alt can be set by an internal GPS or with the help of the app.
|
||||
*/
|
||||
bool fixed_position = 3;
|
||||
|
||||
/*
|
||||
* Is GPS enabled for this node?
|
||||
*/
|
||||
bool gps_enabled = 4[deprecated = true];
|
||||
|
||||
/*
|
||||
* How often should we try to get GPS position (in seconds)
|
||||
* or zero for the default of once every 30 seconds
|
||||
* or a very large value (maxint) to update only once at boot.
|
||||
*/
|
||||
uint32 gps_update_interval = 5;
|
||||
|
||||
/*
|
||||
* Deprecated in favor of using smart / regular broadcast intervals as implicit attempt time
|
||||
*/
|
||||
uint32 gps_attempt_time = 6 [deprecated = true];
|
||||
|
||||
/*
|
||||
* Bit field of boolean configuration options for POSITION messages
|
||||
* (bitwise OR of PositionFlags)
|
||||
*/
|
||||
uint32 position_flags = 7;
|
||||
|
||||
/*
|
||||
* (Re)define GPS_RX_PIN for your board.
|
||||
*/
|
||||
uint32 rx_gpio = 8;
|
||||
|
||||
/*
|
||||
* (Re)define GPS_TX_PIN for your board.
|
||||
*/
|
||||
uint32 tx_gpio = 9;
|
||||
|
||||
/*
|
||||
* The minimum distance in meters traveled (since the last send) before we can send a position to the mesh if position_broadcast_smart_enabled
|
||||
*/
|
||||
uint32 broadcast_smart_minimum_distance = 10;
|
||||
|
||||
/*
|
||||
* The minimum number of seconds (since the last send) before we can send a position to the mesh if position_broadcast_smart_enabled
|
||||
*/
|
||||
uint32 broadcast_smart_minimum_interval_secs = 11;
|
||||
|
||||
/*
|
||||
* (Re)define PIN_GPS_EN for your board.
|
||||
*/
|
||||
uint32 gps_en_gpio = 12;
|
||||
|
||||
/*
|
||||
* Set where GPS is enabled, disabled, or not present
|
||||
*/
|
||||
GpsMode gps_mode = 13;
|
||||
}
|
||||
|
||||
/*
|
||||
* Power Config\
|
||||
* See [Power Config](/docs/settings/config/power) for additional power config details.
|
||||
*/
|
||||
message PowerConfig {
|
||||
/*
|
||||
* If set, we are powered from a low-current source (i.e. solar), so even if it looks like we have power flowing in
|
||||
* we should try to minimize power consumption as much as possible.
|
||||
* YOU DO NOT NEED TO SET THIS IF YOU'VE set is_router (it is implied in that case).
|
||||
* Advanced Option
|
||||
*/
|
||||
bool is_power_saving = 1;
|
||||
|
||||
/*
|
||||
* If non-zero, the device will fully power off this many seconds after external power is removed.
|
||||
*/
|
||||
uint32 on_battery_shutdown_after_secs = 2;
|
||||
|
||||
/*
|
||||
* Ratio of voltage divider for battery pin eg. 3.20 (R1=100k, R2=220k)
|
||||
* Overrides the ADC_MULTIPLIER defined in variant for battery voltage calculation.
|
||||
* Should be set to floating point value between 2 and 4
|
||||
* Fixes issues on Heltec v2
|
||||
*/
|
||||
float adc_multiplier_override = 3;
|
||||
|
||||
/*
|
||||
* Wait Bluetooth Seconds
|
||||
* The number of seconds for to wait before turning off BLE in No Bluetooth states
|
||||
* 0 for default of 1 minute
|
||||
*/
|
||||
uint32 wait_bluetooth_secs = 4;
|
||||
|
||||
/*
|
||||
* Super Deep Sleep Seconds
|
||||
* While in Light Sleep if mesh_sds_timeout_secs is exceeded we will lower into super deep sleep
|
||||
* for this value (default 1 year) or a button press
|
||||
* 0 for default of one year
|
||||
*/
|
||||
uint32 sds_secs = 6;
|
||||
|
||||
/*
|
||||
* Light Sleep Seconds
|
||||
* In light sleep the CPU is suspended, LoRa radio is on, BLE is off an GPS is on
|
||||
* ESP32 Only
|
||||
* 0 for default of 300
|
||||
*/
|
||||
uint32 ls_secs = 7;
|
||||
|
||||
/*
|
||||
* Minimum Wake Seconds
|
||||
* While in light sleep when we receive packets on the LoRa radio we will wake and handle them and stay awake in no BLE mode for this value
|
||||
* 0 for default of 10 seconds
|
||||
*/
|
||||
uint32 min_wake_secs = 8;
|
||||
|
||||
/*
|
||||
* I2C address of INA_2XX to use for reading device battery voltage
|
||||
*/
|
||||
uint32 device_battery_ina_address = 9;
|
||||
}
|
||||
|
||||
/*
|
||||
* Network Config
|
||||
*/
|
||||
message NetworkConfig {
|
||||
enum AddressMode {
|
||||
/*
|
||||
* obtain ip address via DHCP
|
||||
*/
|
||||
DHCP = 0;
|
||||
|
||||
/*
|
||||
* use static ip address
|
||||
*/
|
||||
STATIC = 1;
|
||||
}
|
||||
|
||||
message IpV4Config {
|
||||
/*
|
||||
* Static IP address
|
||||
*/
|
||||
fixed32 ip = 1;
|
||||
|
||||
/*
|
||||
* Static gateway address
|
||||
*/
|
||||
fixed32 gateway = 2;
|
||||
|
||||
/*
|
||||
* Static subnet mask
|
||||
*/
|
||||
fixed32 subnet = 3;
|
||||
|
||||
/*
|
||||
* Static DNS server address
|
||||
*/
|
||||
fixed32 dns = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable WiFi (disables Bluetooth)
|
||||
*/
|
||||
bool wifi_enabled = 1;
|
||||
|
||||
/*
|
||||
* If set, this node will try to join the specified wifi network and
|
||||
* acquire an address via DHCP
|
||||
*/
|
||||
string wifi_ssid = 3;
|
||||
|
||||
/*
|
||||
* If set, will be use to authenticate to the named wifi
|
||||
*/
|
||||
string wifi_psk = 4;
|
||||
|
||||
/*
|
||||
* NTP server to use if WiFi is conneced, defaults to `0.pool.ntp.org`
|
||||
*/
|
||||
string ntp_server = 5;
|
||||
|
||||
/*
|
||||
* Enable Ethernet
|
||||
*/
|
||||
bool eth_enabled = 6;
|
||||
|
||||
/*
|
||||
* acquire an address via DHCP or assign static
|
||||
*/
|
||||
AddressMode address_mode = 7;
|
||||
|
||||
/*
|
||||
* struct to keep static address
|
||||
*/
|
||||
IpV4Config ipv4_config = 8;
|
||||
|
||||
/*
|
||||
* rsyslog Server and Port
|
||||
*/
|
||||
string rsyslog_server = 9;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display Config
|
||||
*/
|
||||
message DisplayConfig {
|
||||
/*
|
||||
* How the GPS coordinates are displayed on the OLED screen.
|
||||
*/
|
||||
enum GpsCoordinateFormat {
|
||||
/*
|
||||
* GPS coordinates are displayed in the normal decimal degrees format:
|
||||
* DD.DDDDDD DDD.DDDDDD
|
||||
*/
|
||||
DEC = 0;
|
||||
|
||||
/*
|
||||
* GPS coordinates are displayed in the degrees minutes seconds format:
|
||||
* DD°MM'SS"C DDD°MM'SS"C, where C is the compass point representing the locations quadrant
|
||||
*/
|
||||
DMS = 1;
|
||||
|
||||
/*
|
||||
* Universal Transverse Mercator format:
|
||||
* ZZB EEEEEE NNNNNNN, where Z is zone, B is band, E is easting, N is northing
|
||||
*/
|
||||
UTM = 2;
|
||||
|
||||
/*
|
||||
* Military Grid Reference System format:
|
||||
* ZZB CD EEEEE NNNNN, where Z is zone, B is band, C is the east 100k square, D is the north 100k square,
|
||||
* E is easting, N is northing
|
||||
*/
|
||||
MGRS = 3;
|
||||
|
||||
/*
|
||||
* Open Location Code (aka Plus Codes).
|
||||
*/
|
||||
OLC = 4;
|
||||
|
||||
/*
|
||||
* Ordnance Survey Grid Reference (the National Grid System of the UK).
|
||||
* Format: AB EEEEE NNNNN, where A is the east 100k square, B is the north 100k square,
|
||||
* E is the easting, N is the northing
|
||||
*/
|
||||
OSGR = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unit display preference
|
||||
*/
|
||||
enum DisplayUnits {
|
||||
/*
|
||||
* Metric (Default)
|
||||
*/
|
||||
METRIC = 0;
|
||||
|
||||
/*
|
||||
* Imperial
|
||||
*/
|
||||
IMPERIAL = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Override OLED outo detect with this if it fails.
|
||||
*/
|
||||
enum OledType {
|
||||
/*
|
||||
* Default / Auto
|
||||
*/
|
||||
OLED_AUTO = 0;
|
||||
|
||||
/*
|
||||
* Default / Auto
|
||||
*/
|
||||
OLED_SSD1306 = 1;
|
||||
|
||||
/*
|
||||
* Default / Auto
|
||||
*/
|
||||
OLED_SH1106 = 2;
|
||||
|
||||
/*
|
||||
* Can not be auto detected but set by proto. Used for 128x128 screens
|
||||
*/
|
||||
OLED_SH1107 = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* Number of seconds the screen stays on after pressing the user button or receiving a message
|
||||
* 0 for default of one minute MAXUINT for always on
|
||||
*/
|
||||
uint32 screen_on_secs = 1;
|
||||
|
||||
/*
|
||||
* How the GPS coordinates are formatted on the OLED screen.
|
||||
*/
|
||||
GpsCoordinateFormat gps_format = 2;
|
||||
|
||||
/*
|
||||
* Automatically toggles to the next page on the screen like a carousel, based the specified interval in seconds.
|
||||
* Potentially useful for devices without user buttons.
|
||||
*/
|
||||
uint32 auto_screen_carousel_secs = 3;
|
||||
|
||||
/*
|
||||
* If this is set, the displayed compass will always point north. if unset, the old behaviour
|
||||
* (top of display is heading direction) is used.
|
||||
*/
|
||||
bool compass_north_top = 4;
|
||||
|
||||
/*
|
||||
* Flip screen vertically, for cases that mount the screen upside down
|
||||
*/
|
||||
bool flip_screen = 5;
|
||||
|
||||
/*
|
||||
* Perferred display units
|
||||
*/
|
||||
DisplayUnits units = 6;
|
||||
|
||||
/*
|
||||
* Override auto-detect in screen
|
||||
*/
|
||||
OledType oled = 7;
|
||||
|
||||
enum DisplayMode {
|
||||
/*
|
||||
* Default. The old style for the 128x64 OLED screen
|
||||
*/
|
||||
DEFAULT = 0;
|
||||
|
||||
/*
|
||||
* Rearrange display elements to cater for bicolor OLED displays
|
||||
*/
|
||||
TWOCOLOR = 1;
|
||||
|
||||
/*
|
||||
* Same as TwoColor, but with inverted top bar. Not so good for Epaper displays
|
||||
*/
|
||||
INVERTED = 2;
|
||||
|
||||
/*
|
||||
* TFT Full Color Displays (not implemented yet)
|
||||
*/
|
||||
COLOR = 3;
|
||||
}
|
||||
/*
|
||||
* Display Mode
|
||||
*/
|
||||
DisplayMode displaymode = 8;
|
||||
|
||||
/*
|
||||
* Print first line in pseudo-bold? FALSE is original style, TRUE is bold
|
||||
*/
|
||||
bool heading_bold = 9;
|
||||
|
||||
/*
|
||||
* Should we wake the screen up on accelerometer detected motion or tap
|
||||
*/
|
||||
bool wake_on_tap_or_motion = 10;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lora Config
|
||||
*/
|
||||
message LoRaConfig {
|
||||
enum RegionCode {
|
||||
/*
|
||||
* Region is not set
|
||||
*/
|
||||
UNSET = 0;
|
||||
|
||||
/*
|
||||
* United States
|
||||
*/
|
||||
US = 1;
|
||||
|
||||
/*
|
||||
* European Union 433mhz
|
||||
*/
|
||||
EU_433 = 2;
|
||||
|
||||
/*
|
||||
* European Union 868mhz
|
||||
*/
|
||||
EU_868 = 3;
|
||||
|
||||
/*
|
||||
* China
|
||||
*/
|
||||
CN = 4;
|
||||
|
||||
/*
|
||||
* Japan
|
||||
*/
|
||||
JP = 5;
|
||||
|
||||
/*
|
||||
* Australia / New Zealand
|
||||
*/
|
||||
ANZ = 6;
|
||||
|
||||
/*
|
||||
* Korea
|
||||
*/
|
||||
KR = 7;
|
||||
|
||||
/*
|
||||
* Taiwan
|
||||
*/
|
||||
TW = 8;
|
||||
|
||||
/*
|
||||
* Russia
|
||||
*/
|
||||
RU = 9;
|
||||
|
||||
/*
|
||||
* India
|
||||
*/
|
||||
IN = 10;
|
||||
|
||||
/*
|
||||
* New Zealand 865mhz
|
||||
*/
|
||||
NZ_865 = 11;
|
||||
|
||||
/*
|
||||
* Thailand
|
||||
*/
|
||||
TH = 12;
|
||||
|
||||
/*
|
||||
* WLAN Band
|
||||
*/
|
||||
LORA_24 = 13;
|
||||
|
||||
/*
|
||||
* Ukraine 433mhz
|
||||
*/
|
||||
UA_433 = 14;
|
||||
|
||||
/*
|
||||
* Ukraine 868mhz
|
||||
*/
|
||||
UA_868 = 15;
|
||||
|
||||
/*
|
||||
* Malaysia 433mhz
|
||||
*/
|
||||
MY_433 = 16;
|
||||
|
||||
/*
|
||||
* Malaysia 919mhz
|
||||
*/
|
||||
MY_919 = 17;
|
||||
|
||||
/*
|
||||
* Singapore 923mhz
|
||||
*/
|
||||
SG_923 = 18;
|
||||
|
||||
/*
|
||||
* Philippines 433mhz
|
||||
*/
|
||||
PH_433 = 19;
|
||||
|
||||
/*
|
||||
* Philippines 868mhz
|
||||
*/
|
||||
PH_868 = 20;
|
||||
|
||||
/*
|
||||
* Philippines 915mhz
|
||||
*/
|
||||
PH_915 = 21;
|
||||
}
|
||||
|
||||
/*
|
||||
* Standard predefined channel settings
|
||||
* Note: these mappings must match ModemPreset Choice in the device code.
|
||||
*/
|
||||
enum ModemPreset {
|
||||
/*
|
||||
* Long Range - Fast
|
||||
*/
|
||||
LONG_FAST = 0;
|
||||
|
||||
/*
|
||||
* Long Range - Slow
|
||||
*/
|
||||
LONG_SLOW = 1;
|
||||
|
||||
/*
|
||||
* Very Long Range - Slow
|
||||
*/
|
||||
VERY_LONG_SLOW = 2;
|
||||
|
||||
/*
|
||||
* Medium Range - Slow
|
||||
*/
|
||||
MEDIUM_SLOW = 3;
|
||||
|
||||
/*
|
||||
* Medium Range - Fast
|
||||
*/
|
||||
MEDIUM_FAST = 4;
|
||||
|
||||
/*
|
||||
* Short Range - Slow
|
||||
*/
|
||||
SHORT_SLOW = 5;
|
||||
|
||||
/*
|
||||
* Short Range - Fast
|
||||
*/
|
||||
SHORT_FAST = 6;
|
||||
|
||||
/*
|
||||
* Long Range - Moderately Fast
|
||||
*/
|
||||
LONG_MODERATE = 7;
|
||||
|
||||
/*
|
||||
* Short Range - Turbo
|
||||
* This is the fastest preset and the only one with 500kHz bandwidth.
|
||||
* It is not legal to use in all regions due to this wider bandwidth.
|
||||
*/
|
||||
SHORT_TURBO = 8;
|
||||
}
|
||||
|
||||
/*
|
||||
* When enabled, the `modem_preset` fields will be adhered to, else the `bandwidth`/`spread_factor`/`coding_rate`
|
||||
* will be taked from their respective manually defined fields
|
||||
*/
|
||||
bool use_preset = 1;
|
||||
|
||||
/*
|
||||
* Either modem_config or bandwidth/spreading/coding will be specified - NOT BOTH.
|
||||
* As a heuristic: If bandwidth is specified, do not use modem_config.
|
||||
* Because protobufs take ZERO space when the value is zero this works out nicely.
|
||||
* This value is replaced by bandwidth/spread_factor/coding_rate.
|
||||
* If you'd like to experiment with other options add them to MeshRadio.cpp in the device code.
|
||||
*/
|
||||
ModemPreset modem_preset = 2;
|
||||
|
||||
/*
|
||||
* Bandwidth in MHz
|
||||
* Certain bandwidth numbers are 'special' and will be converted to the
|
||||
* appropriate floating point value: 31 -> 31.25MHz
|
||||
*/
|
||||
uint32 bandwidth = 3;
|
||||
|
||||
/*
|
||||
* A number from 7 to 12.
|
||||
* Indicates number of chirps per symbol as 1<<spread_factor.
|
||||
*/
|
||||
uint32 spread_factor = 4;
|
||||
|
||||
/*
|
||||
* The denominator of the coding rate.
|
||||
* ie for 4/5, the value is 5. 4/8 the value is 8.
|
||||
*/
|
||||
uint32 coding_rate = 5;
|
||||
|
||||
/*
|
||||
* This parameter is for advanced users with advanced test equipment, we do not recommend most users use it.
|
||||
* A frequency offset that is added to to the calculated band center frequency.
|
||||
* Used to correct for crystal calibration errors.
|
||||
*/
|
||||
float frequency_offset = 6;
|
||||
|
||||
/*
|
||||
* The region code for the radio (US, CN, EU433, etc...)
|
||||
*/
|
||||
RegionCode region = 7;
|
||||
|
||||
/*
|
||||
* Maximum number of hops. This can't be greater than 7.
|
||||
* Default of 3
|
||||
* Attempting to set a value > 7 results in the default
|
||||
*/
|
||||
uint32 hop_limit = 8;
|
||||
|
||||
/*
|
||||
* Disable TX from the LoRa radio. Useful for hot-swapping antennas and other tests.
|
||||
* Defaults to false
|
||||
*/
|
||||
bool tx_enabled = 9;
|
||||
|
||||
/*
|
||||
* If zero, then use default max legal continuous power (ie. something that won't
|
||||
* burn out the radio hardware)
|
||||
* In most cases you should use zero here.
|
||||
* Units are in dBm.
|
||||
*/
|
||||
int32 tx_power = 10;
|
||||
|
||||
/*
|
||||
* This controls the actual hardware frequency the radio transmits on.
|
||||
* Most users should never need to be exposed to this field/concept.
|
||||
* A channel number between 1 and NUM_CHANNELS (whatever the max is in the current region).
|
||||
* If ZERO then the rule is "use the old channel name hash based
|
||||
* algorithm to derive the channel number")
|
||||
* If using the hash algorithm the channel number will be: hash(channel_name) %
|
||||
* NUM_CHANNELS (Where num channels depends on the regulatory region).
|
||||
*/
|
||||
uint32 channel_num = 11;
|
||||
|
||||
/*
|
||||
* If true, duty cycle limits will be exceeded and thus you're possibly not following
|
||||
* the local regulations if you're not a HAM.
|
||||
* Has no effect if the duty cycle of the used region is 100%.
|
||||
*/
|
||||
bool override_duty_cycle = 12;
|
||||
|
||||
/*
|
||||
* If true, sets RX boosted gain mode on SX126X based radios
|
||||
*/
|
||||
bool sx126x_rx_boosted_gain = 13;
|
||||
|
||||
/*
|
||||
* This parameter is for advanced users and licensed HAM radio operators.
|
||||
* Ignore Channel Calculation and use this frequency instead. The frequency_offset
|
||||
* will still be applied. This will allow you to use out-of-band frequencies.
|
||||
* Please respect your local laws and regulations. If you are a HAM, make sure you
|
||||
* enable HAM mode and turn off encryption.
|
||||
*/
|
||||
float override_frequency = 14;
|
||||
|
||||
/*
|
||||
* For testing it is useful sometimes to force a node to never listen to
|
||||
* particular other nodes (simulating radio out of range). All nodenums listed
|
||||
* in ignore_incoming will have packets they send dropped on receive (by router.cpp)
|
||||
*/
|
||||
repeated uint32 ignore_incoming = 103;
|
||||
|
||||
/*
|
||||
* If true, the device will not process any packets received via LoRa that passed via MQTT anywhere on the path towards it.
|
||||
*/
|
||||
bool ignore_mqtt = 104;
|
||||
}
|
||||
|
||||
message BluetoothConfig {
|
||||
enum PairingMode {
|
||||
/*
|
||||
* Device generates a random PIN that will be shown on the screen of the device for pairing
|
||||
*/
|
||||
RANDOM_PIN = 0;
|
||||
|
||||
/*
|
||||
* Device requires a specified fixed PIN for pairing
|
||||
*/
|
||||
FIXED_PIN = 1;
|
||||
|
||||
/*
|
||||
* Device requires no PIN for pairing
|
||||
*/
|
||||
NO_PIN = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable Bluetooth on the device
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* Determines the pairing strategy for the device
|
||||
*/
|
||||
PairingMode mode = 2;
|
||||
|
||||
/*
|
||||
* Specified PIN for PairingMode.FixedPin
|
||||
*/
|
||||
uint32 fixed_pin = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* Payload Variant
|
||||
*/
|
||||
oneof payload_variant {
|
||||
DeviceConfig device = 1;
|
||||
PositionConfig position = 2;
|
||||
PowerConfig power = 3;
|
||||
NetworkConfig network = 4;
|
||||
DisplayConfig display = 5;
|
||||
LoRaConfig lora = 6;
|
||||
BluetoothConfig bluetooth = 7;
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
*WifiConnectionStatus.ssid max_size:33
|
||||
|
|
@ -1,120 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "ConnStatusProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
message DeviceConnectionStatus {
|
||||
/*
|
||||
* WiFi Status
|
||||
*/
|
||||
optional WifiConnectionStatus wifi = 1;
|
||||
/*
|
||||
* WiFi Status
|
||||
*/
|
||||
optional EthernetConnectionStatus ethernet = 2;
|
||||
|
||||
/*
|
||||
* Bluetooth Status
|
||||
*/
|
||||
optional BluetoothConnectionStatus bluetooth = 3;
|
||||
|
||||
/*
|
||||
* Serial Status
|
||||
*/
|
||||
optional SerialConnectionStatus serial = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* WiFi connection status
|
||||
*/
|
||||
message WifiConnectionStatus {
|
||||
/*
|
||||
* Connection status
|
||||
*/
|
||||
NetworkConnectionStatus status = 1;
|
||||
|
||||
/*
|
||||
* WiFi access point SSID
|
||||
*/
|
||||
string ssid = 2;
|
||||
|
||||
/*
|
||||
* RSSI of wireless connection
|
||||
*/
|
||||
int32 rssi = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ethernet connection status
|
||||
*/
|
||||
message EthernetConnectionStatus {
|
||||
/*
|
||||
* Connection status
|
||||
*/
|
||||
NetworkConnectionStatus status = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ethernet or WiFi connection status
|
||||
*/
|
||||
message NetworkConnectionStatus {
|
||||
/*
|
||||
* IP address of device
|
||||
*/
|
||||
fixed32 ip_address = 1;
|
||||
|
||||
/*
|
||||
* Whether the device has an active connection or not
|
||||
*/
|
||||
bool is_connected = 2;
|
||||
|
||||
/*
|
||||
* Whether the device has an active connection to an MQTT broker or not
|
||||
*/
|
||||
bool is_mqtt_connected = 3;
|
||||
|
||||
/*
|
||||
* Whether the device is actively remote syslogging or not
|
||||
*/
|
||||
bool is_syslog_connected = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bluetooth connection status
|
||||
*/
|
||||
message BluetoothConnectionStatus {
|
||||
/*
|
||||
* The pairing PIN for bluetooth
|
||||
*/
|
||||
uint32 pin = 1;
|
||||
|
||||
/*
|
||||
* RSSI of bluetooth connection
|
||||
*/
|
||||
int32 rssi = 2;
|
||||
|
||||
/*
|
||||
* Whether the device has an active connection or not
|
||||
*/
|
||||
bool is_connected = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* Serial connection status
|
||||
*/
|
||||
message SerialConnectionStatus {
|
||||
/*
|
||||
* Serial baud rate
|
||||
*/
|
||||
uint32 baud = 1;
|
||||
|
||||
/*
|
||||
* Whether the device has an active connection or not
|
||||
*/
|
||||
bool is_connected = 2;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# options for nanopb
|
||||
# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options
|
||||
|
||||
# FIXME pick a higher number someday? or do dynamic alloc in nanopb?
|
||||
*DeviceState.node_db_lite max_count:100
|
||||
|
||||
# FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in RAM
|
||||
*DeviceState.receive_queue max_count:1
|
||||
|
||||
*ChannelFile.channels max_count:8
|
||||
|
||||
*OEMStore.oem_text max_size:40
|
||||
*OEMStore.oem_icon_bits max_size:2048
|
||||
*OEMStore.oem_aes_key max_size:32
|
||||
|
||||
*DeviceState.node_remote_hardware_pins max_count:12
|
||||
|
||||
*NodeInfoLite.channel int_size:8
|
||||
*NodeInfoLite.hops_away int_size:8
|
||||
|
|
@ -1,262 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
import "meshtastic/channel.proto";
|
||||
import "meshtastic/localonly.proto";
|
||||
import "meshtastic/mesh.proto";
|
||||
import "meshtastic/telemetry.proto";
|
||||
import "meshtastic/module_config.proto";
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "DeviceOnly";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* This message is never sent over the wire, but it is used for serializing DB
|
||||
* state to flash in the device code
|
||||
* FIXME, since we write this each time we enter deep sleep (and have infinite
|
||||
* flash) it would be better to use some sort of append only data structure for
|
||||
* the receive queue and use the preferences store for the other stuff
|
||||
*/
|
||||
message DeviceState {
|
||||
/*
|
||||
* Read only settings/info about this node
|
||||
*/
|
||||
MyNodeInfo my_node = 2;
|
||||
|
||||
/*
|
||||
* My owner info
|
||||
*/
|
||||
User owner = 3;
|
||||
|
||||
/*
|
||||
* Received packets saved for delivery to the phone
|
||||
*/
|
||||
repeated MeshPacket receive_queue = 5;
|
||||
|
||||
/*
|
||||
* A version integer used to invalidate old save files when we make
|
||||
* incompatible changes This integer is set at build time and is private to
|
||||
* NodeDB.cpp in the device code.
|
||||
*/
|
||||
uint32 version = 8;
|
||||
|
||||
/*
|
||||
* We keep the last received text message (only) stored in the device flash,
|
||||
* so we can show it on the screen.
|
||||
* Might be null
|
||||
*/
|
||||
MeshPacket rx_text_message = 7;
|
||||
|
||||
/*
|
||||
* Used only during development.
|
||||
* Indicates developer is testing and changes should never be saved to flash.
|
||||
*/
|
||||
bool no_save = 9;
|
||||
|
||||
/*
|
||||
* Some GPS receivers seem to have bogus settings from the factory, so we always do one factory reset.
|
||||
*/
|
||||
bool did_gps_reset = 11;
|
||||
|
||||
/*
|
||||
* We keep the last received waypoint stored in the device flash,
|
||||
* so we can show it on the screen.
|
||||
* Might be null
|
||||
*/
|
||||
MeshPacket rx_waypoint = 12;
|
||||
|
||||
/*
|
||||
* The mesh's nodes with their available gpio pins for RemoteHardware module
|
||||
*/
|
||||
repeated NodeRemoteHardwarePin node_remote_hardware_pins = 13;
|
||||
|
||||
/*
|
||||
* New lite version of NodeDB to decrease memory footprint
|
||||
*/
|
||||
repeated NodeInfoLite node_db_lite = 14;
|
||||
}
|
||||
|
||||
message NodeInfoLite {
|
||||
/*
|
||||
* The node number
|
||||
*/
|
||||
uint32 num = 1;
|
||||
|
||||
/*
|
||||
* The user info for this node
|
||||
*/
|
||||
User user = 2;
|
||||
|
||||
/*
|
||||
* This position data. Note: before 1.2.14 we would also store the last time we've heard from this node in position.time, that is no longer true.
|
||||
* Position.time now indicates the last time we received a POSITION from that node.
|
||||
*/
|
||||
PositionLite position = 3;
|
||||
|
||||
/*
|
||||
* Returns the Signal-to-noise ratio (SNR) of the last received message,
|
||||
* as measured by the receiver. Return SNR of the last received message in dB
|
||||
*/
|
||||
float snr = 4;
|
||||
|
||||
/*
|
||||
* Set to indicate the last time we received a packet from this node
|
||||
*/
|
||||
fixed32 last_heard = 5;
|
||||
/*
|
||||
* The latest device metrics for the node.
|
||||
*/
|
||||
DeviceMetrics device_metrics = 6;
|
||||
|
||||
/*
|
||||
* local channel index we heard that node on. Only populated if its not the default channel.
|
||||
*/
|
||||
uint32 channel = 7;
|
||||
|
||||
/*
|
||||
* True if we witnessed the node over MQTT instead of LoRA transport
|
||||
*/
|
||||
bool via_mqtt = 8;
|
||||
|
||||
/*
|
||||
* Number of hops away from us this node is (0 if adjacent)
|
||||
*/
|
||||
uint32 hops_away = 9;
|
||||
}
|
||||
|
||||
/*
|
||||
* Position with static location information only for NodeDBLite
|
||||
*/
|
||||
message PositionLite {
|
||||
/*
|
||||
* The new preferred location encoding, multiply by 1e-7 to get degrees
|
||||
* in floating point
|
||||
*/
|
||||
sfixed32 latitude_i = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
sfixed32 longitude_i = 2;
|
||||
|
||||
/*
|
||||
* In meters above MSL (but see issue #359)
|
||||
*/
|
||||
int32 altitude = 3;
|
||||
|
||||
/*
|
||||
* This is usually not sent over the mesh (to save space), but it is sent
|
||||
* from the phone so that the local device can set its RTC If it is sent over
|
||||
* the mesh (because there are devices on the mesh without GPS), it will only
|
||||
* be sent by devices which has a hardware GPS clock.
|
||||
* seconds since 1970
|
||||
*/
|
||||
fixed32 time = 4;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
Position.LocSource location_source = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* The on-disk saved channels
|
||||
*/
|
||||
message ChannelFile {
|
||||
/*
|
||||
* The channels our node knows about
|
||||
*/
|
||||
repeated Channel channels = 1;
|
||||
|
||||
/*
|
||||
* A version integer used to invalidate old save files when we make
|
||||
* incompatible changes This integer is set at build time and is private to
|
||||
* NodeDB.cpp in the device code.
|
||||
*/
|
||||
uint32 version = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
enum ScreenFonts {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
FONT_SMALL = 0;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
FONT_MEDIUM = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
FONT_LARGE = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* This can be used for customizing the firmware distribution. If populated,
|
||||
* show a secondary bootup screen with custom logo and text for 2.5 seconds.
|
||||
*/
|
||||
message OEMStore {
|
||||
/*
|
||||
* The Logo width in Px
|
||||
*/
|
||||
uint32 oem_icon_width = 1;
|
||||
|
||||
/*
|
||||
* The Logo height in Px
|
||||
*/
|
||||
uint32 oem_icon_height = 2;
|
||||
|
||||
/*
|
||||
* The Logo in XBM bytechar format
|
||||
*/
|
||||
bytes oem_icon_bits = 3;
|
||||
|
||||
/*
|
||||
* Use this font for the OEM text.
|
||||
*/
|
||||
ScreenFonts oem_font = 4;
|
||||
|
||||
/*
|
||||
* Use this font for the OEM text.
|
||||
*/
|
||||
string oem_text = 5;
|
||||
|
||||
/*
|
||||
* The default device encryption key, 16 or 32 byte
|
||||
*/
|
||||
bytes oem_aes_key = 6;
|
||||
|
||||
/*
|
||||
* A Preset LocalConfig to apply during factory reset
|
||||
*/
|
||||
LocalConfig oem_local_config = 7;
|
||||
|
||||
/*
|
||||
* A Preset LocalModuleConfig to apply during factory reset
|
||||
*/
|
||||
LocalModuleConfig oem_local_module_config = 8;
|
||||
}
|
||||
|
||||
/*
|
||||
* RemoteHardwarePins associated with a node
|
||||
*/
|
||||
message NodeRemoteHardwarePin {
|
||||
/*
|
||||
* The node_num exposing the available gpio pin
|
||||
*/
|
||||
uint32 node_num = 1;
|
||||
|
||||
/*
|
||||
* The the available gpio pin for usage with RemoteHardware module
|
||||
*/
|
||||
RemoteHardwarePin pin = 2;
|
||||
}
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
import "meshtastic/config.proto";
|
||||
import "meshtastic/module_config.proto";
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "LocalOnlyProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* Protobuf structures common to apponly.proto and deviceonly.proto
|
||||
* This is never sent over the wire, only for local use
|
||||
*/
|
||||
|
||||
message LocalConfig {
|
||||
/*
|
||||
* The part of the config that is specific to the Device
|
||||
*/
|
||||
Config.DeviceConfig device = 1;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the GPS Position
|
||||
*/
|
||||
Config.PositionConfig position = 2;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Power settings
|
||||
*/
|
||||
Config.PowerConfig power = 3;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Wifi Settings
|
||||
*/
|
||||
Config.NetworkConfig network = 4;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Display
|
||||
*/
|
||||
Config.DisplayConfig display = 5;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Lora Radio
|
||||
*/
|
||||
Config.LoRaConfig lora = 6;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Bluetooth settings
|
||||
*/
|
||||
Config.BluetoothConfig bluetooth = 7;
|
||||
|
||||
/*
|
||||
* A version integer used to invalidate old save files when we make
|
||||
* incompatible changes This integer is set at build time and is private to
|
||||
* NodeDB.cpp in the device code.
|
||||
*/
|
||||
uint32 version = 8;
|
||||
}
|
||||
|
||||
message LocalModuleConfig {
|
||||
/*
|
||||
* The part of the config that is specific to the MQTT module
|
||||
*/
|
||||
ModuleConfig.MQTTConfig mqtt = 1;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Serial module
|
||||
*/
|
||||
ModuleConfig.SerialConfig serial = 2;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the ExternalNotification module
|
||||
*/
|
||||
ModuleConfig.ExternalNotificationConfig external_notification = 3;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Store & Forward module
|
||||
*/
|
||||
ModuleConfig.StoreForwardConfig store_forward = 4;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the RangeTest module
|
||||
*/
|
||||
ModuleConfig.RangeTestConfig range_test = 5;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Telemetry module
|
||||
*/
|
||||
ModuleConfig.TelemetryConfig telemetry = 6;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Canned Message module
|
||||
*/
|
||||
ModuleConfig.CannedMessageConfig canned_message = 7;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Audio module
|
||||
*/
|
||||
ModuleConfig.AudioConfig audio = 9;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Remote Hardware module
|
||||
*/
|
||||
ModuleConfig.RemoteHardwareConfig remote_hardware = 10;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Neighbor Info module
|
||||
*/
|
||||
ModuleConfig.NeighborInfoConfig neighbor_info = 11;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Ambient Lighting module
|
||||
*/
|
||||
ModuleConfig.AmbientLightingConfig ambient_lighting = 12;
|
||||
|
||||
/*
|
||||
* The part of the config that is specific to the Detection Sensor module
|
||||
*/
|
||||
ModuleConfig.DetectionSensorConfig detection_sensor = 13;
|
||||
|
||||
/*
|
||||
* Paxcounter Config
|
||||
*/
|
||||
ModuleConfig.PaxcounterConfig paxcounter = 14;
|
||||
|
||||
/*
|
||||
* A version integer used to invalidate old save files when we make
|
||||
* incompatible changes This integer is set at build time and is private to
|
||||
* NodeDB.cpp in the device code.
|
||||
*/
|
||||
uint32 version = 8;
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
# options for nanopb
|
||||
# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options
|
||||
|
||||
*macaddr max_size:6 fixed_length:true # macaddrs
|
||||
*id max_size:16 # node id strings
|
||||
|
||||
*User.long_name max_size:40
|
||||
*User.short_name max_size:5
|
||||
|
||||
*RouteDiscovery.route max_count:8
|
||||
|
||||
# note: this payload length is ONLY the bytes that are sent inside of the Data protobuf (excluding protobuf overhead). The 16 byte header is
|
||||
# outside of this envelope
|
||||
*Data.payload max_size:237
|
||||
|
||||
*NodeInfo.channel int_size:8
|
||||
*NodeInfo.hops_away int_size:8
|
||||
|
||||
# Big enough for 1.2.28.568032c-d
|
||||
*MyNodeInfo.firmware_version max_size:18
|
||||
|
||||
*MyNodeInfo.air_period_tx max_count:8
|
||||
*MyNodeInfo.air_period_rx max_count:8
|
||||
|
||||
# Note: the actual limit (because of header bytes) on the size of encrypted payloads is 251 bytes, but I use 256
|
||||
# here because we might need to fill with zeros for padding to encryption block size (16 bytes per block)
|
||||
*MeshPacket.encrypted max_size:256
|
||||
*MeshPacket.payload_variant anonymous_oneof:true
|
||||
*MeshPacket.hop_limit int_size:8
|
||||
*MeshPacket.hop_start int_size:8
|
||||
*MeshPacket.channel int_size:8
|
||||
|
||||
*QueueStatus.res int_size:8
|
||||
*QueueStatus.free int_size:8
|
||||
*QueueStatus.maxlen int_size:8
|
||||
|
||||
*ToRadio.payload_variant anonymous_oneof:true
|
||||
|
||||
*FromRadio.payload_variant anonymous_oneof:true
|
||||
|
||||
*Routing.variant anonymous_oneof:true
|
||||
|
||||
*LogRecord.message max_size:64
|
||||
*LogRecord.source max_size:8
|
||||
|
||||
# MyMessage.name max_size:40
|
||||
# or fixed_length or fixed_count, or max_count
|
||||
|
||||
#This value may want to be a few bytes smaller to compensate for the parent fields.
|
||||
*Compressed.data max_size:237
|
||||
|
||||
*Waypoint.name max_size:30
|
||||
*Waypoint.description max_size:100
|
||||
|
||||
*NeighborInfo.neighbors max_count:10
|
||||
|
||||
*DeviceMetadata.firmware_version max_size:18
|
||||
|
||||
*MqttClientProxyMessage.topic max_size:60
|
||||
*MqttClientProxyMessage.data max_size:435
|
||||
*MqttClientProxyMessage.text max_size:435
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
*CannedMessageConfig.allow_input_source max_size:16
|
||||
|
||||
*MQTTConfig.address max_size:64
|
||||
*MQTTConfig.username max_size:64
|
||||
*MQTTConfig.password max_size:64
|
||||
*MQTTConfig.root max_size:16
|
||||
|
||||
*AudioConfig.ptt_pin int_size:8
|
||||
*AudioConfig.i2s_ws int_size:8
|
||||
*AudioConfig.i2s_sd int_size:8
|
||||
*AudioConfig.i2s_din int_size:8
|
||||
*AudioConfig.i2s_sck int_size:8
|
||||
|
||||
*ExternalNotificationConfig.output_vibra int_size:8
|
||||
*ExternalNotificationConfig.output_buzzer int_size:8
|
||||
*ExternalNotificationConfig.nag_timeout int_size:16
|
||||
|
||||
*RemoteHardwareConfig.available_pins max_count:4
|
||||
*RemoteHardwarePin.name max_size:15
|
||||
*RemoteHardwarePin.gpio_pin int_size:8
|
||||
|
||||
*AmbientLightingConfig.current int_size:8
|
||||
*AmbientLightingConfig.red int_size:8
|
||||
*AmbientLightingConfig.green int_size:8
|
||||
*AmbientLightingConfig.blue int_size:8
|
||||
|
||||
*DetectionSensorConfig.monitor_pin int_size:8
|
||||
*DetectionSensorConfig.name max_size:20
|
||||
|
|
@ -1,801 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "ModuleConfigProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* Module Config
|
||||
*/
|
||||
message ModuleConfig {
|
||||
/*
|
||||
* MQTT Client Config
|
||||
*/
|
||||
message MQTTConfig {
|
||||
/*
|
||||
* If a meshtastic node is able to reach the internet it will normally attempt to gateway any channels that are marked as
|
||||
* is_uplink_enabled or is_downlink_enabled.
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* The server to use for our MQTT global message gateway feature.
|
||||
* If not set, the default server will be used
|
||||
*/
|
||||
string address = 2;
|
||||
|
||||
/*
|
||||
* MQTT username to use (most useful for a custom MQTT server).
|
||||
* If using a custom server, this will be honoured even if empty.
|
||||
* If using the default server, this will only be honoured if set, otherwise the device will use the default username
|
||||
*/
|
||||
string username = 3;
|
||||
|
||||
/*
|
||||
* MQTT password to use (most useful for a custom MQTT server).
|
||||
* If using a custom server, this will be honoured even if empty.
|
||||
* If using the default server, this will only be honoured if set, otherwise the device will use the default password
|
||||
*/
|
||||
string password = 4;
|
||||
|
||||
/*
|
||||
* Whether to send encrypted or decrypted packets to MQTT.
|
||||
* This parameter is only honoured if you also set server
|
||||
* (the default official mqtt.meshtastic.org server can handle encrypted packets)
|
||||
* Decrypted packets may be useful for external systems that want to consume meshtastic packets
|
||||
*/
|
||||
bool encryption_enabled = 5;
|
||||
|
||||
/*
|
||||
* Whether to send / consume json packets on MQTT
|
||||
*/
|
||||
bool json_enabled = 6;
|
||||
|
||||
/*
|
||||
* If true, we attempt to establish a secure connection using TLS
|
||||
*/
|
||||
bool tls_enabled = 7;
|
||||
|
||||
/*
|
||||
* The root topic to use for MQTT messages. Default is "msh".
|
||||
* This is useful if you want to use a single MQTT server for multiple meshtastic networks and separate them via ACLs
|
||||
*/
|
||||
string root = 8;
|
||||
|
||||
/*
|
||||
* If true, we can use the connected phone / client to proxy messages to MQTT instead of a direct connection
|
||||
*/
|
||||
bool proxy_to_client_enabled = 9;
|
||||
|
||||
/*
|
||||
* If true, we will periodically report unencrypted information about our node to a map via MQTT
|
||||
*/
|
||||
bool map_reporting_enabled = 10;
|
||||
|
||||
/*
|
||||
* Settings for reporting information about our node to a map via MQTT
|
||||
*/
|
||||
MapReportSettings map_report_settings = 11;
|
||||
}
|
||||
|
||||
/*
|
||||
* Settings for reporting unencrypted information about our node to a map via MQTT
|
||||
*/
|
||||
message MapReportSettings {
|
||||
/*
|
||||
* How often we should report our info to the map (in seconds)
|
||||
*/
|
||||
uint32 publish_interval_secs = 1;
|
||||
|
||||
/*
|
||||
* Bits of precision for the location sent (default of 32 is full precision).
|
||||
*/
|
||||
uint32 position_precision = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* RemoteHardwareModule Config
|
||||
*/
|
||||
message RemoteHardwareConfig {
|
||||
/*
|
||||
* Whether the Module is enabled
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* Whether the Module allows consumers to read / write to pins not defined in available_pins
|
||||
*/
|
||||
bool allow_undefined_pin_access = 2;
|
||||
|
||||
/*
|
||||
* Exposes the available pins to the mesh for reading and writing
|
||||
*/
|
||||
repeated RemoteHardwarePin available_pins = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* NeighborInfoModule Config
|
||||
*/
|
||||
message NeighborInfoConfig {
|
||||
/*
|
||||
* Whether the Module is enabled
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we should try to send our
|
||||
* Neighbor Info to the mesh
|
||||
*/
|
||||
uint32 update_interval = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Detection Sensor Module Config
|
||||
*/
|
||||
message DetectionSensorConfig {
|
||||
/*
|
||||
* Whether the Module is enabled
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we can send a message to the mesh when a state change is detected
|
||||
*/
|
||||
uint32 minimum_broadcast_secs = 2;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we should send a message to the mesh with the current state regardless of changes
|
||||
* When set to 0, only state changes will be broadcasted
|
||||
* Works as a sort of status heartbeat for peace of mind
|
||||
*/
|
||||
uint32 state_broadcast_secs = 3;
|
||||
/*
|
||||
* Send ASCII bell with alert message
|
||||
* Useful for triggering ext. notification on bell
|
||||
*/
|
||||
bool send_bell = 4;
|
||||
|
||||
/*
|
||||
* Friendly name used to format message sent to mesh
|
||||
* Example: A name "Motion" would result in a message "Motion detected"
|
||||
* Maximum length of 20 characters
|
||||
*/
|
||||
string name = 5;
|
||||
|
||||
/*
|
||||
* GPIO pin to monitor for state changes
|
||||
*/
|
||||
uint32 monitor_pin = 6;
|
||||
|
||||
/*
|
||||
* Whether or not the GPIO pin state detection is triggered on HIGH (1)
|
||||
* Otherwise LOW (0)
|
||||
*/
|
||||
bool detection_triggered_high = 7;
|
||||
|
||||
/*
|
||||
* Whether or not use INPUT_PULLUP mode for GPIO pin
|
||||
* Only applicable if the board uses pull-up resistors on the pin
|
||||
*/
|
||||
bool use_pullup = 8;
|
||||
}
|
||||
|
||||
/*
|
||||
* Audio Config for codec2 voice
|
||||
*/
|
||||
message AudioConfig {
|
||||
/*
|
||||
* Baudrate for codec2 voice
|
||||
*/
|
||||
enum Audio_Baud {
|
||||
CODEC2_DEFAULT = 0;
|
||||
CODEC2_3200 = 1;
|
||||
CODEC2_2400 = 2;
|
||||
CODEC2_1600 = 3;
|
||||
CODEC2_1400 = 4;
|
||||
CODEC2_1300 = 5;
|
||||
CODEC2_1200 = 6;
|
||||
CODEC2_700 = 7;
|
||||
CODEC2_700B = 8;
|
||||
}
|
||||
|
||||
/*
|
||||
* Whether Audio is enabled
|
||||
*/
|
||||
bool codec2_enabled = 1;
|
||||
|
||||
/*
|
||||
* PTT Pin
|
||||
*/
|
||||
uint32 ptt_pin = 2;
|
||||
|
||||
/*
|
||||
* The audio sample rate to use for codec2
|
||||
*/
|
||||
Audio_Baud bitrate = 3;
|
||||
|
||||
/*
|
||||
* I2S Word Select
|
||||
*/
|
||||
uint32 i2s_ws = 4;
|
||||
|
||||
/*
|
||||
* I2S Data IN
|
||||
*/
|
||||
uint32 i2s_sd = 5;
|
||||
|
||||
/*
|
||||
* I2S Data OUT
|
||||
*/
|
||||
uint32 i2s_din = 6;
|
||||
|
||||
/*
|
||||
* I2S Clock
|
||||
*/
|
||||
uint32 i2s_sck = 7;
|
||||
}
|
||||
|
||||
/*
|
||||
* Config for the Paxcounter Module
|
||||
*/
|
||||
message PaxcounterConfig {
|
||||
/*
|
||||
* Enable the Paxcounter Module
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we should try to send our
|
||||
* metrics to the mesh
|
||||
*/
|
||||
|
||||
uint32 paxcounter_update_interval = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Serial Config
|
||||
*/
|
||||
message SerialConfig {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
enum Serial_Baud {
|
||||
BAUD_DEFAULT = 0;
|
||||
BAUD_110 = 1;
|
||||
BAUD_300 = 2;
|
||||
BAUD_600 = 3;
|
||||
BAUD_1200 = 4;
|
||||
BAUD_2400 = 5;
|
||||
BAUD_4800 = 6;
|
||||
BAUD_9600 = 7;
|
||||
BAUD_19200 = 8;
|
||||
BAUD_38400 = 9;
|
||||
BAUD_57600 = 10;
|
||||
BAUD_115200 = 11;
|
||||
BAUD_230400 = 12;
|
||||
BAUD_460800 = 13;
|
||||
BAUD_576000 = 14;
|
||||
BAUD_921600 = 15;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
enum Serial_Mode {
|
||||
DEFAULT = 0;
|
||||
SIMPLE = 1;
|
||||
PROTO = 2;
|
||||
TEXTMSG = 3;
|
||||
NMEA = 4;
|
||||
// NMEA messages specifically tailored for CalTopo
|
||||
CALTOPO = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* Preferences for the SerialModule
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
bool echo = 2;
|
||||
|
||||
/*
|
||||
* RX pin (should match Arduino gpio pin number)
|
||||
*/
|
||||
uint32 rxd = 3;
|
||||
|
||||
/*
|
||||
* TX pin (should match Arduino gpio pin number)
|
||||
*/
|
||||
uint32 txd = 4;
|
||||
|
||||
/*
|
||||
* Serial baud rate
|
||||
*/
|
||||
Serial_Baud baud = 5;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
uint32 timeout = 6;
|
||||
|
||||
/*
|
||||
* Mode for serial module operation
|
||||
*/
|
||||
Serial_Mode mode = 7;
|
||||
|
||||
/*
|
||||
* Overrides the platform's defacto Serial port instance to use with Serial module config settings
|
||||
* This is currently only usable in output modes like NMEA / CalTopo and may behave strangely or not work at all in other modes
|
||||
* Existing logging over the Serial Console will still be present
|
||||
*/
|
||||
bool override_console_serial_port = 8;
|
||||
}
|
||||
|
||||
/*
|
||||
* External Notifications Config
|
||||
*/
|
||||
message ExternalNotificationConfig {
|
||||
/*
|
||||
* Enable the ExternalNotificationModule
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* When using in On/Off mode, keep the output on for this many
|
||||
* milliseconds. Default 1000ms (1 second).
|
||||
*/
|
||||
uint32 output_ms = 2;
|
||||
|
||||
/*
|
||||
* Define the output pin GPIO setting Defaults to
|
||||
* EXT_NOTIFY_OUT if set for the board.
|
||||
* In standalone devices this pin should drive the LED to match the UI.
|
||||
*/
|
||||
uint32 output = 3;
|
||||
|
||||
/*
|
||||
* Optional: Define a secondary output pin for a vibra motor
|
||||
* This is used in standalone devices to match the UI.
|
||||
*/
|
||||
uint32 output_vibra = 8;
|
||||
|
||||
/*
|
||||
* Optional: Define a tertiary output pin for an active buzzer
|
||||
* This is used in standalone devices to to match the UI.
|
||||
*/
|
||||
uint32 output_buzzer = 9;
|
||||
|
||||
/*
|
||||
* IF this is true, the 'output' Pin will be pulled active high, false
|
||||
* means active low.
|
||||
*/
|
||||
bool active = 4;
|
||||
|
||||
/*
|
||||
* True: Alert when a text message arrives (output)
|
||||
*/
|
||||
bool alert_message = 5;
|
||||
|
||||
/*
|
||||
* True: Alert when a text message arrives (output_vibra)
|
||||
*/
|
||||
bool alert_message_vibra = 10;
|
||||
|
||||
/*
|
||||
* True: Alert when a text message arrives (output_buzzer)
|
||||
*/
|
||||
bool alert_message_buzzer = 11;
|
||||
|
||||
/*
|
||||
* True: Alert when the bell character is received (output)
|
||||
*/
|
||||
bool alert_bell = 6;
|
||||
|
||||
/*
|
||||
* True: Alert when the bell character is received (output_vibra)
|
||||
*/
|
||||
bool alert_bell_vibra = 12;
|
||||
|
||||
/*
|
||||
* True: Alert when the bell character is received (output_buzzer)
|
||||
*/
|
||||
bool alert_bell_buzzer = 13;
|
||||
|
||||
/*
|
||||
* use a PWM output instead of a simple on/off output. This will ignore
|
||||
* the 'output', 'output_ms' and 'active' settings and use the
|
||||
* device.buzzer_gpio instead.
|
||||
*/
|
||||
bool use_pwm = 7;
|
||||
|
||||
/*
|
||||
* The notification will toggle with 'output_ms' for this time of seconds.
|
||||
* Default is 0 which means don't repeat at all. 60 would mean blink
|
||||
* and/or beep for 60 seconds
|
||||
*/
|
||||
uint32 nag_timeout = 14;
|
||||
|
||||
/*
|
||||
* When true, enables devices with native I2S audio output to use the RTTTL over speaker like a buzzer
|
||||
* T-Watch S3 and T-Deck for example have this capability
|
||||
*/
|
||||
bool use_i2s_as_buzzer = 15;
|
||||
}
|
||||
|
||||
/*
|
||||
* Store and Forward Module Config
|
||||
*/
|
||||
message StoreForwardConfig {
|
||||
/*
|
||||
* Enable the Store and Forward Module
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
bool heartbeat = 2;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
uint32 records = 3;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
uint32 history_return_max = 4;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
uint32 history_return_window = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* Preferences for the RangeTestModule
|
||||
*/
|
||||
message RangeTestConfig {
|
||||
/*
|
||||
* Enable the Range Test Module
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
* Send out range test messages from this node
|
||||
*/
|
||||
uint32 sender = 2;
|
||||
|
||||
/*
|
||||
* Bool value indicating that this node should save a RangeTest.csv file.
|
||||
* ESP32 Only
|
||||
*/
|
||||
bool save = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* Configuration for both device and environment metrics
|
||||
*/
|
||||
message TelemetryConfig {
|
||||
/*
|
||||
* Interval in seconds of how often we should try to send our
|
||||
* device metrics to the mesh
|
||||
*/
|
||||
uint32 device_update_interval = 1;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we should try to send our
|
||||
* environment measurements to the mesh
|
||||
*/
|
||||
|
||||
uint32 environment_update_interval = 2;
|
||||
|
||||
/*
|
||||
* Preferences for the Telemetry Module (Environment)
|
||||
* Enable/Disable the telemetry measurement module measurement collection
|
||||
*/
|
||||
bool environment_measurement_enabled = 3;
|
||||
|
||||
/*
|
||||
* Enable/Disable the telemetry measurement module on-device display
|
||||
*/
|
||||
bool environment_screen_enabled = 4;
|
||||
|
||||
/*
|
||||
* We'll always read the sensor in Celsius, but sometimes we might want to
|
||||
* display the results in Fahrenheit as a "user preference".
|
||||
*/
|
||||
bool environment_display_fahrenheit = 5;
|
||||
|
||||
/*
|
||||
* Enable/Disable the air quality metrics
|
||||
*/
|
||||
bool air_quality_enabled = 6;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we should try to send our
|
||||
* air quality metrics to the mesh
|
||||
*/
|
||||
uint32 air_quality_interval = 7;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we should try to send our
|
||||
* air quality metrics to the mesh
|
||||
*/
|
||||
bool power_measurement_enabled = 8;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we should try to send our
|
||||
* air quality metrics to the mesh
|
||||
*/
|
||||
uint32 power_update_interval = 9;
|
||||
|
||||
/*
|
||||
* Interval in seconds of how often we should try to send our
|
||||
* air quality metrics to the mesh
|
||||
*/
|
||||
bool power_screen_enabled = 10;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
message CannedMessageConfig {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
enum InputEventChar {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
NONE = 0;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
UP = 17;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
DOWN = 18;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
LEFT = 19;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
RIGHT = 20;
|
||||
|
||||
/*
|
||||
* '\n'
|
||||
*/
|
||||
SELECT = 10;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
BACK = 27;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
CANCEL = 24;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the rotary encoder #1. This is a 'dumb' encoder sending pulses on both A and B pins while rotating.
|
||||
*/
|
||||
bool rotary1_enabled = 1;
|
||||
|
||||
/*
|
||||
* GPIO pin for rotary encoder A port.
|
||||
*/
|
||||
uint32 inputbroker_pin_a = 2;
|
||||
|
||||
/*
|
||||
* GPIO pin for rotary encoder B port.
|
||||
*/
|
||||
uint32 inputbroker_pin_b = 3;
|
||||
|
||||
/*
|
||||
* GPIO pin for rotary encoder Press port.
|
||||
*/
|
||||
uint32 inputbroker_pin_press = 4;
|
||||
|
||||
/*
|
||||
* Generate input event on CW of this kind.
|
||||
*/
|
||||
InputEventChar inputbroker_event_cw = 5;
|
||||
|
||||
/*
|
||||
* Generate input event on CCW of this kind.
|
||||
*/
|
||||
InputEventChar inputbroker_event_ccw = 6;
|
||||
|
||||
/*
|
||||
* Generate input event on Press of this kind.
|
||||
*/
|
||||
InputEventChar inputbroker_event_press = 7;
|
||||
|
||||
/*
|
||||
* Enable the Up/Down/Select input device. Can be RAK rotary encoder or 3 buttons. Uses the a/b/press definitions from inputbroker.
|
||||
*/
|
||||
bool updown1_enabled = 8;
|
||||
|
||||
/*
|
||||
* Enable/disable CannedMessageModule.
|
||||
*/
|
||||
bool enabled = 9;
|
||||
|
||||
/*
|
||||
* Input event origin accepted by the canned message module.
|
||||
* Can be e.g. "rotEnc1", "upDownEnc1" or keyword "_any"
|
||||
*/
|
||||
string allow_input_source = 10;
|
||||
|
||||
/*
|
||||
* CannedMessageModule also sends a bell character with the messages.
|
||||
* ExternalNotificationModule can benefit from this feature.
|
||||
*/
|
||||
bool send_bell = 11;
|
||||
}
|
||||
|
||||
/*
|
||||
Ambient Lighting Module - Settings for control of onboard LEDs to allow users to adjust the brightness levels and respective color levels.
|
||||
Initially created for the RAK14001 RGB LED module.
|
||||
*/
|
||||
message AmbientLightingConfig {
|
||||
|
||||
/*
|
||||
* Sets LED to on or off.
|
||||
*/
|
||||
bool led_state = 1;
|
||||
|
||||
/*
|
||||
* Sets the current for the LED output. Default is 10.
|
||||
*/
|
||||
uint32 current = 2;
|
||||
|
||||
/*
|
||||
* Sets the red LED level. Values are 0-255.
|
||||
*/
|
||||
uint32 red = 3;
|
||||
|
||||
/*
|
||||
* Sets the green LED level. Values are 0-255.
|
||||
*/
|
||||
uint32 green = 4;
|
||||
|
||||
/*
|
||||
* Sets the blue LED level. Values are 0-255.
|
||||
*/
|
||||
uint32 blue = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
oneof payload_variant {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
MQTTConfig mqtt = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
SerialConfig serial = 2;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
ExternalNotificationConfig external_notification = 3;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
StoreForwardConfig store_forward = 4;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
RangeTestConfig range_test = 5;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
TelemetryConfig telemetry = 6;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
CannedMessageConfig canned_message = 7;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
AudioConfig audio = 8;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
RemoteHardwareConfig remote_hardware = 9;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
NeighborInfoConfig neighbor_info = 10;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
AmbientLightingConfig ambient_lighting = 11;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
DetectionSensorConfig detection_sensor = 12;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
PaxcounterConfig paxcounter = 13;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A GPIO pin definition for remote hardware module
|
||||
*/
|
||||
message RemoteHardwarePin {
|
||||
/*
|
||||
* GPIO Pin number (must match Arduino)
|
||||
*/
|
||||
uint32 gpio_pin = 1;
|
||||
|
||||
/*
|
||||
* Name for the GPIO pin (i.e. Front gate, mailbox, etc)
|
||||
*/
|
||||
string name = 2;
|
||||
|
||||
/*
|
||||
* Type of GPIO access available to consumers on the mesh
|
||||
*/
|
||||
RemoteHardwarePinType type = 3;
|
||||
}
|
||||
|
||||
enum RemoteHardwarePinType {
|
||||
/*
|
||||
* Unset/unused
|
||||
*/
|
||||
UNKNOWN = 0;
|
||||
|
||||
/*
|
||||
* GPIO pin can be read (if it is high / low)
|
||||
*/
|
||||
DIGITAL_READ = 1;
|
||||
|
||||
/*
|
||||
* GPIO pin can be written to (high / low)
|
||||
*/
|
||||
DIGITAL_WRITE = 2;
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
*ServiceEnvelope.packet type:FT_POINTER
|
||||
*ServiceEnvelope.channel_id type:FT_POINTER
|
||||
*ServiceEnvelope.gateway_id type:FT_POINTER
|
||||
|
||||
*MapReport.long_name max_size:40
|
||||
*MapReport.short_name max_size:5
|
||||
*MapReport.firmware_version max_size:18
|
||||
*MapReport.num_online_local_nodes int_size:16
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
import "meshtastic/mesh.proto";
|
||||
import "meshtastic/config.proto";
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "MQTTProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* This message wraps a MeshPacket with extra metadata about the sender and how it arrived.
|
||||
*/
|
||||
message ServiceEnvelope {
|
||||
/*
|
||||
* The (probably encrypted) packet
|
||||
*/
|
||||
MeshPacket packet = 1;
|
||||
|
||||
/*
|
||||
* The global channel ID it was sent on
|
||||
*/
|
||||
string channel_id = 2;
|
||||
|
||||
/*
|
||||
* The sending gateway node ID. Can we use this to authenticate/prevent fake
|
||||
* nodeid impersonation for senders? - i.e. use gateway/mesh id (which is authenticated) + local node id as
|
||||
* the globally trusted nodenum
|
||||
*/
|
||||
string gateway_id = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* Information about a node intended to be reported unencrypted to a map using MQTT.
|
||||
*/
|
||||
message MapReport {
|
||||
/*
|
||||
* A full name for this user, i.e. "Kevin Hester"
|
||||
*/
|
||||
string long_name = 1;
|
||||
|
||||
/*
|
||||
* A VERY short name, ideally two characters.
|
||||
* Suitable for a tiny OLED screen
|
||||
*/
|
||||
string short_name = 2;
|
||||
|
||||
/*
|
||||
* Role of the node that applies specific settings for a particular use-case
|
||||
*/
|
||||
Config.DeviceConfig.Role role = 3;
|
||||
|
||||
/*
|
||||
* Hardware model of the node, i.e. T-Beam, Heltec V3, etc...
|
||||
*/
|
||||
HardwareModel hw_model = 4;
|
||||
|
||||
/*
|
||||
* Device firmware version string
|
||||
*/
|
||||
string firmware_version = 5;
|
||||
|
||||
/*
|
||||
* The region code for the radio (US, CN, EU433, etc...)
|
||||
*/
|
||||
Config.LoRaConfig.RegionCode region = 6;
|
||||
|
||||
/*
|
||||
* Modem preset used by the radio (LongFast, MediumSlow, etc...)
|
||||
*/
|
||||
Config.LoRaConfig.ModemPreset modem_preset = 7;
|
||||
|
||||
/*
|
||||
* Whether the node has a channel with default PSK and name (LongFast, MediumSlow, etc...)
|
||||
* and it uses the default frequency slot given the region and modem preset.
|
||||
*/
|
||||
bool has_default_channel = 8;
|
||||
|
||||
/*
|
||||
* Latitude: multiply by 1e-7 to get degrees in floating point
|
||||
*/
|
||||
sfixed32 latitude_i = 9;
|
||||
|
||||
/*
|
||||
* Longitude: multiply by 1e-7 to get degrees in floating point
|
||||
*/
|
||||
sfixed32 longitude_i = 10;
|
||||
|
||||
/*
|
||||
* Altitude in meters above MSL
|
||||
*/
|
||||
int32 altitude = 11;
|
||||
|
||||
/*
|
||||
* Indicates the bits of precision for latitude and longitude set by the sending node
|
||||
*/
|
||||
uint32 position_precision = 12;
|
||||
|
||||
/*
|
||||
* Number of online nodes (heard in the last 2 hours) this node has in its list that were received locally (not via MQTT)
|
||||
*/
|
||||
uint32 num_online_local_nodes = 13;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "PaxcountProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
message Paxcount {
|
||||
/*
|
||||
* seen Wifi devices
|
||||
*/
|
||||
uint32 wifi = 1;
|
||||
|
||||
/*
|
||||
* Seen BLE devices
|
||||
*/
|
||||
uint32 ble = 2;
|
||||
|
||||
/*
|
||||
* Uptime in seconds
|
||||
*/
|
||||
uint32 uptime = 3;
|
||||
}
|
||||
|
|
@ -1,216 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "Portnums";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* For any new 'apps' that run on the device or via sister apps on phones/PCs they should pick and use a
|
||||
* unique 'portnum' for their application.
|
||||
* If you are making a new app using meshtastic, please send in a pull request to add your 'portnum' to this
|
||||
* master table.
|
||||
* PortNums should be assigned in the following range:
|
||||
* 0-63 Core Meshtastic use, do not use for third party apps
|
||||
* 64-127 Registered 3rd party apps, send in a pull request that adds a new entry to portnums.proto to register your application
|
||||
* 256-511 Use one of these portnums for your private applications that you don't want to register publically
|
||||
* All other values are reserved.
|
||||
* Note: This was formerly a Type enum named 'typ' with the same id #
|
||||
* We have change to this 'portnum' based scheme for specifying app handlers for particular payloads.
|
||||
* This change is backwards compatible by treating the legacy OPAQUE/CLEAR_TEXT values identically.
|
||||
*/
|
||||
enum PortNum {
|
||||
/*
|
||||
* Deprecated: do not use in new code (formerly called OPAQUE)
|
||||
* A message sent from a device outside of the mesh, in a form the mesh does not understand
|
||||
* NOTE: This must be 0, because it is documented in IMeshService.aidl to be so
|
||||
* ENCODING: binary undefined
|
||||
*/
|
||||
UNKNOWN_APP = 0;
|
||||
|
||||
/*
|
||||
* A simple UTF-8 text message, which even the little micros in the mesh
|
||||
* can understand and show on their screen eventually in some circumstances
|
||||
* even signal might send messages in this form (see below)
|
||||
* ENCODING: UTF-8 Plaintext (?)
|
||||
*/
|
||||
TEXT_MESSAGE_APP = 1;
|
||||
|
||||
/*
|
||||
* Reserved for built-in GPIO/example app.
|
||||
* See remote_hardware.proto/HardwareMessage for details on the message sent/received to this port number
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
REMOTE_HARDWARE_APP = 2;
|
||||
|
||||
/*
|
||||
* The built-in position messaging app.
|
||||
* Payload is a Position message.
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
POSITION_APP = 3;
|
||||
|
||||
/*
|
||||
* The built-in user info app.
|
||||
* Payload is a User message.
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
NODEINFO_APP = 4;
|
||||
|
||||
/*
|
||||
* Protocol control packets for mesh protocol use.
|
||||
* Payload is a Routing message.
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
ROUTING_APP = 5;
|
||||
|
||||
/*
|
||||
* Admin control packets.
|
||||
* Payload is a AdminMessage message.
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
ADMIN_APP = 6;
|
||||
|
||||
/*
|
||||
* Compressed TEXT_MESSAGE payloads.
|
||||
* ENCODING: UTF-8 Plaintext (?) with Unishox2 Compression
|
||||
* NOTE: The Device Firmware converts a TEXT_MESSAGE_APP to TEXT_MESSAGE_COMPRESSED_APP if the compressed
|
||||
* payload is shorter. There's no need for app developers to do this themselves. Also the firmware will decompress
|
||||
* any incoming TEXT_MESSAGE_COMPRESSED_APP payload and convert to TEXT_MESSAGE_APP.
|
||||
*/
|
||||
TEXT_MESSAGE_COMPRESSED_APP = 7;
|
||||
|
||||
/*
|
||||
* Waypoint payloads.
|
||||
* Payload is a Waypoint message.
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
WAYPOINT_APP = 8;
|
||||
|
||||
/*
|
||||
* Audio Payloads.
|
||||
* Encapsulated codec2 packets. On 2.4 GHZ Bandwidths only for now
|
||||
* ENCODING: codec2 audio frames
|
||||
* NOTE: audio frames contain a 3 byte header (0xc0 0xde 0xc2) and a one byte marker for the decompressed bitrate.
|
||||
* This marker comes from the 'moduleConfig.audio.bitrate' enum minus one.
|
||||
*/
|
||||
AUDIO_APP = 9;
|
||||
|
||||
/*
|
||||
* Same as Text Message but originating from Detection Sensor Module.
|
||||
* NOTE: This portnum traffic is not sent to the public MQTT starting at firmware version 2.2.9
|
||||
*/
|
||||
DETECTION_SENSOR_APP = 10;
|
||||
|
||||
/*
|
||||
* Provides a 'ping' service that replies to any packet it receives.
|
||||
* Also serves as a small example module.
|
||||
* ENCODING: ASCII Plaintext
|
||||
*/
|
||||
REPLY_APP = 32;
|
||||
|
||||
/*
|
||||
* Used for the python IP tunnel feature
|
||||
* ENCODING: IP Packet. Handled by the python API, firmware ignores this one and pases on.
|
||||
*/
|
||||
IP_TUNNEL_APP = 33;
|
||||
|
||||
/*
|
||||
* Paxcounter lib included in the firmware
|
||||
* ENCODING: protobuf
|
||||
*/
|
||||
PAXCOUNTER_APP = 34;
|
||||
|
||||
/*
|
||||
* Provides a hardware serial interface to send and receive from the Meshtastic network.
|
||||
* Connect to the RX/TX pins of a device with 38400 8N1. Packets received from the Meshtastic
|
||||
* network is forwarded to the RX pin while sending a packet to TX will go out to the Mesh network.
|
||||
* Maximum packet size of 240 bytes.
|
||||
* Module is disabled by default can be turned on by setting SERIAL_MODULE_ENABLED = 1 in SerialPlugh.cpp.
|
||||
* ENCODING: binary undefined
|
||||
*/
|
||||
SERIAL_APP = 64;
|
||||
|
||||
/*
|
||||
* STORE_FORWARD_APP (Work in Progress)
|
||||
* Maintained by Jm Casler (MC Hamster) : jm@casler.org
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
STORE_FORWARD_APP = 65;
|
||||
|
||||
/*
|
||||
* Optional port for messages for the range test module.
|
||||
* ENCODING: ASCII Plaintext
|
||||
* NOTE: This portnum traffic is not sent to the public MQTT starting at firmware version 2.2.9
|
||||
*/
|
||||
RANGE_TEST_APP = 66;
|
||||
|
||||
/*
|
||||
* Provides a format to send and receive telemetry data from the Meshtastic network.
|
||||
* Maintained by Charles Crossan (crossan007) : crossan007@gmail.com
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
TELEMETRY_APP = 67;
|
||||
|
||||
/*
|
||||
* Experimental tools for estimating node position without a GPS
|
||||
* Maintained by Github user a-f-G-U-C (a Meshtastic contributor)
|
||||
* Project files at https://github.com/a-f-G-U-C/Meshtastic-ZPS
|
||||
* ENCODING: arrays of int64 fields
|
||||
*/
|
||||
ZPS_APP = 68;
|
||||
|
||||
/*
|
||||
* Used to let multiple instances of Linux native applications communicate
|
||||
* as if they did using their LoRa chip.
|
||||
* Maintained by GitHub user GUVWAF.
|
||||
* Project files at https://github.com/GUVWAF/Meshtasticator
|
||||
* ENCODING: Protobuf (?)
|
||||
*/
|
||||
SIMULATOR_APP = 69;
|
||||
|
||||
/*
|
||||
* Provides a traceroute functionality to show the route a packet towards
|
||||
* a certain destination would take on the mesh.
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
TRACEROUTE_APP = 70;
|
||||
|
||||
/*
|
||||
* Aggregates edge info for the network by sending out a list of each node's neighbors
|
||||
* ENCODING: Protobuf
|
||||
*/
|
||||
NEIGHBORINFO_APP = 71;
|
||||
|
||||
/*
|
||||
* ATAK Plugin
|
||||
* Portnum for payloads from the official Meshtastic ATAK plugin
|
||||
*/
|
||||
ATAK_PLUGIN = 72;
|
||||
|
||||
/*
|
||||
* Provides unencrypted information about a node for consumption by a map via MQTT
|
||||
*/
|
||||
MAP_REPORT_APP = 73;
|
||||
|
||||
/*
|
||||
* Private applications should use portnums >= 256.
|
||||
* To simplify initial development and testing you can use "PRIVATE_APP"
|
||||
* in your code without needing to rebuild protobuf files (via [regen-protos.sh](https://github.com/meshtastic/firmware/blob/master/bin/regen-protos.sh))
|
||||
*/
|
||||
PRIVATE_APP = 256;
|
||||
|
||||
/*
|
||||
* ATAK Forwarder Module https://github.com/paulmandal/atak-forwarder
|
||||
* ENCODING: libcotshrink
|
||||
*/
|
||||
ATAK_FORWARDER = 257;
|
||||
|
||||
/*
|
||||
* Currently we limit port nums to no higher than this value
|
||||
*/
|
||||
MAX = 511;
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "RemoteHardware";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* An example app to show off the module system. This message is used for
|
||||
* REMOTE_HARDWARE_APP PortNums.
|
||||
* Also provides easy remote access to any GPIO.
|
||||
* In the future other remote hardware operations can be added based on user interest
|
||||
* (i.e. serial output, spi/i2c input/output).
|
||||
* FIXME - currently this feature is turned on by default which is dangerous
|
||||
* because no security yet (beyond the channel mechanism).
|
||||
* It should be off by default and then protected based on some TBD mechanism
|
||||
* (a special channel once multichannel support is included?)
|
||||
*/
|
||||
message HardwareMessage {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
enum Type {
|
||||
/*
|
||||
* Unset/unused
|
||||
*/
|
||||
UNSET = 0;
|
||||
|
||||
/*
|
||||
* Set gpio gpios based on gpio_mask/gpio_value
|
||||
*/
|
||||
WRITE_GPIOS = 1;
|
||||
|
||||
/*
|
||||
* We are now interested in watching the gpio_mask gpios.
|
||||
* If the selected gpios change, please broadcast GPIOS_CHANGED.
|
||||
* Will implicitly change the gpios requested to be INPUT gpios.
|
||||
*/
|
||||
WATCH_GPIOS = 2;
|
||||
|
||||
/*
|
||||
* The gpios listed in gpio_mask have changed, the new values are listed in gpio_value
|
||||
*/
|
||||
GPIOS_CHANGED = 3;
|
||||
|
||||
/*
|
||||
* Read the gpios specified in gpio_mask, send back a READ_GPIOS_REPLY reply with gpio_value populated
|
||||
*/
|
||||
READ_GPIOS = 4;
|
||||
|
||||
/*
|
||||
* A reply to READ_GPIOS. gpio_mask and gpio_value will be populated
|
||||
*/
|
||||
READ_GPIOS_REPLY = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* What type of HardwareMessage is this?
|
||||
*/
|
||||
Type type = 1;
|
||||
|
||||
/*
|
||||
* What gpios are we changing. Not used for all MessageTypes, see MessageType for details
|
||||
*/
|
||||
uint64 gpio_mask = 2;
|
||||
|
||||
/*
|
||||
* For gpios that were listed in gpio_mask as valid, what are the signal levels for those gpios.
|
||||
* Not used for all MessageTypes, see MessageType for details
|
||||
*/
|
||||
uint64 gpio_value = 3;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
*RTTTLConfig.ringtone max_size:230
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "RTTTLConfigProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* Canned message module configuration.
|
||||
*/
|
||||
message RTTTLConfig {
|
||||
/*
|
||||
* Ringtone for PWM Buzzer in RTTTL Format.
|
||||
*/
|
||||
string ringtone = 1;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
*StoreAndForward.text max_size:237
|
||||
|
|
@ -1,218 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "StoreAndForwardProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
message StoreAndForward {
|
||||
/*
|
||||
* 001 - 063 = From Router
|
||||
* 064 - 127 = From Client
|
||||
*/
|
||||
enum RequestResponse {
|
||||
/*
|
||||
* Unset/unused
|
||||
*/
|
||||
UNSET = 0;
|
||||
|
||||
/*
|
||||
* Router is an in error state.
|
||||
*/
|
||||
ROUTER_ERROR = 1;
|
||||
|
||||
/*
|
||||
* Router heartbeat
|
||||
*/
|
||||
ROUTER_HEARTBEAT = 2;
|
||||
|
||||
/*
|
||||
* Router has requested the client respond. This can work as a
|
||||
* "are you there" message.
|
||||
*/
|
||||
ROUTER_PING = 3;
|
||||
|
||||
/*
|
||||
* The response to a "Ping"
|
||||
*/
|
||||
ROUTER_PONG = 4;
|
||||
|
||||
/*
|
||||
* Router is currently busy. Please try again later.
|
||||
*/
|
||||
ROUTER_BUSY = 5;
|
||||
|
||||
/*
|
||||
* Router is responding to a request for history.
|
||||
*/
|
||||
ROUTER_HISTORY = 6;
|
||||
|
||||
/*
|
||||
* Router is responding to a request for stats.
|
||||
*/
|
||||
ROUTER_STATS = 7;
|
||||
|
||||
/*
|
||||
* Router sends a text message from its history that was a direct message.
|
||||
*/
|
||||
ROUTER_TEXT_DIRECT = 8;
|
||||
|
||||
/*
|
||||
* Router sends a text message from its history that was a broadcast.
|
||||
*/
|
||||
ROUTER_TEXT_BROADCAST = 9;
|
||||
|
||||
/*
|
||||
* Client is an in error state.
|
||||
*/
|
||||
CLIENT_ERROR = 64;
|
||||
|
||||
/*
|
||||
* Client has requested a replay from the router.
|
||||
*/
|
||||
CLIENT_HISTORY = 65;
|
||||
|
||||
/*
|
||||
* Client has requested stats from the router.
|
||||
*/
|
||||
CLIENT_STATS = 66;
|
||||
|
||||
/*
|
||||
* Client has requested the router respond. This can work as a
|
||||
* "are you there" message.
|
||||
*/
|
||||
CLIENT_PING = 67;
|
||||
|
||||
/*
|
||||
* The response to a "Ping"
|
||||
*/
|
||||
CLIENT_PONG = 68;
|
||||
|
||||
/*
|
||||
* Client has requested that the router abort processing the client's request
|
||||
*/
|
||||
CLIENT_ABORT = 106;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
message Statistics {
|
||||
/*
|
||||
* Number of messages we have ever seen
|
||||
*/
|
||||
uint32 messages_total = 1;
|
||||
|
||||
/*
|
||||
* Number of messages we have currently saved our history.
|
||||
*/
|
||||
uint32 messages_saved = 2;
|
||||
|
||||
/*
|
||||
* Maximum number of messages we will save
|
||||
*/
|
||||
uint32 messages_max = 3;
|
||||
|
||||
/*
|
||||
* Router uptime in seconds
|
||||
*/
|
||||
uint32 up_time = 4;
|
||||
|
||||
/*
|
||||
* Number of times any client sent a request to the S&F.
|
||||
*/
|
||||
uint32 requests = 5;
|
||||
|
||||
/*
|
||||
* Number of times the history was requested.
|
||||
*/
|
||||
uint32 requests_history = 6;
|
||||
|
||||
/*
|
||||
* Is the heartbeat enabled on the server?
|
||||
*/
|
||||
bool heartbeat = 7;
|
||||
|
||||
/*
|
||||
* Maximum number of messages the server will return.
|
||||
*/
|
||||
uint32 return_max = 8;
|
||||
|
||||
/*
|
||||
* Maximum history window in minutes the server will return messages from.
|
||||
*/
|
||||
uint32 return_window = 9;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
message History {
|
||||
/*
|
||||
* Number of that will be sent to the client
|
||||
*/
|
||||
uint32 history_messages = 1;
|
||||
|
||||
/*
|
||||
* The window of messages that was used to filter the history client requested
|
||||
*/
|
||||
uint32 window = 2;
|
||||
|
||||
/*
|
||||
* Index in the packet history of the last message sent in a previous request to the server.
|
||||
* Will be sent to the client before sending the history and can be set in a subsequent request to avoid getting packets the server already sent to the client.
|
||||
*/
|
||||
uint32 last_request = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
message Heartbeat {
|
||||
/*
|
||||
* Period in seconds that the heartbeat is sent out that will be sent to the client
|
||||
*/
|
||||
uint32 period = 1;
|
||||
|
||||
/*
|
||||
* If set, this is not the primary Store & Forward router on the mesh
|
||||
*/
|
||||
uint32 secondary = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
RequestResponse rr = 1;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
oneof variant {
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
Statistics stats = 2;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
History history = 3;
|
||||
|
||||
/*
|
||||
* TODO: REPLACE
|
||||
*/
|
||||
Heartbeat heartbeat = 4;
|
||||
|
||||
/*
|
||||
* Text from history message.
|
||||
*/
|
||||
bytes text = 5;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
# options for nanopb
|
||||
# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options
|
||||
|
||||
*EnvironmentMetrics.iaq int_size:16
|
||||
|
|
@ -1,560 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "TelemetryProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
/*
|
||||
* Key native device metrics such as battery level
|
||||
*/
|
||||
message DeviceMetrics {
|
||||
/*
|
||||
* 0-100 (>100 means powered)
|
||||
*/
|
||||
optional uint32 battery_level = 1;
|
||||
|
||||
/*
|
||||
* Voltage measured
|
||||
*/
|
||||
optional float voltage = 2;
|
||||
|
||||
/*
|
||||
* Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise).
|
||||
*/
|
||||
optional float channel_utilization = 3;
|
||||
|
||||
/*
|
||||
* Percent of airtime for transmission used within the last hour.
|
||||
*/
|
||||
optional float air_util_tx = 4;
|
||||
|
||||
/*
|
||||
* How long the device has been running since the last reboot (in seconds)
|
||||
*/
|
||||
optional uint32 uptime_seconds = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* Weather station or other environmental metrics
|
||||
*/
|
||||
message EnvironmentMetrics {
|
||||
/*
|
||||
* Temperature measured
|
||||
*/
|
||||
optional float temperature = 1;
|
||||
|
||||
/*
|
||||
* Relative humidity percent measured
|
||||
*/
|
||||
optional float relative_humidity = 2;
|
||||
|
||||
/*
|
||||
* Barometric pressure in hPA measured
|
||||
*/
|
||||
optional float barometric_pressure = 3;
|
||||
|
||||
/*
|
||||
* Gas resistance in MOhm measured
|
||||
*/
|
||||
optional float gas_resistance = 4;
|
||||
|
||||
/*
|
||||
* Voltage measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x)
|
||||
*/
|
||||
optional float voltage = 5;
|
||||
|
||||
/*
|
||||
* Current measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x)
|
||||
*/
|
||||
optional float current = 6;
|
||||
|
||||
/*
|
||||
* relative scale IAQ value as measured by Bosch BME680 . value 0-500.
|
||||
* Belongs to Air Quality but is not particle but VOC measurement. Other VOC values can also be put in here.
|
||||
*/
|
||||
optional uint32 iaq = 7;
|
||||
|
||||
/*
|
||||
* RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm.
|
||||
*/
|
||||
optional float distance = 8;
|
||||
|
||||
/*
|
||||
* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor.
|
||||
*/
|
||||
optional float lux = 9;
|
||||
|
||||
/*
|
||||
* VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor.
|
||||
*/
|
||||
optional float white_lux = 10;
|
||||
|
||||
/*
|
||||
* Infrared lux
|
||||
*/
|
||||
optional float ir_lux = 11;
|
||||
|
||||
/*
|
||||
* Ultraviolet lux
|
||||
*/
|
||||
optional float uv_lux = 12;
|
||||
|
||||
/*
|
||||
* Wind direction in degrees
|
||||
* 0 degrees = North, 90 = East, etc...
|
||||
*/
|
||||
optional uint32 wind_direction = 13;
|
||||
|
||||
/*
|
||||
* Wind speed in m/s
|
||||
*/
|
||||
optional float wind_speed = 14;
|
||||
|
||||
/*
|
||||
* Weight in KG
|
||||
*/
|
||||
optional float weight = 15;
|
||||
|
||||
/*
|
||||
* Wind gust in m/s
|
||||
*/
|
||||
optional float wind_gust = 16;
|
||||
|
||||
/*
|
||||
* Wind lull in m/s
|
||||
*/
|
||||
optional float wind_lull = 17;
|
||||
|
||||
/*
|
||||
* Radiation in µR/h
|
||||
*/
|
||||
optional float radiation = 18;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Power Metrics (voltage / current / etc)
|
||||
*/
|
||||
message PowerMetrics {
|
||||
/*
|
||||
* Voltage (Ch1)
|
||||
*/
|
||||
optional float ch1_voltage = 1;
|
||||
|
||||
/*
|
||||
* Current (Ch1)
|
||||
*/
|
||||
optional float ch1_current = 2;
|
||||
|
||||
/*
|
||||
* Voltage (Ch2)
|
||||
*/
|
||||
optional float ch2_voltage = 3;
|
||||
|
||||
/*
|
||||
* Current (Ch2)
|
||||
*/
|
||||
optional float ch2_current = 4;
|
||||
|
||||
/*
|
||||
* Voltage (Ch3)
|
||||
*/
|
||||
optional float ch3_voltage = 5;
|
||||
|
||||
/*
|
||||
* Current (Ch3)
|
||||
*/
|
||||
optional float ch3_current = 6;
|
||||
}
|
||||
|
||||
/*
|
||||
* Air quality metrics
|
||||
*/
|
||||
message AirQualityMetrics {
|
||||
/*
|
||||
* Concentration Units Standard PM1.0
|
||||
*/
|
||||
optional uint32 pm10_standard = 1;
|
||||
|
||||
/*
|
||||
* Concentration Units Standard PM2.5
|
||||
*/
|
||||
optional uint32 pm25_standard = 2;
|
||||
|
||||
/*
|
||||
* Concentration Units Standard PM10.0
|
||||
*/
|
||||
optional uint32 pm100_standard = 3;
|
||||
|
||||
/*
|
||||
* Concentration Units Environmental PM1.0
|
||||
*/
|
||||
optional uint32 pm10_environmental = 4;
|
||||
|
||||
/*
|
||||
* Concentration Units Environmental PM2.5
|
||||
*/
|
||||
optional uint32 pm25_environmental = 5;
|
||||
|
||||
/*
|
||||
* Concentration Units Environmental PM10.0
|
||||
*/
|
||||
optional uint32 pm100_environmental = 6;
|
||||
|
||||
/*
|
||||
* 0.3um Particle Count
|
||||
*/
|
||||
optional uint32 particles_03um = 7;
|
||||
|
||||
/*
|
||||
* 0.5um Particle Count
|
||||
*/
|
||||
optional uint32 particles_05um = 8;
|
||||
|
||||
/*
|
||||
* 1.0um Particle Count
|
||||
*/
|
||||
optional uint32 particles_10um = 9;
|
||||
|
||||
/*
|
||||
* 2.5um Particle Count
|
||||
*/
|
||||
optional uint32 particles_25um = 10;
|
||||
|
||||
/*
|
||||
* 5.0um Particle Count
|
||||
*/
|
||||
optional uint32 particles_50um = 11;
|
||||
|
||||
/*
|
||||
* 10.0um Particle Count
|
||||
*/
|
||||
optional uint32 particles_100um = 12;
|
||||
|
||||
/*
|
||||
* 10.0um Particle Count
|
||||
*/
|
||||
optional uint32 co2 = 13;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local device mesh statistics
|
||||
*/
|
||||
message LocalStats {
|
||||
/*
|
||||
* How long the device has been running since the last reboot (in seconds)
|
||||
*/
|
||||
uint32 uptime_seconds = 1;
|
||||
/*
|
||||
* Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise).
|
||||
*/
|
||||
float channel_utilization = 2;
|
||||
/*
|
||||
* Percent of airtime for transmission used within the last hour.
|
||||
*/
|
||||
float air_util_tx = 3;
|
||||
|
||||
/*
|
||||
* Number of packets sent
|
||||
*/
|
||||
uint32 num_packets_tx = 4;
|
||||
|
||||
/*
|
||||
* Number of packets received (both good and bad)
|
||||
*/
|
||||
uint32 num_packets_rx = 5;
|
||||
|
||||
/*
|
||||
* Number of packets received that are malformed or violate the protocol
|
||||
*/
|
||||
uint32 num_packets_rx_bad = 6;
|
||||
|
||||
/*
|
||||
* Number of nodes online (in the past 2 hours)
|
||||
*/
|
||||
uint32 num_online_nodes = 7;
|
||||
|
||||
/*
|
||||
* Number of nodes total
|
||||
*/
|
||||
uint32 num_total_nodes = 8;
|
||||
|
||||
/*
|
||||
* Number of received packets that were duplicates (due to multiple nodes relaying).
|
||||
* If this number is high, there are nodes in the mesh relaying packets when it's unnecessary, for example due to the ROUTER/REPEATER role.
|
||||
*/
|
||||
uint32 num_rx_dupe = 9;
|
||||
|
||||
/*
|
||||
* Number of packets we transmitted that were a relay for others (not originating from ourselves).
|
||||
*/
|
||||
uint32 num_tx_relay = 10;
|
||||
|
||||
/*
|
||||
* Number of times we canceled a packet to be relayed, because someone else did it before us.
|
||||
* This will always be zero for ROUTERs/REPEATERs. If this number is high, some other node(s) is/are relaying faster than you.
|
||||
*/
|
||||
uint32 num_tx_relay_canceled = 11;
|
||||
}
|
||||
|
||||
/*
|
||||
* Health telemetry metrics
|
||||
*/
|
||||
message HealthMetrics {
|
||||
/*
|
||||
* Heart rate (beats per minute)
|
||||
*/
|
||||
optional uint32 heart_bpm = 1;
|
||||
|
||||
/*
|
||||
* SpO2 (blood oxygen saturation) level
|
||||
*/
|
||||
optional uint32 spO2 = 2;
|
||||
|
||||
/*
|
||||
* Body temperature in degrees Celsius
|
||||
*/
|
||||
optional float temperature = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* Types of Measurements the telemetry module is equipped to handle
|
||||
*/
|
||||
message Telemetry {
|
||||
/*
|
||||
* Seconds since 1970 - or 0 for unknown/unset
|
||||
*/
|
||||
fixed32 time = 1;
|
||||
|
||||
oneof variant {
|
||||
/*
|
||||
* Key native device metrics such as battery level
|
||||
*/
|
||||
DeviceMetrics device_metrics = 2;
|
||||
|
||||
/*
|
||||
* Weather station or other environmental metrics
|
||||
*/
|
||||
EnvironmentMetrics environment_metrics = 3;
|
||||
|
||||
/*
|
||||
* Air quality metrics
|
||||
*/
|
||||
AirQualityMetrics air_quality_metrics = 4;
|
||||
|
||||
/*
|
||||
* Power Metrics
|
||||
*/
|
||||
PowerMetrics power_metrics = 5;
|
||||
|
||||
/*
|
||||
* Local device mesh statistics
|
||||
*/
|
||||
LocalStats local_stats = 6;
|
||||
|
||||
/*
|
||||
* Health telemetry metrics
|
||||
*/
|
||||
HealthMetrics health_metrics = 7;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Supported I2C Sensors for telemetry in Meshtastic
|
||||
*/
|
||||
enum TelemetrySensorType {
|
||||
/*
|
||||
* No external telemetry sensor explicitly set
|
||||
*/
|
||||
SENSOR_UNSET = 0;
|
||||
|
||||
/*
|
||||
* High accuracy temperature, pressure, humidity
|
||||
*/
|
||||
BME280 = 1;
|
||||
|
||||
/*
|
||||
* High accuracy temperature, pressure, humidity, and air resistance
|
||||
*/
|
||||
BME680 = 2;
|
||||
|
||||
/*
|
||||
* Very high accuracy temperature
|
||||
*/
|
||||
MCP9808 = 3;
|
||||
|
||||
/*
|
||||
* Moderate accuracy current and voltage
|
||||
*/
|
||||
INA260 = 4;
|
||||
|
||||
/*
|
||||
* Moderate accuracy current and voltage
|
||||
*/
|
||||
INA219 = 5;
|
||||
|
||||
/*
|
||||
* High accuracy temperature and pressure
|
||||
*/
|
||||
BMP280 = 6;
|
||||
|
||||
/*
|
||||
* High accuracy temperature and humidity
|
||||
*/
|
||||
SHTC3 = 7;
|
||||
|
||||
/*
|
||||
* High accuracy pressure
|
||||
*/
|
||||
LPS22 = 8;
|
||||
|
||||
/*
|
||||
* 3-Axis magnetic sensor
|
||||
*/
|
||||
QMC6310 = 9;
|
||||
|
||||
/*
|
||||
* 6-Axis inertial measurement sensor
|
||||
*/
|
||||
QMI8658 = 10;
|
||||
|
||||
/*
|
||||
* 3-Axis magnetic sensor
|
||||
*/
|
||||
QMC5883L = 11;
|
||||
|
||||
/*
|
||||
* High accuracy temperature and humidity
|
||||
*/
|
||||
SHT31 = 12;
|
||||
|
||||
/*
|
||||
* PM2.5 air quality sensor
|
||||
*/
|
||||
PMSA003I = 13;
|
||||
|
||||
/*
|
||||
* INA3221 3 Channel Voltage / Current Sensor
|
||||
*/
|
||||
INA3221 = 14;
|
||||
|
||||
/*
|
||||
* BMP085/BMP180 High accuracy temperature and pressure (older Version of BMP280)
|
||||
*/
|
||||
BMP085 = 15;
|
||||
|
||||
/*
|
||||
* RCWL-9620 Doppler Radar Distance Sensor, used for water level detection
|
||||
*/
|
||||
RCWL9620 = 16;
|
||||
|
||||
/*
|
||||
* Sensirion High accuracy temperature and humidity
|
||||
*/
|
||||
SHT4X = 17;
|
||||
|
||||
/*
|
||||
* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor.
|
||||
*/
|
||||
VEML7700 = 18;
|
||||
|
||||
/*
|
||||
* MLX90632 non-contact IR temperature sensor.
|
||||
*/
|
||||
MLX90632 = 19;
|
||||
|
||||
/*
|
||||
* TI OPT3001 Ambient Light Sensor
|
||||
*/
|
||||
OPT3001 = 20;
|
||||
|
||||
/*
|
||||
* Lite On LTR-390UV-01 UV Light Sensor
|
||||
*/
|
||||
LTR390UV = 21;
|
||||
|
||||
/*
|
||||
* AMS TSL25911FN RGB Light Sensor
|
||||
*/
|
||||
TSL25911FN = 22;
|
||||
|
||||
/*
|
||||
* AHT10 Integrated temperature and humidity sensor
|
||||
*/
|
||||
AHT10 = 23;
|
||||
|
||||
/*
|
||||
* DFRobot Lark Weather station (temperature, humidity, pressure, wind speed and direction)
|
||||
*/
|
||||
DFROBOT_LARK = 24;
|
||||
|
||||
/*
|
||||
* NAU7802 Scale Chip or compatible
|
||||
*/
|
||||
NAU7802 = 25;
|
||||
|
||||
/*
|
||||
* BMP3XX High accuracy temperature and pressure
|
||||
*/
|
||||
BMP3XX = 26;
|
||||
|
||||
/*
|
||||
* ICM-20948 9-Axis digital motion processor
|
||||
*/
|
||||
ICM20948 = 27;
|
||||
|
||||
/*
|
||||
* MAX17048 1S lipo battery sensor (voltage, state of charge, time to go)
|
||||
*/
|
||||
MAX17048 = 28;
|
||||
|
||||
/*
|
||||
* Custom I2C sensor implementation based on https://github.com/meshtastic/i2c-sensor
|
||||
*/
|
||||
CUSTOM_SENSOR = 29;
|
||||
|
||||
/*
|
||||
* MAX30102 Pulse Oximeter and Heart-Rate Sensor
|
||||
*/
|
||||
MAX30102 = 30;
|
||||
|
||||
/*
|
||||
* MLX90614 non-contact IR temperature sensor
|
||||
*/
|
||||
MLX90614 = 31;
|
||||
|
||||
/*
|
||||
* SCD40/SCD41 CO2, humidity, temperature sensor
|
||||
*/
|
||||
SCD4X = 32;
|
||||
|
||||
/*
|
||||
* ClimateGuard RadSens, radiation, Geiger-Muller Tube
|
||||
*/
|
||||
RADSENS = 33;
|
||||
|
||||
/*
|
||||
* High accuracy current and voltage
|
||||
*/
|
||||
INA226 = 34;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* NAU7802 Telemetry configuration, for saving to flash
|
||||
*/
|
||||
message Nau7802Config {
|
||||
/*
|
||||
* The offset setting for the NAU7802
|
||||
*/
|
||||
int32 zeroOffset = 1;
|
||||
|
||||
/*
|
||||
* The calibration factor for the NAU7802
|
||||
*/
|
||||
float calibrationFactor = 2;
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# options for nanopb
|
||||
# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options
|
||||
|
||||
*XModem.buffer max_size:128
|
||||
*XModem.seq int_size:16
|
||||
*XModem.crc16 int_size:16
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meshtastic;
|
||||
|
||||
option csharp_namespace = "Meshtastic.Protobufs";
|
||||
option go_package = "github.com/meshtastic/go/generated";
|
||||
option java_outer_classname = "XmodemProtos";
|
||||
option java_package = "com.geeksville.mesh";
|
||||
option swift_prefix = "";
|
||||
|
||||
message XModem {
|
||||
enum Control {
|
||||
NUL = 0;
|
||||
SOH = 1;
|
||||
STX = 2;
|
||||
EOT = 4;
|
||||
ACK = 6;
|
||||
NAK = 21;
|
||||
CAN = 24;
|
||||
CTRLZ = 26;
|
||||
}
|
||||
|
||||
Control control = 1;
|
||||
uint32 seq = 2;
|
||||
uint32 crc16 = 3;
|
||||
bytes buffer = 4;
|
||||
}
|
||||
115
src/public/assets/css/styles.css
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/* used to prevent ui flicker before vuejs loads */
|
||||
[v-cloak] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.icon-longfast {
|
||||
background-color: #009016;
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.icon-mediumfast {
|
||||
background-color: #326be7;
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.icon-shortslow {
|
||||
background-color: #0077e6;
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.icon-mqtt-connected {
|
||||
background-color: #2563eb; /* Change to use same color as disconnected // #16a34a; */
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.icon-mqtt-disconnected {
|
||||
background-color: #2563eb;
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.icon-offline {
|
||||
background-color: #e2286c;
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.icon-position-history {
|
||||
background-color: #a855f7;
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.icon-traceroute-start {
|
||||
background-color: #16a34a; /* green */
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.icon-traceroute-end {
|
||||
background-color: #dc2626; /* red */
|
||||
border-radius: 25px;
|
||||
border: 1px solid #2C2D3C;
|
||||
}
|
||||
|
||||
.waypoint-label {
|
||||
font-size: 26px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.link {
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
.link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.tooltip .tooltip-text {
|
||||
visibility: hidden;
|
||||
width: 80px;
|
||||
background-color: black;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 4px 0;
|
||||
border-radius: 6px;
|
||||
position: absolute;
|
||||
z-index: 10000;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
margin-top: 8px;
|
||||
margin-left: -40px; /* Use half of the width (120/2 = 60), to center the tooltip */
|
||||
}
|
||||
|
||||
.tooltip .tooltip-text::after {
|
||||
content: " ";
|
||||
position: absolute;
|
||||
bottom: 100%; /* At the top of the tooltip */
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
border-color: transparent transparent black transparent;
|
||||
}
|
||||
|
||||
.tooltip:hover .tooltip-text {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.z-search {
|
||||
z-index: 1001;
|
||||
}
|
||||
|
||||
.z-sidebar {
|
||||
z-index: 1002;
|
||||
}
|
||||
956
src/public/assets/js/app.js
Normal file
|
|
@ -0,0 +1,956 @@
|
|||
Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
|
||||
isShowingAnnouncement: this.shouldShowAnnouncement(),
|
||||
|
||||
configNodesMaxAgeInSeconds: window.getConfigNodesMaxAgeInSeconds(),
|
||||
configNodesOfflineAgeInSeconds: window.getConfigNodesOfflineAgeInSeconds(),
|
||||
configWaypointsMaxAgeInSeconds: window.getConfigWaypointsMaxAgeInSeconds(),
|
||||
configConnectionsMaxDistanceInMeters: window.getConfigConnectionsMaxDistanceInMeters(),
|
||||
configZoomLevelGoToNode: window.getConfigZoomLevelGoToNode(),
|
||||
configAutoUpdatePositionInUrl: window.getConfigAutoUpdatePositionInUrl(),
|
||||
configEnableMapAnimations: window.getConfigEnableMapAnimations(),
|
||||
configTemperatureFormat: window.getConfigTemperatureFormat(),
|
||||
configConnectionsTimePeriodInSeconds: window.getConfigConnectionsTimePeriodInSeconds(),
|
||||
configConnectionsColoredLines: window.getConfigConnectionsColoredLines(),
|
||||
configConnectionsBidirectionalOnly: window.getConfigConnectionsBidirectionalOnly(),
|
||||
configConnectionsMinSnrDb: window.getConfigConnectionsMinSnrDb(),
|
||||
configConnectionsBidirectionalMinSnr: window.getConfigConnectionsBidirectionalMinSnr(),
|
||||
|
||||
isShowingHardwareModels: false,
|
||||
hardwareModelStats: null,
|
||||
|
||||
isShowingInfoModal: this.shouldShowInfoModal(),
|
||||
isShowingMobileSearch: false,
|
||||
isShowingSettings: false,
|
||||
|
||||
nodes: [],
|
||||
searchText: "",
|
||||
|
||||
selectedNode: null,
|
||||
selectedNodeDeviceMetrics: [],
|
||||
selectedNodeEnvironmentMetrics: [],
|
||||
selectedNodePowerMetrics: [],
|
||||
selectedNodeMqttMetrics: [],
|
||||
selectedNodeTraceroutes: [],
|
||||
|
||||
deviceMetricsTimeRange: "7d",
|
||||
environmentMetricsTimeRange: "7d",
|
||||
powerMetricsTimeRange: "7d",
|
||||
|
||||
isPositionHistoryModalExpanded: true,
|
||||
positionHistoryDateTimeFrom: null,
|
||||
positionHistoryDateTimeTo: null,
|
||||
selectedNodePositionHistory: [],
|
||||
selectedNodeToShowPositionHistory: null,
|
||||
selectedNodePositionHistoryMarkers: [],
|
||||
selectedNodePositionHistoryPolyLines: [],
|
||||
|
||||
selectedTraceRoute: null,
|
||||
tracerouteEdges: [],
|
||||
|
||||
selectedNodeToShowConnections: null,
|
||||
|
||||
moment: window.moment,
|
||||
|
||||
};
|
||||
},
|
||||
mounted: function() {
|
||||
|
||||
// load data
|
||||
this.loadHardwareModelStats();
|
||||
|
||||
// handle map click callback from outside of vue
|
||||
window._onMapClick = () => {
|
||||
this.searchText = "";
|
||||
this.isShowingMobileSearch = false;
|
||||
};
|
||||
|
||||
// handle node callback from outside of vue
|
||||
window._onNodeClick = (node) => {
|
||||
this.selectedNode = node;
|
||||
this.loadNodeDeviceMetrics(node.node_id);
|
||||
this.loadNodeEnvironmentMetrics(node.node_id);
|
||||
this.loadNodePowerMetrics(node.node_id);
|
||||
this.loadNodeMqttMetrics(node.node_id);
|
||||
this.loadNodeTraceroutes(node.node_id);
|
||||
//this.loadNodePositionHistory(node.node_id);
|
||||
};
|
||||
|
||||
// handle node callback from outside of vue
|
||||
window._onShowNodeConnectionsClick = (node) => {
|
||||
this.selectedNodeToShowConnections = node;
|
||||
};
|
||||
|
||||
// handle nodes updated callback from outside of vue
|
||||
window._onNodesUpdated = (nodes) => {
|
||||
this.nodes = nodes;
|
||||
};
|
||||
|
||||
},
|
||||
methods: {
|
||||
getAnnouncementId: function() {
|
||||
// change this when making a new announcement
|
||||
return "1";
|
||||
},
|
||||
shouldShowAnnouncement: function() {
|
||||
const lastSeenAnnouncementId = window.localStorage.getItem("last-seen-announcement-id");
|
||||
return lastSeenAnnouncementId?.toString() !== this.getAnnouncementId();
|
||||
},
|
||||
dismissAnnouncement: function() {
|
||||
window.localStorage.setItem("last-seen-announcement-id", this.getAnnouncementId());
|
||||
this.isShowingAnnouncement = false;
|
||||
},
|
||||
shouldShowInfoModal: function() {
|
||||
return !window.getConfigHasSeenInfoModal()
|
||||
&& !window.isMobile();
|
||||
},
|
||||
loadHardwareModelStats: function() {
|
||||
window.axios.get('/api/v1/stats/hardware-models').then((response) => {
|
||||
this.hardwareModelStats = response.data.hardware_model_stats;
|
||||
}).catch((error) => {
|
||||
// do nothing
|
||||
});
|
||||
},
|
||||
loadNodeDeviceMetrics: function(nodeId) {
|
||||
|
||||
// calculate unix timestamps in milliseconds for supported time ranges
|
||||
const oneDayAgoInMilliseconds = new Date().getTime() - (86400 * 1000);
|
||||
const threeDaysAgoInMilliseconds = new Date().getTime() - (259200 * 1000);
|
||||
const sevenDaysAgoInMilliseconds = new Date().getTime() - (604800 * 1000);
|
||||
const thirtyDaysAgoInMilliseconds = new Date().getTime() - (259200 * 1000 * 10);
|
||||
|
||||
// determine how long back to load device metrics from
|
||||
var timeFrom = threeDaysAgoInMilliseconds;
|
||||
switch(this.deviceMetricsTimeRange){
|
||||
case "1d": {
|
||||
timeFrom = oneDayAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "3d": {
|
||||
timeFrom = threeDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "7d": {
|
||||
timeFrom = sevenDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "30d": {
|
||||
timeFrom = thirtyDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window.axios.get(`/api/v1/nodes/${nodeId}/device-metrics`, {
|
||||
params: {
|
||||
time_from: timeFrom,
|
||||
},
|
||||
}).then((response) => {
|
||||
// reverse response, as it's newest to oldest, but we want oldest to newest
|
||||
this.selectedNodeDeviceMetrics = response.data.device_metrics.reverse();
|
||||
this.renderDeviceMetricCharts();
|
||||
}).catch(() => {
|
||||
this.selectedNodeDeviceMetrics = [];
|
||||
this.renderDeviceMetricCharts();
|
||||
});
|
||||
},
|
||||
loadNodeEnvironmentMetrics: function(nodeId) {
|
||||
|
||||
// calculate unix timestamps in milliseconds for supported time ranges
|
||||
const oneDayAgoInMilliseconds = new Date().getTime() - (86400 * 1000);
|
||||
const threeDaysAgoInMilliseconds = new Date().getTime() - (259200 * 1000);
|
||||
const sevenDaysAgoInMilliseconds = new Date().getTime() - (604800 * 1000);
|
||||
const thirtyDaysAgoInMilliseconds = new Date().getTime() - (259200 * 1000 * 10);
|
||||
|
||||
// determine how long back to load environment metrics from
|
||||
var timeFrom = threeDaysAgoInMilliseconds;
|
||||
switch(this.environmentMetricsTimeRange){
|
||||
case "1d": {
|
||||
timeFrom = oneDayAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "3d": {
|
||||
timeFrom = threeDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "7d": {
|
||||
timeFrom = sevenDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "30d": {
|
||||
timeFrom = thirtyDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window.axios.get(`/api/v1/nodes/${nodeId}/environment-metrics`, {
|
||||
params: {
|
||||
time_from: timeFrom,
|
||||
},
|
||||
}).then((response) => {
|
||||
// reverse response, as it's newest to oldest, but we want oldest to newest
|
||||
this.selectedNodeEnvironmentMetrics = response.data.environment_metrics.reverse();
|
||||
this.renderEnvironmentMetricCharts();
|
||||
}).catch(() => {
|
||||
this.selectedNodeEnvironmentMetrics = [];
|
||||
this.renderEnvironmentMetricCharts();
|
||||
});
|
||||
},
|
||||
loadNodePowerMetrics: function(nodeId) {
|
||||
|
||||
// calculate unix timestamps in milliseconds for supported time ranges
|
||||
const oneDayAgoInMilliseconds = new Date().getTime() - (86400 * 1000);
|
||||
const threeDaysAgoInMilliseconds = new Date().getTime() - (259200 * 1000);
|
||||
const sevenDaysAgoInMilliseconds = new Date().getTime() - (604800 * 1000);
|
||||
const thirtyDaysAgoInMilliseconds = new Date().getTime() - (259200 * 1000 * 10);
|
||||
|
||||
// determine how long back to load power metrics from
|
||||
var timeFrom = threeDaysAgoInMilliseconds;
|
||||
switch(this.powerMetricsTimeRange){
|
||||
case "1d": {
|
||||
timeFrom = oneDayAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "3d": {
|
||||
timeFrom = threeDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "7d": {
|
||||
timeFrom = sevenDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
case "30d": {
|
||||
timeFrom = thirtyDaysAgoInMilliseconds;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window.axios.get(`/api/v1/nodes/${nodeId}/power-metrics`, {
|
||||
params: {
|
||||
time_from: timeFrom,
|
||||
},
|
||||
}).then((response) => {
|
||||
// reverse response, as it's newest to oldest, but we want oldest to newest
|
||||
this.selectedNodePowerMetrics = response.data.power_metrics.reverse();
|
||||
this.renderPowerMetricCharts();
|
||||
}).catch(() => {
|
||||
this.selectedNodePowerMetrics = [];
|
||||
this.renderPowerMetricCharts();
|
||||
});
|
||||
},
|
||||
loadNodeMqttMetrics: function(nodeId) {
|
||||
this.selectedNodeMqttMetrics = [];
|
||||
window.axios.get(`/api/v1/nodes/${nodeId}/mqtt-metrics`).then((response) => {
|
||||
this.selectedNodeMqttMetrics = response.data.mqtt_metrics;
|
||||
}).catch(() => {
|
||||
// do nothing
|
||||
});
|
||||
},
|
||||
loadNodeTraceroutes: function(nodeId) {
|
||||
this.selectedNodeTraceroutes = [];
|
||||
window.axios.get(`/api/v1/nodes/${nodeId}/traceroutes`, {
|
||||
params: {
|
||||
count: 5,
|
||||
},
|
||||
}).then((response) => {
|
||||
this.selectedNodeTraceroutes = response.data.traceroutes;
|
||||
}).catch(() => {
|
||||
// do nothing
|
||||
});
|
||||
},
|
||||
loadNodePositionHistory: function(nodeId) {
|
||||
this.selectedNodePositionHistory = [];
|
||||
window.axios.get(`/api/v1/nodes/${nodeId}/position-history`, {
|
||||
params: {
|
||||
// parse from datetime-local format, and send as unix timestamp in milliseconds
|
||||
time_from: moment(this.positionHistoryDateTimeFrom, "YYYY-MM-DDTHH:mm").format("x"),
|
||||
time_to: moment(this.positionHistoryDateTimeTo, "YYYY-MM-DDTHH:mm").format("x"),
|
||||
},
|
||||
}).then((response) => {
|
||||
this.selectedNodePositionHistory = response.data.position_history;
|
||||
if(this.selectedNodeToShowPositionHistory != null){
|
||||
clearAllPositionHistory();
|
||||
onPositionHistoryUpdated(response.data.position_history);
|
||||
}
|
||||
|
||||
}).catch(() => {
|
||||
// do nothing
|
||||
});
|
||||
},
|
||||
renderDeviceMetricCharts: function() {
|
||||
try {
|
||||
this.updateDeviceMetricsChart();
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
updateDeviceMetricsChart: function() {
|
||||
|
||||
// destroy existing chart
|
||||
const chartElementId = "deviceMetricsChart";
|
||||
const existingChart = window.Chart.getChart(chartElementId);
|
||||
if(existingChart != null){
|
||||
existingChart.destroy();
|
||||
}
|
||||
|
||||
// get chart element
|
||||
const chartElement = window.document.getElementById(chartElementId);
|
||||
if(!chartElement){
|
||||
return;
|
||||
}
|
||||
|
||||
// create chart data
|
||||
const labels = [];
|
||||
const batteryMetrics = [];
|
||||
const channelUtilizationMetrics = [];
|
||||
const airUtilTxMetrics = [];
|
||||
for(const deviceMetric of this.selectedNodeDeviceMetrics){
|
||||
labels.push(moment(deviceMetric.created_at));
|
||||
batteryMetrics.push(deviceMetric.battery_level);
|
||||
channelUtilizationMetrics.push(deviceMetric.channel_utilization);
|
||||
airUtilTxMetrics.push(deviceMetric.air_util_tx);
|
||||
}
|
||||
|
||||
// create chart
|
||||
new window.Chart(chartElement, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Battery Level',
|
||||
borderColor: '#3b82f6',
|
||||
backgroundColor: '#3b82f6',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: batteryMetrics,
|
||||
},
|
||||
{
|
||||
label: 'Channel Util',
|
||||
borderColor: '#22c55e',
|
||||
backgroundColor: '#22c55e',
|
||||
showLine: false, // no lines between points
|
||||
fill: false,
|
||||
data: channelUtilizationMetrics,
|
||||
},
|
||||
{
|
||||
label: 'Air Util TX',
|
||||
borderColor: '#f97316',
|
||||
backgroundColor: '#f97316',
|
||||
showLine: false, // no lines between points
|
||||
fill: false,
|
||||
data: airUtilTxMetrics,
|
||||
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
borderWidth: 2,
|
||||
elements: {
|
||||
point: {
|
||||
radius: 2,
|
||||
},
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
position: 'top',
|
||||
type: 'time',
|
||||
time: {
|
||||
unit: 'day',
|
||||
displayFormats: {
|
||||
day: 'MMM DD', // Jan 01
|
||||
},
|
||||
},
|
||||
},
|
||||
y: {
|
||||
min: 0,
|
||||
max: 101, // 101 is "Plugged In", need to include for tooltip to work
|
||||
ticks: {
|
||||
callback: (label) => `${label}%`,
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
tooltip: {
|
||||
mode: "index",
|
||||
intersect: false,
|
||||
callbacks: {
|
||||
label: (item) => {
|
||||
return `${item.dataset.label}: ${item.formattedValue}%`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
renderEnvironmentMetricCharts: function() {
|
||||
try {
|
||||
this.updateEnvironmentMetricsChart();
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
updateEnvironmentMetricsChart: function() {
|
||||
|
||||
// destroy existing chart
|
||||
const chartElementId = "environmentMetricsChart";
|
||||
const existingChart = window.Chart.getChart(chartElementId);
|
||||
if(existingChart != null){
|
||||
existingChart.destroy();
|
||||
}
|
||||
|
||||
// get chart element
|
||||
const chartElement = window.document.getElementById(chartElementId);
|
||||
if(!chartElement){
|
||||
return;
|
||||
}
|
||||
|
||||
// create chart data
|
||||
const labels = [];
|
||||
const temperatureMetrics = [];
|
||||
const relativeHumidityMetrics = [];
|
||||
const barometricPressureMetrics = [];
|
||||
const iaqMetrics = [];
|
||||
for(const deviceMetric of this.selectedNodeEnvironmentMetrics){
|
||||
labels.push(moment(deviceMetric.created_at));
|
||||
temperatureMetrics.push(deviceMetric.temperature);
|
||||
relativeHumidityMetrics.push(deviceMetric.relative_humidity);
|
||||
barometricPressureMetrics.push(deviceMetric.barometric_pressure);
|
||||
iaqMetrics.push(deviceMetric.iaq);
|
||||
}
|
||||
|
||||
// create chart
|
||||
new window.Chart(chartElement, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Temperature',
|
||||
suffix: '°C',
|
||||
borderColor: '#3b82f6',
|
||||
backgroundColor: '#3b82f6',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: temperatureMetrics,
|
||||
yAxisID: 'y',
|
||||
},
|
||||
{
|
||||
label: 'Humidity',
|
||||
suffix: '%',
|
||||
borderColor: '#22c55e',
|
||||
backgroundColor: '#22c55e',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: relativeHumidityMetrics,
|
||||
yAxisID: 'y',
|
||||
},
|
||||
{
|
||||
label: 'Pressure',
|
||||
suffix: 'hPa',
|
||||
borderColor: '#f97316',
|
||||
backgroundColor: '#f97316',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: barometricPressureMetrics,
|
||||
yAxisID: 'y1',
|
||||
|
||||
},
|
||||
{
|
||||
label: 'IAQ',
|
||||
suffix: 'IAQ',
|
||||
borderColor: '#f472b6',
|
||||
backgroundColor: '#f472b6',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: iaqMetrics,
|
||||
yAxisID: 'yIAQ',
|
||||
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
borderWidth: 2,
|
||||
spanGaps: 1000 * 60 * 60 * 24, // only show lines between metrics with a 24 hour or less gap
|
||||
elements: {
|
||||
point: {
|
||||
radius: 2,
|
||||
},
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
position: 'top',
|
||||
type: 'time',
|
||||
time: {
|
||||
unit: 'day',
|
||||
displayFormats: {
|
||||
day: 'MMM DD', // Jan 01
|
||||
},
|
||||
},
|
||||
},
|
||||
y: {
|
||||
min: -20,
|
||||
max: 100,
|
||||
},
|
||||
y1: {
|
||||
min: 800,
|
||||
max: 1100,
|
||||
ticks: {
|
||||
stepSize: 10,
|
||||
callback: (label) => `${label} hPa`,
|
||||
},
|
||||
position: 'right',
|
||||
grid: {
|
||||
drawOnChartArea: false, // only want the grid lines for one axis to show up
|
||||
},
|
||||
},
|
||||
yIAQ: {
|
||||
type: 'linear',
|
||||
display: false,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
tooltip: {
|
||||
mode: "index",
|
||||
intersect: false,
|
||||
callbacks: {
|
||||
label: (item) => {
|
||||
return `${item.dataset.label}: ${item.formattedValue}${item.dataset.suffix}`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
renderPowerMetricCharts: function() {
|
||||
try {
|
||||
this.updatePowerMetricsChart();
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
updatePowerMetricsChart: function() {
|
||||
|
||||
// destroy existing chart
|
||||
const chartElementId = "powerMetricsChart";
|
||||
const existingChart = window.Chart.getChart(chartElementId);
|
||||
if(existingChart != null){
|
||||
existingChart.destroy();
|
||||
}
|
||||
|
||||
// get chart element
|
||||
const chartElement = window.document.getElementById(chartElementId);
|
||||
if(!chartElement){
|
||||
return;
|
||||
}
|
||||
|
||||
// create chart data
|
||||
const labels = [];
|
||||
const channel1VoltageReadings = [];
|
||||
const channel2VoltageReadings = [];
|
||||
const channel3VoltageReadings = [];
|
||||
const channel1CurrentReadings = [];
|
||||
const channel2CurrentReadings = [];
|
||||
const channel3CurrentReadings = [];
|
||||
for(const powerMetric of this.selectedNodePowerMetrics){
|
||||
labels.push(moment(powerMetric.created_at));
|
||||
channel1VoltageReadings.push(powerMetric.ch1_voltage);
|
||||
channel2VoltageReadings.push(powerMetric.ch2_voltage);
|
||||
channel3VoltageReadings.push(powerMetric.ch3_voltage);
|
||||
channel1CurrentReadings.push(powerMetric.ch1_current);
|
||||
channel2CurrentReadings.push(powerMetric.ch2_current);
|
||||
channel3CurrentReadings.push(powerMetric.ch3_current);
|
||||
}
|
||||
|
||||
// create chart
|
||||
new window.Chart(chartElement, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Ch1 Voltage',
|
||||
suffix: "V",
|
||||
borderColor: '#3b82f6',
|
||||
backgroundColor: '#3b82f6',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: channel1VoltageReadings,
|
||||
yAxisID: 'y',
|
||||
},
|
||||
{
|
||||
label: 'Ch2 Voltage',
|
||||
suffix: "V",
|
||||
borderColor: '#22c55e',
|
||||
backgroundColor: '#22c55e',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: channel2VoltageReadings,
|
||||
yAxisID: 'y',
|
||||
},
|
||||
{
|
||||
label: 'Ch3 Voltage',
|
||||
suffix: "V",
|
||||
borderColor: '#f97316',
|
||||
backgroundColor: '#f97316',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: channel3VoltageReadings,
|
||||
yAxisID: 'y',
|
||||
},
|
||||
{
|
||||
label: 'Ch1 Current',
|
||||
suffix: "mA",
|
||||
borderColor: '#93c5fd',
|
||||
backgroundColor: '#93c5fd',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: channel1CurrentReadings,
|
||||
yAxisID: 'y1',
|
||||
},
|
||||
{
|
||||
label: 'Ch2 Current',
|
||||
suffix: "mA",
|
||||
borderColor: '#86efac',
|
||||
backgroundColor: '#86efac',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: channel2CurrentReadings,
|
||||
yAxisID: 'y1',
|
||||
},
|
||||
{
|
||||
label: 'Ch3 Current',
|
||||
suffix: "mA",
|
||||
borderColor: '#fdba74',
|
||||
backgroundColor: '#fdba74',
|
||||
pointStyle: false, // no points
|
||||
fill: false,
|
||||
data: channel3CurrentReadings,
|
||||
yAxisID: 'y1',
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
borderWidth: 2,
|
||||
spanGaps: 1000 * 60 * 60 * 3, // only show lines between metrics with a 3 hour or less gap
|
||||
elements: {
|
||||
point: {
|
||||
radius: 2,
|
||||
},
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
position: 'top',
|
||||
type: 'time',
|
||||
time: {
|
||||
unit: 'day',
|
||||
displayFormats: {
|
||||
day: 'MMM DD', // Jan 01
|
||||
},
|
||||
},
|
||||
},
|
||||
y: {
|
||||
min: 0,
|
||||
suggestedMax: 6,
|
||||
ticks: {
|
||||
callback: (label) => `${label}V`,
|
||||
},
|
||||
},
|
||||
y1: {
|
||||
suggestedMin: -50,
|
||||
suggestedMax: 50,
|
||||
ticks: {
|
||||
stepSize: 50,
|
||||
callback: (label) => `${label}mA`,
|
||||
},
|
||||
position: 'right',
|
||||
grid: {
|
||||
drawOnChartArea: false, // only want the grid lines for one axis to show up
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
tooltip: {
|
||||
mode: "index",
|
||||
intersect: false,
|
||||
callbacks: {
|
||||
label: (item) => {
|
||||
return `${item.dataset.label}: ${item.formattedValue}${item.dataset.suffix}`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
showTraceRoute: function(traceroute) {
|
||||
this.selectedTraceRoute = traceroute;
|
||||
},
|
||||
findNodeById: function(id) {
|
||||
return window.findNodeById(id);
|
||||
},
|
||||
findNodeMarkerById: function(id) {
|
||||
return window.findNodeMarkerById(id);
|
||||
},
|
||||
onSearchResultNodeClick: function(node) {
|
||||
|
||||
// clear search
|
||||
this.searchText = "";
|
||||
|
||||
// hide search
|
||||
this.isShowingMobileSearch = false;
|
||||
|
||||
// go to node
|
||||
if(window.goToNode(node.node_id)){
|
||||
return;
|
||||
}
|
||||
|
||||
// fallback to showing node details since we can't go to the node
|
||||
window.showNodeDetails(node.node_id);
|
||||
|
||||
},
|
||||
dismissInfoModal: function() {
|
||||
this.isShowingInfoModal = false;
|
||||
window.setConfigHasSeenInfoModal(true);
|
||||
},
|
||||
getRegionFrequencyRange: function(regionName) {
|
||||
return window.getRegionFrequencyRange(regionName);
|
||||
},
|
||||
showNodePositionHistory: function(nodeId) {
|
||||
|
||||
// find node
|
||||
const node = findNodeById(nodeId);
|
||||
if(!node){
|
||||
return;
|
||||
}
|
||||
|
||||
// update ui
|
||||
this.selectedNode = null;
|
||||
this.selectedNodeToShowPositionHistory = node;
|
||||
this.isPositionHistoryModalExpanded = true;
|
||||
|
||||
// close node info tooltip as position history shows under it
|
||||
window.closeAllTooltips();
|
||||
|
||||
// reset default time range when opening position history ui
|
||||
// YYYY-MM-DDTHH:mm is the format expected by the datetime-local input type
|
||||
this.positionHistoryDateTimeFrom = moment().subtract(1, "hours").format('YYYY-MM-DDTHH:mm');
|
||||
this.positionHistoryDateTimeTo = moment().format('YYYY-MM-DDTHH:mm');
|
||||
|
||||
// load position history
|
||||
this.loadNodePositionHistory(nodeId);
|
||||
|
||||
},
|
||||
onPositionHistoryQuickRangeClick: function(range) {
|
||||
|
||||
// update position history time range
|
||||
switch(range){
|
||||
case "1h": {
|
||||
this.positionHistoryDateTimeFrom = moment().subtract(1, "hours").format('YYYY-MM-DDTHH:mm');
|
||||
this.positionHistoryDateTimeTo = moment().format('YYYY-MM-DDTHH:mm');
|
||||
break;
|
||||
}
|
||||
case "24h": {
|
||||
this.positionHistoryDateTimeFrom = moment().subtract(24, "hours").format('YYYY-MM-DDTHH:mm');
|
||||
this.positionHistoryDateTimeTo = moment().format('YYYY-MM-DDTHH:mm');
|
||||
break;
|
||||
}
|
||||
case "7d": {
|
||||
this.positionHistoryDateTimeFrom = moment().subtract(7, "days").format('YYYY-MM-DDTHH:mm');
|
||||
this.positionHistoryDateTimeTo = moment().format('YYYY-MM-DDTHH:mm');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// reload position history
|
||||
const node = this.selectedNodeToShowPositionHistory;
|
||||
if(node){
|
||||
this.loadNodePositionHistory(node.node_id);
|
||||
}
|
||||
|
||||
},
|
||||
getShareLinkForNode: function(nodeId) {
|
||||
return window.location.origin + `/?node_id=${nodeId}`;
|
||||
},
|
||||
copyShareLinkForNode: function(nodeId) {
|
||||
|
||||
// make sure copy to clipboard is supported
|
||||
if(!navigator.clipboard || !navigator.clipboard.writeText){
|
||||
alert("Clipboard not supported. Site must be served via https on iOS.");
|
||||
return;
|
||||
}
|
||||
|
||||
// copy share link to clipboard
|
||||
const url = this.getShareLinkForNode(nodeId);
|
||||
navigator.clipboard.writeText(url);
|
||||
|
||||
// tell user we copied it
|
||||
alert("Link copied to clipboard!");
|
||||
|
||||
},
|
||||
dismissShowingNodeConnections: function() {
|
||||
window._onHideNodeConnectionsClick();
|
||||
this.selectedNodeToShowConnections = null;
|
||||
},
|
||||
dismissShowingNodePositionHistory: function() {
|
||||
this.selectedNodePositionHistory = [];
|
||||
this.selectedNodeToShowPositionHistory = null;
|
||||
this.selectedNodePositionHistoryMarkers = [];
|
||||
this.selectedNodePositionHistoryPolyLines = [];
|
||||
cleanUpPositionHistory();
|
||||
},
|
||||
formatUptimeSeconds: function(secondsToFormat) {
|
||||
secondsToFormat = Number(secondsToFormat);
|
||||
var days = Math.floor(secondsToFormat / (3600 * 24));
|
||||
var hours = Math.floor((secondsToFormat % (3600 * 24)) / 3600);
|
||||
var minutes = Math.floor((secondsToFormat % 3600) / 60);
|
||||
var seconds = Math.floor(secondsToFormat % 60);
|
||||
var daysPlural = days === 1 ? 'day' : 'days';
|
||||
return `${days} ${daysPlural} ${hours}h ${minutes}m ${seconds}s`;
|
||||
},
|
||||
formatTemperature: function(celsius) {
|
||||
switch(this.configTemperatureFormat){
|
||||
case "celsius": {
|
||||
return `${Number(celsius).toFixed(0)}°C`;
|
||||
}
|
||||
case "fahrenheit": {
|
||||
const fahrenheit = this.celsiusToFahrenheit(celsius);
|
||||
return `${fahrenheit.toFixed(0)}°F`;
|
||||
}
|
||||
}
|
||||
},
|
||||
convertTemperature: function(celsius) {
|
||||
switch(this.configTemperatureFormat){
|
||||
case "celsius": {
|
||||
return celsius;
|
||||
}
|
||||
case "fahrenheit": {
|
||||
return this.celsiusToFahrenheit(celsius);
|
||||
}
|
||||
}
|
||||
},
|
||||
getTemperatureUnit: function() {
|
||||
switch(this.configTemperatureFormat){
|
||||
case "celsius": return "°C";
|
||||
case "fahrenheit": return "°F";
|
||||
}
|
||||
},
|
||||
celsiusToFahrenheit: function(celsius) {
|
||||
return (celsius * 9/5) + 32;
|
||||
},
|
||||
getNodeColour(nodeId) {
|
||||
// convert node id to a hex colour
|
||||
return "#" + (nodeId & 0x00FFFFFF).toString(16).padStart(6, '0');
|
||||
},
|
||||
getNodeTextColour(nodeId) {
|
||||
|
||||
// extract rgb components
|
||||
const r = (nodeId & 0xFF0000) >> 16;
|
||||
const g = (nodeId & 0x00FF00) >> 8;
|
||||
const b = nodeId & 0x0000FF;
|
||||
|
||||
// calculate brightness
|
||||
const brightness = ((r * 0.299) + (g * 0.587) + (b * 0.114)) / 255;
|
||||
|
||||
// determine text color based on brightness
|
||||
return brightness > 0.5 ? "#000000" : "#FFFFFF";
|
||||
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
searchedNodes() {
|
||||
|
||||
// search nodes
|
||||
const nodes = this.nodes.filter((node) => {
|
||||
const matchesId = node.node_id?.toLowerCase()?.includes(this.searchText.toLowerCase());
|
||||
const matchesHexId = node.node_id_hex?.toLowerCase()?.includes(this.searchText.toLowerCase());
|
||||
const matchesLongName = node.long_name?.toLowerCase()?.includes(this.searchText.toLowerCase());
|
||||
const matchesShortName = node.short_name?.toLowerCase()?.includes(this.searchText.toLowerCase());
|
||||
return matchesId || matchesHexId || matchesLongName || matchesShortName;
|
||||
});
|
||||
|
||||
// order alphabetically by long name
|
||||
nodes.sort((nodeA, nodeB) => {
|
||||
const nodeALongName = nodeA.long_name || "";
|
||||
const nodeBLongName = nodeB.long_name || "";
|
||||
return nodeALongName.localeCompare(nodeBLongName);
|
||||
});
|
||||
|
||||
// only return the first 500 results to avoid ui lag...
|
||||
return nodes.slice(0, 500);
|
||||
|
||||
},
|
||||
selectedNodeLatestPowerMetric() {
|
||||
const [ latestPowerMetric ] = this.selectedNodePowerMetrics.slice(-1);
|
||||
return latestPowerMetric;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
configNodesMaxAgeInSeconds() {
|
||||
window.setConfigNodesMaxAgeInSeconds(this.configNodesMaxAgeInSeconds);
|
||||
},
|
||||
configNodesOfflineAgeInSeconds() {
|
||||
window.setConfigNodesOfflineAgeInSeconds(this.configNodesOfflineAgeInSeconds);
|
||||
},
|
||||
configWaypointsMaxAgeInSeconds() {
|
||||
window.setConfigWaypointsMaxAgeInSeconds(this.configWaypointsMaxAgeInSeconds);
|
||||
},
|
||||
configConnectionsMaxDistanceInMeters() {
|
||||
window.setConfigConnectionsMaxDistanceInMeters(this.configConnectionsMaxDistanceInMeters);
|
||||
},
|
||||
configZoomLevelGoToNode() {
|
||||
window.setConfigZoomLevelGoToNode(this.configZoomLevelGoToNode);
|
||||
},
|
||||
configAutoUpdatePositionInUrl() {
|
||||
window.setConfigAutoUpdatePositionInUrl(this.configAutoUpdatePositionInUrl);
|
||||
},
|
||||
configEnableMapAnimations() {
|
||||
window.setConfigEnableMapAnimations(this.configEnableMapAnimations);
|
||||
},
|
||||
configTemperatureFormat() {
|
||||
window.setConfigTemperatureFormat(this.configTemperatureFormat);
|
||||
},
|
||||
configConnectionsTimePeriodInSeconds() {
|
||||
window.setConfigConnectionsTimePeriodInSeconds(this.configConnectionsTimePeriodInSeconds);
|
||||
},
|
||||
configConnectionsColoredLines() {
|
||||
window.setConfigConnectionsColoredLines(this.configConnectionsColoredLines);
|
||||
},
|
||||
configConnectionsBidirectionalOnly() {
|
||||
window.setConfigConnectionsBidirectionalOnly(this.configConnectionsBidirectionalOnly);
|
||||
},
|
||||
configConnectionsMinSnrDb() {
|
||||
window.setConfigConnectionsMinSnrDb(this.configConnectionsMinSnrDb);
|
||||
},
|
||||
configConnectionsBidirectionalMinSnr() {
|
||||
window.setConfigConnectionsBidirectionalMinSnr(this.configConnectionsBidirectionalMinSnr);
|
||||
},
|
||||
deviceMetricsTimeRange() {
|
||||
this.loadNodeDeviceMetrics(this.selectedNode.node_id);
|
||||
},
|
||||
environmentMetricsTimeRange() {
|
||||
this.loadNodeEnvironmentMetrics(this.selectedNode.node_id);
|
||||
},
|
||||
powerMetricsTimeRange() {
|
||||
this.loadNodePowerMetrics(this.selectedNode.node_id);
|
||||
},
|
||||
},
|
||||
}).mount('#app');
|
||||
199
src/public/assets/js/config.js
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
function getConfigHasSeenInfoModal() {
|
||||
return localStorage.getItem("config_has_seen_info_modal") === "true";
|
||||
}
|
||||
|
||||
function setConfigHasSeenInfoModal(value) {
|
||||
return localStorage.setItem("config_has_seen_info_modal", value);
|
||||
}
|
||||
|
||||
function getConfigAutoUpdatePositionInUrl() {
|
||||
// use user preference, or enable by default
|
||||
const value = localStorage.getItem("config_auto_update_position_in_url");
|
||||
return value === "true" || value == null;
|
||||
}
|
||||
|
||||
function setConfigAutoUpdatePositionInUrl(value) {
|
||||
return localStorage.setItem("config_auto_update_position_in_url", value);
|
||||
}
|
||||
|
||||
function getConfigEnableMapAnimations() {
|
||||
|
||||
const value = localStorage.getItem("config_enable_map_animations");
|
||||
|
||||
// enable animations by default
|
||||
if(value === null){
|
||||
return true;
|
||||
}
|
||||
|
||||
return value === "true";
|
||||
|
||||
}
|
||||
|
||||
function setConfigEnableMapAnimations(value) {
|
||||
return localStorage.setItem("config_enable_map_animations", value);
|
||||
}
|
||||
|
||||
function getConfigTemperatureFormat() {
|
||||
return localStorage.getItem("config_temperature_format") || "celsius";
|
||||
}
|
||||
|
||||
function setConfigTemperatureFormat(format) {
|
||||
return localStorage.setItem("config_temperature_format", format);
|
||||
}
|
||||
|
||||
function getConfigMapSelectedTileLayer() {
|
||||
return localStorage.getItem("config_map_selected_tile_layer") || "Thunderforest Neighbourhood";
|
||||
}
|
||||
|
||||
function setConfigMapSelectedTileLayer(layer) {
|
||||
return localStorage.setItem("config_map_selected_tile_layer", layer);
|
||||
}
|
||||
|
||||
function getConfigMapEnabledOverlayLayers() {
|
||||
|
||||
try {
|
||||
const value = localStorage.getItem("config_map_enabled_overlay_layers");
|
||||
if(value){
|
||||
return JSON.parse(value);
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// overlays enabled by default
|
||||
return ["Legend", "Position History", "Traceroutes"];
|
||||
|
||||
}
|
||||
|
||||
function setConfigMapEnabledOverlayLayers(layers) {
|
||||
return localStorage.setItem("config_map_enabled_overlay_layers", JSON.stringify(layers));
|
||||
}
|
||||
|
||||
function getConfigNodesMaxAgeInSeconds() {
|
||||
const value = localStorage.getItem("config_nodes_max_age_in_seconds");
|
||||
return value != null ? parseInt(value) : null;
|
||||
}
|
||||
|
||||
function setConfigNodesMaxAgeInSeconds(value) {
|
||||
if(value != null){
|
||||
return localStorage.setItem("config_nodes_max_age_in_seconds", value);
|
||||
} else {
|
||||
return localStorage.removeItem("config_nodes_max_age_in_seconds");
|
||||
}
|
||||
}
|
||||
|
||||
function getConfigNodesOfflineAgeInSeconds() {
|
||||
const value = localStorage.getItem("config_nodes_offline_age_in_seconds");
|
||||
return value != null ? parseInt(value) : 10800;
|
||||
}
|
||||
|
||||
function setConfigNodesOfflineAgeInSeconds(value) {
|
||||
if(value != null){
|
||||
return localStorage.setItem("config_nodes_offline_age_in_seconds", value);
|
||||
} else {
|
||||
return localStorage.removeItem("config_nodes_offline_age_in_seconds");
|
||||
}
|
||||
}
|
||||
|
||||
function getConfigWaypointsMaxAgeInSeconds() {
|
||||
const value = localStorage.getItem("config_waypoints_max_age_in_seconds");
|
||||
return value != null ? parseInt(value) : null;
|
||||
}
|
||||
|
||||
function setConfigWaypointsMaxAgeInSeconds(value) {
|
||||
if(value != null){
|
||||
return localStorage.setItem("config_waypoints_max_age_in_seconds", value);
|
||||
} else {
|
||||
return localStorage.removeItem("config_waypoints_max_age_in_seconds");
|
||||
}
|
||||
}
|
||||
|
||||
function getConfigConnectionsMaxDistanceInMeters() {
|
||||
const value = localStorage.getItem("config_connections_max_distance_in_meters");
|
||||
// default to 70km (70,000 meters)
|
||||
return value != null ? parseInt(value) : 70000;
|
||||
}
|
||||
|
||||
function setConfigConnectionsMaxDistanceInMeters(value) {
|
||||
return localStorage.setItem("config_connections_max_distance_in_meters", value);
|
||||
}
|
||||
|
||||
function getConfigZoomLevelGoToNode() {
|
||||
const value = localStorage.getItem("config_zoom_level_go_to_node");
|
||||
const parsedValue = value != null ? parseInt(value) : null;
|
||||
return parsedValue || 15;
|
||||
}
|
||||
|
||||
function setConfigZoomLevelGoToNode(value) {
|
||||
return localStorage.setItem("config_zoom_level_go_to_node", value);
|
||||
}
|
||||
|
||||
function getConfigConnectionsTimePeriodInSeconds() {
|
||||
const value = localStorage.getItem("config_connections_time_period_in_seconds");
|
||||
// default to 7 days if unset
|
||||
return value != null ? parseInt(value) : 604800;
|
||||
}
|
||||
|
||||
function setConfigConnectionsTimePeriodInSeconds(value) {
|
||||
return localStorage.setItem("config_connections_time_period_in_seconds", value);
|
||||
}
|
||||
|
||||
function getConfigConnectionsColoredLines() {
|
||||
const value = localStorage.getItem("config_connections_colored_lines");
|
||||
// disable colored lines by default
|
||||
if(value === null){
|
||||
return false;
|
||||
}
|
||||
return value === "true";
|
||||
}
|
||||
|
||||
function setConfigConnectionsColoredLines(value) {
|
||||
return localStorage.setItem("config_connections_colored_lines", value);
|
||||
}
|
||||
|
||||
function getConfigConnectionsBidirectionalOnly() {
|
||||
const value = localStorage.getItem("config_connections_bidirectional_only");
|
||||
// disable bidirectional filter by default
|
||||
if(value === null){
|
||||
return false;
|
||||
}
|
||||
return value === "true";
|
||||
}
|
||||
|
||||
function setConfigConnectionsBidirectionalOnly(value) {
|
||||
return localStorage.setItem("config_connections_bidirectional_only", value);
|
||||
}
|
||||
|
||||
function getConfigConnectionsMinSnrDb() {
|
||||
const value = localStorage.getItem("config_connections_min_snr_db");
|
||||
// default to null (unset)
|
||||
if(value === null || value === ""){
|
||||
return null;
|
||||
}
|
||||
const parsed = parseFloat(value);
|
||||
return isNaN(parsed) ? null : parsed;
|
||||
}
|
||||
|
||||
function setConfigConnectionsMinSnrDb(value) {
|
||||
if(value === null || value === "" || value === undefined){
|
||||
return localStorage.removeItem("config_connections_min_snr_db");
|
||||
}
|
||||
// Convert to string for localStorage (handles both number and string inputs)
|
||||
const stringValue = typeof value === "number" ? value.toString() : String(value);
|
||||
return localStorage.setItem("config_connections_min_snr_db", stringValue);
|
||||
}
|
||||
|
||||
function getConfigConnectionsBidirectionalMinSnr() {
|
||||
const value = localStorage.getItem("config_connections_bidirectional_min_snr");
|
||||
// disable bidirectional minimum SNR by default
|
||||
if(value === null){
|
||||
return false;
|
||||
}
|
||||
return value === "true";
|
||||
}
|
||||
|
||||
function setConfigConnectionsBidirectionalMinSnr(value) {
|
||||
return localStorage.setItem("config_connections_bidirectional_min_snr", value);
|
||||
}
|
||||
|
||||
function isMobile() {
|
||||
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||
}
|
||||
1692
src/public/assets/js/map.js
Normal file
BIN
src/public/images/devices/HELTEC_MESH_POCKET.png
Normal file
|
After Width: | Height: | Size: 134 KiB |
BIN
src/public/images/devices/HELTEC_MESH_SOLAR.png
Normal file
|
After Width: | Height: | Size: 364 KiB |
BIN
src/public/images/devices/HELTEC_V2_0.png
Executable file → Normal file
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 38 KiB |
BIN
src/public/images/devices/HELTEC_V2_1.png
Executable file → Normal file
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 38 KiB |
BIN
src/public/images/devices/HELTEC_V3.png
Executable file → Normal file
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 38 KiB |
BIN
src/public/images/devices/HELTEC_V4.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
src/public/images/devices/HELTEC_VISION_MASTER_E213.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
src/public/images/devices/LILYGO_TBEAM_S3_CORE.png
Executable file → Normal file
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 70 KiB |
BIN
src/public/images/devices/NRF52_PROMICRO_DIY.png
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
src/public/images/devices/PORTDUINO.png
Normal file
|
After Width: | Height: | Size: 118 KiB |
BIN
src/public/images/devices/RP2040_LORA.png
Executable file → Normal file
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 45 KiB |
BIN
src/public/images/devices/RPI_PICO.png
Executable file → Normal file
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 40 KiB |
BIN
src/public/images/devices/SEEED_SOLAR_NODE.png
Normal file
|
After Width: | Height: | Size: 128 KiB |
BIN
src/public/images/devices/SEEED_WIO_TRACKER_L1.png
Normal file
|
After Width: | Height: | Size: 309 KiB |
BIN
src/public/images/devices/SEEED_XIAO_S3.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
src/public/images/devices/STATION_G2.png
Normal file
|
After Width: | Height: | Size: 111 KiB |
BIN
src/public/images/devices/TBEAM.png
Executable file → Normal file
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 83 KiB |
BIN
src/public/images/devices/THINKNODE_M1.png
Normal file
|
After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 43 KiB |
BIN
src/public/images/devices/TLORA_V2_1_1P6.png
Executable file → Normal file
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 45 KiB |
BIN
src/public/images/devices/T_DECK.png
Executable file → Normal file
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 90 KiB |
BIN
src/public/images/devices/T_ECHO.png
Executable file → Normal file
|
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 57 KiB |
BIN
src/public/images/devices/T_ETH_ELITE.png
Normal file
|
After Width: | Height: | Size: 346 KiB |
BIN
src/public/images/devices/XIAO_NRF52_KIT.png
Normal file
|
After Width: | Height: | Size: 495 KiB |
244
src/stats.js
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
const path = require('path');
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const protobufjs = require("protobufjs");
|
||||
|
||||
// create prisma db client
|
||||
const { Prisma, PrismaClient } = require("@prisma/client");
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// load protobufs
|
||||
const root = new protobufjs.Root();
|
||||
root.resolvePath = (origin, target) => path.join(__dirname, "protobufs", target);
|
||||
root.loadSync('meshtastic/mqtt.proto');
|
||||
const HardwareModel = root.lookupEnum("HardwareModel");
|
||||
const PortNum = root.lookupEnum("PortNum");
|
||||
|
||||
|
||||
router.get('/hardware-models', async (req, res) => {
|
||||
try {
|
||||
|
||||
// get nodes from db
|
||||
const results = await prisma.node.groupBy({
|
||||
by: ['hardware_model'],
|
||||
where: {
|
||||
// Since we removed retention; only include nodes that have been updated in the last 30 days
|
||||
updated_at: {
|
||||
gte: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) // within last 30 days
|
||||
}
|
||||
},
|
||||
orderBy: {
|
||||
_count: {
|
||||
hardware_model: 'desc',
|
||||
},
|
||||
},
|
||||
_count: {
|
||||
hardware_model: true,
|
||||
},
|
||||
});
|
||||
|
||||
const hardwareModelStats = results.map((result) => {
|
||||
return {
|
||||
count: result._count.hardware_model,
|
||||
hardware_model: result.hardware_model,
|
||||
hardware_model_name: HardwareModel.valuesById[result.hardware_model] ?? "UNKNOWN",
|
||||
};
|
||||
});
|
||||
|
||||
res.json({
|
||||
hardware_model_stats: hardwareModelStats,
|
||||
});
|
||||
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
res.status(500).json({
|
||||
message: "Something went wrong, try again later.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/messages-per-hour', async (req, res) => {
|
||||
try {
|
||||
const hours = 168;
|
||||
const now = new Date();
|
||||
const startTime = new Date(now.getTime() - hours * 60 * 60 * 1000);
|
||||
|
||||
const messages = await prisma.textMessage.findMany({
|
||||
where: { created_at: { gte: startTime } },
|
||||
select: { packet_id: true, created_at: true },
|
||||
distinct: ['packet_id'], // Ensures only unique packet_id entries are counted
|
||||
orderBy: { created_at: 'asc' }
|
||||
});
|
||||
|
||||
// Pre-fill `uniqueCounts` with zeros for all hours, including the current hour
|
||||
const uniqueCounts = Object.fromEntries(
|
||||
Array.from({ length: hours }, (_, i) => {
|
||||
const hourTime = new Date(now.getTime() - (hours - 1 - i) * 60 * 60 * 1000);
|
||||
const hourString = hourTime.toISOString().slice(0, 13) + ":00:00.000Z"; // zero out the minutes and seconds
|
||||
return [hourString, 0];
|
||||
})
|
||||
);
|
||||
|
||||
// Populate actual message counts
|
||||
messages.forEach(({ created_at }) => {
|
||||
const hourString = created_at.toISOString().slice(0, 13) + ":00:00.000Z"; // zero out the minutes and seconds
|
||||
uniqueCounts[hourString] = (uniqueCounts[hourString] ?? 0) + 1;
|
||||
});
|
||||
|
||||
// Convert to final result format
|
||||
const result = Object.entries(uniqueCounts).map(([hour, count]) => ({ hour, count }));
|
||||
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
console.error('Error fetching messages:', error);
|
||||
res.status(500).json({ error: 'Internal Server Error' });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/most-active-nodes', async (req, res) => {
|
||||
try {
|
||||
const channelId = req.query.channel_id;
|
||||
const result = await prisma.$queryRaw(
|
||||
Prisma.sql`
|
||||
SELECT n.long_name, COUNT(*) AS count
|
||||
FROM (
|
||||
SELECT DISTINCT \`from\`, packet_id
|
||||
FROM service_envelopes
|
||||
WHERE
|
||||
created_at >= NOW() - INTERVAL 1 DAY
|
||||
AND packet_id IS NOT NULL
|
||||
AND portnum != 73
|
||||
AND \`to\` != 1
|
||||
${channelId ? Prisma.sql`AND channel_id = ${channelId}` : Prisma.sql``}
|
||||
) AS unique_packets
|
||||
JOIN nodes n ON unique_packets.from = n.node_id
|
||||
GROUP BY n.long_name
|
||||
ORDER BY count DESC
|
||||
LIMIT 25;
|
||||
`
|
||||
);
|
||||
|
||||
res.set('Cache-Control', 'public, max-age=600'); // 10 min cache
|
||||
res.json(result);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching data:', error);
|
||||
res.status(500).json({ error: 'Internal Server Error' });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/portnum-counts', async (req, res) => {
|
||||
const nodeId = req.query.nodeId ? parseInt(req.query.nodeId, 10) : null;
|
||||
const channelId = req.query.channel_id;
|
||||
const hours = 24;
|
||||
const now = new Date();
|
||||
const startTime = new Date(now.getTime() - hours * 60 * 60 * 1000);
|
||||
|
||||
try {
|
||||
const envelopes = await prisma.serviceEnvelope.findMany({
|
||||
where: {
|
||||
created_at: { gte: startTime },
|
||||
...(Number.isInteger(nodeId) ? { from: nodeId } : {}),
|
||||
...(channelId ? { channel_id: channelId } : {}),
|
||||
packet_id: { not: null },
|
||||
to: { not: 1 }, // Filter out NODENUM_BROADCAST_NO_LORA
|
||||
OR: [
|
||||
{ portnum: { not: 73 } }, // Exclude portnum 73 (e.g. map reports)
|
||||
{ portnum: null } // But include PKI packages, they have no portnum
|
||||
]
|
||||
},
|
||||
select: {from: true, packet_id: true, portnum: true, channel_id: true}
|
||||
});
|
||||
|
||||
// Ensure uniqueness based on (from, packet_id)
|
||||
const seen = new Set();
|
||||
const counts = {};
|
||||
|
||||
for (const envelope of envelopes) {
|
||||
const uniqueKey = `${envelope.from}-${envelope.packet_id}`;
|
||||
if (seen.has(uniqueKey)) continue;
|
||||
seen.add(uniqueKey);
|
||||
|
||||
// Override portnum to 512 if channel_id is "PKI"
|
||||
const portnum = envelope.channel_id === "PKI" ? 512 : (envelope.portnum ?? 0);
|
||||
counts[portnum] = (counts[portnum] || 0) + 1;
|
||||
}
|
||||
|
||||
const result = Object.entries(counts).map(([portnum, count]) => ({
|
||||
portnum: parseInt(portnum, 10),
|
||||
count: count,
|
||||
label: parseInt(portnum, 10) === 512 ? "PKI" : (PortNum.valuesById[portnum] ?? "UNKNOWN"),
|
||||
})).sort((a, b) => a.portnum - b.portnum);
|
||||
|
||||
res.json(result);
|
||||
|
||||
} catch (err) {
|
||||
console.error("Error in /portnum-counts:", err);
|
||||
res.status(500).json({ message: "Internal server error" });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/battery-stats', async (req, res) => {
|
||||
const days = parseInt(req.query.days || '1', 10);
|
||||
|
||||
try {
|
||||
const stats = await prisma.$queryRaw`
|
||||
SELECT id, recorded_at, avg_battery_level
|
||||
FROM battery_stats
|
||||
WHERE recorded_at >= NOW() - INTERVAL ${days} DAY
|
||||
ORDER BY recorded_at DESC;
|
||||
`;
|
||||
|
||||
res.json(stats);
|
||||
} catch (err) {
|
||||
console.error('Error fetching battery stats:', err);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/channel-utilization-stats', async (req, res) => {
|
||||
const days = parseInt(req.query.days || '1', 10);
|
||||
const channelId = req.query.channel_id; // optional string
|
||||
|
||||
try {
|
||||
const stats = await prisma.$queryRaw(
|
||||
Prisma.sql`
|
||||
SELECT recorded_at, channel_id, avg_channel_utilization
|
||||
FROM channel_utilization_stats
|
||||
WHERE recorded_at >= NOW() - INTERVAL ${days} DAY
|
||||
${channelId ? Prisma.sql`AND channel_id = ${channelId}` : Prisma.sql``}
|
||||
ORDER BY recorded_at DESC;
|
||||
`
|
||||
);
|
||||
|
||||
res.json(stats);
|
||||
} catch (err) {
|
||||
console.error('Error fetching channel utilization stats:', err);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/channel-utilization', async (req, res) => {
|
||||
const channelId = req.query.channel_id;
|
||||
|
||||
try {
|
||||
const snapshot = await prisma.$queryRaw(
|
||||
Prisma.sql`
|
||||
SELECT recorded_at, channel_id, avg_channel_utilization
|
||||
FROM channel_utilization_stats
|
||||
WHERE recorded_at = (
|
||||
SELECT MAX(recorded_at) FROM channel_utilization_stats
|
||||
)
|
||||
${channelId ? Prisma.sql`AND channel_id = ${channelId}` : Prisma.sql``}
|
||||
ORDER BY channel_id;
|
||||
`
|
||||
);
|
||||
|
||||
res.json(snapshot);
|
||||
} catch (err) {
|
||||
console.error('Error fetching latest channel utilization:', err);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
33
src/utils/logger.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Override console methods to add formatted timestamps
|
||||
const originalLog = console.log;
|
||||
const originalError = console.error;
|
||||
const originalWarn = console.warn;
|
||||
const originalInfo = console.info;
|
||||
|
||||
function formatTimestamp() {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
const hours = String(now.getHours()).padStart(2, '0');
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(now.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
|
||||
console.log = function(...args) {
|
||||
originalLog(`${formatTimestamp()} [Info]`, ...args);
|
||||
};
|
||||
|
||||
console.error = function(...args) {
|
||||
originalError(`${formatTimestamp()} [Error]`, ...args);
|
||||
};
|
||||
|
||||
console.warn = function(...args) {
|
||||
originalWarn(`${formatTimestamp()} [Warn]`, ...args);
|
||||
};
|
||||
|
||||
console.info = function(...args) {
|
||||
originalInfo(`${formatTimestamp()} [Info]`, ...args);
|
||||
};
|
||||
|
||||
314
src/ws.js
Normal file
|
|
@ -0,0 +1,314 @@
|
|||
require('./utils/logger');
|
||||
const crypto = require("crypto");
|
||||
const path = require("path");
|
||||
const http = require("http");
|
||||
const mqtt = require("mqtt");
|
||||
const protobufjs = require("protobufjs");
|
||||
const commandLineArgs = require("command-line-args");
|
||||
const commandLineUsage = require("command-line-usage");
|
||||
const { WebSocketServer } = require("ws");
|
||||
|
||||
const optionsList = [
|
||||
{
|
||||
name: 'help',
|
||||
alias: 'h',
|
||||
type: Boolean,
|
||||
description: 'Display this usage guide.'
|
||||
},
|
||||
{
|
||||
name: "mqtt-broker-url",
|
||||
type: String,
|
||||
description: "MQTT Broker URL (e.g: mqtt://mqtt.meshtastic.org)",
|
||||
},
|
||||
{
|
||||
name: "mqtt-username",
|
||||
type: String,
|
||||
description: "MQTT Username (e.g: meshdev)",
|
||||
},
|
||||
{
|
||||
name: "mqtt-password",
|
||||
type: String,
|
||||
description: "MQTT Password (e.g: large4cats)",
|
||||
},
|
||||
{
|
||||
name: "mqtt-client-id",
|
||||
type: String,
|
||||
description: "MQTT Client ID (e.g: map.example.com)",
|
||||
},
|
||||
{
|
||||
name: "mqtt-topic",
|
||||
type: String,
|
||||
multiple: true,
|
||||
typeLabel: '<topic> ...',
|
||||
description: "MQTT Topic to subscribe to (e.g: msh/#)",
|
||||
},
|
||||
{
|
||||
name: "decryption-keys",
|
||||
type: String,
|
||||
multiple: true,
|
||||
typeLabel: '<base64DecryptionKey> ...',
|
||||
description: "Decryption keys encoded in base64 to use when decrypting service envelopes.",
|
||||
},
|
||||
{
|
||||
name: "ws-port",
|
||||
type: Number,
|
||||
description: "WebSocket server port (default: 8081)",
|
||||
},
|
||||
];
|
||||
|
||||
// parse command line args
|
||||
const options = commandLineArgs(optionsList);
|
||||
|
||||
// show help
|
||||
if(options.help){
|
||||
const usage = commandLineUsage([
|
||||
{
|
||||
header: 'Meshtastic WebSocket Publisher',
|
||||
content: 'Publishes real-time Meshtastic packets via WebSocket.',
|
||||
},
|
||||
{
|
||||
header: 'Options',
|
||||
optionList: optionsList,
|
||||
},
|
||||
]);
|
||||
console.log(usage);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// get options and fallback to default values
|
||||
const mqttBrokerUrl = options["mqtt-broker-url"] ?? "mqtt://mqtt.meshtastic.org";
|
||||
const mqttUsername = options["mqtt-username"] ?? "meshdev";
|
||||
const mqttPassword = options["mqtt-password"] ?? "large4cats";
|
||||
const mqttClientId = options["mqtt-client-id"] ?? null;
|
||||
const mqttTopics = options["mqtt-topic"] ?? ["msh/#"];
|
||||
const decryptionKeys = options["decryption-keys"] ?? [
|
||||
"1PG7OiApB1nwvP+rz05pAQ==", // add default "AQ==" decryption key
|
||||
];
|
||||
const wsPort = options["ws-port"] ?? 8081;
|
||||
|
||||
// create mqtt client
|
||||
const client = mqtt.connect(mqttBrokerUrl, {
|
||||
username: mqttUsername,
|
||||
password: mqttPassword,
|
||||
clientId: mqttClientId,
|
||||
});
|
||||
|
||||
// load protobufs
|
||||
const root = new protobufjs.Root();
|
||||
root.resolvePath = (origin, target) => path.join(__dirname, "protobufs", target);
|
||||
root.loadSync('meshtastic/mqtt.proto');
|
||||
const Data = root.lookupType("Data");
|
||||
const ServiceEnvelope = root.lookupType("ServiceEnvelope");
|
||||
const RouteDiscovery = root.lookupType("RouteDiscovery");
|
||||
|
||||
// create HTTP server for WebSocket
|
||||
const server = http.createServer();
|
||||
const wss = new WebSocketServer({ server });
|
||||
|
||||
// track connected clients
|
||||
const clients = new Set();
|
||||
|
||||
wss.on('connection', (ws) => {
|
||||
clients.add(ws);
|
||||
console.log(`WebSocket client connected. Total clients: ${clients.size}`);
|
||||
|
||||
ws.on('close', () => {
|
||||
clients.delete(ws);
|
||||
console.log(`WebSocket client disconnected. Total clients: ${clients.size}`);
|
||||
});
|
||||
|
||||
ws.on('error', (error) => {
|
||||
console.error('WebSocket error:', error);
|
||||
clients.delete(ws);
|
||||
});
|
||||
});
|
||||
|
||||
// broadcast message to all connected clients
|
||||
function broadcast(message) {
|
||||
const messageStr = JSON.stringify(message);
|
||||
clients.forEach((client) => {
|
||||
if (client.readyState === 1) { // WebSocket.OPEN
|
||||
try {
|
||||
client.send(messageStr);
|
||||
} catch (error) {
|
||||
console.error('Error sending message to client:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createNonce(packetId, fromNode) {
|
||||
// Expand packetId to 64 bits
|
||||
const packetId64 = BigInt(packetId);
|
||||
|
||||
// Initialize block counter (32-bit, starts at zero)
|
||||
const blockCounter = 0;
|
||||
|
||||
// Create a buffer for the nonce
|
||||
const buf = Buffer.alloc(16);
|
||||
|
||||
// Write packetId, fromNode, and block counter to the buffer
|
||||
buf.writeBigUInt64LE(packetId64, 0);
|
||||
buf.writeUInt32LE(fromNode, 8);
|
||||
buf.writeUInt32LE(blockCounter, 12);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* References:
|
||||
* https://github.com/crypto-smoke/meshtastic-go/blob/develop/radio/aes.go#L42
|
||||
* https://github.com/pdxlocations/Meshtastic-MQTT-Connect/blob/main/meshtastic-mqtt-connect.py#L381
|
||||
*/
|
||||
function decrypt(packet) {
|
||||
// attempt to decrypt with all available decryption keys
|
||||
for(const decryptionKey of decryptionKeys){
|
||||
try {
|
||||
// convert encryption key to buffer
|
||||
const key = Buffer.from(decryptionKey, "base64");
|
||||
|
||||
// create decryption iv/nonce for this packet
|
||||
const nonceBuffer = createNonce(packet.id, packet.from);
|
||||
|
||||
// determine algorithm based on key length
|
||||
var algorithm = null;
|
||||
if(key.length === 16){
|
||||
algorithm = "aes-128-ctr";
|
||||
} else if(key.length === 32){
|
||||
algorithm = "aes-256-ctr";
|
||||
} else {
|
||||
// skip this key, try the next one...
|
||||
console.error(`Skipping decryption key with invalid length: ${key.length}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// create decipher
|
||||
const decipher = crypto.createDecipheriv(algorithm, key, nonceBuffer);
|
||||
|
||||
// decrypt encrypted packet
|
||||
const decryptedBuffer = Buffer.concat([decipher.update(packet.encrypted), decipher.final()]);
|
||||
|
||||
// parse as data message
|
||||
return Data.decode(decryptedBuffer);
|
||||
|
||||
} catch(e){}
|
||||
}
|
||||
|
||||
// couldn't decrypt
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts hex id to numeric id, for example: !FFFFFFFF to 4294967295
|
||||
* @param hexId a node id in hex format with a prepended "!"
|
||||
* @returns {bigint} the node id in numeric form
|
||||
*/
|
||||
function convertHexIdToNumericId(hexId) {
|
||||
return BigInt('0x' + hexId.replaceAll("!", ""));
|
||||
}
|
||||
|
||||
// subscribe to everything when connected
|
||||
client.on("connect", () => {
|
||||
console.log("Connected to MQTT broker");
|
||||
for(const mqttTopic of mqttTopics){
|
||||
client.subscribe(mqttTopic);
|
||||
console.log(`Subscribed to MQTT topic: ${mqttTopic}`);
|
||||
}
|
||||
});
|
||||
|
||||
// handle message received
|
||||
client.on("message", async (topic, message) => {
|
||||
try {
|
||||
// decode service envelope
|
||||
const envelope = ServiceEnvelope.decode(message);
|
||||
if(!envelope.packet){
|
||||
return;
|
||||
}
|
||||
|
||||
// attempt to decrypt encrypted packets
|
||||
const isEncrypted = envelope.packet.encrypted?.length > 0;
|
||||
if(isEncrypted){
|
||||
const decoded = decrypt(envelope.packet);
|
||||
if(decoded){
|
||||
envelope.packet.decoded = decoded;
|
||||
}
|
||||
}
|
||||
|
||||
// get portnum from decoded packet
|
||||
const portnum = envelope.packet?.decoded?.portnum;
|
||||
|
||||
// check if we can see the decrypted packet data
|
||||
if(envelope.packet.decoded == null){
|
||||
return;
|
||||
}
|
||||
|
||||
// handle traceroutes (portnum 70)
|
||||
if(portnum === 70) {
|
||||
try {
|
||||
const routeDiscovery = RouteDiscovery.decode(envelope.packet.decoded.payload);
|
||||
|
||||
const traceroute = {
|
||||
type: "traceroute",
|
||||
data: {
|
||||
to: envelope.packet.to,
|
||||
from: envelope.packet.from,
|
||||
want_response: envelope.packet.decoded.wantResponse,
|
||||
route: routeDiscovery.route,
|
||||
snr_towards: routeDiscovery.snrTowards,
|
||||
route_back: routeDiscovery.routeBack,
|
||||
snr_back: routeDiscovery.snrBack,
|
||||
channel_id: envelope.channelId,
|
||||
gateway_id: envelope.gatewayId ? Number(convertHexIdToNumericId(envelope.gatewayId)) : null,
|
||||
packet_id: envelope.packet.id,
|
||||
}
|
||||
};
|
||||
broadcast(traceroute);
|
||||
} catch (e) {
|
||||
console.error("Error processing traceroute:", e);
|
||||
}
|
||||
}
|
||||
|
||||
} catch(e) {
|
||||
console.error("Error processing MQTT message:", e);
|
||||
}
|
||||
});
|
||||
|
||||
// start WebSocket server
|
||||
server.listen(wsPort, () => {
|
||||
console.log(`WebSocket server running on port ${wsPort}`);
|
||||
});
|
||||
|
||||
// Graceful shutdown handlers
|
||||
function gracefulShutdown(signal) {
|
||||
console.log(`Received ${signal}. Starting graceful shutdown...`);
|
||||
|
||||
// Close all WebSocket connections
|
||||
clients.forEach((client) => {
|
||||
client.close();
|
||||
});
|
||||
clients.clear();
|
||||
|
||||
// Close WebSocket server
|
||||
wss.close(() => {
|
||||
console.log('WebSocket server closed');
|
||||
});
|
||||
|
||||
// Close HTTP server
|
||||
server.close(() => {
|
||||
console.log('HTTP server closed');
|
||||
});
|
||||
|
||||
// Close MQTT client
|
||||
client.end(false, () => {
|
||||
console.log('MQTT client disconnected');
|
||||
console.log('Graceful shutdown completed');
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
// Handle SIGTERM (Docker, systemd, etc.)
|
||||
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
|
||||
|
||||
// Handle SIGINT (Ctrl+C)
|
||||
process.on('SIGINT', () => gracefulShutdown('SIGINT'));
|
||||
|
||||