diff --git a/package.json b/package.json index 243388f..61a0283 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/meshDevice.ts b/src/meshDevice.ts index 735109b..4977831 100755 --- a/src/meshDevice.ts +++ b/src/meshDevice.ts @@ -276,6 +276,29 @@ export abstract class MeshDevice { ); } + // Write cannedMessages to device + public async setCannedMessages( + cannedMessages: Protobuf.CannedMessages.CannedMessageModuleConfig, + ): Promise { + 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 */ diff --git a/src/types.ts b/src/types.ts index 39ce790..b6a6d0c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -123,6 +123,7 @@ export enum Emitter { FactoryReset = 30, EnterDfuMode = 31, RemoveNodeByNum = 32, + SetCannedMessages = 33, } export interface LogEvent {