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().

  • Hi Petter, thank you for the respond.

    I've looked at the post you linked me and I have tried to implement it.

    In the client_handling.c file in the client_handling_ble_evt_handler() function i have made to new cases:

    case BLE_GATTC_EVT_CHAR_DISC_RSP: sd_ble_gattc_read(p_ble_evt->evt.gatts_evt.conn_handle,0x0000,0); break;

    case BLE_GATTC_EVT_READ_RSP: //DEBUG z = p_ble_evt->evt.gattc_evt.params.char_disc_rsp.chars[index].handle_value; z = p_client->client_acc_z_value; char buffer[20]; sprintf(buffer,"Value is: %d\n\r",z); debug_printf(buffer); break;

    I get one reading in my UART terminal, so my question is why does this only occur once? And how could I make it repeat it self? I want continuous reading as the value from the peripheral is changing.

    I have set the peripheral characteristic up to notify, so maybe I could utilize that?

    Thank you!

Reply
  • Hi Petter, thank you for the respond.

    I've looked at the post you linked me and I have tried to implement it.

    In the client_handling.c file in the client_handling_ble_evt_handler() function i have made to new cases:

    case BLE_GATTC_EVT_CHAR_DISC_RSP: sd_ble_gattc_read(p_ble_evt->evt.gatts_evt.conn_handle,0x0000,0); break;

    case BLE_GATTC_EVT_READ_RSP: //DEBUG z = p_ble_evt->evt.gattc_evt.params.char_disc_rsp.chars[index].handle_value; z = p_client->client_acc_z_value; char buffer[20]; sprintf(buffer,"Value is: %d\n\r",z); debug_printf(buffer); break;

    I get one reading in my UART terminal, so my question is why does this only occur once? And how could I make it repeat it self? I want continuous reading as the value from the peripheral is changing.

    I have set the peripheral characteristic up to notify, so maybe I could utilize that?

    Thank you!

Children
No Data
Related