Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shelly] Make blu gw script more robust on startup #16304

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,22 @@ function scanCB(ev, res) {
}
}

// retry several times to start the scanner if script was started before
// BLE infrastructure was up in the Shelly
function startBLEScan() {
let bleScanSuccess = BLE.Scanner.Start({ duration_ms: SCAN_DURATION, active: true }, scanCB);
if( bleScanSuccess === null ) {
console.log('Unable to start OH-BLU Scanner, make sure Shelly Gateway Support is disabled in device config.');
Timer.set(3000, false, startBLEScan);
} else {
console.log('Success: OH-BLU Event Gateway running');
}
}

let BLEConfig = Shelly.getComponentConfig('ble');
if(BLEConfig.enable === false) {
console.log('Error: BLE not enabled, unable to start OH-BLU Scanner');
console.log('Error: BLE not enabled, unable to start OH-BLU Scanner');
} else {
BLE.Scanner.Start({ duration_ms: SCAN_DURATION, active: true }, scanCB);
console.log('OH-BLU Event Gateway running');
Timer.set(1000, false, startBLEScan);
}