From: Pawel Wasowski Date: Tue, 15 Sep 2020 14:37:55 +0000 (+0200) Subject: [Bluetooth] Implement BluetoothGATTServerDescriptor::setReadValueRequestCallback() X-Git-Tag: submit/tizen/20200918.124009~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e02945f443adc4c8bc03d7aa0b1639f7bc9d46b3;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Bluetooth] Implement BluetoothGATTServerDescriptor::setReadValueRequestCallback() This commit isolates the implementation of setReadValueRequestCallback, which is common for GATT characteristic and descriptor and adds it to both these interfaces. [Verification] Tested manually in Chrome DevTools. It works fine Change-Id: I721db57deb597634dedad3b947590ad7a6e116b7 Signed-off-by: Pawel Wasowski --- diff --git a/src/bluetooth/bluetooth_api.js b/src/bluetooth/bluetooth_api.js index 5608e2ed..6bfcbec7 100755 --- a/src/bluetooth/bluetooth_api.js +++ b/src/bluetooth/bluetooth_api.js @@ -2512,7 +2512,6 @@ function _createReadValueRequestCallback( function(event, readValueRequestCallback, unusedErrorCallback) { var clientAddress = event.clientAddress; var offset = event.offset; - privUtils_.warn('event: ' + JSON.stringify(event)); if (readValueRequestCallback) { var requestReply = readValueRequestCallback(clientAddress, offset); @@ -2524,7 +2523,6 @@ function _createReadValueRequestCallback( statusCode: requestReply.statusCode, data: requestReply.data }; - privUtils_.warn('event: ' + JSON.stringify(response)); var callback = function(result) { if (native.isFailure(result)) { native.callIfPossible( @@ -2548,7 +2546,7 @@ function _createReadValueRequestCallback( var _BluetoothGATTServerReadWriteValueRequestCallbacks = {}; -BluetoothGATTServerCharacteristic.prototype.setReadValueRequestCallback = function() { +var _setReadValueRequestCallbackCommon = function() { var args = AV.validateArgs(arguments, [ { name: 'readValueRequestCallback', @@ -2580,14 +2578,14 @@ BluetoothGATTServerCharacteristic.prototype.setReadValueRequestCallback = functi } ]); - var characteristicId = this._id; + var entityId = this._id; var callback = function(result) { if (native.isFailure(result)) { native.callIfPossible(args.errorCallback, native.getErrorObject(result)); } else { var readValueRequestCallback = _createReadValueRequestCallback( - characteristicId, + entityId, args.sendResponseSuccessCallback, args.sendResponseErrorCallback ); @@ -2598,7 +2596,7 @@ BluetoothGATTServerCharacteristic.prototype.setReadValueRequestCallback = functi } ); _BluetoothGATTServerReadWriteValueRequestCallbacks[ - 'ReadValueCallback' + characteristicId + "ReadValueCallback" + entityId ] = readValueRequestCallback; native.callIfPossible(args.successCallback, native.getErrorObject(result)); } @@ -2616,6 +2614,8 @@ BluetoothGATTServerCharacteristic.prototype.setReadValueRequestCallback = functi } }; +BluetoothGATTServerCharacteristic.prototype.setReadValueRequestCallback = _setReadValueRequestCallbackCommon; + /** * Creates a manager for specified listener event. Manager handles multiple * registered listeners @@ -2981,6 +2981,8 @@ Object.defineProperty(BluetoothGATTServerDescriptor.prototype, 'constructor', { writable: true }); +BluetoothGATTServerDescriptor.prototype.setReadValueRequestCallback = _setReadValueRequestCallbackCommon; + // class BluetoothAdapter /////////////////////////// var BluetoothAdapter = function() { function nameGetter() {