Skip to content

Commit

Permalink
Merge pull request #108 from Hunter275/cannedmessages-messages
Browse files Browse the repository at this point in the history
Add setCannedMessages
  • Loading branch information
Hunter275 authored Sep 11, 2024
2 parents 0279fd4 + f0cba9b commit 47b1881
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
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.3.7-2",
"version": "2.3.7-3",
"description": "Browser library for interfacing with meshtastic devices",
"license": "GPL-3.0-only",
"scripts": {
Expand Down
23 changes: 23 additions & 0 deletions src/meshDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,29 @@ export abstract class MeshDevice {
);
}

// Write cannedMessages to device
public async setCannedMessages(
cannedMessages: Protobuf.CannedMessages.CannedMessageModuleConfig,
): Promise<number> {
this.log.debug(
Types.Emitter[Types.Emitter.SetCannedMessages],
"⚙️ Setting CannedMessages",
);

const cannedMessagesMessage = new Protobuf.Admin.AdminMessage({
payloadVariant: {
case: "setCannedMessageModuleMessages",
value: cannedMessages.messages,
},
});

return await this.sendPacket(
cannedMessagesMessage.toBinary(),
Protobuf.Portnums.PortNum.ADMIN_APP,
"self",
);
}

/**
* Sets devices owner data
*/
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export enum Emitter {
FactoryReset = 30,
EnterDfuMode = 31,
RemoveNodeByNum = 32,
SetCannedMessages = 33,
}

export interface LogEvent {
Expand Down

0 comments on commit 47b1881

Please sign in to comment.