| Index: chrome/browser/resources/bluetooth_internals/value_control.js
|
| diff --git a/chrome/browser/resources/bluetooth_internals/value_control.js b/chrome/browser/resources/bluetooth_internals/value_control.js
|
| index 9146e59412c909f225cf254de3419bab58c1a8ef..04b5a4aabed9c830c3b8da39a94dcb776c4ec9a5 100644
|
| --- a/chrome/browser/resources/bluetooth_internals/value_control.js
|
| +++ b/chrome/browser/resources/bluetooth_internals/value_control.js
|
| @@ -341,29 +341,33 @@ cr.define('value_control', function() {
|
| readValue_: function() {
|
| this.readBtn_.disabled = true;
|
|
|
| - device_broker.connectToDevice(this.deviceAddress_).then(function(device) {
|
| - if (this.descriptorId_) {
|
| - return device.readValueForDescriptor(
|
| - this.serviceId_, this.characteristicId_, this.descriptorId_);
|
| - }
|
| -
|
| - return device.readValueForCharacteristic(
|
| - this.serviceId_, this.characteristicId_);
|
| - }.bind(this)).then(function(response) {
|
| - this.readBtn_.disabled = false;
|
| -
|
| - if (response.result === interfaces.BluetoothDevice.GattResult.SUCCESS) {
|
| - this.setValue(response.value);
|
| - Snackbar.show(
|
| - this.deviceAddress_ + ': Read succeeded', SnackbarType.SUCCESS);
|
| - return;
|
| - }
|
| -
|
| - var errorString = this.getErrorString_(response.result);
|
| - Snackbar.show(
|
| - this.deviceAddress_ + ': ' + errorString, SnackbarType.ERROR,
|
| - 'Retry', this.readValue_.bind(this));
|
| - }.bind(this));
|
| + device_broker.connectToDevice(this.deviceAddress_)
|
| + .then(function(device) {
|
| + if (this.descriptorId_) {
|
| + return device.readValueForDescriptor(
|
| + this.serviceId_, this.characteristicId_, this.descriptorId_);
|
| + }
|
| +
|
| + return device.readValueForCharacteristic(
|
| + this.serviceId_, this.characteristicId_);
|
| + }.bind(this))
|
| + .then(function(response) {
|
| + this.readBtn_.disabled = false;
|
| +
|
| + if (response.result ===
|
| + interfaces.BluetoothDevice.GattResult.SUCCESS) {
|
| + this.setValue(response.value);
|
| + Snackbar.show(
|
| + this.deviceAddress_ + ': Read succeeded',
|
| + SnackbarType.SUCCESS);
|
| + return;
|
| + }
|
| +
|
| + var errorString = this.getErrorString_(response.result);
|
| + Snackbar.show(
|
| + this.deviceAddress_ + ': ' + errorString, SnackbarType.ERROR,
|
| + 'Retry', this.readValue_.bind(this));
|
| + }.bind(this));
|
| },
|
|
|
| /**
|
| @@ -376,29 +380,34 @@ cr.define('value_control', function() {
|
| writeValue_: function() {
|
| this.writeBtn_.disabled = true;
|
|
|
| - device_broker.connectToDevice(this.deviceAddress_).then(function(device) {
|
| - if (this.descriptorId_) {
|
| - return device.writeValueForDescriptor(
|
| - this.serviceId_, this.characteristicId_, this.descriptorId_,
|
| - this.value_.getArray());
|
| - }
|
| -
|
| - return device.writeValueForCharacteristic(
|
| - this.serviceId_, this.characteristicId_, this.value_.getArray());
|
| - }.bind(this)).then(function(response) {
|
| - this.writeBtn_.disabled = false;
|
| -
|
| - if (response.result === interfaces.BluetoothDevice.GattResult.SUCCESS) {
|
| - Snackbar.show(
|
| - this.deviceAddress_ + ': Write succeeded', SnackbarType.SUCCESS);
|
| - return;
|
| - }
|
| -
|
| - var errorString = this.getErrorString_(response.result);
|
| - Snackbar.show(
|
| - this.deviceAddress_ + ': ' + errorString, SnackbarType.ERROR,
|
| - 'Retry', this.writeValue_.bind(this));
|
| - }.bind(this));
|
| + device_broker.connectToDevice(this.deviceAddress_)
|
| + .then(function(device) {
|
| + if (this.descriptorId_) {
|
| + return device.writeValueForDescriptor(
|
| + this.serviceId_, this.characteristicId_, this.descriptorId_,
|
| + this.value_.getArray());
|
| + }
|
| +
|
| + return device.writeValueForCharacteristic(
|
| + this.serviceId_, this.characteristicId_,
|
| + this.value_.getArray());
|
| + }.bind(this))
|
| + .then(function(response) {
|
| + this.writeBtn_.disabled = false;
|
| +
|
| + if (response.result ===
|
| + interfaces.BluetoothDevice.GattResult.SUCCESS) {
|
| + Snackbar.show(
|
| + this.deviceAddress_ + ': Write succeeded',
|
| + SnackbarType.SUCCESS);
|
| + return;
|
| + }
|
| +
|
| + var errorString = this.getErrorString_(response.result);
|
| + Snackbar.show(
|
| + this.deviceAddress_ + ': ' + errorString, SnackbarType.ERROR,
|
| + 'Retry', this.writeValue_.bind(this));
|
| + }.bind(this));
|
| },
|
| };
|
|
|
|
|