Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd Start/Stop notifications #14276
Add Start/Stop notifications #14276
Conversation
highfive
commented
Nov 18, 2016
|
Heads up! This PR modifies the following files: |
|
r? @jdm |
|
Note: These changes will only enable the ability to start/stop notifications, you can't subscribe for these (yet). This is useful for those devices which requires registering for a notification as a handshake mechanism (e.g. Parrot drones). |
|
|
| #[allow(unrooted_must_root)] | ||
| // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-startnotifications | ||
| fn StartNotifications(&self) -> Rc<Promise> { | ||
| let p = Promise::new(&self.global()); |
This comment has been minimized.
This comment has been minimized.
| let p = Promise::new(&self.global()); | ||
| let p_cx = p.global().get_cx(); | ||
|
|
||
| if !self.Service().Device().Gatt().Connected() { |
This comment has been minimized.
This comment has been minimized.
jdm
Nov 22, 2016
Member
What step is this implementing? The spec doesn't say to reject with a network error.
This comment has been minimized.
This comment has been minimized.
dati91
Nov 22, 2016
Author
Contributor
You are right about this. We differ from the spec, because we do not support any notification context (yet). The reason I put this here to have at least one "early return". But i can remove it if you prefer.
This comment has been minimized.
This comment has been minimized.
| #[allow(unrooted_must_root)] | ||
| // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-stopnotifications | ||
| fn StopNotifications(&self) -> Rc<Promise> { | ||
| let p = Promise::new(&self.global()); |
This comment has been minimized.
This comment has been minimized.
| .then(service => service.getCharacteristic(device_name.name)) | ||
| .then(characteristic => promise_rejects(t, 'NotSupportedError', characteristic.startNotifications())); | ||
| }); | ||
| }, 'startNotifications should throw NotSupportedError without Notify or Indent flag.'); |
This comment has been minimized.
This comment has been minimized.
| return characteristic.startNotifications() | ||
| .then(result => assert_equals(result, characteristic)); | ||
| }); | ||
| }); |
This comment has been minimized.
This comment has been minimized.
jdm
Nov 22, 2016
Member
.then(gattServer => gattServer.getPrimaryService(heart_rate.name))
.then(service => service.getCharacteristic(heart_rate_measurement.name))
.then(characteristic => {
return characteristic.startNotifications()
.then(result => assert_equals(result, characteristic));
});| return characteristic.stopNotifications() | ||
| .then(result => assert_equals(result, characteristic)); | ||
| }); | ||
| }); |
This comment has been minimized.
This comment has been minimized.
jdm
Nov 22, 2016
Member
.then(gattServer => gattServer.getPrimaryService(heart_rate.name))
.then(service => service.getCharacteristic(heart_rate_measurement.name))
.then(characteristic => characteristic.startNotifications())
.then(characteristic => {
return characteristic.stopNotifications()
.then(result => assert_equals(result, characteristic));
});| @@ -953,10 +953,13 @@ impl BluetoothManager { | |||
| false => c.stop_notify(), | |||
| }; | |||
| match result { | |||
| // Step 11. | |||
This comment has been minimized.
This comment has been minimized.
jdm
Nov 22, 2016
Member
We'll need a comment containing a link to the appropriate specification, otherwise these steps are mysterious :)
|
@bors-servo: delegate+ |
|
|
|
@bors-servo: r+ |
|
|
Add Start/Stop notifications Add support for Start and Stop Notifications for WebBluetooth --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14276) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
Add Start/Stop notifications Add support for Start and Stop Notifications for WebBluetooth --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14276) <!-- Reviewable:end -->
|
@bors-servo r=jdm |
|
|
Add Start/Stop notifications Add support for Start and Stop Notifications for WebBluetooth --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14276) <!-- Reviewable:end -->
|
|
|
@bors-servo: retry |
|
|
|
|
dati91 commentedNov 18, 2016
•
edited by larsbergstrom
Add support for Start and Stop Notifications for WebBluetooth
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is