feat: added disconnect method to core lib (#712)
This commit is contained in:
@@ -818,6 +818,13 @@ export class MeshDevice {
|
||||
this.queue.clear();
|
||||
}
|
||||
|
||||
/** Disconnects from the device **/
|
||||
public async disconnect(): Promise<void> {
|
||||
this.log.debug(Emitter[Emitter.Disconnect], "🔌 Disconnecting from device");
|
||||
this.complete();
|
||||
await this.transport.toDevice.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called when a MeshPacket is received from device
|
||||
*/
|
||||
|
||||
@@ -99,6 +99,7 @@ export enum Emitter {
|
||||
EnterDfuMode = 31,
|
||||
RemoveNodeByNum = 32,
|
||||
SetCannedMessages = 33,
|
||||
Disconnect = 34,
|
||||
}
|
||||
|
||||
export interface LogEvent {
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
"rebootToOtaMode": "Reboot To OTA Mode",
|
||||
"resetNodeDb": "Reset Node DB",
|
||||
"factoryResetDevice": "Factory Reset Device",
|
||||
"factoryResetConfig": "Factory Reset Config"
|
||||
"factoryResetConfig": "Factory Reset Config",
|
||||
"disconnect": "Disconnect"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
ArrowLeftRightIcon,
|
||||
BoxSelectIcon,
|
||||
BugIcon,
|
||||
CloudOff,
|
||||
EraserIcon,
|
||||
FactoryIcon,
|
||||
LayersIcon,
|
||||
@@ -199,6 +200,15 @@ export const CommandPalette = () => {
|
||||
connection?.resetNodes();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t("contextual.command.disconnect"),
|
||||
icon: CloudOff,
|
||||
action() {
|
||||
connection?.disconnect().catch((error) => {
|
||||
console.error("Failed to disconnect:", error);
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t("contextual.command.factoryResetDevice"),
|
||||
icon: FactoryIcon,
|
||||
|
||||
Reference in New Issue
Block a user