add ability to remove contacts

This commit is contained in:
liamcottle 2025-02-11 17:51:18 +13:00
parent 54df5ed9c3
commit 25cb211060
3 changed files with 16 additions and 1 deletions

View file

@ -44,6 +44,9 @@
<button @click="sendCommandSetAdvertLatLon" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
SetAdvertLatLon
</button>
<button @click="sendCommandRemoveContact" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
RemoveContact
</button>
<button @click="sendCommandAddUpdateContact" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
AddUpdateContact
</button>
@ -160,6 +163,10 @@
const lon = 456;
await this.device.sendCommandSetAdvertLatLon(lat, lon);
},
async sendCommandRemoveContact() {
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]);
await this.device.sendCommandRemoveContact(publicKey);
},
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;

View file

@ -18,7 +18,8 @@ class Constants {
SyncNextMessage: 10, // done
SetRadioParams: 11, // done
SetTxPower: 12, // done
SetAdvertLatLon: 14,
SetAdvertLatLon: 14, // done
RemoveContact: 15, // done
}
static ResponseCodes = {

View file

@ -174,6 +174,13 @@ class Device {
await this.sendToRadioFrame(data.toBytes());
}
async sendCommandRemoveContact(pubKey) {
const data = new BufferWriter();
data.writeByte(Constants.CommandCodes.RemoveContact);
data.writeBytes(pubKey); // 32 bytes
await this.sendToRadioFrame(data.toBytes());
}
async readLoop() {
try {
while(true){