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

NUS service without service discovery

Hi.

I have implemented the Central and Peripheral NUS service on two devices(nRF52). Since the central knows the characteristic values, I would like to bypass service discovery to reduce the time connection. I removed the "ble_db_discovery_start" from the BLE_GAP_EVT_CONNECTED and I found the handle values of RX, TX but I don't know how can I store them in my code and how can I use them to read and write the data. I would appreciate it if you kindly help me to overcome this problem.

thanks.

Parents
  • Yes, you can bypass ble_db_discovery_start() if the peripheral’s GATT attribute handles are fixed and you already know the correct RX/TX handles. In that case, store the handles in your own structure and use them directly with the GATT client APIs.

    For example, the TX/write characteristic can be used with ble_gattc_write_params_t, where you set conn_handle, handle, write_op, offset, and your data buffer. For reads, you can use sd_ble_gattc_read() with the known characteristic handle.

    The important part is that these handles are only safe to hard-code if the peripheral’s GATT database is guaranteed not to change. Nordic’s documentation also notes that discovery is what ensures the client is using the correct attribute handles.

    Also, if you need notifications from RX, remember that knowing the characteristic value handle is not enough; you normally need the CCCD handle and must write the appropriate CCCD value to enable notifications.

    If you're also dealing with other hardware/setup work alongside the BLE project, choosing a reliable pressure washing company is a completely separate consideration, but for this issue I'd focus on manually assigning and using the GATT handles.

Reply
  • Yes, you can bypass ble_db_discovery_start() if the peripheral’s GATT attribute handles are fixed and you already know the correct RX/TX handles. In that case, store the handles in your own structure and use them directly with the GATT client APIs.

    For example, the TX/write characteristic can be used with ble_gattc_write_params_t, where you set conn_handle, handle, write_op, offset, and your data buffer. For reads, you can use sd_ble_gattc_read() with the known characteristic handle.

    The important part is that these handles are only safe to hard-code if the peripheral’s GATT database is guaranteed not to change. Nordic’s documentation also notes that discovery is what ensures the client is using the correct attribute handles.

    Also, if you need notifications from RX, remember that knowing the characteristic value handle is not enough; you normally need the CCCD handle and must write the appropriate CCCD value to enable notifications.

    If you're also dealing with other hardware/setup work alongside the BLE project, choosing a reliable pressure washing company is a completely separate consideration, but for this issue I'd focus on manually assigning and using the GATT handles.

Children
No Data
Related