convert GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT

This commit is contained in:
Matthias Ringwald 2015-10-15 10:38:23 +02:00
parent ba626ec371
commit 87258ec740
3 changed files with 39 additions and 20 deletions

View File

@ -903,9 +903,31 @@ static void report_gatt_long_characteristic_value_blob(gatt_client_t * periphera
#endif
}
static void report_gatt_characteristic_descriptor(gatt_client_t * peripheral, uint16_t handle, uint8_t *value, uint16_t value_length, uint16_t value_offset, uint8_t event_type){
static void report_gatt_characteristic_descriptor(gatt_client_t * peripheral, uint16_t descriptor_handle, uint8_t *value, uint16_t value_length, uint16_t value_offset){
uint8_t * packet = setup_characteristic_value_packet(GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT, peripheral->handle, descriptor_handle, value, value_length);
emit_event_new(peripheral->subclient_id, packet, value_length + 8);
#ifdef OLD
le_characteristic_descriptor_event_t event;
event.type = event_type;
event.type = GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT;
event.handle = peripheral->handle;
le_characteristic_descriptor_t descriptor;
descriptor.handle = descriptor_handle;
descriptor.uuid16 = peripheral->uuid16;
memcpy(descriptor.uuid128, peripheral->uuid128, 16);
event.value_offset = value_offset;
event.value = value;
event.value_length = value_length;
event.characteristic_descriptor = descriptor;
emit_event(peripheral->subclient_id, (le_event_t*)&event);
#endif
}
static void report_gatt_long_characteristic_descriptor(gatt_client_t * peripheral, uint16_t handle, uint8_t *value, uint16_t value_length, uint16_t value_offset){
#ifdef OLD
le_characteristic_descriptor_event_t event;
event.type = GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT;
event.handle = peripheral->handle;
le_characteristic_descriptor_t descriptor;
@ -918,6 +940,7 @@ static void report_gatt_characteristic_descriptor(gatt_client_t * peripheral, ui
event.value_length = value_length;
event.characteristic_descriptor = descriptor;
emit_event(peripheral->subclient_id, (le_event_t*)&event);
#endif
}
static void report_gatt_all_characteristic_descriptors(gatt_client_t * peripheral, uint8_t * packet, uint16_t size, uint16_t pair_size){
@ -1376,7 +1399,7 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle,
case P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT:{
gatt_client_handle_transaction_complete(peripheral);
report_gatt_characteristic_descriptor(peripheral, peripheral->attribute_handle, &packet[1], size-1, 0, GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT);
report_gatt_characteristic_descriptor(peripheral, peripheral->attribute_handle, &packet[1], size-1, 0);
emit_gatt_complete_event(peripheral, 0);
break;
}
@ -1456,9 +1479,9 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle,
// GATT_QUERY_COMPLETE is emitted by trigger_next_xxx when done
break;
case P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT:
report_gatt_characteristic_descriptor(peripheral, peripheral->attribute_handle,
report_gatt_long_characteristic_descriptor(peripheral, peripheral->attribute_handle,
&packet[1], received_blob_length,
peripheral->attribute_offset, GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT);
peripheral->attribute_offset);
trigger_next_blob_query(peripheral, P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY, received_blob_length);
// GATT_QUERY_COMPLETE is emitted by trigger_next_xxx when done
break;

View File

@ -516,6 +516,7 @@ extern "C" {
* @format H2LV
* @param handle
* @param value_handle
* @param value_offset
* @param value_length
* @param value
*/
@ -540,16 +541,19 @@ extern "C" {
#define GATT_INDICATION 0xA8
/**
* @format HZ
* @param handle
* @param characteristic_descriptor
* @format H2LV
* @param descriptor_handle
* @param descriptor_length
* @param descriptor
*/
#define GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xA9
/**
* @format HZ
* @format H2LV
* @param handle
* @param characteristic_descriptor
* @param descriptor_offset
* @param descriptor_length
* @param descriptor
*/
#define GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xAA

View File

@ -202,29 +202,21 @@ static void handle_ble_client_event_new(uint8_t packet_type, uint8_t *packet, ui
result_counter++;
break;
case GATT_CHARACTERISTIC_VALUE_QUERY_RESULT:
case GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT:
CHECK_EQUAL(short_value_length, READ_BT_16(packet, 6));
CHECK_EQUAL_ARRAY((uint8_t*)short_value, &packet[8], short_value_length);
result_counter++;
break;
case GATT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT:{
case GATT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT:
verify_blob(READ_BT_16(packet, 8), READ_BT_16(packet, 6), &packet[10]);
result_counter++;
break;
}
}
}
static void handle_ble_client_event(le_event_t * event){
switch(event->type){
case GATT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT: {
le_characteristic_descriptor_event *descriptor_event = (le_characteristic_descriptor_event_t *) event;
CHECK_EQUAL(short_value_length, descriptor_event->value_length);
CHECK_EQUAL_ARRAY((uint8_t*)short_value, descriptor_event->value, short_value_length);
result_counter++;
break;
}
case GATT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT:{
le_characteristic_descriptor_event_t *descriptor_event = (le_characteristic_descriptor_event_t *) event;