Skip to content

Commit 5fe7af5

Browse files
committed
update readme, fix critical android bug, standardize permissions
update readme, fix critical android bug, standardize permissions
1 parent f03657c commit 5fe7af5

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

readme.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,8 +1616,8 @@ var params = {
16161616
{
16171617
uuid: "ABCD",
16181618
permissions: {
1619-
readable: true,
1620-
writeable: true,
1619+
read: true,
1620+
write: true,
16211621
//readEncryptionRequired: true,
16221622
//writeEncryptionRequired: true,
16231623
},
@@ -1689,7 +1689,7 @@ bluetoothle.removeAllServices(success, error);
16891689
16901690
16911691
### startAdvertising ###
1692-
Start advertising as a BLE device
1692+
Start advertising as a BLE device. Note: This needs to be improved so services can be used for both Android and iOS.
16931693
16941694
```javascript
16951695
bluetoothle.startAdvertising(success, error, params);
@@ -1698,7 +1698,8 @@ bluetoothle.startAdvertising(success, error, params);
16981698
##### Params #####
16991699
```javascript
17001700
var params = {
1701-
"services":["1234"],
1701+
"services":["1234"], //iOS
1702+
"service":"1234", //Android
17021703
"name":"Hello World",
17031704
};
17041705
```

src/android/BluetoothLePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ private void initializePeripheralAction(JSONArray args, CallbackContext callback
629629
initPeripheralCallback = callbackContext;
630630

631631
//Re-opening Gatt server seems to cause some issues
632-
if (gattServer != null) {
632+
if (gattServer == null) {
633633
Activity activity = cordova.getActivity();
634634
BluetoothManager bluetoothManager = (BluetoothManager) activity.getSystemService(Context.BLUETOOTH_SERVICE);
635635
gattServer = bluetoothManager.openGattServer(activity.getApplicationContext(), bluetoothGattServerCallback);

src/ios/BluetoothLePlugin.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ - (void)addService:(CDVInvokedUrlCommand *)command {
217217
CBAttributePermissions permissions = 0;
218218

219219
if (permissionsIn) {
220-
if ([permissionsIn valueForKey:@"readable"]) {
220+
if ([permissionsIn valueForKey:@"read"]) {
221221
permissions |= CBAttributePermissionsReadable;
222222
}
223223

224-
if ([permissionsIn valueForKey:@"writeable"]) {
224+
if ([permissionsIn valueForKey:@"write"]) {
225225
permissions |= CBAttributePermissionsWriteable;
226226
}
227227

@@ -3271,6 +3271,8 @@ -(NSData*) getValue:(NSDictionary *) obj {
32713271
}
32723272

32733273
-(void) addValue:(NSData *) bytes toDictionary:(NSMutableDictionary *) obj {
3274+
//TODO what if the value is null
3275+
32743276
NSString *string = [bytes base64EncodedStringWithOptions:0];
32753277

32763278
if (string == nil || string.length == 0) {

src/osx/BluetoothLePlugin.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ - (void)addService:(CDVInvokedUrlCommand *)command {
217217
CBAttributePermissions permissions = 0;
218218

219219
if (permissionsIn) {
220-
if ([permissionsIn valueForKey:@"readable"]) {
220+
if ([permissionsIn valueForKey:@"read"]) {
221221
permissions |= CBAttributePermissionsReadable;
222222
}
223223

224-
if ([permissionsIn valueForKey:@"writeable"]) {
224+
if ([permissionsIn valueForKey:@"write"]) {
225225
permissions |= CBAttributePermissionsWriteable;
226226
}
227227

@@ -3271,6 +3271,8 @@ -(NSData*) getValue:(NSDictionary *) obj {
32713271
}
32723272

32733273
-(void) addValue:(NSData *) bytes toDictionary:(NSMutableDictionary *) obj {
3274+
//TODO what if the value is null
3275+
32743276
NSString *string = [bytes base64EncodedStringWithOptions:0];
32753277

32763278
if (string == nil || string.length == 0) {

0 commit comments

Comments
 (0)