WIP updates

This commit is contained in:
Sacha Weatherstone
2022-11-27 22:50:46 +10:00
parent a9561fe622
commit e457cef3da
79 changed files with 2100 additions and 1284 deletions
+10 -6
View File
@@ -1,14 +1,13 @@
import { toast } from "react-hot-toast";
import type { Device } from "@core/stores/deviceStore.js";
import { Protobuf, Types } from "@meshtastic/meshtasticjs";
import { Types } from "@meshtastic/meshtasticjs";
export const subscribeAll = (
device: Device,
connection: Types.ConnectionType
) => {
let myNodeNum = 0;
connection.setLogLevel(Protobuf.LogRecord_Level.TRACE);
// onLogEvent
// onMeshHeartbeat
@@ -43,26 +42,31 @@ export const subscribeAll = (
device.addWaypointMessage({
waypointID: data.id,
ack: rest.packet.from !== myNodeNum,
...rest,
...rest
});
});
connection.onMyNodeInfo.subscribe((nodeInfo) => {
console.log("^^^^^^^ GOT MY NODE INFO");
device.setHardware(nodeInfo);
myNodeNum = nodeInfo.myNodeNum;
});
connection.onUserPacket.subscribe((user) => {
console.log("^^^^^^^ GOT USER");
device.addUser(user);
});
connection.onPositionPacket.subscribe((position) => {
console.log("^^^^^^^ GOT POSITION");
device.addPosition(position);
});
connection.onNodeInfoPacket.subscribe((nodeInfo) => {
console.log("^^^^^^^ GOT NODE INFO");
toast(`New Node Discovered: ${nodeInfo.data.user?.shortName ?? "UNK"}`, {
icon: "🔎",
icon: "🔎"
});
device.addNodeInfo(nodeInfo);
});
@@ -71,7 +75,7 @@ export const subscribeAll = (
device.addChannel({
config: channel.data,
lastInterraction: new Date(),
messages: [],
messages: []
});
});
connection.onConfigPacket.subscribe((config) => {
@@ -84,7 +88,7 @@ export const subscribeAll = (
connection.onMessagePacket.subscribe((messagePacket) => {
device.addMessage({
...messagePacket,
ack: messagePacket.packet.from !== myNodeNum,
ack: messagePacket.packet.from !== myNodeNum
});
});
};