public void RetrievePeripherals() { if (TestRuntime.CheckXcodeVersion(7, 0)) { // ToString in a CBUUID with true returns the full uuid which can be used to create a NSUuid using (var uuid = new NSUuid(heartRateMonitorUUID.ToString(true))) mgr.RetrievePeripheralsWithIdentifiers(uuid); } else { // that API was deprecated in 7.0 and removed from 9.0 mgr.RetrievePeripherals(heartRateMonitorUUID); } }
public async Task <List <string> > scanDevices() { //throw new NotImplementedException(); //ea.ShowBluetoothAccessoryPicker(null, null); Console.WriteLine("Start scan request!"); var u = CBUUID.FromString("00001101-0000-1000-8000-00805f9b34fb"); var a = new CBUUID[] { u }; if (!bluetoothManager.IsScanning) { //bluetoothManager.StopScan(); bluetoothManager.RetrievePeripherals(a); PeripheralScanningOptions option = new PeripheralScanningOptions(NSDictionary.FromObjectAndKey(CBCentralManager.ScanOptionSolicitedServiceUUIDsKey, CBUUID.FromString("00001101-0000-1000-8000-00805F9B34FB"))); bluetoothManager.ScanForPeripherals(a, option); } await Task.Delay(8000); /** bluetoothManager.ScanForPeripherals(null, option); * List<string> devices = new List<string>(); * bluetoothManager.RetrievePeripherals(CBUUID.FromString("00001101-0000-1000-8000-00805F9B34FB")); * * * bluetoothManager.DiscoveredPeripheral += (sender, e) => * { * * var name = e.Peripheral.UUID; * string uuid = name.ToString(); * devices.Add(uuid); * if (e.AdvertisementData.ContainsKey(CBAdvertisement.DataLocalNameKey)) * { * // iOS caches the peripheral name, so it can become stale (if changing) * // keep track of the local name key manually * name = ((NSString)e.AdvertisementData.ValueForKey(CBAdvertisement.)).ToString(); * * } * };**/ List <string> ids = new List <string>(); /**foreach (CBUUID uuid in a) * { * ids.Add(uuid.ToString()); * }***/ foreach (CBPeripheral p in retrievedDevices) { ids.Add(p.UUID.ToString()); } return(ids); }
public void RetrievePeripherals() { if (mgr.State == CBCentralManagerState.Unknown) { // ensure we do get called mgrDelegate.Event.WaitOne(); } if (mgr.State != CBCentralManagerState.PoweredOn) { Assert.Inconclusive("Bluetooth is off and therefore the test cannot be ran. State == {0}.", mgr.State); } if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { using (var uuid = new NSUuid("B9401000-F5F8-466E-AFF9-25556B57FE6D")) mgr.RetrievePeripheralsWithIdentifiers(uuid); } else { // that API was deprecated in 7.0 and removed from 9.0 using (var uuid = CBUUID.FromString("B9401000-F5F8-466E-AFF9-25556B57FE6D")) mgr.RetrievePeripherals(uuid); } }
public void RetrievePeripherals() { if (mgr.State == CBCentralManagerState.Unknown) { // ensure we do get called Assert.IsTrue(mgrDelegate.Event.WaitOne(TimeSpan.FromSeconds(5)), "Initialization"); } if (mgr.State != CBCentralManagerState.PoweredOn) { Assert.Inconclusive("Bluetooth is off and therefore the test cannot be ran. State == {0}.", mgr.State); } if (TestRuntime.CheckXcodeVersion(7, 0)) { // ToString in a CBUUID with true returns the full uuid which can be used to create a NSUuid using (var uuid = new NSUuid(heartRateMonitorUUID.ToString(true))) mgr.RetrievePeripheralsWithIdentifiers(uuid); } else { // that API was deprecated in 7.0 and removed from 9.0 mgr.RetrievePeripherals(heartRateMonitorUUID); } }
public void RetrievePeripherals() { if (mgr.State == CBCentralManagerState.Unknown) { // ensure we do get called Assert.IsTrue(mgrDelegate.Event.WaitOne(TimeSpan.FromSeconds(5)), "Initialization"); } if (mgr.State != CBCentralManagerState.PoweredOn) { Assert.Inconclusive("Bluetooth is off and therefore the test cannot be ran. State == {0}.", mgr.State); } if (TestRuntime.CheckXcodeVersion(7, 0)) { using (var uuid = new NSUuid("B9401000-F5F8-466E-AFF9-25556B57FE6D")) mgr.RetrievePeripheralsWithIdentifiers(uuid); } else { // that API was deprecated in 7.0 and removed from 9.0 using (var uuid = CBUUID.FromString("B9401000-F5F8-466E-AFF9-25556B57FE6D")) mgr.RetrievePeripherals(uuid); } }