This commit is contained in:
liamcottle 2025-02-12 00:54:46 +13:00
parent 5735dc8b66
commit 46b18d00ae

View file

@ -60,10 +60,10 @@
AppStart
</button>
<button @click="sendSendSelfAdvert(0)" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
SendSelfAdvert(ZeroHop)
Advert (ZeroHop)
</button>
<button @click="sendSendSelfAdvert(1)" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
SendSelfAdvert(Flood)
Advert (Flood)
</button>
<button @click="sendCommandSetAdvertName" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
SetAdvertName
@ -71,18 +71,12 @@
<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>
<button @click="sendCommandSyncNextMessage" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
SyncNextMessage
</button>
<button @click="sendCommandGetContacts" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
GetContacts
</button>
<button @click="sendCommandGetDeviceTime" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
GetDeviceTime
</button>
@ -95,17 +89,17 @@
<button @click="sendCommandSetTxPower" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
SetTxPower
</button>
<button @click="sendCommandResetPath" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
ResetPath
</button>
<button @click="sendCommandSendTxtMsg" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
SendTxtMsg
</button>
</div>
</div>
<!-- contacts -->
<div class="border bg-gray-50 rounded shadow">
<div class="flex border-b p-2">
<div class="font-semibold my-auto mr-auto">Contacts</div>
<div class="my-auto">
<div @click="loadContacts" class="hover:underline cursor-pointer">Reload</div>
</div>
</div>
<div class="divide-y">
<div v-for="contact of contacts" class="flex px-2 py-1">
<div class="my-auto mr-auto">
@ -113,10 +107,9 @@
<div class="text-sm text-gray-500"><{{ bytesToHex(contact.publicKey) }}></div>
<div class="text-sm text-gray-500">Type: {{ contactTypeToString(contact.type) }} • Last Advert: {{ contact.lastAdvert }}</div>
</div>
<div class="my-auto mx-2">
<div @click="sendMessage(contact)" class="hover:underline cursor-pointer">Send Message</div>
</div>
<div class="my-auto mx-2">
<div class="flex my-auto ml-2 space-x-2">
<div @click="sendMessage(contact)" class="hover:underline cursor-pointer">Message</div>
<div @click="resetPath(contact)" class="hover:underline cursor-pointer">Reset Path</div>
<div @click="removeContact(contact)" class="hover:underline cursor-pointer">Forget</div>
</div>
</div>
@ -202,14 +195,6 @@
const selfInfo = await this.connection.getSelfInfo();
console.log(selfInfo);
},
async sendCommandSendTxtMsg() {
const txtType = Constants.TxtTypes.Plain;
const attempt = 0;
const senderTimestamp = Math.floor(Date.now() / 1000);
const pubKeyPrefix = 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 text = `Test Message: ${senderTimestamp}`;
await this.connection.sendCommandSendTxtMsg(txtType, attempt, senderTimestamp, pubKeyPrefix, text);
},
async sendSendSelfAdvert(type) {
await this.connection.sendCommandSendSelfAdvert(type);
},
@ -228,10 +213,6 @@
const txPower = 22;
await this.connection.sendCommandSetTxPower(txPower);
},
async sendCommandResetPath() {
const publicKey = new Uint8Array([244, 231, 60, 250, 245, 218, 131, 156, 156, 98, 130, 39, 222, 43, 123, 147, 98, 200, 218, 251, 242, 89, 111, 108, 25, 191, 127, 151, 222, 192, 233, 177]);
await this.connection.sendCommandResetPath(publicKey);
},
async sendCommandSetRadioParams() {
const radioFreq = 917375;
const radioBw = 250000;
@ -257,10 +238,6 @@
console.log(lat, lon);
await this.connection.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.connection.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;
@ -294,6 +271,15 @@
// send message
await this.connection.sendCommandSendTxtMsg(txtType, attempt, senderTimestamp, pubKeyPrefix, text);
},
async resetPath(contact) {
// remove contact from device
await this.connection.sendCommandResetPath(contact.publicKey);
// reload contacts
await this.loadContacts();
},
async removeContact(contact) {