Skip to content

Commit

Permalink
Reorder startNotifications steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakor Gyula authored and dati91 committed Feb 10, 2017
1 parent 384391d commit fae2bee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions components/bluetooth/lib.rs
Expand Up @@ -886,7 +886,7 @@ impl BluetoothManager {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-startnotifications
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-stopnotifications
fn enable_notification(&mut self, id: String, enable: bool) -> BluetoothResponseResult {
// (StartNotifications) Step 2 - 3.
// (StartNotifications) Step 3 - 4.
// (StopNotifications) Step 1 - 2.
if !self.characteristic_is_cached(&id) {
return Err(BluetoothError::InvalidState);
Expand All @@ -909,11 +909,11 @@ impl BluetoothManager {
// (StopNotification) Step 5.
Ok(_) => return Ok(BluetoothResponse::EnableNotification(())),

// (StartNotification) Step 4.
// (StartNotification) Step 5.
Err(_) => return Err(BluetoothError::NotSupported),
}
},
// (StartNotification) Step 3.
// (StartNotification) Step 4.
None => return Err(BluetoothError::InvalidState),
}
}
Expand Down
18 changes: 9 additions & 9 deletions components/script/dom/bluetoothremotegattcharacteristic.rs
Expand Up @@ -209,22 +209,22 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
return p;
}

// Step 4.
// Step 2.
if !self.Service().Device().Gatt().Connected() {
p.reject_error(p_cx, Network);
return p;
}

// Step 5.
if !(self.Properties().Notify() ||
self.Properties().Indicate()) {
p.reject_error(p_cx, NotSupported);
return p;
}

// TODO: Step 5: Implement `active notification context set` for BluetoothRemoteGATTCharacteristic.

// Step 6.
if !self.Service().Device().Gatt().Connected() {
p.reject_error(p_cx, Network);
return p;
}
// TODO: Step 6: Implement `active notification context set` for BluetoothRemoteGATTCharacteristic.

// Note: Steps 2 - 3, 7 - 11 are implemented in components/bluetooth/lib.rs in enable_notification function
// Note: Steps 3 - 4, 7 - 11 are implemented in components/bluetooth/lib.rs in enable_notification function
// and in handle_response function.
let sender = response_async(&p, self);
self.get_bluetooth_thread().send(
Expand Down

0 comments on commit fae2bee

Please sign in to comment.