diff --git a/app/diario-bordo.html b/app/diario-bordo.html index b3b0e5c..94ec173 100644 --- a/app/diario-bordo.html +++ b/app/diario-bordo.html @@ -6125,12 +6125,30 @@ async function bmsQueryBasic(deviceId,withoutResponse){ await bmsWriteCmd(deviceId,BMS_CMD_BASIC,withoutResponse); } -// Re-leitura manual a partir do botão UI +// Re-leitura manual: garante init + reconecta GATT + roda probe async function bmsManualRead(deviceId){ - setBleDiag('🔄 Re-leitura manual · re-rodando probe completo...','info'); + setBleDiag('🔄 Re-leitura manual','info'); + const dev=state.btDevices?.find(d=>d.id===deviceId); + const deviceName=dev?.name||'BMS'; try{ - // Re-roda probe completo (lista chars de novo + tenta protocolos) - await bmsProbeAndAttach(deviceId,state.btDevices?.find(d=>d.id===deviceId)?.name||'BMS'); + // 1. Garante plugin inicializado + await ensureBleNativeReady(); + setBleDiag('Plugin init OK','info'); + // 2. Reconecta GATT (Android pode ter desconectado em background) + const ble=window.Capacitor?.Plugins?.BluetoothLe; + if(ble){ + try{ + await ble.connect({deviceId,timeout:15000}); + setBleDiag('GATT reconectado','ok'); + await new Promise(r=>setTimeout(r,500)); + }catch(e){ + const msg=e.message||e.errorMessage||'?'; + if(/already/i.test(msg))setBleDiag('GATT já conectado','info'); + else setBleDiag('Reconnect erro: '+msg,'warn'); + } + } + // 3. Roda probe completo + await bmsProbeAndAttach(deviceId,deviceName); }catch(e){setBleDiag('Manual read falhou: '+(e.message||e.errorMessage),'err')} } @@ -6247,7 +6265,7 @@ async function removeBluetoothDevice(id){ renderBluetoothCard(); } -const APP_VERSION='1.10.4'; +const APP_VERSION='1.10.5'; 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 3f8b370..9783657 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 20 - versionName "1.10.4" + versionCode 21 + versionName "1.10.5" 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 031baff..911102d 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -1,6 +1,6 @@ { "name": "shivao-mobile", - "version": "1.10.4", + "version": "1.10.5", "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 b3b0e5c..94ec173 100644 --- a/server/public/index.html +++ b/server/public/index.html @@ -6125,12 +6125,30 @@ async function bmsQueryBasic(deviceId,withoutResponse){ await bmsWriteCmd(deviceId,BMS_CMD_BASIC,withoutResponse); } -// Re-leitura manual a partir do botão UI +// Re-leitura manual: garante init + reconecta GATT + roda probe async function bmsManualRead(deviceId){ - setBleDiag('🔄 Re-leitura manual · re-rodando probe completo...','info'); + setBleDiag('🔄 Re-leitura manual','info'); + const dev=state.btDevices?.find(d=>d.id===deviceId); + const deviceName=dev?.name||'BMS'; try{ - // Re-roda probe completo (lista chars de novo + tenta protocolos) - await bmsProbeAndAttach(deviceId,state.btDevices?.find(d=>d.id===deviceId)?.name||'BMS'); + // 1. Garante plugin inicializado + await ensureBleNativeReady(); + setBleDiag('Plugin init OK','info'); + // 2. Reconecta GATT (Android pode ter desconectado em background) + const ble=window.Capacitor?.Plugins?.BluetoothLe; + if(ble){ + try{ + await ble.connect({deviceId,timeout:15000}); + setBleDiag('GATT reconectado','ok'); + await new Promise(r=>setTimeout(r,500)); + }catch(e){ + const msg=e.message||e.errorMessage||'?'; + if(/already/i.test(msg))setBleDiag('GATT já conectado','info'); + else setBleDiag('Reconnect erro: '+msg,'warn'); + } + } + // 3. Roda probe completo + await bmsProbeAndAttach(deviceId,deviceName); }catch(e){setBleDiag('Manual read falhou: '+(e.message||e.errorMessage),'err')} } @@ -6247,7 +6265,7 @@ async function removeBluetoothDevice(id){ renderBluetoothCard(); } -const APP_VERSION='1.10.4'; +const APP_VERSION='1.10.5'; function renderBluetoothCard(){ const el=document.getElementById('bt-list'); const supportEl=document.getElementById('bt-support'); diff --git a/server/src/index.js b/server/src/index.js index 1148743..4ef6f1a 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -347,7 +347,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.4/Shivao-v1.10.4.apk'; +const LATEST_APK_URL = 'https://git.pontualtech.work/karlao/shivao-projeto/releases/download/v1.10.5/Shivao-v1.10.5.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)