firmware update implemented and checked

This commit is contained in:
Bogdan Pilyugin 2023-08-21 11:30:52 +02:00
parent 8c9c8478d5
commit 9391785df3
2 changed files with 15 additions and 11 deletions

View File

@ -11,10 +11,9 @@
<q-input v-model="data.ota_url" label="OTA firmware file URL" />
<q-input type="number" v-model="data.ota_auto_int" label="New firmware check interval, sec" />
<div>Current firmware version: {{ data.fw_rev }}</div>
<div>Available firmware version: {{ data.fw_rev }}</div>
<div>Firmware status: <div v-html="data.ota_state"></div>
</div>
<q-btn color="primary" label="Check firmware" @click="PostData({ ota_start: 1 }, 2, 0, null)"></q-btn>
<div>Available firmware version: {{ data.ota_newver }}</div>
<div>Firmware status: <span v-html="data.ota_state"></span></div>
<q-btn color="primary" label="Check firmware" @click="CheckFirmware"></q-btn>
</div>
</div>
</q-card-section>
@ -23,7 +22,7 @@
</template>
<script setup>
import { reactive } from "vue";
import { reactive, onUnmounted } from "vue";
import { PostData } from "components/webguicomp/network";
import CardActions from "components/webguicomp/CardActions.vue"
@ -36,6 +35,14 @@ const init = {
ota_auto_int: 0, fw_rev: '', ota_newver: '', ota_state: ''
}
const data = reactive(init);
PostData(data, 2, 0, null);
let intervalId;
function CheckFirmware() {
PostData({ ota_start: 1 }, 2, 0, null);
intervalId = setInterval(() => {
PostData(data, 2, 0, null);
}, 1000)
}
onUnmounted(() => clearInterval(intervalId));
PostData(data, 2, 0, null);
</script>

View File

@ -38,8 +38,7 @@ defineOptions({
})
const init = {
time: 0,
uptime: 0,
time: 0, uptime: 0,
wifi_level: "",
eth_stat: "",
wifi_stat: "",
@ -50,8 +49,6 @@ const init = {
free_ram_min: 0
}
const data = reactive(init);
PostData(data, 2, 0, null);
let intervalId
onMounted(() => {
intervalId = setInterval(() => {
@ -61,5 +58,5 @@ onMounted(() => {
onUnmounted(() => clearInterval(intervalId))
const timestr = computed({ get() { return (new Date(data.time * 1000).toISOString()) } })
const uptimestr = computed({ get() { return (secondsToHms(data.uptime)) } })
PostData(data, 2, 0, null);
</script>