Skip to content

Commit

Permalink
Add enterDfuMode back
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern committed Oct 29, 2024
1 parent d55452d commit f764f15
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
"editor.formatOnSave": false
}
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@meshtastic/js",
"version": "2.5.9-1",
"version": "2.5.9-2",
"exports": "./src/mod.ts"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshtastic/js",
"version": "2.5.9-0",
"version": "2.5.9-2",
"description": "Browser library for interfacing with meshtastic devices",
"license": "GPL-3.0-only",
"scripts": {
Expand Down
43 changes: 37 additions & 6 deletions src/meshDevice.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import { Logger } from "tslog";
import { broadcastNum, minFwVer } from "./constants.ts";
import * as Protobuf from "@meshtastic/protobufs";
import * as Types from "./types.ts";
import { EventSystem, Queue, Xmodem } from "./utils/index.ts";
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
import { Logger } from 'tslog';

import {
create,
fromBinary,
toBinary,
} from '@bufbuild/protobuf';
import * as Protobuf from '@meshtastic/protobufs';

import {
broadcastNum,
minFwVer,
} from './constants.ts';
import * as Types from './types.ts';
import {
EventSystem,
Queue,
Xmodem,
} from './utils/index.ts';

/** Base class for connection methods to extend */
export abstract class MeshDevice {
Expand Down Expand Up @@ -345,6 +358,24 @@ export abstract class MeshDevice {
"self",
);
}
public async enterDfuMode(): Promise<number> {
this.log.debug(
Types.Emitter[Types.Emitter.EnterDfuMode],
'🔌 Entering DFU mode',
);

const enterDfuModeRequest = create(Protobuf.Admin.AdminMessageSchema, {
payloadVariant: {
case: "enterDfuModeRequest",
value: true,
},
});
return await this.sendPacket(
toBinary(Protobuf.Admin.AdminMessageSchema, enterDfuModeRequest),
Protobuf.Portnums.PortNum.ADMIN_APP,
"self"
);
}

public async setPosition(
positionMessage: Protobuf.Mesh.Position,
Expand Down

0 comments on commit f764f15

Please sign in to comment.