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

ble_nus_c possible bug

Hi

we are working on ble_nus_c multilink implementation and had problems when more than 1 server is connected: we've noticed that data get mixed between servers.

when I tried to debug, I noticed that sometimes, under on_hvx function, I get 2 calls: one is OK and on the second one p_ble_evt->evt.gap_evt.conn_handle is invalid, while p_ble_nus_c->conn_handle stays the same as the previous call.

diving a bit into the ble_nus_c.c code, I found the following lines under ble_nus_c_on_ble_evt:

    if ( (p_ble_nus_c->conn_handle != BLE_CONN_HANDLE_INVALID) 
       &&(p_ble_nus_c->conn_handle != p_ble_evt->evt.gap_evt.conn_handle)
       )
    {
        return;
    }

my question is: shouldn't it be:

    if ( (p_ble_nus_c->conn_handle == BLE_CONN_HANDLE_INVALID) 
       || (p_ble_nus_c->conn_handle != p_ble_evt->evt.gap_evt.conn_handle)
       )
    {
        return;
    }

changing to the second solved our problems...

thanks

Related