当前位置: 首页>>代码示例>>C#>>正文


C# IDevice.DiscoverServices方法代码示例

本文整理汇总了C#中IDevice.DiscoverServices方法的典型用法代码示例。如果您正苦于以下问题:C# IDevice.DiscoverServices方法的具体用法?C# IDevice.DiscoverServices怎么用?C# IDevice.DiscoverServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDevice的用法示例。


在下文中一共展示了IDevice.DiscoverServices方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ServiceList

		public ServiceList (IAdapter adapter, IDevice device)
		{
			InitializeComponent ();
			this.adapter = adapter;
			this.device = device;
			this.services = new ObservableCollection<IService> ();
			listView.ItemsSource = services;

			// when device is connected
			adapter.DeviceConnected += (s, e) => {
				device = e.Device; // do we need to overwrite this?

				// when services are discovered
				device.ServicesDiscovered += (object se, EventArgs ea) => {
					Debug.WriteLine("device.ServicesDiscovered");
					//services = (List<IService>)device.Services;
					if (services.Count == 0)
						Device.BeginInvokeOnMainThread(() => {
							foreach (var service in device.Services) {
								services.Add(service);
							}
						});
				};
				// start looking for services
				device.DiscoverServices ();

			};
			// TODO: add to IAdapter first
			//adapter.DeviceFailedToConnect += (sender, else) => {};

			DisconnectButton.Activated += (sender, e) => {
				adapter.DisconnectDevice (device);
				Navigation.PopToRootAsync(); // disconnect means start over
			};
		}
开发者ID:Roddoric,项目名称:Monkey.Robotics,代码行数:35,代码来源:ServiceList.xaml.cs

示例2: DevicePage

		public DevicePage(IDevice device)
		{
			_device = device;
			_device.ServiceDiscovered += ServiceDiscovered;

			DiscoveredServices = new ObservableCollection<Grouping<IService, ICharacteristic>>();

			InitializeComponent();

			BindingContext = _device;
			serviceListView.ItemsSource = DiscoveredServices;
			serviceListView.ItemSelected += ServiceSelected;

			App.BluetoothAdapter.DeviceDisconnected += DeviceDisconnected;

			_device.DiscoverServices();
		}
开发者ID:CocoFeng,项目名称:Xamarin.BluetoothLE,代码行数:17,代码来源:DevicePage.xaml.cs

示例3: Adapter_DeviceConnected

		void Adapter_DeviceConnected (object sender, DeviceConnectionEventArgs e)
		{
			Debug.WriteLine("Device connected");
			//adapter.StopScanningForDevices();
			StopScanning();
			Device.BeginInvokeOnMainThread(() => {
				this.lblConnectedDevice.IsVisible = true;
				this.btnGenerateCode.IsVisible = true;
				this.btnDisconnect.IsVisible = true;
				this.lblConnectedDevice.Text = "Device Connected: " + e.Device.Name;
			});

			Debug.WriteLine("Connected Devices Count: "+ adapter.ConnectedDevices.Count);

			device = e.Device;
			device.ServicesDiscovered += Device_ServicesDiscovered;

			device.DiscoverServices ();
		}
开发者ID:yelkrebb,项目名称:XamTest,代码行数:19,代码来源:TestPage.xaml.cs


注:本文中的IDevice.DiscoverServices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。