SDK 17.1.0
nRF52840 DK central + nRF52840 peripheral device
Hello,
I'm attempting to set up reading characteristic values on the nRF52840 DK as a central from a peripheral device which is a nRF52840 module with a SHT40 temperature and humidity sensor. I've set up a custom service on the peripheral with 3 characteristics for temperature, humidity, and battery voltage. So far, using examples from the SDK ble_central and posts on this forum, I have managed to scan, connect, complete discovery, and read a single characteristic (temperature). I'm currently using sd_ble_gattc_char_value_by_uuid_read()
I'd like to read all three characteristics and haven't figured out how to accomplish this other than to sequence through several sd_ble_gattc_char_value_by_uuid_read() and BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP events.
I've noticed that there is a handle-value pair count in ble_gattc_evt_char_val_by_uuid_read_rsp_t. Can this somehow be used to read all 3 characteristics? If so, how do I differentiate between the handle-value pairs?
I'm not sure how to launch reading all three characteristics either. My read routine now looks like:
void read_sensor_temp(void)
{
ret_code_t err_code;
ble_uuid_t m_temp_uuid;
m_temp_uuid.type = BLE_UUID_TYPE_VENDOR_BEGIN;
m_temp_uuid.uuid = BLE_UUID_sht40_TEMP_CHARACTERISTIC;
ble_gattc_handle_range_t m_handle_range;
m_handle_range.start_handle = 0x0001;
m_handle_range.end_handle = 0xFFFF;
temp_read = true;
err_code = sd_ble_gattc_char_value_by_uuid_read(m_ble_sht40_c.conn_handle, &m_temp_uuid, &m_handle_range);
APP_ERROR_CHECK(err_code);
}
I know from the forum and examples that using notify is usually used to send characteristic data. However I've targeted the sensor as a battery operated device and I do not want to remain connected. I just want to periodically read the data placed in the characteristics and being slow moving temperature and humidity it's not time critical. I'm hoping to connect, read the data, and disconnect periodically.
Any guidance you can provide much appreciated.
Thanks,
Max