File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,21 @@ function log(x) {
30
30
}
31
31
32
32
// ----------------------------------------------------------------------
33
+ var powerOnTimer ;
34
+ if ( config . ble_timeout > 0 )
35
+ powerOnTimer = setTimeout ( function ( ) {
36
+ powerOnTimer = undefined ;
37
+ log ( "BLE broken? No Noble State Change to 'poweredOn' in " + config . ble_timeout + " seconds - restarting!" ) ;
38
+ process . exit ( 1 ) ;
39
+ } , config . ble_timeout * 1000 )
40
+
33
41
function onStateChange ( state ) {
42
+ log ( "Noble StateChange: " + state ) ;
34
43
if ( state != "poweredOn" ) return ;
44
+ if ( powerOnTimer ) {
45
+ clearTimeout ( powerOnTimer ) ;
46
+ powerOnTimer = undefined ;
47
+ }
35
48
// delay startup to allow Bleno to set discovery up
36
49
setTimeout ( function ( ) {
37
50
log ( "Starting scan..." ) ;
@@ -187,7 +200,10 @@ exports.inRange = inRange;
187
200
188
201
exports . restartScan = function ( ) {
189
202
if ( ! isScanning ) {
203
+ log ( "Restarting scan" ) ;
190
204
noble . startScanning ( [ ] , true ) ;
205
+ } else {
206
+ log ( "restartScan: already scanning!" ) ;
191
207
}
192
208
}
193
209
You can’t perform that action at this time.
0 commit comments