diff --git a/index.html b/index.html index 86c345b..85d65ad 100644 --- a/index.html +++ b/index.html @@ -107,13 +107,14 @@
<{{ bytesToHex(contact.publicKey) }}>
Type: {{ contactTypeToString(contact.type) }} • Last Advert: {{ contact.lastAdvert }}
- Path: ??? + Path: ??? (Flood) Path: Direct - Path: {{ contact.outPathLen }} hops + Path: {{ contact.outPathLen }} hops [{{ formatOutPath(contact) }}]
Message
+
Set Path
Reset Path
Forget
@@ -196,6 +197,20 @@ case 3: return "Room"; } }, + formatOutPath(contact) { + + // get out path + const outPath = contact.outPath.slice(0, contact.outPathLen); + + // convert each path to hex + const pathHashes = Array.from(outPath).map((path) => { + return path.toString(16); + }); + + // return with separator + return pathHashes.join(" -> "); + + }, async sendCommandAppStart() { const selfInfo = await this.connection.getSelfInfo(); console.log(selfInfo); @@ -299,6 +314,26 @@ // reload contacts await this.loadContacts(); + }, + async setPath(contact) { + + const newOutPath = [ + 0xf4, + ]; + + // create out path + const outPath = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + for(var i = 0; i < newOutPath.length; i++){ + outPath[i] = newOutPath[i]; + } + + // update contact details + contact.outPathLen = newOutPath.length; + contact.outPath = outPath; + + // update contact + await this.connection.sendCommandAddUpdateContact(contact.publicKey, contact.type, contact.flags, contact.outPathLen, contact.outPath, contact.advName, contact.lastAdvert, contact.advLat, contact.advLon); + }, bytesToHex(uint8Array) { return Array.from(uint8Array).map(byte => byte.toString(16).padStart(2, '0')).join('');