mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 11:42:34 +00:00
util.h: new names uuid_has_bluetooth_prefix();uuid_add_bluetooth_prefix()
This commit is contained in:
parent
058e3d6b6b
commit
e1a125df32
@ -143,7 +143,7 @@ static void extract_service(le_service_t * service, uint8_t * packet){
|
||||
service->end_group_handle = little_endian_read_16(packet, 6);
|
||||
service->uuid16 = 0;
|
||||
swap128(&packet[8], service->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(service->uuid128)){
|
||||
service->uuid16 = big_endian_read_32(service->uuid128, 0);
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ static void extract_characteristic(le_characteristic_t * characteristic, uint8_t
|
||||
characteristic->properties = little_endian_read_16(packet, 10);
|
||||
characteristic->uuid16 = 0;
|
||||
swap128(&packet[12], characteristic->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(characteristic->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(characteristic->uuid128)){
|
||||
characteristic->uuid16 = big_endian_read_32(characteristic->uuid128, 0);
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ static void extract_service(le_service_t * service, uint8_t * packet){
|
||||
service->end_group_handle = little_endian_read_16(packet, 6);
|
||||
service->uuid16 = 0;
|
||||
swap128(&packet[8], service->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(service->uuid128)){
|
||||
service->uuid16 = big_endian_read_32(service->uuid128, 0);
|
||||
}
|
||||
}
|
||||
@ -257,7 +257,7 @@ static void extract_characteristic(le_characteristic_t * characteristic, uint8_t
|
||||
characteristic->properties = little_endian_read_16(packet, 10);
|
||||
characteristic->uuid16 = 0;
|
||||
swap128(&packet[12], characteristic->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(characteristic->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(characteristic->uuid128)){
|
||||
characteristic->uuid16 = big_endian_read_32(characteristic->uuid128, 0);
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ static void extract_service(le_service_t * service, uint8_t * packet){
|
||||
service->end_group_handle = little_endian_read_16(packet, 6);
|
||||
service->uuid16 = 0;
|
||||
swap128(&packet[8], service->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(service->uuid128)){
|
||||
service->uuid16 = big_endian_read_32(service->uuid128, 0);
|
||||
}
|
||||
}
|
||||
@ -210,7 +210,7 @@ static void extract_characteristic(le_characteristic_t * characteristic, uint8_t
|
||||
characteristic->properties = little_endian_read_16(packet, 10);
|
||||
characteristic->uuid16 = 0;
|
||||
swap128(&packet[12], characteristic->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(characteristic->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(characteristic->uuid128)){
|
||||
characteristic->uuid16 = big_endian_read_32(characteristic->uuid128, 0);
|
||||
}
|
||||
}
|
||||
@ -330,7 +330,7 @@ UUID::UUID(const char * uuidStr){
|
||||
uint16_t uuid16;
|
||||
int result = sscanf( (char *) uuidStr, "%x", &uuid16);
|
||||
if (result == 1){
|
||||
sdp_normalize_uuid(uuid, uuid16);
|
||||
uuid_add_bluetooth_prefix(uuid, uuid16);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -359,8 +359,8 @@ const uint8_t * UUID::getUuid(void) const {
|
||||
|
||||
static char uuid16_buffer[5];
|
||||
const char * UUID::getUuidString() const {
|
||||
// TODO: fix sdp_has_blueooth_base_uuid call to use const
|
||||
if (sdp_has_blueooth_base_uuid((uint8_t*)uuid)){
|
||||
// TODO: fix uuid_has_bluetooth_prefix call to use const
|
||||
if (uuid_has_bluetooth_prefix((uint8_t*)uuid)){
|
||||
sprintf(uuid16_buffer, "%04x", (uint16_t) big_endian_read_32(uuid, 0));
|
||||
return uuid16_buffer;
|
||||
} else {
|
||||
|
@ -108,7 +108,7 @@ int ad_data_contains_uuid16(uint8_t ad_len, uint8_t * ad_data, uint16_t uuid16){
|
||||
break;
|
||||
case IncompleteList128:
|
||||
case CompleteList128:
|
||||
sdp_normalize_uuid(ad_uuid128, uuid16);
|
||||
uuid_add_bluetooth_prefix(ad_uuid128, uuid16);
|
||||
swap128(ad_uuid128, uuid128_bt);
|
||||
|
||||
for (i=0; i<data_len; i+=16){
|
||||
@ -141,7 +141,7 @@ int ad_data_contains_uuid128(uint8_t ad_len, uint8_t * ad_data, uint8_t * uuid12
|
||||
case CompleteList16:
|
||||
for (i=0; i<data_len; i+=2){
|
||||
uint16_t uuid16 = little_endian_read_16(data, i);
|
||||
sdp_normalize_uuid(ad_uuid128, uuid16);
|
||||
uuid_add_bluetooth_prefix(ad_uuid128, uuid16);
|
||||
|
||||
if (memcmp(ad_uuid128, uuid128_le, 16) == 0) return 1;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ static void extract_service(le_service_t * service, uint8_t * packet){
|
||||
service->end_group_handle = little_endian_read_16(packet, 6);
|
||||
service->uuid16 = 0;
|
||||
swap128(&packet[8], service->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(service->uuid128)){
|
||||
service->uuid16 = big_endian_read_32(service->uuid128, 0);
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ static void extract_characteristic(le_characteristic_t * characteristic, uint8_t
|
||||
characteristic->properties = little_endian_read_16(packet, 10);
|
||||
characteristic->uuid16 = 0;
|
||||
swap128(&packet[12], characteristic->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(characteristic->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(characteristic->uuid128)){
|
||||
characteristic->uuid16 = big_endian_read_32(characteristic->uuid128, 0);
|
||||
}
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ static void report_gatt_services(gatt_client_t * peripheral, uint8_t * packet,
|
||||
|
||||
if (uuid_length == 2){
|
||||
uuid16 = little_endian_read_16(packet, i+4);
|
||||
sdp_normalize_uuid((uint8_t*) &uuid128, uuid16);
|
||||
uuid_add_bluetooth_prefix((uint8_t*) &uuid128, uuid16);
|
||||
} else {
|
||||
swap128(&packet[i+4], uuid128);
|
||||
}
|
||||
@ -610,7 +610,7 @@ static void characteristic_start_found(gatt_client_t * peripheral, uint16_t star
|
||||
uint16_t uuid16 = 0;
|
||||
if (uuid_length == 2){
|
||||
uuid16 = little_endian_read_16(uuid, 0);
|
||||
sdp_normalize_uuid((uint8_t*) uuid128, uuid16);
|
||||
uuid_add_bluetooth_prefix((uint8_t*) uuid128, uuid16);
|
||||
} else {
|
||||
swap128(uuid, uuid128);
|
||||
}
|
||||
@ -653,7 +653,7 @@ static void report_gatt_characteristics(gatt_client_t * peripheral, uint8_t * pa
|
||||
|
||||
static void report_gatt_included_service_uuid16(gatt_client_t * peripheral, uint16_t include_handle, uint16_t uuid16){
|
||||
uint8_t normalized_uuid128[16];
|
||||
sdp_normalize_uuid(normalized_uuid128, uuid16);
|
||||
uuid_add_bluetooth_prefix(normalized_uuid128, uuid16);
|
||||
emit_gatt_included_service_query_result_event(peripheral, include_handle, peripheral->query_start_handle,
|
||||
peripheral->query_end_handle, normalized_uuid128);
|
||||
}
|
||||
@ -742,7 +742,7 @@ static void report_gatt_all_characteristic_descriptors(gatt_client_t * periphera
|
||||
uint16_t uuid16 = 0;
|
||||
if (pair_size == 4){
|
||||
uuid16 = little_endian_read_16(packet,i+2);
|
||||
sdp_normalize_uuid(uuid128, uuid16);
|
||||
uuid_add_bluetooth_prefix(uuid128, uuid16);
|
||||
} else {
|
||||
swap128(&packet[i+2], uuid128);
|
||||
}
|
||||
@ -1435,7 +1435,7 @@ uint8_t gatt_client_discover_primary_services_by_uuid16(uint16_t gatt_client_id,
|
||||
peripheral->end_group_handle = 0xffff;
|
||||
peripheral->gatt_client_state = P_W2_SEND_SERVICE_WITH_UUID_QUERY;
|
||||
peripheral->uuid16 = uuid16;
|
||||
sdp_normalize_uuid((uint8_t*) &(peripheral->uuid128), peripheral->uuid16);
|
||||
uuid_add_bluetooth_prefix((uint8_t*) &(peripheral->uuid128), peripheral->uuid16);
|
||||
gatt_client_run();
|
||||
return 0;
|
||||
}
|
||||
@ -1498,7 +1498,7 @@ uint8_t gatt_client_discover_characteristics_for_handle_range_by_uuid16(uint16_t
|
||||
peripheral->end_group_handle = end_handle;
|
||||
peripheral->filter_with_uuid = 1;
|
||||
peripheral->uuid16 = uuid16;
|
||||
sdp_normalize_uuid((uint8_t*) &(peripheral->uuid128), uuid16);
|
||||
uuid_add_bluetooth_prefix((uint8_t*) &(peripheral->uuid128), uuid16);
|
||||
peripheral->characteristic_start_handle = 0;
|
||||
peripheral->gatt_client_state = P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY;
|
||||
|
||||
@ -1579,7 +1579,7 @@ uint8_t gatt_client_read_value_of_characteristics_by_uuid16(uint16_t gatt_client
|
||||
peripheral->query_start_handle = start_handle;
|
||||
peripheral->query_end_handle = end_handle;
|
||||
peripheral->uuid16 = uuid16;
|
||||
sdp_normalize_uuid((uint8_t*) &(peripheral->uuid128), uuid16);
|
||||
uuid_add_bluetooth_prefix((uint8_t*) &(peripheral->uuid128), uuid16);
|
||||
peripheral->gatt_client_state = P_W2_SEND_READ_BY_TYPE_REQUEST;
|
||||
gatt_client_run();
|
||||
return 0;
|
||||
|
@ -189,12 +189,12 @@ void log_key(const char * name, sm_key_t key){
|
||||
const uint8_t sdp_bluetooth_base_uuid[] = { 0x00, 0x00, 0x00, 0x00, /* - */ 0x00, 0x00, /* - */ 0x10, 0x00, /* - */
|
||||
0x80, 0x00, /* - */ 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
|
||||
|
||||
void sdp_normalize_uuid(uint8_t *uuid, uint32_t shortUUID){
|
||||
void uuid_add_bluetooth_prefix(uint8_t *uuid, uint32_t shortUUID){
|
||||
memcpy(uuid, sdp_bluetooth_base_uuid, 16);
|
||||
big_endian_store_32(uuid, 0, shortUUID);
|
||||
}
|
||||
|
||||
int sdp_has_blueooth_base_uuid(uint8_t * uuid128){
|
||||
int uuid_has_bluetooth_prefix(uint8_t * uuid128){
|
||||
return memcmp(&uuid128[4], &sdp_bluetooth_base_uuid[4], 12) == 0;
|
||||
}
|
||||
|
||||
|
@ -154,8 +154,8 @@ char * bd_addr_to_str(bd_addr_t addr);
|
||||
int sscan_bd_addr(uint8_t * addr_string, bd_addr_t addr);
|
||||
|
||||
|
||||
void sdp_normalize_uuid(uint8_t *uuid, uint32_t shortUUID);
|
||||
int sdp_has_blueooth_base_uuid(uint8_t * uuid128);
|
||||
void uuid_add_bluetooth_prefix(uint8_t *uuid, uint32_t shortUUID);
|
||||
int uuid_has_bluetooth_prefix(uint8_t * uuid128);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ int de_get_normalized_uuid(uint8_t *uuid128, uint8_t *element){
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
sdp_normalize_uuid(uuid128, shortUUID);
|
||||
uuid_add_bluetooth_prefix(uuid128, shortUUID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ uint32_t de_get_uuid32(uint8_t * element){
|
||||
uint8_t uuid128[16];
|
||||
int validUuid128 = de_get_normalized_uuid(uuid128, element);
|
||||
if (!validUuid128) return 0;
|
||||
int hasBlueoothBaseUuid = sdp_has_blueooth_base_uuid(uuid128);
|
||||
int hasBlueoothBaseUuid = uuid_has_bluetooth_prefix(uuid128);
|
||||
if (!hasBlueoothBaseUuid) return 0;
|
||||
return big_endian_read_32(uuid128, 0);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ static void handle_ble_client_event(uint8_t packet_type, uint16_t channel, uint8
|
||||
service.end_group_handle = little_endian_read_16(packet, 6);
|
||||
service.uuid16 = 0;
|
||||
swap128(&packet[8], service.uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service.uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(service.uuid128)){
|
||||
service.uuid16 = big_endian_read_32(service.uuid128, 0);
|
||||
}
|
||||
services[result_index++] = service;
|
||||
@ -173,7 +173,7 @@ static void handle_ble_client_event(uint8_t packet_type, uint16_t channel, uint8
|
||||
service.end_group_handle = little_endian_read_16(packet, 8);
|
||||
service.uuid16 = 0;
|
||||
swap128(&packet[10], service.uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service.uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(service.uuid128)){
|
||||
service.uuid16 = big_endian_read_32(service.uuid128, 0);
|
||||
}
|
||||
included_services[result_index++] = service;
|
||||
@ -186,7 +186,7 @@ static void handle_ble_client_event(uint8_t packet_type, uint16_t channel, uint8
|
||||
characteristic.properties = little_endian_read_16(packet, 10);
|
||||
characteristic.uuid16 = 0;
|
||||
swap128(&packet[12], characteristic.uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(characteristic.uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(characteristic.uuid128)){
|
||||
characteristic.uuid16 = big_endian_read_32(characteristic.uuid128, 0);
|
||||
}
|
||||
characteristics[result_index++] = characteristic;
|
||||
@ -195,7 +195,7 @@ static void handle_ble_client_event(uint8_t packet_type, uint16_t channel, uint8
|
||||
case GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT:
|
||||
descriptor.handle = little_endian_read_16(packet, 4);
|
||||
swap128(&packet[6], descriptor.uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(descriptor.uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(descriptor.uuid128)){
|
||||
descriptor.uuid16 = big_endian_read_32(descriptor.uuid128, 0);
|
||||
}
|
||||
descriptors[result_index++] = descriptor;
|
||||
|
@ -414,7 +414,7 @@ static void extract_service(le_service_t * aService, uint8_t * data){
|
||||
aService->end_group_handle = little_endian_read_16(data, 2);
|
||||
aService->uuid16 = 0;
|
||||
swap128(&data[4], aService->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(aService->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(aService->uuid128)){
|
||||
aService->uuid16 = big_endian_read_32(aService->uuid128, 0);
|
||||
}
|
||||
}
|
||||
@ -426,7 +426,7 @@ static void extract_characteristic(le_characteristic_t * characteristic, uint8_t
|
||||
characteristic->properties = little_endian_read_16(packet, 10);
|
||||
characteristic->uuid16 = 0;
|
||||
swap128(&packet[12], characteristic->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(characteristic->uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(characteristic->uuid128)){
|
||||
characteristic->uuid16 = big_endian_read_32(characteristic->uuid128, 0);
|
||||
}
|
||||
}
|
||||
@ -516,7 +516,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint8_t *packet, uint1
|
||||
uint16_t descriptor_handle = little_endian_read_16(packet, 4);
|
||||
uint8_t uuid128[16];
|
||||
swap128(&packet[6], uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(uuid128)){
|
||||
if (uuid_has_bluetooth_prefix(uuid128)){
|
||||
printf("Characteristic descriptor at 0x%04x with UUID %04x\n", descriptor_handle, big_endian_read_32(uuid128, 0));
|
||||
} else {
|
||||
printf("Characteristic descriptor at 0x%04x with UUID %s\n", descriptor_handle, uuid128_to_str(uuid128));
|
||||
|
Loading…
x
Reference in New Issue
Block a user