private async void Button_Click(object sender, RoutedEventArgs e) { string aqs = RfcommDeviceService.GetDeviceSelector(RfcommServiceId.ObexObjectPush); DevicePicker picker = new DevicePicker(); picker.Appearance.BackgroundColor = Color.FromArgb(0xff, 0, 0x33, 0x33); picker.Appearance.ForegroundColor = Colors.White; picker.Appearance.AccentColor = Colors.Goldenrod; // add our query string picker.Filter.SupportedDeviceSelectors.Add(aqs); // prompt user to select a single device DeviceInformation dev = await picker.PickSingleDeviceAsync(new Rect(200, 20, 50, 50)); if (dev != null) { // if a device is selected create a BluetoothDevice instance to get more information RfcommDeviceService service = await RfcommDeviceService.FromIdAsync(dev.Id); if (service != null) { foreach (KeyValuePair <uint, IBuffer> attrib in await service.GetSdpRawAttributesAsync()) { SdpDataElement de = SdpDataElement.FromByteArray(attrib.Value.ToArray()); System.Diagnostics.Debug.WriteLine(attrib.Key.ToString("X") + " " + de.ToString()); } // set data-binding so that device properties are displayed DeviceInformationPanel.DataContext = service; } } }
private async void Button_Click(object sender, RoutedEventArgs e) { string aqs = RfcommDeviceService.GetDeviceSelector(RfcommServiceId.ObexObjectPush); DevicePicker picker = new DevicePicker(); picker.Appearance.BackgroundColor = Color.FromArgb(0xff, 0, 0x33, 0x33); picker.Appearance.ForegroundColor = Colors.White; picker.Appearance.AccentColor = Colors.Goldenrod; // add our query string picker.Filter.SupportedDeviceSelectors.Add(aqs); // prompt user to select a single device DeviceInformation dev = await picker.PickSingleDeviceAsync(new Rect()); if (dev != null) { // if a device is selected create a BluetoothDevice instance to get more information BluetoothDevice bd = await BluetoothDevice.FromIdAsync(dev.Id); foreach (IBuffer r in bd.SdpRecords) { if (r.Length > 0) { SdpDataElement record = SdpDataElement.FromByteArray(r.ToArray()); if (record.Value != null) { string s = record.ToString(); System.Diagnostics.Debug.WriteLine(s); } } } // set data-binding so that device properties are displayed DeviceInformationPanel.DataContext = bd; } }