mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
implement login and status request for fetching metrics from repeaters
This commit is contained in:
parent
4010cfc3b2
commit
84df5aa57f
5 changed files with 240 additions and 0 deletions
27
index.html
27
index.html
|
|
@ -136,6 +136,7 @@
|
|||
<div class="flex my-auto space-x-2">
|
||||
<div @click="sendMessage(contact)" class="hover:underline cursor-pointer">Message</div>
|
||||
<div @click="setPath(contact)" class="hover:underline cursor-pointer">Set Path</div>
|
||||
<div @click="statusRequest(contact)" class="hover:underline cursor-pointer">GetStats</div>
|
||||
<div @click="shareContact(contact)" class="hover:underline cursor-pointer">Share (Zero Hop)</div>
|
||||
<div @click="exportContact(contact)" class="hover:underline cursor-pointer">Export</div>
|
||||
<div @click="resetPath(contact)" class="hover:underline cursor-pointer">Reset Path</div>
|
||||
|
|
@ -435,6 +436,32 @@
|
|||
alert("Failed to get battery voltage!");
|
||||
}
|
||||
},
|
||||
async statusRequest(contact) {
|
||||
|
||||
// ask user for password
|
||||
const password = prompt("Please enter Admin, or Guest password");
|
||||
if(!password){
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// log in to repeater
|
||||
const response = await this.connection.login(contact.publicKey, password);
|
||||
console.log("login response", response);
|
||||
|
||||
// request status
|
||||
const statusResponse = await this.connection.getStatus(contact.publicKey);
|
||||
console.log("status response", statusResponse);
|
||||
|
||||
// show status response
|
||||
alert(`status request success:\n${JSON.stringify(statusResponse, null, 4)}`);
|
||||
|
||||
} catch(e) {
|
||||
alert(`Failed to login: ${e}`);
|
||||
}
|
||||
|
||||
},
|
||||
bytesToHex(uint8Array) {
|
||||
return Array.from(uint8Array).map(byte => byte.toString(16).padStart(2, '0')).join('');
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue