gatt_client: add service and connection id to long reads

This commit is contained in:
Matthias Ringwald 2024-08-27 11:43:38 +02:00
parent 691e02c222
commit b641e2af2d
3 changed files with 57 additions and 15 deletions

View File

@ -1048,8 +1048,8 @@ setup_characteristic_value_packet(const gatt_client_t *gatt_client, uint8_t type
} }
// @return packet pointer // @return packet pointer
// @note assume that value is part of an l2cap buffer - overwrite parts of the HCI/L2CAP/ATT packet (4/4/3) bytes // @note assume that value is part of an l2cap buffer - overwrite HCI + L2CAP packet headers + 6 pre_buffer bytes
#define LONG_CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE 10 #define LONG_CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE 14
// L2CAP Header (4) + ACL Header (4) => 8 bytes // L2CAP Header (4) + ACL Header (4) => 8 bytes
#if !defined(HCI_INCOMING_PRE_BUFFER_SIZE) || ((HCI_INCOMING_PRE_BUFFER_SIZE < LONG_CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE - 8)) #if !defined(HCI_INCOMING_PRE_BUFFER_SIZE) || ((HCI_INCOMING_PRE_BUFFER_SIZE < LONG_CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE - 8))
@ -1071,9 +1071,11 @@ setup_long_characteristic_value_packet(const gatt_client_t *gatt_client, uint8_t
packet[0] = type; packet[0] = type;
packet[1] = LONG_CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE - 2 + length; packet[1] = LONG_CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE - 2 + length;
little_endian_store_16(packet, 2, gatt_client->con_handle); little_endian_store_16(packet, 2, gatt_client->con_handle);
little_endian_store_16(packet, 4, attribute_handle); little_endian_store_16(packet, 4, gatt_client->service_id);
little_endian_store_16(packet, 6, offset); little_endian_store_16(packet, 6, gatt_client->connection_id);
little_endian_store_16(packet, 8, length); little_endian_store_16(packet, 8, attribute_handle);
little_endian_store_16(packet, 10, offset);
little_endian_store_16(packet, 12, length);
return packet; return packet;
} }

View File

@ -1478,8 +1478,10 @@ typedef uint8_t sm_key_t[16];
#define GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT 0xA5u #define GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT 0xA5u
/** /**
* @format H22LV * @format H2222LV
* @param handle * @param handle
* @param service_id
* @param connection_id
* @param value_handle * @param value_handle
* @param value_offset * @param value_offset
* @param value_length * @param value_length
@ -1515,8 +1517,10 @@ typedef uint8_t sm_key_t[16];
#define GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xA9u #define GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT 0xA9u
/** /**
* @format H22LV * @format H2222LV
* @param handle * @param handle
* @param service_id
* @param connection_id
* @param descriptor_handle * @param descriptor_handle
* @param descriptor_offset * @param descriptor_offset
* @param descriptor_length * @param descriptor_length

View File

@ -2912,6 +2912,24 @@ static inline const uint8_t * gatt_event_characteristic_value_query_result_get_v
static inline hci_con_handle_t gatt_event_long_characteristic_value_query_result_get_handle(const uint8_t * event){ static inline hci_con_handle_t gatt_event_long_characteristic_value_query_result_get_handle(const uint8_t * event){
return little_endian_read_16(event, 2); return little_endian_read_16(event, 2);
} }
/**
* @brief Get field service_id from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT
* @param event packet
* @return service_id
* @note: btstack_type 2
*/
static inline uint16_t gatt_event_long_characteristic_value_query_result_get_service_id(const uint8_t * event){
return little_endian_read_16(event, 4);
}
/**
* @brief Get field connection_id from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT
* @param event packet
* @return connection_id
* @note: btstack_type 2
*/
static inline uint16_t gatt_event_long_characteristic_value_query_result_get_connection_id(const uint8_t * event){
return little_endian_read_16(event, 6);
}
/** /**
* @brief Get field value_handle from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT * @brief Get field value_handle from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT
* @param event packet * @param event packet
@ -2919,7 +2937,7 @@ static inline hci_con_handle_t gatt_event_long_characteristic_value_query_result
* @note: btstack_type 2 * @note: btstack_type 2
*/ */
static inline uint16_t gatt_event_long_characteristic_value_query_result_get_value_handle(const uint8_t * event){ static inline uint16_t gatt_event_long_characteristic_value_query_result_get_value_handle(const uint8_t * event){
return little_endian_read_16(event, 4); return little_endian_read_16(event, 8);
} }
/** /**
* @brief Get field value_offset from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT * @brief Get field value_offset from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT
@ -2928,7 +2946,7 @@ static inline uint16_t gatt_event_long_characteristic_value_query_result_get_val
* @note: btstack_type 2 * @note: btstack_type 2
*/ */
static inline uint16_t gatt_event_long_characteristic_value_query_result_get_value_offset(const uint8_t * event){ static inline uint16_t gatt_event_long_characteristic_value_query_result_get_value_offset(const uint8_t * event){
return little_endian_read_16(event, 6); return little_endian_read_16(event, 10);
} }
/** /**
* @brief Get field value_length from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT * @brief Get field value_length from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT
@ -2937,7 +2955,7 @@ static inline uint16_t gatt_event_long_characteristic_value_query_result_get_val
* @note: btstack_type L * @note: btstack_type L
*/ */
static inline uint16_t gatt_event_long_characteristic_value_query_result_get_value_length(const uint8_t * event){ static inline uint16_t gatt_event_long_characteristic_value_query_result_get_value_length(const uint8_t * event){
return little_endian_read_16(event, 8); return little_endian_read_16(event, 12);
} }
/** /**
* @brief Get field value from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT * @brief Get field value from event GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT
@ -2946,7 +2964,7 @@ static inline uint16_t gatt_event_long_characteristic_value_query_result_get_val
* @note: btstack_type V * @note: btstack_type V
*/ */
static inline const uint8_t * gatt_event_long_characteristic_value_query_result_get_value(const uint8_t * event){ static inline const uint8_t * gatt_event_long_characteristic_value_query_result_get_value(const uint8_t * event){
return &event[10]; return &event[14];
} }
#endif #endif
@ -3077,6 +3095,24 @@ static inline const uint8_t * gatt_event_characteristic_descriptor_query_result_
static inline hci_con_handle_t gatt_event_long_characteristic_descriptor_query_result_get_handle(const uint8_t * event){ static inline hci_con_handle_t gatt_event_long_characteristic_descriptor_query_result_get_handle(const uint8_t * event){
return little_endian_read_16(event, 2); return little_endian_read_16(event, 2);
} }
/**
* @brief Get field service_id from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
* @param event packet
* @return service_id
* @note: btstack_type 2
*/
static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_get_service_id(const uint8_t * event){
return little_endian_read_16(event, 4);
}
/**
* @brief Get field connection_id from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
* @param event packet
* @return connection_id
* @note: btstack_type 2
*/
static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_get_connection_id(const uint8_t * event){
return little_endian_read_16(event, 6);
}
/** /**
* @brief Get field descriptor_handle from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT * @brief Get field descriptor_handle from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
* @param event packet * @param event packet
@ -3084,7 +3120,7 @@ static inline hci_con_handle_t gatt_event_long_characteristic_descriptor_query_r
* @note: btstack_type 2 * @note: btstack_type 2
*/ */
static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_get_descriptor_handle(const uint8_t * event){ static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_get_descriptor_handle(const uint8_t * event){
return little_endian_read_16(event, 4); return little_endian_read_16(event, 8);
} }
/** /**
* @brief Get field descriptor_offset from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT * @brief Get field descriptor_offset from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
@ -3093,7 +3129,7 @@ static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_ge
* @note: btstack_type 2 * @note: btstack_type 2
*/ */
static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_get_descriptor_offset(const uint8_t * event){ static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_get_descriptor_offset(const uint8_t * event){
return little_endian_read_16(event, 6); return little_endian_read_16(event, 10);
} }
/** /**
* @brief Get field descriptor_length from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT * @brief Get field descriptor_length from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
@ -3102,7 +3138,7 @@ static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_ge
* @note: btstack_type L * @note: btstack_type L
*/ */
static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_get_descriptor_length(const uint8_t * event){ static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_get_descriptor_length(const uint8_t * event){
return little_endian_read_16(event, 8); return little_endian_read_16(event, 12);
} }
/** /**
* @brief Get field descriptor from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT * @brief Get field descriptor from event GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
@ -3111,7 +3147,7 @@ static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_ge
* @note: btstack_type V * @note: btstack_type V
*/ */
static inline const uint8_t * gatt_event_long_characteristic_descriptor_query_result_get_descriptor(const uint8_t * event){ static inline const uint8_t * gatt_event_long_characteristic_descriptor_query_result_get_descriptor(const uint8_t * event){
return &event[10]; return &event[14];
} }
#endif #endif