diff options
author | zakorgyula <gyula.zakor@gmail.com> | 2016-11-02 08:40:14 +0100 |
---|---|---|
committer | Keith Yeung <kungfukeith11@gmail.com> | 2016-11-23 01:25:21 -0800 |
commit | 1b1b07ef420f440f8d3390dc5a8d74a2ab680648 (patch) | |
tree | f022a41ea9caf1e531a1225a9f7c970056fcd6a1 /components/bluetooth/test.rs | |
parent | bcf41844833e1818768f9d8ca73a931996617868 (diff) | |
download | servo-1b1b07ef420f440f8d3390dc5a8d74a2ab680648.tar.gz servo-1b1b07ef420f440f8d3390dc5a8d74a2ab680648.zip |
serviceData and manufacturerData support
Diffstat (limited to 'components/bluetooth/test.rs')
-rw-r--r-- | components/bluetooth/test.rs | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/components/bluetooth/test.rs b/components/bluetooth/test.rs index ee84fcc976a..b4aa7ef286b 100644 --- a/components/bluetooth/test.rs +++ b/components/bluetooth/test.rs @@ -7,7 +7,7 @@ use device::bluetooth::{BluetoothAdapter, BluetoothDevice}; use device::bluetooth::{BluetoothGATTCharacteristic, BluetoothGATTDescriptor, BluetoothGATTService}; use std::borrow::ToOwned; use std::cell::RefCell; -use std::collections::HashSet; +use std::collections::{HashSet, HashMap}; use std::error::Error; use std::string::String; use uuid::Uuid; @@ -417,6 +417,29 @@ fn create_blocklisted_device(adapter: &BluetoothAdapter) -> Result<(), Box<Error Ok(()) } +fn create_glucose_heart_rate_devices(adapter: &BluetoothAdapter) -> Result<(), Box<Error>> { + let glucose_devie = try!(create_device_with_uuids(adapter, + GLUCOSE_DEVICE_NAME.to_owned(), + GLUCOSE_DEVICE_ADDRESS.to_owned(), + vec![GLUCOSE_SERVICE_UUID.to_owned(), + TX_POWER_SERVICE_UUID.to_owned()])); + + let heart_rate_device_empty = try!(create_heart_rate_device(adapter, true)); + + let mut manufacturer_dta = HashMap::new(); + manufacturer_dta.insert(17, vec![1, 2, 3]); + try!(glucose_devie.set_manufacturer_data(manufacturer_dta)); + + let mut service_data = HashMap::new(); + service_data.insert(GLUCOSE_SERVICE_UUID.to_owned(), vec![1, 2, 3]); + try!(glucose_devie.set_service_data(service_data)); + + service_data = HashMap::new(); + service_data.insert(HEART_RATE_SERVICE_UUID.to_owned(), vec![1, 2, 3]); + try!(heart_rate_device_empty.set_service_data(service_data)); + Ok(()) +} + pub fn test(manager: &mut BluetoothManager, data_set_name: String) -> Result<(), Box<Error>> { let may_existing_adapter = manager.get_or_create_adapter(); let adapter = match may_existing_adapter.as_ref() { @@ -437,14 +460,7 @@ pub fn test(manager: &mut BluetoothManager, data_set_name: String) -> Result<(), }, GLUCOSE_HEART_RATE_ADAPTER => { try!(set_adapter(adapter, GLUCOSE_HEART_RATE_ADAPTER.to_owned())); - - let _glucose_devie = try!(create_device_with_uuids(adapter, - GLUCOSE_DEVICE_NAME.to_owned(), - GLUCOSE_DEVICE_ADDRESS.to_owned(), - vec![GLUCOSE_SERVICE_UUID.to_owned(), - TX_POWER_SERVICE_UUID.to_owned()])); - - let _heart_rate_device_empty = try!(create_heart_rate_device(adapter, true)); + let _ = try!(create_glucose_heart_rate_devices(adapter)); }, UNICODE_DEVICE_ADAPTER => { try!(set_adapter(adapter, UNICODE_DEVICE_ADAPTER.to_owned())); |