enable and disable tnc mode

This commit is contained in:
liamcottle
2024-07-16 13:05:30 +12:00
parent 1340d255e1
commit 84b4f27b21

View File

@@ -76,9 +76,14 @@
<div> <div>
<div>6. Configure TNC mode: frequency, bandwidth, tx power, spreading factor, coding rate</div> <div>6. Configure TNC mode: frequency, bandwidth, tx power, spreading factor, coding rate</div>
<button @click="configure" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded"> <div class="space-x-1">
Configure <button @click="enableTncMode" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
Enable
</button> </button>
<button @click="disableTncMode" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
Disable
</button>
</div>
</div> </div>
<div> <div>
@@ -404,7 +409,7 @@
alert("firmware hash has been set!"); alert("firmware hash has been set!");
}, },
async configure() { async enableTncMode() {
// ask for serial port // ask for serial port
const serialPort = await this.askForSerialPort(); const serialPort = await this.askForSerialPort();
@@ -448,7 +453,48 @@
// done // done
await rnode.reset(); await rnode.reset();
await rnode.close(); 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!");
}, },
}, },