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

Read custom characteristics value in multilink example [central]

Hello!

I have a problem with getting a value (uint8_t) from a characteristics.

I am using 2 nrf51422 boards, where one is a central and the other is a peripheral. I have modified the multilink example (peripheral) to make an additional characteristic that holds a value that I would like to read at the central unit. How do I do this?

From several posts here at the forum I found something about BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP... but I am not quite sure if that is the right way, and if so where and how to use it.

Help would be much appreciated.

/Christian

Parents
  • Please have a look at this question.

    If you have the attribute handle of the characteristic value that you want to read you should use sd_ble_gattc_read().

  • I'm guessing that you only get the BLE_GATTC_EVT_CHAR_DISC_RSP event once, and because of this sd_ble_gattc_read() is only called once. You can call sd_ble_gattc_read() again when you get the BLE_GATTC_EVT_READ_RSP event. Then it would repeat itself, but you need to make sure that sd_ble_gattc_read() returns NRF_SUCCESS or 0x00000000. If it returns something else, you will not get the BLE_GATTC_EVT_READ_RSP event.

    Notifications are initiated by the server, or peripheral in your case, by calling sd_ble_gatts_hvx() in the server application. Then you will get the BLE_GATTC_EVT_HVX event in the client application. For the server to be able to send notifications, the client first has to enable them by writing 0x0001 to the CCCD of the characteristic you want to send notifications from. In client_handling.c this is done by notif_enable().

Reply
  • I'm guessing that you only get the BLE_GATTC_EVT_CHAR_DISC_RSP event once, and because of this sd_ble_gattc_read() is only called once. You can call sd_ble_gattc_read() again when you get the BLE_GATTC_EVT_READ_RSP event. Then it would repeat itself, but you need to make sure that sd_ble_gattc_read() returns NRF_SUCCESS or 0x00000000. If it returns something else, you will not get the BLE_GATTC_EVT_READ_RSP event.

    Notifications are initiated by the server, or peripheral in your case, by calling sd_ble_gatts_hvx() in the server application. Then you will get the BLE_GATTC_EVT_HVX event in the client application. For the server to be able to send notifications, the client first has to enable them by writing 0x0001 to the CCCD of the characteristic you want to send notifications from. In client_handling.c this is done by notif_enable().

Children
No Data
Related