Discover, Connect and Write to BLE using windows store app

If you aren’t familiar with BLE devices then please have a look and learn features of BLE devices BLE devices features. As per latest version of windows 8.1 added feature to connect and communicate with the windows store app and GATT api which inclueded Connect, Read/Write, Notify BLE devices.
I have developed a windows store app using BLE devices name OLP425. I followed the below link and customize the code as per my requirement. Basically I have to blink the OLP425 tag by sending write characterstic to BLE device and able to write value to devices successfully.

Here the link i followed Here. Please read this blog very carefully and then try to implement.In that blog demo they are using sensor tag.

But in my project I am using OLP425 BLE device and write code to blink. So the Services and Characteristics UUID would be different. Here the link of OLP425 BLE device documentation for UUID OLP425 BLE Documentation

Here my Package.appxmanifest file code.

   <Capability Name="internetClient" />  
   <m2:DeviceCapability Name="bluetooth.genericAttributeProfile">  
    <m2:Device Id="any">  
     <m2:Function Type="serviceId:0000ffa0-0000-1000-8000-00805f9b34fb"/>  
     <m2:Function Type="serviceId:0000ffd0-0000-1000-8000-00805f9b34fb"/>  
     <m2:Function Type="serviceId:0000180F-0000-1000-8000-00805f9b34fb"/>  
     <m2:Function Type="serviceId:0000ffe0-0000-1000-8000-00805f9b34fb"/>  
     <m2:Function Type="serviceId:00001800-0000-1000-8000-00805f9b34fb"/>  
     <m2:Function Type="serviceId:00001801-0000-1000-8000-00805f9b34fb"/>  
     <m2:Function Type="serviceId:0000180A-0000-1000-8000-00805f9b34fb"/>  

The code to detect BLE devices and send signal to blink

   //Find the devices that expose the RED LED service 
            var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(new Guid("0000ffd0-0000-1000-8000-00805f9b34fb")));
       if (devices.Count==0)  
       //Connect to the service  
       var service = await GattDeviceService.FromIdAsync(devices[0].Id);  
if (accService == null)
                //Get the RED LED Service data characteristic with UUID ffd1 
                var accData = accService.GetCharacteristics(new Guid("0000ffd1-0000-1000-8000-00805f9b34fb"))[0];
                //Set configuration to notify  
               // await accData.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);
                //Get the ble tag configuration characteristic  
                var accConfig = accService.GetCharacteristics(new Guid("0000ffd1-0000-1000-8000-00805f9b34fb"))[0];
                //Write 1 to start blink RED LED of SBOR tag
                await accConfig.WriteValueAsync((new byte[] { 0 }).AsBuffer());      

If need help, feel free to contact me

Happy Coding..

Posted by | View Post | View Group