From 84b4f27b21a71c807569d07b7dbc09c75d96da5e Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 16 Jul 2024 13:05:30 +1200 Subject: [PATCH] enable and disable tnc mode --- index.html | 56 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 9b410e8..d65e543 100644 --- a/index.html +++ b/index.html @@ -76,9 +76,14 @@
6. Configure TNC mode: frequency, bandwidth, tx power, spreading factor, coding rate
- +
+ + +
@@ -404,7 +409,7 @@ alert("firmware hash has been set!"); }, - async configure() { + async enableTncMode() { // ask for serial port const serialPort = await this.askForSerialPort(); @@ -448,7 +453,48 @@ // done await rnode.reset(); await rnode.close(); - alert("Device has been configured!"); + alert("TNC mode has been enabled!"); + + }, + async disableTncMode() { + + // ask for serial port + const serialPort = await this.askForSerialPort(); + if(!serialPort){ + return; + } + + // check if device is an rnode + const rnode = await RNode.fromSerialPort(serialPort); + const isRNode = await rnode.detect(); + if(!isRNode){ + alert("Selected device is not an RNode!"); + return; + } + + // check if device has been provisioned + const rom = await rnode.getRomAsObject(); + const details = rom.parse(); + if(!details || !details.is_provisioned){ + alert("Eeprom is not provisioned. You must do this first!"); + await rnode.close(); + return; + } + + // todo check if firmware hashes match, as config will not save if device has invalid target hash + + // configure + console.log("disabling tnc mode"); + await rnode.deleteConfig(); + console.log("disabling tnc mode: done"); + + // wait a bit for eeprom writes to complete + await Utils.sleepMillis(5000); + + // done + await rnode.reset(); + await rnode.close(); + alert("TNC mode has been disabled!"); }, },