Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
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ł

22
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.
23
Bluetooth Framework / Re: GATT Client - Write Request
« Last post by briandunham on May 19, 2022, 11:36:24 PM »
I'm handling the long write events on the server side, but they do not get triggered when doing a long write from the GATT client. In fact, zero events get triggered so I'm not sure the packets are even making it to the server. The MTU is already set to 64 bytes and I verified that gets exchanged when establishing connection. Not sure what else could be causing the issue.

Here is what the characteristic on the GATT server looks like:
      s_rxDataCharacteristic.ServiceHandle = 0x0006;
      s_rxDataCharacteristic.Uuid.IsShortUuid = FALSE;
      s_rxDataCharacteristic.Uuid.ShortUuid = 0xCCCC;
      s_rxDataCharacteristic.Uuid.LongUuid = { 0x3347AB02, 0xFB94, 0x11E2, {0xAB, 0xE4, 0xF2, 0x3C, 0x91, 0xAE, 0xC0, 0x5E} };
      s_rxDataCharacteristic.Handle = 0x000A;
      s_rxDataCharacteristic.ValueHandle = 0x0000;
      s_rxDataCharacteristic.IsBroadcastable = FALSE;
      s_rxDataCharacteristic.IsReadable = TRUE;
      s_rxDataCharacteristic.IsWritable = TRUE;
      s_rxDataCharacteristic.IsWritableWithoutResponse = FALSE;
      s_rxDataCharacteristic.IsSignedWritable = FALSE;
      s_rxDataCharacteristic.IsNotifiable = FALSE;
      s_rxDataCharacteristic.IsIndicatable = FALSE;
      s_rxDataCharacteristic.HasExtendedProperties = FALSE;
24
Bluetooth Framework / Re: GATT Client - Write Request
« Last post by briandunham on May 19, 2022, 10:09:09 PM »
Hi Mike,

Thank you for sharing your knowledge on this subject. When I lowered the data size down to 20 bytes, it sent the proper Attribute Write and the expected event was received by the server.

So I will now try doing a long write from the GATT client and look to handle the proper Prepare and Execute Write responses on the server side.

Thanks again,
Brian
25
Bluetooth Framework / Re: GATT Client - Write Request
« Last post by Mike Petrichenko on May 19, 2022, 09:20:55 PM »
Ok, i have checked what windows does with different options.

* If the characteristic is writable without response MS driver uses Write Command
* If the characteristic is not writable without response MS driver uses Attribute Write
*  If the characteristic is long and not writable without response MS driver uses Prepare Write/Execute Write.
26
Bluetooth Framework / Re: GATT Client - Write Request
« Last post by Mike Petrichenko on May 19, 2022, 08:44:56 PM »
I have no idea about what that specification defines but GATT specification defines the following commands:

Attribute Write - used for short write without response.
Write Command - used for short write with response
Prepare write - used for long and reliable writes always with response.
Execute Wriute - used after prepare write to confirm or decline transaction.

Short write - data size <= 20 bytes (common PDU size).
Long write - data size > 20 bytes.

Bluetooth Framework with BLEd112 controls the write by following way: If it is short write without reponse the Attribute Write is used. If it is shirt write with response the Write Command is used. If it is long write the Prepare/execute write is used.

Bluetooth Framework can not control when MS driver uses Write/Write Command but it can control when it uses short or long write by switching between Write with and Write without response.
27
Bluetooth Framework / Re: GATT Client - Write Request
« Last post by briandunham on May 19, 2022, 06:48:11 PM »
It looks like people call it different names on the internet, but yes a write with response is what I'm looking for. Setting the IsWritableWithoutResponse property to false still doesn't do what I'm expecting.

Section 3.4.5.1 in the article here: https://iotexpert.com/ble-write-request-write-command-signed-write-command-prepare-write/ shows what I'm looking for. I basically just need to get the attribute opcode to be equal to 0x12 in order for it to trigger the attribute changed event on the server.

If you test using Nordic nRF Connect mobile app to write to a GATT server, you will see the advanced options to do the different type of writes. And using "request" is what triggers the event properly on the server. I need to get the same behavior using this framework. Do you have any other ideas what might be going wrong here?
28
Bluetooth Framework / Re: GATT Client - Write Request
« Last post by Mike Petrichenko on May 19, 2022, 05:52:30 AM »
Hi,

There is no Write Request. However there is Write with and write without response. You can control it by changing the characteristic's WriteWithoutReposnse property (in the characteristic structure). Set it to false before calling Write method to execute Write with response. Set the property to true to execute write without resposne. (Server must support preffered way). Also you can execute long write (WriteWithoutResponse must be set to false) and the length of the value must be more than 30 bytes.
29
Bluetooth Framework / GATT Client - Write Request
« Last post by briandunham on May 19, 2022, 12:56:38 AM »
Hi Mike,

I'm trying to do a write request from a GATT client using your framework but I'm unsure how to do this. I am currently using m_pGattClient->WriteCharacteristicValue(s_rxDataCharacteristic, data, sizeof(STRUCT_BT_MESSAGE), plNone); without errors and was able to successfully poll for that data on the server side.

But the GATT server isn't receiving an event when new data is written from the client. I'm assuming my GATT client is doing a write command instead of a write request. I've tested this by using the nRF Connect app to do a "write request", and the GATT server successfully receives the data with an event. How can I do a write request using your framework?

Thank you,
Brian
30
Bluetooth Framework / Re: GATT Server - Characteristic Max Size
« Last post by briandunham on May 10, 2022, 05:23:37 PM »
Thank you for the clarification. I was able to find a "set_max_mtu" function in other API that we're using for the GATT server. Which allowed my WCL application in Windows to automatically adjust to the new MTU value.
Pages: 1 2 [3] 4 5 ... 10