mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 10:21:49 +00:00
gatt_client: add service and connection id to regular reads, notify + indicate
This commit is contained in:
parent
b641e2af2d
commit
f6a28e2542
@ -1026,8 +1026,8 @@ static void gatt_client_handle_transaction_complete(gatt_client_t *gatt_client,
|
||||
}
|
||||
|
||||
// @return packet pointer
|
||||
// @note assume that value is part of an l2cap buffer - overwrite HCI + L2CAP packet headers
|
||||
#define CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE 8
|
||||
// @note assume that value is part of an l2cap buffer - overwrite HCI + L2CAP packet headers + 4 pre_buffer bytes
|
||||
#define CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE 12
|
||||
static uint8_t *
|
||||
setup_characteristic_value_packet(const gatt_client_t *gatt_client, uint8_t type, uint16_t attribute_handle,
|
||||
uint8_t *value, uint16_t length) {
|
||||
@ -1042,8 +1042,10 @@ setup_characteristic_value_packet(const gatt_client_t *gatt_client, uint8_t type
|
||||
packet[0] = type;
|
||||
packet[1] = CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE - 2 + length;
|
||||
little_endian_store_16(packet, 2, gatt_client->con_handle);
|
||||
little_endian_store_16(packet, 4, attribute_handle);
|
||||
little_endian_store_16(packet, 6, length);
|
||||
little_endian_store_16(packet, 4, gatt_client->service_id);
|
||||
little_endian_store_16(packet, 6, gatt_client->connection_id);
|
||||
little_endian_store_16(packet, 8, attribute_handle);
|
||||
little_endian_store_16(packet, 10, length);
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
@ -1469,8 +1469,10 @@ typedef uint8_t sm_key_t[16];
|
||||
#define GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT 0xA4u
|
||||
|
||||
/**
|
||||
* @format H2LV
|
||||
* @format H222LV
|
||||
* @param handle
|
||||
* @param service_id
|
||||
* @param connection_id
|
||||
* @param value_handle
|
||||
* @param value_length
|
||||
* @param value
|
||||
@ -1490,8 +1492,10 @@ typedef uint8_t sm_key_t[16];
|
||||
#define GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT 0xA6u
|
||||
|
||||
/**
|
||||
* @format H2LV
|
||||
* @format H222LV
|
||||
* @param handle
|
||||
* @param service_id
|
||||
* @param connection_id
|
||||
* @param value_handle
|
||||
* @param value_length
|
||||
* @param value
|
||||
@ -1499,8 +1503,10 @@ typedef uint8_t sm_key_t[16];
|
||||
#define GATT_EVENT_NOTIFICATION 0xA7u
|
||||
|
||||
/**
|
||||
* @format H2LV
|
||||
* @format H222LV
|
||||
* @param handle
|
||||
* @param service_id
|
||||
* @param connection_id
|
||||
* @param value_handle
|
||||
* @param value_length
|
||||
* @param value
|
||||
@ -1508,8 +1514,10 @@ typedef uint8_t sm_key_t[16];
|
||||
#define GATT_EVENT_INDICATION 0xA8u
|
||||
|
||||
/**
|
||||
* @format H2LV
|
||||
* @format H222LV
|
||||
* @param handle
|
||||
* @param service_id
|
||||
* @param connection_id
|
||||
* @param descriptor_handle
|
||||
* @param descriptor_length
|
||||
* @param descriptor
|
||||
|
@ -2873,6 +2873,24 @@ static inline void gatt_event_all_characteristic_descriptors_query_result_get_ch
|
||||
static inline hci_con_handle_t gatt_event_characteristic_value_query_result_get_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 2);
|
||||
}
|
||||
/**
|
||||
* @brief Get field service_id from event GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT
|
||||
* @param event packet
|
||||
* @return service_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_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_CHARACTERISTIC_VALUE_QUERY_RESULT
|
||||
* @param event packet
|
||||
* @return connection_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_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_CHARACTERISTIC_VALUE_QUERY_RESULT
|
||||
* @param event packet
|
||||
@ -2880,7 +2898,7 @@ static inline hci_con_handle_t gatt_event_characteristic_value_query_result_get_
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_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_length from event GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT
|
||||
@ -2889,7 +2907,7 @@ static inline uint16_t gatt_event_characteristic_value_query_result_get_value_ha
|
||||
* @note: btstack_type L
|
||||
*/
|
||||
static inline uint16_t gatt_event_characteristic_value_query_result_get_value_length(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
return little_endian_read_16(event, 10);
|
||||
}
|
||||
/**
|
||||
* @brief Get field value from event GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT
|
||||
@ -2898,7 +2916,7 @@ static inline uint16_t gatt_event_characteristic_value_query_result_get_value_le
|
||||
* @note: btstack_type V
|
||||
*/
|
||||
static inline const uint8_t * gatt_event_characteristic_value_query_result_get_value(const uint8_t * event){
|
||||
return &event[8];
|
||||
return &event[12];
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2978,6 +2996,24 @@ static inline const uint8_t * gatt_event_long_characteristic_value_query_result_
|
||||
static inline hci_con_handle_t gatt_event_notification_get_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 2);
|
||||
}
|
||||
/**
|
||||
* @brief Get field service_id from event GATT_EVENT_NOTIFICATION
|
||||
* @param event packet
|
||||
* @return service_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_notification_get_service_id(const uint8_t * event){
|
||||
return little_endian_read_16(event, 4);
|
||||
}
|
||||
/**
|
||||
* @brief Get field connection_id from event GATT_EVENT_NOTIFICATION
|
||||
* @param event packet
|
||||
* @return connection_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_notification_get_connection_id(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
}
|
||||
/**
|
||||
* @brief Get field value_handle from event GATT_EVENT_NOTIFICATION
|
||||
* @param event packet
|
||||
@ -2985,7 +3021,7 @@ static inline hci_con_handle_t gatt_event_notification_get_handle(const uint8_t
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_notification_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_length from event GATT_EVENT_NOTIFICATION
|
||||
@ -2994,7 +3030,7 @@ static inline uint16_t gatt_event_notification_get_value_handle(const uint8_t *
|
||||
* @note: btstack_type L
|
||||
*/
|
||||
static inline uint16_t gatt_event_notification_get_value_length(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
return little_endian_read_16(event, 10);
|
||||
}
|
||||
/**
|
||||
* @brief Get field value from event GATT_EVENT_NOTIFICATION
|
||||
@ -3003,7 +3039,7 @@ static inline uint16_t gatt_event_notification_get_value_length(const uint8_t *
|
||||
* @note: btstack_type V
|
||||
*/
|
||||
static inline const uint8_t * gatt_event_notification_get_value(const uint8_t * event){
|
||||
return &event[8];
|
||||
return &event[12];
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3017,6 +3053,24 @@ static inline const uint8_t * gatt_event_notification_get_value(const uint8_t *
|
||||
static inline hci_con_handle_t gatt_event_indication_get_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 2);
|
||||
}
|
||||
/**
|
||||
* @brief Get field service_id from event GATT_EVENT_INDICATION
|
||||
* @param event packet
|
||||
* @return service_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_indication_get_service_id(const uint8_t * event){
|
||||
return little_endian_read_16(event, 4);
|
||||
}
|
||||
/**
|
||||
* @brief Get field connection_id from event GATT_EVENT_INDICATION
|
||||
* @param event packet
|
||||
* @return connection_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_indication_get_connection_id(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
}
|
||||
/**
|
||||
* @brief Get field value_handle from event GATT_EVENT_INDICATION
|
||||
* @param event packet
|
||||
@ -3024,7 +3078,7 @@ static inline hci_con_handle_t gatt_event_indication_get_handle(const uint8_t *
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_indication_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_length from event GATT_EVENT_INDICATION
|
||||
@ -3033,7 +3087,7 @@ static inline uint16_t gatt_event_indication_get_value_handle(const uint8_t * ev
|
||||
* @note: btstack_type L
|
||||
*/
|
||||
static inline uint16_t gatt_event_indication_get_value_length(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
return little_endian_read_16(event, 10);
|
||||
}
|
||||
/**
|
||||
* @brief Get field value from event GATT_EVENT_INDICATION
|
||||
@ -3042,7 +3096,7 @@ static inline uint16_t gatt_event_indication_get_value_length(const uint8_t * ev
|
||||
* @note: btstack_type V
|
||||
*/
|
||||
static inline const uint8_t * gatt_event_indication_get_value(const uint8_t * event){
|
||||
return &event[8];
|
||||
return &event[12];
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3056,6 +3110,24 @@ static inline const uint8_t * gatt_event_indication_get_value(const uint8_t * ev
|
||||
static inline hci_con_handle_t gatt_event_characteristic_descriptor_query_result_get_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 2);
|
||||
}
|
||||
/**
|
||||
* @brief Get field service_id from event GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
|
||||
* @param event packet
|
||||
* @return service_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_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_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
|
||||
* @param event packet
|
||||
* @return connection_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_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_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
|
||||
* @param event packet
|
||||
@ -3063,7 +3135,7 @@ static inline hci_con_handle_t gatt_event_characteristic_descriptor_query_result
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t gatt_event_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_length from event GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
|
||||
@ -3072,7 +3144,7 @@ static inline uint16_t gatt_event_characteristic_descriptor_query_result_get_des
|
||||
* @note: btstack_type L
|
||||
*/
|
||||
static inline uint16_t gatt_event_characteristic_descriptor_query_result_get_descriptor_length(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
return little_endian_read_16(event, 10);
|
||||
}
|
||||
/**
|
||||
* @brief Get field descriptor from event GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT
|
||||
@ -3081,7 +3153,7 @@ static inline uint16_t gatt_event_characteristic_descriptor_query_result_get_des
|
||||
* @note: btstack_type V
|
||||
*/
|
||||
static inline const uint8_t * gatt_event_characteristic_descriptor_query_result_get_descriptor(const uint8_t * event){
|
||||
return &event[8];
|
||||
return &event[12];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user