diff --git a/app/diario-bordo.html b/app/diario-bordo.html index 39fe82b..7b9ede4 100644 --- a/app/diario-bordo.html +++ b/app/diario-bordo.html @@ -6226,26 +6226,13 @@ async function bmsProbeAndAttach(deviceId,deviceName){ else if(first===0xAA)bmsHandleJK(deviceId,dv,deviceName); // JK BMS else if(first===0xA5)bmsHandleDaly(deviceId,dv,deviceName); // Daly }); - await ble.startNotifications({deviceId,service:foundService,characteristic:notifyChar}); - setBleDiag('Notify ativo · iniciando wake sequence...','ok'); - await new Promise(r=>setTimeout(r,500)); - // Wake-up sequence (técnica Xiaoxiang): read inicial + wake bytes try{ - await ble.read({deviceId,service:foundService,characteristic:notifyChar}); - setBleDiag('Read inicial OK (acorda stack)','info'); - }catch(e){setBleDiag('Read inicial skip: '+(e.message||'?'),'info')} - await new Promise(r=>setTimeout(r,300)); - // Wake bytes 5A x4 (algumas firmwares Xiaoxiang) - try{ - const useWnr=writeOnlyWnr; - const fn=useWnr?'writeWithoutResponse':'write'; - const wakePromise=ble[fn]({deviceId,service:foundService,characteristic:writeChar,value:bytesToBase64([0x5A,0x5A,0x5A,0x5A])}); - const wakeTimeout=new Promise((_,rej)=>setTimeout(()=>rej(new Error('wake timeout')),2000)); - await Promise.race([wakePromise,wakeTimeout]); - setBleDiag('Wake 5A x4 enviado','info'); - }catch(e){setBleDiag('Wake skip: '+(e.message||'?'),'info')} - await new Promise(r=>setTimeout(r,1500)); - setBleDiag('Iniciando probe de protocolos...','ok'); + await ble.startNotifications({deviceId,service:foundService,characteristic:notifyChar}); + setBleDiag('Notify ativo · aguardando 800ms...','ok'); + }catch(e){setBleDiag('startNotifications erro: '+(e.message||e.errorMessage||'?'),'err');return false} + await new Promise(r=>setTimeout(r,800)); + // Wake-up REMOVIDO no path Capacitor — chamadas extra causavam crash nativo + // Provamos no PC (Web Bluetooth) que JBD-0x03 direto funciona // Salva config no device pra reuso const dev=state.btDevices?.find(d=>d.id===deviceId); if(dev){ @@ -6474,7 +6461,7 @@ async function removeBluetoothDevice(id){ renderBluetoothCard(); } -const APP_VERSION='1.10.16'; +const APP_VERSION='1.10.17'; function renderBluetoothCard(){ const el=document.getElementById('bt-list'); const supportEl=document.getElementById('bt-support'); diff --git a/mobile/android/app/build.gradle b/mobile/android/app/build.gradle index c80f021..b42bb9e 100644 --- a/mobile/android/app/build.gradle +++ b/mobile/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "br.com.pontualtech.shivao" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 29 - versionName "1.10.16" + versionCode 30 + versionName "1.10.17" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/mobile/package.json b/mobile/package.json index 0f13f43..8beb1e8 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -1,6 +1,6 @@ { "name": "shivao-mobile", - "version": "1.10.16", + "version": "1.10.17", "description": "Shivao app nativo (Capacitor wrapper Android/iOS)", "main": "index.js", "type": "module", diff --git a/server/public/index.html b/server/public/index.html index 39fe82b..7b9ede4 100644 --- a/server/public/index.html +++ b/server/public/index.html @@ -6226,26 +6226,13 @@ async function bmsProbeAndAttach(deviceId,deviceName){ else if(first===0xAA)bmsHandleJK(deviceId,dv,deviceName); // JK BMS else if(first===0xA5)bmsHandleDaly(deviceId,dv,deviceName); // Daly }); - await ble.startNotifications({deviceId,service:foundService,characteristic:notifyChar}); - setBleDiag('Notify ativo · iniciando wake sequence...','ok'); - await new Promise(r=>setTimeout(r,500)); - // Wake-up sequence (técnica Xiaoxiang): read inicial + wake bytes try{ - await ble.read({deviceId,service:foundService,characteristic:notifyChar}); - setBleDiag('Read inicial OK (acorda stack)','info'); - }catch(e){setBleDiag('Read inicial skip: '+(e.message||'?'),'info')} - await new Promise(r=>setTimeout(r,300)); - // Wake bytes 5A x4 (algumas firmwares Xiaoxiang) - try{ - const useWnr=writeOnlyWnr; - const fn=useWnr?'writeWithoutResponse':'write'; - const wakePromise=ble[fn]({deviceId,service:foundService,characteristic:writeChar,value:bytesToBase64([0x5A,0x5A,0x5A,0x5A])}); - const wakeTimeout=new Promise((_,rej)=>setTimeout(()=>rej(new Error('wake timeout')),2000)); - await Promise.race([wakePromise,wakeTimeout]); - setBleDiag('Wake 5A x4 enviado','info'); - }catch(e){setBleDiag('Wake skip: '+(e.message||'?'),'info')} - await new Promise(r=>setTimeout(r,1500)); - setBleDiag('Iniciando probe de protocolos...','ok'); + await ble.startNotifications({deviceId,service:foundService,characteristic:notifyChar}); + setBleDiag('Notify ativo · aguardando 800ms...','ok'); + }catch(e){setBleDiag('startNotifications erro: '+(e.message||e.errorMessage||'?'),'err');return false} + await new Promise(r=>setTimeout(r,800)); + // Wake-up REMOVIDO no path Capacitor — chamadas extra causavam crash nativo + // Provamos no PC (Web Bluetooth) que JBD-0x03 direto funciona // Salva config no device pra reuso const dev=state.btDevices?.find(d=>d.id===deviceId); if(dev){ @@ -6474,7 +6461,7 @@ async function removeBluetoothDevice(id){ renderBluetoothCard(); } -const APP_VERSION='1.10.16'; +const APP_VERSION='1.10.17'; 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 0327b41..f661c19 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.16'; +const VERSION = 'shivao-v1.10.17'; 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}`; diff --git a/server/src/index.js b/server/src/index.js index d6423a2..9aa5c01 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -413,7 +413,7 @@ app.get('/.well-known/assetlinks.json', (req, res) => { }); // Atalho: /apk redireciona pra última APK release no Forgejo -const LATEST_APK_URL = 'https://git.pontualtech.work/karlao/shivao-projeto/releases/download/v1.10.16/Shivao-v1.10.16.apk'; +const LATEST_APK_URL = 'https://git.pontualtech.work/karlao/shivao-projeto/releases/download/v1.10.17/Shivao-v1.10.17.apk'; app.get('/apk', (req, res) => res.redirect(302, LATEST_APK_URL)); // Página A4 imprimível com QR Code + instruções (cola no barco/marina)