From 05e7a9c6594c3afd22b45038a5be5fb6f61fc636 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Fri, 14 Feb 2025 12:39:17 +1300 Subject: [PATCH] fix saving settings on rak via ble, we can't send too many packets to radio at once --- package-lock.json | 14 ++++++++++---- package.json | 2 +- src/components/pages/RadioSettingsPage.vue | 14 ++++++++++++-- src/js/Connection.js | 11 +++++++---- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index aeb1a09..d31d89e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "license": "MIT", "dependencies": { - "@liamcottle/meshcore.js": "^1.0.3", + "@liamcottle/meshcore.js": "^1.0.4", "@tailwindcss/forms": "^0.5.10", "@vitejs/plugin-vue": "^5.2.1", "autoprefixer": "^10.4.20", @@ -25,6 +25,12 @@ "vue-router": "^4.5.0" } }, + "../meshcore.js": { + "name": "@liamcottle/meshcore.js", + "version": "1.0.4", + "extraneous": true, + "license": "MIT" + }, "node_modules/@alloc/quick-lru": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", @@ -1116,9 +1122,9 @@ } }, "node_modules/@liamcottle/meshcore.js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@liamcottle/meshcore.js/-/meshcore.js-1.0.3.tgz", - "integrity": "sha512-i3AZt2xjSi7kTu86ou+t93K2IPyr7r56ZUZa2A3FRGWzumQ/OxXt30sCox5W6UUcMSLKGzEkMviiTRj7JaDWKw==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@liamcottle/meshcore.js/-/meshcore.js-1.0.4.tgz", + "integrity": "sha512-AWVeQASX/3vJANX6acUJwyHELZByHiSLI6J8hD1IfqS9UOACbFRGCWJYxq1x4/SJbJwjFgkxJyc6Nze3miV1SA==" }, "node_modules/@mongodb-js/saslprep": { "version": "1.2.0", diff --git a/package.json b/package.json index 3eaef14..4f3e98b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "author": "Liam Cottle ", "license": "MIT", "dependencies": { - "@liamcottle/meshcore.js": "^1.0.3", + "@liamcottle/meshcore.js": "^1.0.4", "@tailwindcss/forms": "^0.5.10", "@vitejs/plugin-vue": "^5.2.1", "autoprefixer": "^10.4.20", diff --git a/src/components/pages/RadioSettingsPage.vue b/src/components/pages/RadioSettingsPage.vue index ba3a5fb..6f9ee69 100644 --- a/src/components/pages/RadioSettingsPage.vue +++ b/src/components/pages/RadioSettingsPage.vue @@ -4,7 +4,7 @@ @@ -66,6 +66,7 @@ export default { components: {Page, SaveButton, AppBar}, data() { return { + isSaving: false, name: null, radioFreq: null, radioBw: null, @@ -88,6 +89,10 @@ export default { this.txPower = GlobalState.selfInfo?.txPower; }, async save() { + + // show loading + this.isSaving = true; + try { // ensure name provided @@ -128,7 +133,8 @@ export default { // save settings await Connection.setAdvertName(this.name); - await Connection.setRadioParams(this.radioFreq, this.radioBw, this.radioSf, this.radioCr, this.txPower); + await Connection.setTxPower(this.txPower); + await Connection.setRadioParams(this.radioFreq, this.radioBw, this.radioSf, this.radioCr); // reload self info await Connection.loadSelfInfo(); @@ -145,6 +151,10 @@ export default { console.log(e); alert("Failed to save settings!"); } + + // show loading + this.isSaving = false; + }, }, computed: { diff --git a/src/js/Connection.js b/src/js/Connection.js index 2273bbe..94bc1b1 100644 --- a/src/js/Connection.js +++ b/src/js/Connection.js @@ -150,12 +150,15 @@ class Connection { } static async setAdvertName(name) { - await GlobalState.connection.sendCommandSetAdvertName(name); + await GlobalState.connection.setAdvertName(name); } - static async setRadioParams(radioFreq, radioBw, radioSf, radioCr, txPower) { - await GlobalState.connection.sendCommandSetTxPower(txPower); - await GlobalState.connection.sendCommandSetRadioParams(radioFreq, radioBw, radioSf, radioCr); + static async setTxPower(txPower) { + await GlobalState.connection.setTxPower(txPower); + } + + static async setRadioParams(radioFreq, radioBw, radioSf, radioCr) { + await GlobalState.connection.setRadioParams(radioFreq, radioBw, radioSf, radioCr); } static async syncDeviceTime() {