[BLE] Incorrectly used closure
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Wed, 23 Sep 2015 14:07:34 +0000 (16:07 +0200)
committersangrae.kim <sangrae.kim@samsung.com>
Wed, 23 Sep 2015 14:53:46 +0000 (23:53 +0900)
closures can't be used with prototype.
All instances of BluetoothGATTCharacteristic had the
same _handle variable (last created).

Change-Id: Ia89987637733596345a7bdbc3d2e99c092986fd1
Signed-off-by: Przemyslaw Ciezkowski <p.ciezkowski@samsung.com>
src/bluetooth/bluetooth_api.js

index 710c771..997ebb3 100755 (executable)
@@ -1637,7 +1637,7 @@ var BluetoothGATTCharacteristic = function(data, address) {
     }
   });
 
-  BluetoothGATTCharacteristic.prototype.readValue = function() {
+  this.readValue = function() {
       console.log('Entered BluetoothGATTCharacteristic.readValue()');
 
       xwalk.utils.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_ADMIN);
@@ -1670,7 +1670,7 @@ var BluetoothGATTCharacteristic = function(data, address) {
       }
     };
 
-    BluetoothGATTCharacteristic.prototype.writeValue = function() {
+    this.writeValue = function() {
       console.log('Entered BluetoothGATTCharacteristic.writeValue()');
 
       xwalk.utils.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_ADMIN);
@@ -1708,7 +1708,7 @@ var BluetoothGATTCharacteristic = function(data, address) {
       }
     };
 
-  BluetoothGATTCharacteristic.prototype.addValueChangeListener = function() {
+  this.addValueChangeListener = function() {
     console.log('Entered BluetoothGATTCharacteristic.addValueChangeListener()');
 
     xwalk.utils.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_ADMIN);
@@ -1729,7 +1729,7 @@ var BluetoothGATTCharacteristic = function(data, address) {
     return _bluetoothGATTCharacteristicListener.addListener(callback, callArgs);
   };
 
-  BluetoothGATTCharacteristic.prototype.removeValueChangeListener = function() {
+  this.removeValueChangeListener = function() {
     console.log('Entered BluetoothGATTCharacteristic.removeValueChangeListener()');
 
     var args = AV.validateMethod(arguments, [{
@@ -1855,7 +1855,7 @@ var BluetoothGATTDescriptor = function(data, address) {
   //address_ is needed to control if device is still connected
   var address_ = address;
 
-  BluetoothGATTDescriptor.prototype.readValue = function() {
+  this.readValue = function() {
     console.log('Entered BluetoothGATTDescriptor.readValue()');
 
     xwalk.utils.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_ADMIN);
@@ -1888,7 +1888,7 @@ var BluetoothGATTDescriptor = function(data, address) {
     }
   };
 
-  BluetoothGATTDescriptor.prototype.writeValue = function() {
+  this.writeValue = function() {
     console.log('Entered BluetoothGATTDescriptor.writeValue()');
 
     xwalk.utils.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_ADMIN);