This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sd_ble_gatts_hvx indication sets len 0 and doesn't call onCharacteristicChanged on Adroid App

Hi,

I trying to send indication supplied with some data to my Android app (which BTW works fine with other BLE devices) as an answer to characteristic write command

Here is my sequence of calls:

Android:

1) Discover services and characteristic

2) Write 0x3 to CCCD (0x2902) of required characteristic to enable notifications and indications

3) Enable characteristic notifications

4) Write characteristic

nRF52:

1) create services, characteristic and CCCD

2) upone receiving BLE_GATTS_EVT_WRITE set new characteristic  value with sd_ble_gatts_value_set

3) call sd_ble_gatts_hvx with p_data as NULL (returns success)

 

Unfortunately Android callback onCharacteristicChanged is never called and p_len member of ble_gatts_hvx_params_t passed to sd_ble_gatts_hvx remains 0

Here is my add characteristic function:

Here is my write response function called on BLE_GATTS_EVT_WRITE 

What am I missing?

Parents
  • So... looks like I found a bug:

    Comments in ble_gatts.h says:

    that means my write_response function is OK.

    But whe I set  params.p_data = data (existing pointer)  then I do get onCharacteristicChanged called on Android. BUT with zero-length byte array

    So I decided to set wr_len = len hoping that in this case I'll get data in Android but I didn't - onCharacteristicChanged again not called.

    I might say - API documentation/comments are very unclear..

  • Looking at the implementation of HVX inside softdevice, the documentation looks correct. So I am not sure why you see that behaviour.

    Can you try the below instead in your write_response and see what happens?

  • Have you ment "params.p_len = &len"?

  • Sorry. Yes you are right 

  • result is the same: if len = MTU, nothing sent

Reply Children
No Data