Received empty data array after notification

Hi,

I adapted the nus_client from the Nordic Connect SDK v2.7.0. I changed the UUID and some function names, but in general the code stays the same. I can subscribe one of the characteristics and receive data from it. But the problem is, that everytime I receive a notification, I get another receive event with an empty data array. This leads to an unsubscribtion of the characteristic. 

The client only sends notifications with length = 1, so it's unlikely that the event comes from the client. The client is implemented in nrf5 SDK and sends data with the following code:

How can I resolve this problem?

Best regards,

Christian

Parents
  • Triple-check the return code of your notification function. A return value of BT_GATT_ITER_STOP will automagically unsubscribe!

  • Hi, 

    the only place where BT_GATT_ITER_STOP is returned is when the [UNSUBSCRIBE] happens. I attached the wireshark file for the connection.

     keyfob_unsubscribe.pcapng

    At the same time these were the logs of the peripheral:

    At the moment I use a workaround and subscribe everytime when the characteristic gets unsubscribed. This is why there are more than one [SUBSCRIBED] messages.

    I hope this helps.

    Christian

Reply
  • Hi, 

    the only place where BT_GATT_ITER_STOP is returned is when the [UNSUBSCRIBE] happens. I attached the wireshark file for the connection.

     keyfob_unsubscribe.pcapng

    At the same time these were the logs of the peripheral:

    At the moment I use a workaround and subscribe everytime when the characteristic gets unsubscribed. This is why there are more than one [SUBSCRIBED] messages.

    I hope this helps.

    Christian

Children
  • ilockit_CFR said:
    I attached the wireshark file for the connection.

    unfortunately, the connection is encrypted, and the sniffer did not have the keys, so could not read much from that log.

      

    https://docs.nordicsemi.com/bundle/nrfutil/page/nrfutil-ble-sniffer/guides/common_actions_sniffing_conn_bonded_devs.html 

    https://docs.nordicsemi.com/bundle/nrfutil/page/nrfutil-ble-sniffer/guides/common_actions_sniffing_pairing_procedure.html

  • Thanks for the reply. I tried it again with your instructions and received this: 

    6874.keyfob_unsubscribe.pcapng

  • Could you post the code that handles the notifications on the central side?

  • Hi,

    here are the corresponding parts of the central code:

     

    And here is the part where I subscribe the characteristic in my application:

  • And there is the location for your BT_GATT_ITER_STOP return value, passed from from the callback function:

    Pretty sure that your callback function returns zero, which is the value of BT_GATT_ITER_STOP. Try putting a LOG_DBG statement in there.