You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* iOS with [BLEMini](http://redbearlab.com/blemini), [BLEShield](http://redbearlab.com/bleshield/) or [Adafruit Bluefruit LE](http://www.adafruit.com/products/1697)
11
-
10
+
* iOS with [RedBearLab](http://redbearlab.com) BLE hardware, [Adafruit Bluefruit LE](http://www.adafruit.com/products/1697), or [Laird BL600](http://www.lairdtech.com/Products/Embedded-Wireless-Solutions/Bluetooth-Radio-Modules/BL600-Series/#.VBI7AS5dUzI)
11
+
12
12
[Supporting other Bluetooth Low Energy hardware](#supporting-other-ble-hardware)
13
13
14
14
## Limitations
15
15
16
16
* The phone must initiate the Bluetooth connection
17
17
* Data sent over the connection is assumed to be Strings
18
18
* iOS Bluetooth Low Energy requires iPhone 4S, iPhone5, iPod 5, or iPad3+
19
+
* Will *not* connect Android to Android
20
+
* Will *not* connect iOS to iOS[*](https://github.com/don/BluetoothSerial/issues/75#issuecomment-52591397)
This plugin is also available for [PhoneGap Build](https://build.phonegap.com/plugins/366)
27
29
28
30
# Examples
29
31
@@ -66,8 +68,8 @@ For iOS, `connect` takes the UUID of the remote device. Optionally, you can pas
66
68
67
69
### Parameters
68
70
69
-
-__macAddress_or_uuid__: Identifier of the remote device.
70
-
-__connectSuccess__: Success callback function that is invoked when the connection is successful.
71
+
-__macAddress_or_uuid__: Identifier of the remote device.
72
+
-__connectSuccess__: Success callback function that is invoked when the connection is successful.
71
73
-__connectFailure__: Error callback function, invoked when error occurs or the connection disconnects.
72
74
73
75
## connectInsecure
@@ -88,8 +90,8 @@ For Android, `connectInsecure` takes a macAddress of the remote device.
88
90
89
91
### Parameters
90
92
91
-
-__macAddress__: Identifier of the remote device.
92
-
-__connectSuccess__: Success callback function that is invoked when the connection is successful.
93
+
-__macAddress__: Identifier of the remote device.
94
+
-__connectSuccess__: Success callback function that is invoked when the connection is successful.
93
95
-__connectFailure__: Error callback function, invoked when error occurs or the connection disconnects.
94
96
95
97
@@ -186,8 +188,8 @@ Function `readUntil` reads the data from the buffer until it reaches a delimiter
186
188
bluetoothSerial.readUntil('\n', function (data) {
187
189
console.log(data);
188
190
}, failure);
189
-
190
-
## subscribe
191
+
192
+
## subscribe
191
193
192
194
Subscribe to be notified when data is received.
193
195
@@ -249,7 +251,7 @@ Function `clear` removes any data from the receive buffer.
249
251
Lists bonded devices
250
252
251
253
bluetoothSerial.list(success, failure);
252
-
254
+
253
255
### Description
254
256
255
257
#### Android
@@ -260,32 +262,32 @@ Example list passed to success callback. See [BluetoothDevice](http://developer
260
262
261
263
[{
262
264
"class": 276,
263
-
"id": "10:BF:48:CB:00:00",
265
+
"id": "10:BF:48:CB:00:00",
264
266
"address": "10:BF:48:CB:00:00",
265
267
"name": "Nexus 7"
266
268
}, {
267
269
"class": 7936,
268
-
"id": "00:06:66:4D:00:00",
270
+
"id": "00:06:66:4D:00:00",
269
271
"address": "00:06:66:4D:00:00",
270
272
"name": "RN42"
271
273
}]
272
-
274
+
273
275
#### iOS
274
276
275
277
Function `list` lists the discovered Bluetooth Low Energy peripheral. The success callback is called with a list of objects.
276
278
277
279
Example list passed to success callback for iOS.
278
280
279
281
[{
280
-
"id": "CC410A23-2865-F03E-FC6A-4C17E858E11E",
282
+
"id": "CC410A23-2865-F03E-FC6A-4C17E858E11E",
281
283
"uuid": "CC410A23-2865-F03E-FC6A-4C17E858E11E",
282
284
"name": "Biscuit",
283
285
"rssi": -68
284
286
}]
285
-
287
+
286
288
The advertised RSSI **may** be included if available.
287
289
288
-
`id` is the generic name for `uuid` or [mac]`address` so that code can be platform independent.
290
+
`id` is the generic name for `uuid` or [mac]`address` so that code can be platform independent.
289
291
290
292
### Parameters
291
293
@@ -299,10 +301,10 @@ The advertised RSSI **may** be included if available.
299
301
console.log(device.id);
300
302
})
301
303
}, failure);
302
-
304
+
303
305
## isConnected
304
306
305
-
Reports the connection status.
307
+
Reports the connection status.
306
308
307
309
bluetoothSerial.isConnected(success, failure);
308
310
@@ -318,14 +320,14 @@ Function `isConnected` calls the success callback when connected to a peer and t
318
320
### Quick Example
319
321
320
322
bluetoothSerial.isConnected(
321
-
function() {
323
+
function() {
322
324
console.log("Bluetooth is connected");
323
325
},
324
-
function() {
326
+
function() {
325
327
console.log("Bluetooth is *not* connected");
326
328
}
327
-
);
328
-
329
+
);
330
+
329
331
## isEnabled
330
332
331
333
Reports if bluetooth is enabled.
@@ -344,13 +346,13 @@ Function `isEnabled` calls the success callback when bluetooth is enabled and th
344
346
### Quick Example
345
347
346
348
bluetoothSerial.isEnabled(
347
-
function() {
349
+
function() {
348
350
console.log("Bluetooth is enabled");
349
351
},
350
-
function() {
352
+
function() {
351
353
console.log("Bluetooth is *not* enabled");
352
354
}
353
-
);
355
+
);
354
356
355
357
## readRSSI
356
358
@@ -372,15 +374,15 @@ Function `readRSSI` calls the success callback with the rssi.
372
374
### Quick Example
373
375
374
376
bluetoothSerial.readRSSI(
375
-
function(rssi) {
377
+
function(rssi) {
376
378
console.log(rssi);
377
379
}
378
-
);
380
+
);
379
381
380
382
381
383
# Misc
382
384
383
-
## Where does this work?
385
+
## Where does this work?
384
386
385
387
### Android
386
388
@@ -396,7 +398,7 @@ Development Devices include
396
398
On the Arduino side I test with [Sparkfun Mate Silver](https://www.sparkfun.com/products/10393) and the [Seeed Studio Bluetooth Shield](http://www.seeedstudio.com/depot/bluetooth-shield-p-866.html?cPath=19_21). The code should be generic and work with most hardware.
397
399
398
400
I highly recommend [Adafruit's Bluefruit EZ-Link](http://www.adafruit.com/products/1588).
399
-
401
+
400
402
### iOS
401
403
402
404
**NOTE: Currently iOS only works with RedBear Labs Hardware and Adafruit Bluefruit LE**
@@ -409,7 +411,7 @@ Ensure that you have update the BLE Mini firmware to at least [Biscuit-UART_2013
409
411
410
412
For Bluetooth Low Energy, this plugin supports the RedBear Labs hardware by default, but can support any Bluetooth Low Energy hardware with a "serial like" service. This means a transmit characteristic that is writable and a receive characteristic that supports notification.
411
413
412
-
Edit [BLEdefines.h](src/ios/BLEDefines.h) and adjust the UUIDs for your service.
414
+
Edit [BLEdefines.h](src/ios/BLEDefines.h) and adjust the UUIDs for your service.
413
415
414
416
## Props
415
417
@@ -429,11 +431,13 @@ The API for available, read, readUntil was influenced by the [BtSerial Library f
429
431
430
432
If you don't need **serial** over Bluetooth, try the [PhoneGap Bluetooth Plugin for Android](https://github.com/phonegap/phonegap-plugins/tree/DEPRECATED/Android/Bluetooth/2.2.0) or perhaps [phonegap-plugin-bluetooth](https://github.com/tanelih/phonegap-bluetooth-plugin).
431
433
432
-
If you need generic Bluetooth Low Energy support checkout Rand Dusing's [BluetoothLE](https://github.com/randdusing/BluetoothLE).
434
+
If you need generic Bluetooth Low Energy support checkout my [Cordova BLE Plugin](https://github.com/don/cordova-plugin-ble-central).
435
+
436
+
If you need BLE for RFduino checkout my [RFduino Plugin](https://github.com/don/cordova-plugin-rfduino).
433
437
434
438
## What format should the Mac Address be in?
435
439
An example a properly formatted mac address is ``AA:BB:CC:DD:EE:FF``
436
440
437
441
## Feedback
438
-
442
+
439
443
Try the code. If you find an problem or missing feature, file an issue or create a pull request.
0 commit comments