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

Problem with HVX behavior

Hello. I am working on a application in a NRF5238 with s132, where I send 20 byte packets using notifications from a peripheral to a central board. The central is a modified version of the hrs_c example, while the peripheral is a custom BLE app.

When the boards connect, I immediately enable notifications on the peripheral because I have had quite a lot of trouble enabling them from the central board. Note that this seemed to be working fine initially so I believe it may not be the cause:

static void on_connect(ble_cus_t * p_cus, ble_evt_t const * p_ble_evt)
{
    uint16_t buffer[4];
    buffer[0] = 16;      // cccd handle
    buffer[1] = 2;       // cccd attribute size = 2
    buffer[2] = 1;       // 1 = enable notifications
    buffer[3] = 0xCACD;  // CRC-CCITT (0xFFFF)
    sd_ble_gatts_sys_attr_set(p_cus->conn_handle, (uint8_t*)(buffer), 8, 0);    // initialize cccd attribute
}

As a result, when I connect to my phone I get sd_ble_gatts_hvx return value of 8 repeatedly until I enable incoming notifications on my phone and start getting a value of 0. The information transmitted to the phone is correct. However, when I connect to my central board I always get sd_ble_gatts_hvx return value of 3401, meaning a problem with the system attributes.

I apologize if I'm missing useful information but I don't even know where the problem might lie.

I don't understand what the error even means, or why it behaves differently since it was working with the central not long ago. Any help is greatly appreciated.

  • Hi Catalina

    The sd_ble_gatts_hvx return of 3401 (BLE_ERROR_GATTS_SYS_ATTR_MISSING) is a recurring topic here on the DevZone, and we have many posts dealing with that issue. I'll link to some here, here and here. If these fail to solve your problem, you could search for BLE_ERROR_GATTS_SYS_ATTR_MISSING in the search field above, and you will likely find the solution to your problem in one of the posts.

    Due to the summer holidays in Norway, our support team is understaffed this week, and delayed replies must be expected. Sorry for the inconvenience!

    Best regards,

    Simon

  • Thank you! By reading those resources I realized that by calling sd_ble_gatts_sys_attr_set(p_cus->conn_handle, NULL, NULL, NULL) in the BLE_GAP_EVT_CONNECTED before the on_connect() call the problem is solved. I will search more thoroughly before posting next time.

Related