From 54df5ed9c3ac50fbbb87652744b042b2d302088f Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 11 Feb 2025 17:45:53 +1300 Subject: [PATCH] add ability to set advert lat lon --- index.html | 8 ++++++++ src/constants.js | 1 + src/device.js | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/index.html b/index.html index 402cbe0..ae9bda3 100644 --- a/index.html +++ b/index.html @@ -41,6 +41,9 @@ + @@ -152,6 +155,11 @@ await this.device.sendCommandSetAdvertName(name); }, + async sendCommandSetAdvertLatLon() { + const lat = 123; + const lon = 456; + await this.device.sendCommandSetAdvertLatLon(lat, lon); + }, async sendCommandAddUpdateContact() { const publicKey = new Uint8Array([148, 63, 175, 162, 88, 212, 192, 40, 214, 185, 213, 140, 42, 145, 194, 186, 70, 71, 112, 68, 0, 192, 65, 4, 105, 143, 230, 50, 162, 79, 247, 192]); const type = Constants.AdvType.Chat; diff --git a/src/constants.js b/src/constants.js index 73eacc8..cd4662a 100644 --- a/src/constants.js +++ b/src/constants.js @@ -18,6 +18,7 @@ class Constants { SyncNextMessage: 10, // done SetRadioParams: 11, // done SetTxPower: 12, // done + SetAdvertLatLon: 14, } static ResponseCodes = { diff --git a/src/device.js b/src/device.js index a9c8329..44bfa3f 100644 --- a/src/device.js +++ b/src/device.js @@ -166,6 +166,14 @@ class Device { await this.sendToRadioFrame(data.toBytes()); } + async sendCommandSetAdvertLatLon(lat, lon) { + const data = new BufferWriter(); + data.writeByte(Constants.CommandCodes.SetAdvertLatLon); + data.writeUInt32LE(lat); + data.writeUInt32LE(lon); + await this.sendToRadioFrame(data.toBytes()); + } + async readLoop() { try { while(true){