diff --git a/app/diario-bordo.html b/app/diario-bordo.html index 384b412..d7d7385 100644 --- a/app/diario-bordo.html +++ b/app/diario-bordo.html @@ -6091,6 +6091,12 @@ async function bmsProbeWebBluetooth(deviceId,deviceName){ const dv=ev.target.value; const hex=Array.from(new Uint8Array(dv.buffer)).map(b=>b.toString(16).padStart(2,'0')).join(' '); setBleDiag(`← RX ${dv.byteLength}b: ${hex.slice(0,100)}${hex.length>100?'...':''}`,'ok'); + // Se há buffer pendente JBD, é chunk de continuação — roteia sempre + if(_bmsBuffers.has(deviceId)){ + bmsHandleChunk(deviceId,dv,deviceName); + return; + } + // Buffer vazio: primeiro byte determina protocolo (início de novo pacote) const first=new Uint8Array(dv.buffer)[0]; if(first===0xDD)bmsHandleChunk(deviceId,dv,deviceName); else if(first===0xAA)bmsHandleJK(deviceId,dv,deviceName); @@ -6192,7 +6198,12 @@ async function bmsProbeAndAttach(deviceId,deviceName){ const dv=parseDataView(ev.value); const hex=Array.from(new Uint8Array(dv.buffer)).map(b=>b.toString(16).padStart(2,'0')).join(' '); setBleDiag('← RX '+dv.byteLength+'b: '+hex.slice(0,100)+(hex.length>100?'...':''),'ok'); - // Detecta protocolo por byte de início + // Se buffer JBD pendente, é continuação — roteia sempre + if(_bmsBuffers.has(deviceId)){ + bmsHandleChunk(deviceId,dv,deviceName); + return; + } + // Detecta protocolo por byte de início (novo pacote) const first=new Uint8Array(dv.buffer)[0]; if(first===0xDD)bmsHandleChunk(deviceId,dv,deviceName); // JBD else if(first===0xAA)bmsHandleJK(deviceId,dv,deviceName); // JK BMS @@ -6446,7 +6457,7 @@ async function removeBluetoothDevice(id){ renderBluetoothCard(); } -const APP_VERSION='1.10.14'; +const APP_VERSION='1.10.15'; function renderBluetoothCard(){ const el=document.getElementById('bt-list'); const supportEl=document.getElementById('bt-support'); diff --git a/server/public/index.html b/server/public/index.html index 384b412..d7d7385 100644 --- a/server/public/index.html +++ b/server/public/index.html @@ -6091,6 +6091,12 @@ async function bmsProbeWebBluetooth(deviceId,deviceName){ const dv=ev.target.value; const hex=Array.from(new Uint8Array(dv.buffer)).map(b=>b.toString(16).padStart(2,'0')).join(' '); setBleDiag(`← RX ${dv.byteLength}b: ${hex.slice(0,100)}${hex.length>100?'...':''}`,'ok'); + // Se há buffer pendente JBD, é chunk de continuação — roteia sempre + if(_bmsBuffers.has(deviceId)){ + bmsHandleChunk(deviceId,dv,deviceName); + return; + } + // Buffer vazio: primeiro byte determina protocolo (início de novo pacote) const first=new Uint8Array(dv.buffer)[0]; if(first===0xDD)bmsHandleChunk(deviceId,dv,deviceName); else if(first===0xAA)bmsHandleJK(deviceId,dv,deviceName); @@ -6192,7 +6198,12 @@ async function bmsProbeAndAttach(deviceId,deviceName){ const dv=parseDataView(ev.value); const hex=Array.from(new Uint8Array(dv.buffer)).map(b=>b.toString(16).padStart(2,'0')).join(' '); setBleDiag('← RX '+dv.byteLength+'b: '+hex.slice(0,100)+(hex.length>100?'...':''),'ok'); - // Detecta protocolo por byte de início + // Se buffer JBD pendente, é continuação — roteia sempre + if(_bmsBuffers.has(deviceId)){ + bmsHandleChunk(deviceId,dv,deviceName); + return; + } + // Detecta protocolo por byte de início (novo pacote) const first=new Uint8Array(dv.buffer)[0]; if(first===0xDD)bmsHandleChunk(deviceId,dv,deviceName); // JBD else if(first===0xAA)bmsHandleJK(deviceId,dv,deviceName); // JK BMS @@ -6446,7 +6457,7 @@ async function removeBluetoothDevice(id){ renderBluetoothCard(); } -const APP_VERSION='1.10.14'; +const APP_VERSION='1.10.15'; function renderBluetoothCard(){ const el=document.getElementById('bt-list'); const supportEl=document.getElementById('bt-support'); diff --git a/server/public/sw.js b/server/public/sw.js index cbab32c..1ad12bf 100644 --- a/server/public/sw.js +++ b/server/public/sw.js @@ -1,7 +1,7 @@ // Shivao Service Worker — offline real // Estratégia: shell precachado, tiles cache-first, windy network-first, /api passa direto. // Versão usada nos cache names — bumpa essa string pra invalidar caches antigos em deploys. -const VERSION = 'shivao-v1.10.14'; +const VERSION = 'shivao-v1.10.15'; const SHELL_CACHE = `shivao-shell-${VERSION}`; const TILES_CACHE = 'shivao-tiles-v1'; // separado pra não invalidar tiles em update do shell const WINDY_CACHE = `shivao-windy-${VERSION}`;