1
1
import { Injectable } from '@angular/core' ;
2
- import { Cordova , Plugin , IonicNativePlugin } from '@ionic-native/core' ;
2
+ import { Cordova , IonicNativePlugin , Plugin } from '@ionic-native/core' ;
3
3
import { Observable } from 'rxjs/Observable' ;
4
4
5
+ export interface BLEScanOptions {
6
+ /** true if duplicate devices should be reported, false (default) if devices should only be reported once. */
7
+ reportDuplicates ?: boolean ;
8
+ }
9
+
5
10
/**
6
11
* @name BLE
7
12
* @description
@@ -167,6 +172,8 @@ import { Observable } from 'rxjs/Observable';
167
172
*
168
173
* UUIDs are always strings and not numbers. Some 16-bit UUIDs, such as '2220' look like integers, but they're not. (The integer 2220 is 0x8AC in hex.) This isn't a problem with 128 bit UUIDs since they look like strings 82b9e6e1-593a-456f-be9b-9215160ebcac. All 16-bit UUIDs should also be passed to methods as strings.
169
174
*
175
+ * @interfaces
176
+ * BLEScanOptions
170
177
*/
171
178
@Plugin ( {
172
179
pluginName : 'BLE' ,
@@ -177,7 +184,6 @@ import { Observable } from 'rxjs/Observable';
177
184
} )
178
185
@Injectable ( )
179
186
export class BLE extends IonicNativePlugin {
180
-
181
187
/**
182
188
* Scan and discover BLE peripherals for the specified amount of time.
183
189
*
@@ -194,7 +200,9 @@ export class BLE extends IonicNativePlugin {
194
200
@Cordova ( {
195
201
observable : true
196
202
} )
197
- scan ( services : string [ ] , seconds : number ) : Observable < any > { return ; }
203
+ scan ( services : string [ ] , seconds : number ) : Observable < any > {
204
+ return ;
205
+ }
198
206
199
207
/**
200
208
* Scan and discover BLE peripherals until `stopScan` is called.
@@ -217,7 +225,9 @@ export class BLE extends IonicNativePlugin {
217
225
clearFunction : 'stopScan' ,
218
226
clearWithArgs : false
219
227
} )
220
- startScan ( services : string [ ] ) : Observable < any > { return ; }
228
+ startScan ( services : string [ ] ) : Observable < any > {
229
+ return ;
230
+ }
221
231
222
232
/**
223
233
* Scans for BLE devices. This function operates similarly to the `startScan` function, but allows you to specify extra options (like allowing duplicate device reports).
@@ -230,7 +240,12 @@ export class BLE extends IonicNativePlugin {
230
240
clearFunction : 'stopScan' ,
231
241
clearWithArgs : false
232
242
} )
233
- startScanWithOptions ( services : string [ ] , options : { reportDuplicates ?: boolean } | any ) : Observable < any > { return ; }
243
+ startScanWithOptions (
244
+ services : string [ ] ,
245
+ options : BLEScanOptions
246
+ ) : Observable < any > {
247
+ return ;
248
+ }
234
249
235
250
/**
236
251
* Stop a scan started by `startScan`.
@@ -247,7 +262,9 @@ export class BLE extends IonicNativePlugin {
247
262
* @return returns a Promise.
248
263
*/
249
264
@Cordova ( )
250
- stopScan ( ) : Promise < any > { return ; }
265
+ stopScan ( ) : Promise < any > {
266
+ return ;
267
+ }
251
268
252
269
/**
253
270
* Connect to a peripheral.
@@ -268,7 +285,9 @@ export class BLE extends IonicNativePlugin {
268
285
clearFunction : 'disconnect' ,
269
286
clearWithArgs : true
270
287
} )
271
- connect ( deviceId : string ) : Observable < any > { return ; }
288
+ connect ( deviceId : string ) : Observable < any > {
289
+ return ;
290
+ }
272
291
273
292
/**
274
293
* Disconnect from a peripheral.
@@ -282,7 +301,9 @@ export class BLE extends IonicNativePlugin {
282
301
* @return Returns a Promise
283
302
*/
284
303
@Cordova ( )
285
- disconnect ( deviceId : string ) : Promise < any > { return ; }
304
+ disconnect ( deviceId : string ) : Promise < any > {
305
+ return ;
306
+ }
286
307
287
308
/**
288
309
* Read the value of a characteristic.
@@ -297,7 +318,9 @@ export class BLE extends IonicNativePlugin {
297
318
deviceId : string ,
298
319
serviceUUID : string ,
299
320
characteristicUUID : string
300
- ) : Promise < any > { return ; } ;
321
+ ) : Promise < any > {
322
+ return ;
323
+ }
301
324
302
325
/**
303
326
* Write the value of a characteristic.
@@ -333,7 +356,9 @@ export class BLE extends IonicNativePlugin {
333
356
serviceUUID : string ,
334
357
characteristicUUID : string ,
335
358
value : ArrayBuffer
336
- ) : Promise < any > { return ; }
359
+ ) : Promise < any > {
360
+ return ;
361
+ }
337
362
338
363
/**
339
364
* Write the value of a characteristic without waiting for confirmation from the peripheral.
@@ -350,7 +375,9 @@ export class BLE extends IonicNativePlugin {
350
375
serviceUUID : string ,
351
376
characteristicUUID : string ,
352
377
value : ArrayBuffer
353
- ) : Promise < any > { return ; }
378
+ ) : Promise < any > {
379
+ return ;
380
+ }
354
381
355
382
/**
356
383
* Register to be notified when the value of a characteristic changes.
@@ -376,7 +403,9 @@ export class BLE extends IonicNativePlugin {
376
403
deviceId : string ,
377
404
serviceUUID : string ,
378
405
characteristicUUID : string
379
- ) : Observable < any > { return ; }
406
+ ) : Observable < any > {
407
+ return ;
408
+ }
380
409
381
410
/**
382
411
* Stop being notified when the value of a characteristic changes.
@@ -391,7 +420,9 @@ export class BLE extends IonicNativePlugin {
391
420
deviceId : string ,
392
421
serviceUUID : string ,
393
422
characteristicUUID : string
394
- ) : Promise < any > { return ; }
423
+ ) : Promise < any > {
424
+ return ;
425
+ }
395
426
396
427
/**
397
428
* Report the connection status.
@@ -407,15 +438,19 @@ export class BLE extends IonicNativePlugin {
407
438
* @returns {Promise<any> }
408
439
*/
409
440
@Cordova ( )
410
- isConnected ( deviceId : string ) : Promise < any > { return ; }
441
+ isConnected ( deviceId : string ) : Promise < any > {
442
+ return ;
443
+ }
411
444
412
445
/**
413
446
* Report if bluetooth is enabled.
414
447
*
415
448
* @returns {Promise<void> } Returns a Promise that resolves if Bluetooth is enabled, and rejects if disabled.
416
449
*/
417
450
@Cordova ( )
418
- isEnabled ( ) : Promise < void > { return ; }
451
+ isEnabled ( ) : Promise < void > {
452
+ return ;
453
+ }
419
454
420
455
/**
421
456
* Register to be notified when Bluetooth state changes on the device.
@@ -434,31 +469,39 @@ export class BLE extends IonicNativePlugin {
434
469
clearFunction : 'stopStateNotifications' ,
435
470
clearWithArgs : false
436
471
} )
437
- startStateNotifications ( ) : Observable < any > { return ; }
472
+ startStateNotifications ( ) : Observable < any > {
473
+ return ;
474
+ }
438
475
439
476
/**
440
477
* Stop state notifications.
441
478
*
442
479
* @returns {Promise<any> }
443
480
*/
444
481
@Cordova ( )
445
- stopStateNotifications ( ) : Promise < any > { return ; }
482
+ stopStateNotifications ( ) : Promise < any > {
483
+ return ;
484
+ }
446
485
447
486
/**
448
487
* Open System Bluetooth settings (Android only).
449
488
*
450
489
* @returns {Promise<any> }
451
490
*/
452
491
@Cordova ( )
453
- showBluetoothSettings ( ) : Promise < any > { return ; }
492
+ showBluetoothSettings ( ) : Promise < any > {
493
+ return ;
494
+ }
454
495
455
496
/**
456
497
* Enable Bluetooth on the device (Android only).
457
498
*
458
499
* @returns {Promise<any> }
459
500
*/
460
501
@Cordova ( )
461
- enable ( ) : Promise < any > { return ; }
502
+ enable ( ) : Promise < any > {
503
+ return ;
504
+ }
462
505
463
506
/**
464
507
* Read the RSSI value on the device connection.
@@ -468,7 +511,7 @@ export class BLE extends IonicNativePlugin {
468
511
*@returns {Promise<any> }
469
512
*/
470
513
@Cordova ( )
471
- readRSSI (
472
- deviceId : string ,
473
- ) : Promise < any > { return ; }
514
+ readRSSI ( deviceId : string ) : Promise < any > {
515
+ return ;
516
+ }
474
517
}
0 commit comments