•   about 5 years ago

Getting a service using the short SIG service reference?

I am trying to get access to the Immediate Alert Service. I found the SIG list of approved Bluetooth LE service IDs:

https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx

The IDs listed there are all short IDs (16-bit). I tried using the code below to get access to the Immediate Alert Service using it's ID of 0x1811. However, I don't get any devices back from FindAllAsync(). What am I doing wrong? Note, the full GUID returned by GattCharacteristic.ConvertShortIdToUuid() is "00001811-0000-1000-8000-00805f9b34fb".

private async Task GetImmediateAlertService()
{
Guid immediateAlertSvcUuid = GattCharacteristic.ConvertShortIdToUuid(0x1811);
string aqs = GattDeviceService.GetDeviceSelectorFromUuid(immediateAlertSvcUuid);

DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(
aqs,
new string[] { "System.Devices.ContainerId" });

if (devices == null)
throw new ArgumentNullException("The devices collection is unassigned.");

if (devices.Count < 1)
throw new ArgumentOutOfRangeException("The devices collection is empty.");

DeviceInformation device = devices[0];

string deviceContainerId = "{" + device.Properties["System.Devices.ContainerId"] + "}";

// GattDeviceService.
service = await GattDeviceService.FromIdAsync(device.Id);

if (service == null)
throw new NullReferenceException("could not find the immediate alert service.");

return service;
}

  • 1 comment

  • Moderator   •   about 5 years ago

    V.BTTN actually supports Immediate Alert Service 0x1802 and not Alert Notification Service (0x1811).

Comments are closed.