xref: /btstack/src/classic/sdp_client.h (revision 2fca4dad957cd7b88f4657ed51e89c12615dda72)
13deb3ec6SMatthias Ringwald /*
23deb3ec6SMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
33deb3ec6SMatthias Ringwald  *
43deb3ec6SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
53deb3ec6SMatthias Ringwald  * modification, are permitted provided that the following conditions
63deb3ec6SMatthias Ringwald  * are met:
73deb3ec6SMatthias Ringwald  *
83deb3ec6SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
93deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
103deb3ec6SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
113deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
123deb3ec6SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
133deb3ec6SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
143deb3ec6SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
153deb3ec6SMatthias Ringwald  *    from this software without specific prior written permission.
163deb3ec6SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
173deb3ec6SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
183deb3ec6SMatthias Ringwald  *    monetary gain.
193deb3ec6SMatthias Ringwald  *
203deb3ec6SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
213deb3ec6SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
223deb3ec6SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*2fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24*2fca4dadSMilanka Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
253deb3ec6SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
263deb3ec6SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
273deb3ec6SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
283deb3ec6SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
293deb3ec6SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
303deb3ec6SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
313deb3ec6SMatthias Ringwald  * SUCH DAMAGE.
323deb3ec6SMatthias Ringwald  *
333deb3ec6SMatthias Ringwald  * Please inquire about commercial licensing options at
343deb3ec6SMatthias Ringwald  * [email protected]
353deb3ec6SMatthias Ringwald  *
363deb3ec6SMatthias Ringwald  */
373deb3ec6SMatthias Ringwald 
38fe5a6c4eSMilanka Ringwald /**
39fe5a6c4eSMilanka Ringwald  * @title SDP Client
40fe5a6c4eSMilanka Ringwald  *
413deb3ec6SMatthias Ringwald  */
423deb3ec6SMatthias Ringwald 
4380e33422SMatthias Ringwald #ifndef SDP_CLIENT_H
4480e33422SMatthias Ringwald #define SDP_CLIENT_H
453deb3ec6SMatthias Ringwald 
467907f069SMatthias Ringwald #include "btstack_config.h"
473deb3ec6SMatthias Ringwald 
48eb886013SMatthias Ringwald #include "btstack_util.h"
493deb3ec6SMatthias Ringwald 
503deb3ec6SMatthias Ringwald #if defined __cplusplus
513deb3ec6SMatthias Ringwald extern "C" {
523deb3ec6SMatthias Ringwald #endif
533deb3ec6SMatthias Ringwald 
543deb3ec6SMatthias Ringwald /* API_START */
553deb3ec6SMatthias Ringwald 
566c927b22SMatthias Ringwald typedef struct de_state {
576c927b22SMatthias Ringwald     uint8_t  in_state_GET_DE_HEADER_LENGTH ;
586c927b22SMatthias Ringwald     uint32_t addon_header_bytes;
596c927b22SMatthias Ringwald     uint32_t de_size;
606c927b22SMatthias Ringwald     uint32_t de_offset;
616c927b22SMatthias Ringwald } de_state_t;
626c927b22SMatthias Ringwald 
636c927b22SMatthias Ringwald void de_state_init(de_state_t * state);
646c927b22SMatthias Ringwald int  de_state_size(uint8_t eventByte, de_state_t *de_state);
656c927b22SMatthias Ringwald 
666c927b22SMatthias Ringwald /**
670396d6ccSMatthias Ringwald  * @brief SDP Client Init
680396d6ccSMatthias Ringwald  */
690396d6ccSMatthias Ringwald void sdp_client_init(void);
700396d6ccSMatthias Ringwald 
710396d6ccSMatthias Ringwald /**
726c927b22SMatthias Ringwald  * @brief Checks if the SDP Client is ready
73e094740eSMatthias Ringwald  * @deprecated Please use sdp_client_register_query_callback instead
74b443d25dSMatthias Ringwald  * @return true when no query is active
756c927b22SMatthias Ringwald  */
76b443d25dSMatthias Ringwald bool sdp_client_ready(void);
776c927b22SMatthias Ringwald 
783deb3ec6SMatthias Ringwald /**
79e094740eSMatthias Ringwald  * @brief Requests a callback, when the SDP Client is ready and can be used
80e094740eSMatthias Ringwald  * @note The callback might happens before sdp_client_register_query_callback has returned
81e094740eSMatthias Ringwald  * @param callback_registration
82e094740eSMatthias Ringwald  */
83e094740eSMatthias Ringwald uint8_t sdp_client_register_query_callback(btstack_context_callback_registration_t * callback_registration);
84e094740eSMatthias Ringwald 
85e094740eSMatthias Ringwald /**
8689374882SMatthias Ringwald  * @brief Queries the SDP service of the remote device given a service search pattern and a list of attribute IDs.
876c927b22SMatthias Ringwald  * The remote data is handled by the SDP parser. The SDP parser delivers attribute values and done event via the callback.
886c927b22SMatthias Ringwald  * @param callback for attributes values and done event
896c927b22SMatthias Ringwald  * @param remote address
906c927b22SMatthias Ringwald  * @param des_service_search_pattern
916c927b22SMatthias Ringwald  * @param des_attribute_id_list
923deb3ec6SMatthias Ringwald  */
93282ceebcSMatthias Ringwald uint8_t sdp_client_query(btstack_packet_handler_t callback, bd_addr_t remote, const uint8_t * des_service_search_pattern, const uint8_t * des_attribute_id_list);
943deb3ec6SMatthias Ringwald 
95023f2764SMatthias Ringwald /*
96023f2764SMatthias Ringwald  * @brief Searches SDP records on a remote device for all services with a given UUID.
97023f2764SMatthias Ringwald  * @note calls sdp_client_query with service search pattern based on uuid16
98023f2764SMatthias Ringwald  */
99282ceebcSMatthias Ringwald uint8_t sdp_client_query_uuid16(btstack_packet_handler_t callback, bd_addr_t remote, uint16_t uuid16);
100023f2764SMatthias Ringwald 
101023f2764SMatthias Ringwald /*
102023f2764SMatthias Ringwald  * @brief Searches SDP records on a remote device for all services with a given UUID.
103023f2764SMatthias Ringwald  * @note calls sdp_client_query with service search pattern based on uuid128
104023f2764SMatthias Ringwald  */
105282ceebcSMatthias Ringwald uint8_t sdp_client_query_uuid128(btstack_packet_handler_t callback, bd_addr_t remote, const uint8_t* uuid128);
106023f2764SMatthias Ringwald 
107023f2764SMatthias Ringwald 
1086c927b22SMatthias Ringwald /**
1096c927b22SMatthias Ringwald  * @brief Retrieves all attribute IDs of a SDP record specified by its service record handle and a list of attribute IDs.
1106c927b22SMatthias Ringwald  * The remote data is handled by the SDP parser. The SDP parser delivers attribute values and done event via the callback.
1116c927b22SMatthias Ringwald  * @note only provided if ENABLE_SDP_EXTRA_QUERIES is defined
1126c927b22SMatthias Ringwald  * @param callback for attributes values and done event
1136c927b22SMatthias Ringwald  * @param remote address
1146c927b22SMatthias Ringwald  * @param search_service_record_handle
1156c927b22SMatthias Ringwald  * @param des_attributeIDList
1166c927b22SMatthias Ringwald  */
117282ceebcSMatthias Ringwald uint8_t sdp_client_service_attribute_search(btstack_packet_handler_t callback, bd_addr_t remote, uint32_t search_service_record_handle, const uint8_t * des_attributeIDList);
1186c927b22SMatthias Ringwald 
1196c927b22SMatthias Ringwald /**
1206c927b22SMatthias Ringwald  * @brief Query the list of SDP records that match a given service search pattern.
1216c927b22SMatthias Ringwald  * The remote data is handled by the SDP parser. The SDP parser delivers attribute values and done event via the callback.
1226c927b22SMatthias Ringwald  * @note only provided if ENABLE_SDP_EXTRA_QUERIES is defined
1236c927b22SMatthias Ringwald  * @param callback for attributes values and done event
1246c927b22SMatthias Ringwald  * @param remote address
1256c927b22SMatthias Ringwald  * @param des_service_search_pattern
1266c927b22SMatthias Ringwald  */
127282ceebcSMatthias Ringwald uint8_t sdp_client_service_search(btstack_packet_handler_t callback, bd_addr_t remote, const uint8_t * des_service_search_pattern);
1286c927b22SMatthias Ringwald 
1298eaf1b42SMilanka Ringwald #ifdef ENABLE_SDP_EXTRA_QUERIES
1308eaf1b42SMilanka Ringwald void sdp_client_parse_service_record_handle_list(uint8_t* packet, uint16_t total_count, uint16_t current_count);
1318eaf1b42SMilanka Ringwald #endif
1326c927b22SMatthias Ringwald 
1330396d6ccSMatthias Ringwald /**
1340396d6ccSMatthias Ringwald  * @brief De-Init SDP Client
1350396d6ccSMatthias Ringwald  */
1360396d6ccSMatthias Ringwald void sdp_client_deinit(void);
1370396d6ccSMatthias Ringwald 
1383deb3ec6SMatthias Ringwald /* API_END */
1393deb3ec6SMatthias Ringwald 
1403deb3ec6SMatthias Ringwald #if defined __cplusplus
1413deb3ec6SMatthias Ringwald }
1423deb3ec6SMatthias Ringwald #endif
1433deb3ec6SMatthias Ringwald 
14480e33422SMatthias Ringwald #endif // SDP_CLIENT_H
145