WIP updates
This commit is contained in:
@@ -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
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user