How to read from a characteristic which does not have a notify characteristic property?

Hi,

I am not sure how to read from a characteristic which doesnt have notify property in them. I started looking into nrf_ble_gq_item_add() But I am not sure on what parameters to pass to this function to read from my characterstic.

Is there any example code where I can look into this type of reading without notification?

I am using SDK version 17.1.0

Thank you in advance,

Vinayaka

Parents
  • Hi Vinayaka,

    You can use sd_ble_gattc_read() as illustrated by the message sequence chart "GATTC Characteristic or Descriptor Value Read". There aren't any GATT client implementations in the SDK that use this function. Grepping through the SDK only gave me the following results:

    examples/ble_central_and_peripheral/experimental/ble_app_interactive/cli_m.c:    err_code = sd_ble_gattc_read(conn_handle, val_handle, 0);
    examples/ble_central_and_peripheral/experimental/ble_app_interactive/ble_m.c:                err_code = sd_ble_gattc_read(conn_handle, p_service[i].handle_range.start_handle, 0);
    examples/ble_central_and_peripheral/experimental/ble_app_interactive/ble_m.c:                err_code = sd_ble_gattc_read(conn_handle, m_srv_char.char_data[i].decl_handle, 0);
    examples/ble_central_and_peripheral/experimental/ble_app_interactive/ble_m.c:                err_code = sd_ble_gattc_read(conn_handle, mp_device_srv[conn_handle]->services[i].handle_range.start_handle, 0);
    examples/ble_central_and_peripheral/experimental/ble_app_interactive/ble_m.c:                err_code = sd_ble_gattc_read(conn_handle, m_srv_char.char_data[i].decl_handle, 0);
    components/ble/nrf_ble_gq/nrf_ble_gq.c:                err_code = sd_ble_gattc_read(conn_handle,
    components/ble/nrf_ble_gq/nrf_ble_gq.c:            err_code = sd_ble_gattc_read(conn_handle,
    components/ble/peer_manager/gatt_cache_manager.c:                    ret_code_t err_code = sd_ble_gattc_read(conn_handle, *(uint16_t*)p_val->handle_value, 0);
    components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c:/**@brief Command response callback function for @ref sd_ble_gattc_read BLE command.
    components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c:#ifndef _sd_ble_gattc_read
    components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c:#define _sd_ble_gattc_read sd_ble_gattc_read
    components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c:uint32_t _sd_ble_gattc_read(uint16_t conn_handle,
    components/serialization/connectivity/codecs/ble/middleware/conn_mw_ble_gattc.c:    sd_err_code = sd_ble_gattc_read(conn_handle, handle, offset);
    

    The key thing is to find the attribute handle value you want to read from. This is found during the Service discovery procedure.

    Best regards,

    Vidar

Reply
  • Hi Vinayaka,

    You can use sd_ble_gattc_read() as illustrated by the message sequence chart "GATTC Characteristic or Descriptor Value Read". There aren't any GATT client implementations in the SDK that use this function. Grepping through the SDK only gave me the following results:

    examples/ble_central_and_peripheral/experimental/ble_app_interactive/cli_m.c:    err_code = sd_ble_gattc_read(conn_handle, val_handle, 0);
    examples/ble_central_and_peripheral/experimental/ble_app_interactive/ble_m.c:                err_code = sd_ble_gattc_read(conn_handle, p_service[i].handle_range.start_handle, 0);
    examples/ble_central_and_peripheral/experimental/ble_app_interactive/ble_m.c:                err_code = sd_ble_gattc_read(conn_handle, m_srv_char.char_data[i].decl_handle, 0);
    examples/ble_central_and_peripheral/experimental/ble_app_interactive/ble_m.c:                err_code = sd_ble_gattc_read(conn_handle, mp_device_srv[conn_handle]->services[i].handle_range.start_handle, 0);
    examples/ble_central_and_peripheral/experimental/ble_app_interactive/ble_m.c:                err_code = sd_ble_gattc_read(conn_handle, m_srv_char.char_data[i].decl_handle, 0);
    components/ble/nrf_ble_gq/nrf_ble_gq.c:                err_code = sd_ble_gattc_read(conn_handle,
    components/ble/nrf_ble_gq/nrf_ble_gq.c:            err_code = sd_ble_gattc_read(conn_handle,
    components/ble/peer_manager/gatt_cache_manager.c:                    ret_code_t err_code = sd_ble_gattc_read(conn_handle, *(uint16_t*)p_val->handle_value, 0);
    components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c:/**@brief Command response callback function for @ref sd_ble_gattc_read BLE command.
    components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c:#ifndef _sd_ble_gattc_read
    components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c:#define _sd_ble_gattc_read sd_ble_gattc_read
    components/serialization/application/codecs/ble/middleware/app_mw_ble_gattc.c:uint32_t _sd_ble_gattc_read(uint16_t conn_handle,
    components/serialization/connectivity/codecs/ble/middleware/conn_mw_ble_gattc.c:    sd_err_code = sd_ble_gattc_read(conn_handle, handle, offset);
    

    The key thing is to find the attribute handle value you want to read from. This is found during the Service discovery procedure.

    Best regards,

    Vidar

Children
Related