1

For example, I have two heart rate monitors paired with my tablet PC. I'm using such code to get list of HRM devices:

var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync
(
    GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.HeartRate)
);

Then I show a listbox in GUI with device names got from devices[i].Name. For example, I select device with index 0. Then I can get access to it HR serivice and HRM characteristic:

var service = await GattDeviceService.FromIdAsync(devices[0].Id);
var characteristic = await service.GetCharacteristics(attCharacteristicUuids.HeartRateMeasurement);

Along with heart rate I need a battery status. How can I get access to battery service of the same (already selected) device?

vadim b.
  • 31
  • 3

1 Answers1

0

Some information before we start:

You do have to pair your Bluetooth devices with your computer, before you could scan them!

Listing your paired devices:

ListBox1.Items.Clear();

var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));

foreach (var device in devices)
{
    ListBox1.Items.Add(device);
}

If you want to know the battery life of the Bluetooth device:

How to get the battery level after connect to the BLE device?

To access multiple services at once, you need to "reconnect" to the device:

Device A can connect only one at a time to service S on Device B. Device A can connect to service S on Device B, C, D and E, etc at the same time.

@alanjmcf

Source: Establishing multiple bluetooth SPPs at the same time

But do not get confused with the method GetAllIncludedServices();, because it does really return "included services". As one answer stated at an other question:

You probably don't want to get the "included services". Included services is a special concept in BLE which I doubt you are using that is used to link one service from another.

@Emil

Community
  • 1
  • 1
TheRealVira
  • 1,444
  • 4
  • 16
  • 28
  • 1
    Devices are paired and there are no problems with device listing. There also no problems with getting bettery life without getting HRM. I have problem with accessing BOTH servicies of ONCE selected device. – vadim b. Nov 02 '16 at 05:11