From 09ac355c8abe8b376b35bea67591fa791cd037de Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 6 Apr 2017 11:14:58 +0200 Subject: [PATCH] sdp_rfcom_query: add sdp_client_query_rfcomm_channel_and_name_for_uuid128, use sdp_service_search_pattern_for_uuid16 and sdp_service_search_pattern_for_uuid128 instead of creating search pattern manually --- src/classic/sdp_client_rfcomm.c | 20 ++++++++++++++------ src/classic/sdp_client_rfcomm.h | 10 +++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/classic/sdp_client_rfcomm.c b/src/classic/sdp_client_rfcomm.c index dc8035117..b51f000c1 100644 --- a/src/classic/sdp_client_rfcomm.c +++ b/src/classic/sdp_client_rfcomm.c @@ -70,9 +70,8 @@ typedef enum { // higher layer query - get rfcomm channel and name -const uint8_t des_attributeIDList[] = { 0x35, 0x05, 0x0A, 0x00, 0x01, 0x01, 0x00}; // Arribute: 0x0001 - 0x0100 - -static uint8_t des_service_search_pattern[5] = {0x35, 0x03, 0x19, 0x00, 0x00}; +// All attributes: 0x0001 - 0x0100 +static const uint8_t des_attributeIDList[] = { 0x35, 0x05, 0x0A, 0x00, 0x01, 0x01, 0x00}; static uint8_t sdp_service_name[SDP_SERVICE_NAME_LEN+1]; static uint8_t sdp_service_name_len = 0; @@ -315,11 +314,20 @@ uint8_t sdp_client_query_rfcomm_channel_and_name_for_search_pattern(btstack_pack return 0; } -uint8_t sdp_client_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid){ +uint8_t sdp_client_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid16){ if (!sdp_client_ready()) return SDP_QUERY_BUSY; - big_endian_store_16(des_service_search_pattern, 3, uuid); - sdp_client_query_rfcomm_channel_and_name_for_search_pattern(callback, remote, (uint8_t*)des_service_search_pattern); + uint8_t * service_search_pattern = sdp_service_search_pattern_for_uuid16(uuid16); + sdp_client_query_rfcomm_channel_and_name_for_search_pattern(callback, remote, service_search_pattern); + return 0; +} + +uint8_t sdp_client_query_rfcomm_channel_and_name_for_uuid128(btstack_packet_handler_t callback, bd_addr_t remote, uint8_t * uuid128){ + + if (!sdp_client_ready()) return SDP_QUERY_BUSY; + + uint8_t * service_search_pattern = sdp_service_search_pattern_for_uuid128(uuid128); + sdp_client_query_rfcomm_channel_and_name_for_search_pattern(callback, remote, service_search_pattern); return 0; } diff --git a/src/classic/sdp_client_rfcomm.h b/src/classic/sdp_client_rfcomm.h index f209d2bc4..ea4ad6ed0 100644 --- a/src/classic/sdp_client_rfcomm.h +++ b/src/classic/sdp_client_rfcomm.h @@ -53,14 +53,22 @@ extern "C" { /* API_START */ /** - * @brief Searches SDP records on a remote device for RFCOMM services with a given UUID. + * @brief Searches SDP records on a remote device for RFCOMM services with a given 16-bit UUID. + * @note calls sdp_service_search_pattern_for_uuid16 that uses global buffer */ uint8_t sdp_client_query_rfcomm_channel_and_name_for_uuid(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid); +/** + * @brief Searches SDP records on a remote device for RFCOMM services with a given 128-bit UUID. + * @note calls sdp_service_search_pattern_for_uuid128 that uses global buffer + */ +uint8_t sdp_client_query_rfcomm_channel_and_name_for_uuid128(btstack_packet_handler_t callback, bd_addr_t remote, uint8_t * uuid128); + /** * @brief Searches SDP records on a remote device for RFCOMM services with a given service search pattern. */ uint8_t sdp_client_query_rfcomm_channel_and_name_for_search_pattern(btstack_packet_handler_t callback, bd_addr_t remote, uint8_t * des_serviceSearchPattern); + /* API_END */ #if defined __cplusplus