static void ble_gatt_disc_c_test_misc_rx_rsp(struct ble_hs_conn *conn, uint16_t end_handle, struct ble_gatt_disc_c_test_char *chars) { int count; int idx; idx = 0; while (chars[idx].decl_handle != 0) { count = ble_gatt_disc_c_test_misc_rx_rsp_once(conn, chars + idx); if (count == 0) { break; } idx += count; } if (chars[idx - 1].decl_handle != end_handle) { /* Send the pending ATT Request. */ ble_hs_test_util_tx_all(); ble_hs_test_util_rx_att_err_rsp(conn, BLE_ATT_OP_READ_TYPE_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, chars[idx - 1].decl_handle); } }
static int ble_gatt_find_s_test_misc_rx_read_type( uint16_t conn_handle, struct ble_gatt_find_s_test_entry *entries) { struct ble_att_read_type_rsp rsp; uint16_t uuid16; uint8_t buf[1024]; int off; int rc; int i; memset(&rsp, 0, sizeof rsp); off = BLE_ATT_READ_TYPE_RSP_BASE_SZ; for (i = 0; entries[i].inc_handle != 0; i++) { if (rsp.batp_length == BLE_GATTS_INC_SVC_LEN_NO_UUID + 2) { break; } uuid16 = ble_uuid_128_to_16(entries[i].uuid128); if (uuid16 == 0) { if (rsp.batp_length != 0) { break; } rsp.batp_length = BLE_GATTS_INC_SVC_LEN_NO_UUID + 2; } else { rsp.batp_length = BLE_GATTS_INC_SVC_LEN_UUID + 2; } TEST_ASSERT_FATAL(off + rsp.batp_length <= sizeof buf); htole16(buf + off, entries[i].inc_handle); off += 2; htole16(buf + off, entries[i].start_handle); off += 2; htole16(buf + off, entries[i].end_handle); off += 2; if (uuid16 != 0) { htole16(buf + off, uuid16); off += 2; } } if (i == 0) { ble_hs_test_util_rx_att_err_rsp(conn_handle, BLE_ATT_OP_READ_TYPE_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, 0); return 0; } ble_att_read_type_rsp_write(buf + 0, BLE_ATT_READ_TYPE_RSP_BASE_SZ, &rsp); rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, off); TEST_ASSERT(rc == 0); return i; }