File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,11 @@ export class SwitchBotBLE extends EventEmitter {
171
171
this . log ( 'error' , `discover stopScanningAsync error: ${ JSON . stringify ( e . message ?? e ) } ` )
172
172
}
173
173
}
174
- return Object . values ( peripherals )
174
+ const devices = Object . values ( peripherals )
175
+ if ( devices . length === 0 ) {
176
+ this . log ( 'warn' , 'No devices found during discovery.' )
177
+ }
178
+ return devices
175
179
}
176
180
177
181
return new Promise < SwitchbotDevice [ ] > ( ( resolve , reject ) => {
@@ -192,7 +196,14 @@ export class SwitchBotBLE extends EventEmitter {
192
196
193
197
this . noble . startScanningAsync ( PRIMARY_SERVICE_UUID_LIST , false )
194
198
. then ( ( ) => {
195
- timer = setTimeout ( async ( ) => resolve ( await finishDiscovery ( ) ) , p . duration )
199
+ timer = setTimeout ( async ( ) => {
200
+ const result = await finishDiscovery ( )
201
+ if ( result . length === 0 ) {
202
+ reject ( new Error ( 'No devices found during discovery.' ) )
203
+ } else {
204
+ resolve ( result )
205
+ }
206
+ } , p . duration )
196
207
} )
197
208
. catch ( reject )
198
209
} )
You can’t perform that action at this time.
0 commit comments