add version characteristic

This commit is contained in:
Shuanglei Tao
2025-05-10 21:29:06 +08:00
parent 4d040502f9
commit 883d2f918a
3 changed files with 41 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
let bleDevice, gattServer;
let epdService, epdCharacteristic;
let startTime, msgIndex;
let startTime, msgIndex, appVersion;
let canvas, ctx, textDecoder;
const EpdCmd = {
@@ -231,6 +231,16 @@ async function connect() {
return;
}
try {
const versionCharacteristic = await epdService.getCharacteristic('62750003-d828-918d-fb46-b6c11c675aec');
const versionData = await versionCharacteristic.readValue();
appVersion = versionData.getUint8(0);
addLog(`固件版本: 0x${appVersion.toString(16)}`);
} catch (e) {
console.error(e);
appVersion = 0x15;
}
try {
await epdCharacteristic.startNotifications();
epdCharacteristic.addEventListener('characteristicvaluechanged', (event) => {