feat(deploy-tab): auto re-pair before deploy if connection lost

This commit is contained in:
a2nr 2026-07-05 17:49:40 +07:00
parent 87364da0c5
commit bb19523f65
1 changed files with 19 additions and 2 deletions

View File

@ -87,11 +87,28 @@
} }
async function handleDeploy() { async function handleDeploy() {
if (!deployer || !isPaired) { if (!deployer) {
errorMessage = 'Hubungkan perangkat dulu'; errorMessage = 'Deployer belum diinisialisasi';
return; return;
} }
// Auto re-pair if BLE connection is lost
if (!deployer.isConnected || !isPaired) {
console.log('[DEPLOY] Connection lost, attempting re-pair...');
try {
deployState = 'pairing';
deployMessage = 'Re-connecting to device...';
await deployer.pair();
isPaired = true;
deployState = 'idle';
console.log('[DEPLOY] Re-pair successful!');
} catch (err: any) {
deployState = 'error';
errorMessage = 'Re-pair gagal: ' + err.message;
return;
}
}
serialActive = false; serialActive = false;
try { try {