Skip to content
Permalink
Browse files

Check if the BluetoothDevice is connected, when calling getGATT funct…

…ions.
  • Loading branch information...
zakorgy committed Oct 6, 2016
1 parent 11dbb71 commit b72dcf326baeef621d265fbdef8cebadeef72080
@@ -87,6 +87,9 @@ impl BluetoothRemoteGATTCharacteristic {
if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
return Err(Security)
}
if !self.Service().Device().Gatt().Connected() {
return Err(Network)
}
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::GetDescriptor(self.get_instance_id(), uuid, sender)).unwrap();
@@ -117,6 +120,9 @@ impl BluetoothRemoteGATTCharacteristic {
}
}
};
if !self.Service().Device().Gatt().Connected() {
return Err(Network)
}
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::GetDescriptors(self.get_instance_id(), uuid, sender)).unwrap();
@@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMet
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{self, Security};
use dom::bindings::error::Error::{self, Network, Security};
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
@@ -72,6 +72,9 @@ impl BluetoothRemoteGATTServer {
if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
return Err(Security)
}
if !self.Device().Gatt().Connected() {
return Err(Network)
}
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::GetPrimaryService(String::from(self.Device().Id()), uuid, sender)).unwrap();
@@ -103,6 +106,9 @@ impl BluetoothRemoteGATTServer {
}
}
};
if !self.Device().Gatt().Connected() {
return Err(Network)
}
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::GetPrimaryServices(String::from(self.Device().Id()), uuid, sender)).unwrap();
@@ -4,9 +4,11 @@

use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
use dom::bindings::error::Error::{self, Security};
use dom::bindings::error::Error::{self, Network, Security};
use dom::bindings::error::Fallible;
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
@@ -76,6 +78,9 @@ impl BluetoothRemoteGATTService {
if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
return Err(Security)
}
if !self.Device().Gatt().Connected() {
return Err(Network)
}
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::GetCharacteristic(self.get_instance_id(), uuid, sender)).unwrap();
@@ -118,6 +123,9 @@ impl BluetoothRemoteGATTService {
}
}
};
if !self.Device().Gatt().Connected() {
return Err(Network)
}
let mut characteristics = vec!();
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
@@ -159,6 +167,9 @@ impl BluetoothRemoteGATTService {
if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
return Err(Security)
}
if !self.Device().Gatt().Connected() {
return Err(Network)
}
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::GetIncludedService(self.get_instance_id(),
@@ -192,6 +203,9 @@ impl BluetoothRemoteGATTService {
}
}
};
if !self.Device().Gatt().Connected() {
return Err(Network)
}
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::GetIncludedServices(self.get_instance_id(),

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

0 comments on commit b72dcf3

Please sign in to comment.
You can’t perform that action at this time.