WriteValue should return undefined

This commit is contained in:
Attila Dusnoki 2016-11-28 16:31:48 +01:00
parent 4dbca055c6
commit 50a5639a8b
4 changed files with 8 additions and 8 deletions

View file

@ -300,9 +300,8 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTCharacteristic {
promise.resolve_native(promise_cx, &value); promise.resolve_native(promise_cx, &value);
}, },
BluetoothResponse::WriteValue(result) => { BluetoothResponse::WriteValue(result) => {
let value = ByteString::new(result); *self.value.borrow_mut() = Some(ByteString::new(result));
*self.value.borrow_mut() = Some(value.clone()); promise.resolve_native(promise_cx, &());
promise.resolve_native(promise_cx, &value);
}, },
BluetoothResponse::EnableNotification(_result) => { BluetoothResponse::EnableNotification(_result) => {
promise.resolve_native(promise_cx, self); promise.resolve_native(promise_cx, self);

View file

@ -137,9 +137,8 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTDescriptor {
promise.resolve_native(promise_cx, &value); promise.resolve_native(promise_cx, &value);
}, },
BluetoothResponse::WriteValue(result) => { BluetoothResponse::WriteValue(result) => {
let value = ByteString::new(result); *self.value.borrow_mut() = Some(ByteString::new(result));
*self.value.borrow_mut() = Some(value.clone()); promise.resolve_native(promise_cx, &());
promise.resolve_native(promise_cx, &value);
}, },
_ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())), _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
} }

View file

@ -13,6 +13,7 @@ promise_test(() => {
.then(device => device.gatt.connect()) .then(device => device.gatt.connect())
.then(gattServer => gattServer.getPrimaryService(generic_access.name)) .then(gattServer => gattServer.getPrimaryService(generic_access.name))
.then(service => service.getCharacteristic(device_name.name)) .then(service => service.getCharacteristic(device_name.name))
.then(characteristic => characteristic.writeValue(new Uint8Array(1))); .then(characteristic => characteristic.writeValue(new Uint8Array(1)))
.then(result => assert_equals(result, undefined));
}, 'A regular write request to a writable characteristic should succeed.'); }, 'A regular write request to a writable characteristic should succeed.');
</script> </script>

View file

@ -14,6 +14,7 @@ promise_test(t => {
.then(gattServer => gattServer.getPrimaryService(generic_access.name)) .then(gattServer => gattServer.getPrimaryService(generic_access.name))
.then(service => service.getCharacteristic(device_name.name)) .then(service => service.getCharacteristic(device_name.name))
.then(characteristic => characteristic.getDescriptor(number_of_digitals.name)) .then(characteristic => characteristic.getDescriptor(number_of_digitals.name))
.then(descriptor => descriptor.writeValue(new Uint8Array(1))); .then(descriptor => descriptor.writeValue(new Uint8Array(1)))
.then(result => assert_equals(result, undefined));
}, 'A regular write request to a writable descriptor should succeed.'); }, 'A regular write request to a writable descriptor should succeed.');
</script> </script>