locked
Can not find Bluetooth LE device after change of gatt services RRS feed

  • Question

  • Hi,

    I am able to retrieve the DeviceInformation of a BLE service by using the service uuid.

    DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(id), new string[] { "System.Devices.ContainerId" });

    After that, I can communicate with the device.
    For some services (in my case Device Firmeware Update) it is necessary that the device switches its GattDeviceService and uses other GattCharacterstics to communicate.
    I am able to retrieve this DeviceInformation with another service uuid as well, if the device was already in that state, but I am not able to retrieve the DeviceInformation after the already connected device switches its state.

    In that case the DeviceInformation.FindAllAsync call returns no elements, but it still gives me a result if I use the first service id, which should not be available at that time.

    I guess the DeviceInformationCollection is cached or the old BLE connection blocks a new connection to that device.
    The name of the device also changes during that process.

    Should I somehow refresh that collection or manually free some objects that prevent the detection of a new service?

    The code is inside a portable lib, and therefor BluetoothLEDevice with the GattServicesChanged event is not available there.

    Thanks

    Thursday, September 18, 2014 9:16 AM

All replies

  • What state does the device switch to? This sounds similar to a problem I am working on where devices cannot be found when the BT service is turned off and back on - the FindAllAsync method fails to return any devices.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, September 18, 2014 12:06 PM
    Moderator
  • After sending a specific command to the device, the device restarts internally and boots into another mode that offers a Device Firmware Update BLE service, which uses other GattCharacteristics for communication than our default BLE service.
    Thursday, September 18, 2014 1:13 PM
  • Does all of this work fine using desktop APIs?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, October 3, 2014 4:58 PM
    Moderator
  • The whole process of a firmware update with that device (Runtastic Orbit) works fine on Android and iOS.
    Now we are working on a universal app for Windows and do not have a desktop app.

    So unfortunately I do not know.
    Did I understand you correctly?

    Or are there some other APIs that can be accessed within a universal app, that I should try?


    Monday, October 6, 2014 8:51 AM
  • Hi,

      I used this code i paired in bluetooth phone and miura device.but all paired bluetooth name is showing in my app but that miura bluetooth device its not showing in my app.i want to know why its not showing the muira device name


    Alert


    • Edited by Raamchandar Thursday, October 9, 2014 6:04 AM
    Thursday, October 9, 2014 5:58 AM
  • Hey Chrisika

    I am doing exactly the same thing as you, DFU(device firmware update). I am experiment on a windows phone, so the "BluetoothLEDevice" is available, and I did experiment the Gattservicechange event and put the Generic Attributes to indicate, both of the listener were trigger, and windows phone successful did the reconnection. and also I found out when windows phone did the reconnection it has read new services aswell. BUT When I later in code(see the code down)try to retrieve those new services, it gives wrong services(one of service should be there).

    var deviceList = await DeviceInformation.FindAllAsync(BluetoothLEDevice.GetDeviceSelector());
    			var newDevice = deviceList.FirstOrDefault(x => x.Id == bLEDeviceOnApplication.DeviceID);
    			var newBLE = await BluetoothLEDevice.FromIdAsync(newDevice.Id) as BluetoothLEDevice;
    I would like to talk with you, you can send me email to jovirus.q at gmail dot com


    Jiajun Qiu


    • Edited by JIAJUN.QIU Thursday, November 13, 2014 9:32 PM
    Thursday, November 13, 2014 3:58 PM