This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Does NCS ble api thread safe?

Hi Nordic,

We are using NRF52840 and the NCS sdk to design a new product which may have multiple threads designed. And each thread may need to do some BLE operation at the same time or not the same time. 

For example, I registerred a GATT service (A) with a Characterstic (B) which has the notification property. If threads I, II, and III need to send notification of B at the same time. Do I need add a semphore to protect the bt_gatt_notify just like the following code shown?



int jss_send_notfiy(struct bt_conn *conn, uint8_t* p_send, uint16_t len)
{

  int rc;

  k_sem_take(...,K_FOREVER); // Do I need the 2 steps to protect the BLE API in zephyr
  rc = bt_gatt_notify(conn, &jss_svc.attrs[1], p_send, len);
  k_sem_give(...);
  return rc == -ENOTCONN ? 0 : rc;
}

Parents Reply Children
No Data
Related