Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Bluetooth Framework / Re: Windows 10 perhipheral disconnect long timeout
« Last post by Mike Petrichenko on June 01, 2022, 10:12:13 AM »
Hi,

If you use version with source code please send an e-mail to us at support@btframework.com and we will provide a latest beta version that possible fixes the issue.
Unfortunately if you use version without source code you have to wait for release. We are planing the release of new version in about a couple of weeks.
22
Bluetooth Framework / Re: Windows 10 perhipheral disconnect long timeout
« Last post by mksiezopolski on June 01, 2022, 10:10:09 AM »
Hi,
Any progress on this issue or maybe some estimated time when we might expect an update?

23
Its OS timing. We will add flag to indicate that remote device disconnects so Bluetooth Framework will not try to unsubscribe.
24
Bluetooth Framework / Re: Windows 10 perhipheral disconnect long timeout
« Last post by mksiezopolski on May 25, 2022, 10:28:17 AM »
OK. Thanks.
Just out of curiosity, does the Unsubscribe timeout occur in the library or is it an OS thing (trying to write to a disconnected device produces such a timeout)? Is the timeout related to the connection parameters of the peripheral device or is it hardcoded somewhere?

25
Got it. It may take time when disconnecting because when you call Disconnect() or when emote device disconnects its implementation unsubscribes from all subscribed characteristics. This operation includes 2 steps:

1. Call to Unsubscribe()
2. Write client configuration descriptor.

So in case your app calls Disconnect() it does not take too much time because device is available. However if device is not available writing client configuration descriptor takes time.

We will try to find better solution for this case. I will let you know once we find it (should not take too long).
26
Bluetooth Framework / Re: Windows 10 perhipheral disconnect long timeout
« Last post by mksiezopolski on May 25, 2022, 09:49:27 AM »
Also a collegue of mine sent you a video (to support) which maybe helps a bit to see what happens  ;). I just wanted to describe the problem more thoroughly here.
27
Bluetooth Framework / Re: Windows 10 perhipheral disconnect long timeout
« Last post by mksiezopolski on May 25, 2022, 09:43:38 AM »
Hey,
Not sure what you mean by "which notifications" but I will try to answer.

We turn on notifications for various characteristics - standard BLE battery service (0x180f) and battery characteristic (0x2a19) and 8 custom characteristics in our device (in 4 custom services). It does not matter whether we turn on notifications in our custom services or only the standard BLE battery service (custom services not used in this case) - the problem always occurs. All the characteristics are either Read/Notify or Read/Write/Notify - no indications are used.

Here is a snippet for the code turning on notifications:
Code: [Select]
BleError BleCharacteristic::setNotificationEnabled(bool suscribe) {

  if (!characteristic.IsNotifiable && !characteristic.IsIndicatable) {
    return BleError::CharacteristicNotNotifiable;
  }
  if (!cccdPresent) {
    return BleError::CharacteristicNoCccd;
  }
  qDebug() << "Start write descriptor for char" << getUuid() << suscribe;

  if (suscribe) {
    int result = gattClient.SubscribeForNotifications(characteristic, goReadFromDevice, plNone);
    if (result != WCL_E_SUCCESS) {
      auto errorString = BleUtils::convertWclErrorCodeToString(result);
      qWarning() << "Error writing CCCD for char" << getUuid() << errorString;
      return {BleError::CharacteristicSubscribeError, errorString};
    }
  } else {
    int result = gattClient.UnsubscribeFromNotifications(characteristic, goReadFromDevice, plNone);
    if (result != WCL_E_SUCCESS) {
      auto errorString = BleUtils::convertWclErrorCodeToString(result);
      qWarning() << "Error writing CCCD for char" << getUuid() << errorString;
      return {BleError::CharacteristicUnsubscribeError, errorString};
    }
  }
  return BleError::NoError;
}

We hook up the notifications using:
Code: [Select]
  __hook(&CwclGattClient::OnCharacteristicChanged, gattClient, &BleDevice::handleCharacteristicChanged);

Everything works perfectly during normal operation of the device: we can connect/disconnect, interact with the device, pair/unpair etc. The only major problem is the one that I described, that if the device turns off suddenly (or performs a reset which leads to a spurious disconnect) then the library waits a long time before calling the event:
Code: [Select]
  __hook(&CwclGattClient::OnDisconnect, gattClient, &BleDevice::handleDisconnected);
If we turn off the notifications then this problem does not occur and as I have mentioned the more characteristics we have subscriptions turned on, the longer this delay lasts...

Let me just mention that this problem does not occur in Android (using Android BLE library) in our custom Android application nor in the nRF connect Android application - the disconnect is caught within a few seconds (according to connection timeout parameter of the BLE device).
28
Hi,

To be able to reproduce and fix the issue it would be great to know which notifications you turned off/on.
29
Bluetooth Framework / Windows 10 perhipheral disconnect long timeout
« Last post by mksiezopolski on May 24, 2022, 10:28:21 PM »
Hi,
We have the following problem while developing an app using BLE on Windows 10 and the Bluetooth Framework library. This problem occurs both with our app and the demo app Gatt Client. Whenever any notifications are turned on and the peripheral device gets turned off or resets unexpectedly, Windows 10 sees the disconnect almost immediately (couple of seconds due to the BLE connection timeout) - we see this in the Bluetooth Manager window of Windows 10 where the device changes state from Connected to Paired. However, the library disconnect handler only gets triggered after a long time - let's call this time the "library disconnect delay time".
What is more interesting I just ran a test where I turned each notification on one by one and measured the library disconnect delay time - for 1 notifications turned on it was 8s, for 2 notifications it was 16s and for 3 notifications it was 24s!!! So each notification that is turned on whilst connected to the device adds 8s to the library disconnect delay time (maybe the 8s is somehow connected to the connection parameters of the device and may be different for other devices).
If I turn off all notifications I get the disconnect immediately - at the same time that Windows Bluetooth Manager sees it.

This behavior does not occur if we trigger a disconnect from the Windows host - then the disconnect occurs immediately as well.

So my question is:
1. Why does this delay occur in the first place?
2. Why is it related to the number of notifications turned on?
3. How to get rid of it? Obviously we cannot turn off all notifications during connection since we want them for the system to work properly.

Regards,
Michał

30
Bluetooth Framework / Re: GATT Client - Write Request
« Last post by Mike Petrichenko on May 20, 2022, 03:43:00 AM »
The long write starts only if the data length is more then MTU/PDU length. BLED112 and BlueSoleil always uses 20 bytes PDU/MTU (by docs for BLED112 and by experience for BlueSoleil). But Microsoft dinamically changes that.

Internally Bluetooth Framework checks only that Data Size must be less then 20 bytes and WriteWithoutResposen can be any value. If the data size if more then 20 bytes the WriteWithoutResponse must be set to false (Bluetooth Framework assumes long write in this case). However once WIndows changes it when needed you sould write data packet more than 20 bytes. 64 in your case (62 actually, but 64 should definatelly start long write operation).

Unfortunately currently there is no way to get MTU/PDU size but I think in next release we will add such feature.
Pages: 1 2 [3] 4 5 ... 10