xref: /btstack/src/classic/pbap_client.h (revision 5d59e25a1aaf5a505bffd503e47aae125eed43ec)
1f1b34e8dSMatthias Ringwald /*
2f1b34e8dSMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
3f1b34e8dSMatthias Ringwald  *
4f1b34e8dSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5f1b34e8dSMatthias Ringwald  * modification, are permitted provided that the following conditions
6f1b34e8dSMatthias Ringwald  * are met:
7f1b34e8dSMatthias Ringwald  *
8f1b34e8dSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9f1b34e8dSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10f1b34e8dSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11f1b34e8dSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12f1b34e8dSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13f1b34e8dSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14f1b34e8dSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15f1b34e8dSMatthias Ringwald  *    from this software without specific prior written permission.
16f1b34e8dSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17f1b34e8dSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18f1b34e8dSMatthias Ringwald  *    monetary gain.
19f1b34e8dSMatthias Ringwald  *
20f1b34e8dSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21f1b34e8dSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22f1b34e8dSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
232fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25f1b34e8dSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26f1b34e8dSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27f1b34e8dSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28f1b34e8dSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29f1b34e8dSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30f1b34e8dSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31f1b34e8dSMatthias Ringwald  * SUCH DAMAGE.
32f1b34e8dSMatthias Ringwald  *
33f1b34e8dSMatthias Ringwald  * Please inquire about commercial licensing options at
34f1b34e8dSMatthias Ringwald  * [email protected]
35f1b34e8dSMatthias Ringwald  *
36f1b34e8dSMatthias Ringwald  */
37f1b34e8dSMatthias Ringwald 
38fe5a6c4eSMilanka Ringwald /**
39fe5a6c4eSMilanka Ringwald  * @title PBAP Client
40fe5a6c4eSMilanka Ringwald  *
41fe5a6c4eSMilanka Ringwald  */
42fe5a6c4eSMilanka Ringwald 
4380e33422SMatthias Ringwald #ifndef PBAP_CLIENT_H
4480e33422SMatthias Ringwald #define PBAP_CLIENT_H
45f1b34e8dSMatthias Ringwald 
46f1b34e8dSMatthias Ringwald #if defined __cplusplus
47f1b34e8dSMatthias Ringwald extern "C" {
48f1b34e8dSMatthias Ringwald #endif
49f1b34e8dSMatthias Ringwald 
50e14fb63cSMatthias Ringwald #include <stdint.h>
51e14fb63cSMatthias Ringwald 
52f1b34e8dSMatthias Ringwald #include "btstack_config.h"
530e7551b0SMatthias Ringwald #include "yxml.h"
54e14fb63cSMatthias Ringwald #include "classic/obex_srm_client.h"
55def79b09SMatthias Ringwald #include "classic/obex_parser.h"
56f1b34e8dSMatthias Ringwald 
5783f1bca0SMatthias Ringwald // max len of phone number used for lookup in pbap_lookup_by_number
5883f1bca0SMatthias Ringwald #define PBAP_MAX_PHONE_NUMBER_LEN 32
5983f1bca0SMatthias Ringwald 
6083f1bca0SMatthias Ringwald // max len of name reported in PBAP_SUBEVENT_CARD_RESULT
6183f1bca0SMatthias Ringwald #define PBAP_MAX_NAME_LEN   32
6283f1bca0SMatthias Ringwald // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT
6383f1bca0SMatthias Ringwald #define PBAP_MAX_HANDLE_LEN 16
6483f1bca0SMatthias Ringwald 
650e7551b0SMatthias Ringwald 
660e7551b0SMatthias Ringwald typedef enum {
670e7551b0SMatthias Ringwald     PBAP_CLIENT_INIT = 0,
680e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GOEP_CONNECTION,
690e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_CONNECT_REQUEST,
700e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_CONNECT_RESPONSE,
710e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_USER_AUTHENTICATION,
720e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_AUTHENTICATED_CONNECT,
730e7551b0SMatthias Ringwald     PBAP_CLIENT_CONNECTED,
740e7551b0SMatthias Ringwald     //
750e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_DISCONNECT_REQUEST,
760e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_DISCONNECT_RESPONSE,
770e7551b0SMatthias Ringwald     //
780e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_PULL_PHONEBOOK,
790e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_PHONEBOOK,
800e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SET_PATH_ROOT,
810e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_SET_PATH_ROOT_COMPLETE,
820e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SET_PATH_ELEMENT,
830e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_SET_PATH_ELEMENT_COMPLETE,
840e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_PHONEBOOK_SIZE,
850e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_PHONEBOOK_SIZE_COMPLETE,
860e7551b0SMatthias Ringwald     // - pull vacard liast
870e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_CARD_LIST,
880e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_CARD_LIST_COMPLETE,
890e7551b0SMatthias Ringwald     // - pull vcard entry
900e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_CARD_ENTRY,
910e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_CARD_ENTRY_COMPLETE,
920e7551b0SMatthias Ringwald     // abort operation
930e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_ABORT_COMPLETE,
940e7551b0SMatthias Ringwald 
950e7551b0SMatthias Ringwald } pbap_client_state_t;
960e7551b0SMatthias Ringwald 
970e7551b0SMatthias Ringwald typedef enum {
980e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_TYPE = 0,
990e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_LEN,
1000e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_VALUE,
1010e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_INVALID,
1020e7551b0SMatthias Ringwald } pbap_client_phonebook_size_parser_state_t;
1030e7551b0SMatthias Ringwald 
1040e7551b0SMatthias Ringwald typedef struct {
1050e7551b0SMatthias Ringwald     // parsing
1060e7551b0SMatthias Ringwald     pbap_client_phonebook_size_parser_state_t state;
1070e7551b0SMatthias Ringwald     uint8_t type;
1080e7551b0SMatthias Ringwald     uint8_t len;
1090e7551b0SMatthias Ringwald     uint8_t pos;
1100e7551b0SMatthias Ringwald     // data
1110e7551b0SMatthias Ringwald     bool have_size;
1120e7551b0SMatthias Ringwald     uint8_t  size_buffer[2];
1130e7551b0SMatthias Ringwald } pbap_client_phonebook_size_parser_t;
1140e7551b0SMatthias Ringwald 
1151a3b1957SMatthias Ringwald typedef enum {
1161a3b1957SMatthias Ringwald     OBEX_AUTH_PARSER_STATE_W4_TYPE = 0,
1171a3b1957SMatthias Ringwald     OBEX_AUTH_PARSER_STATE_W4_LEN,
1181a3b1957SMatthias Ringwald     OBEX_AUTH_PARSER_STATE_W4_VALUE,
1191a3b1957SMatthias Ringwald     OBEX_AUTH_PARSER_STATE_INVALID,
1201a3b1957SMatthias Ringwald } pbap_client_obex_auth_parser_state_t;
1211a3b1957SMatthias Ringwald 
1221a3b1957SMatthias Ringwald typedef struct {
1231a3b1957SMatthias Ringwald     // parsing
1241a3b1957SMatthias Ringwald     pbap_client_obex_auth_parser_state_t state;
1251a3b1957SMatthias Ringwald     uint8_t type;
1261a3b1957SMatthias Ringwald     uint8_t len;
1271a3b1957SMatthias Ringwald     uint8_t pos;
1281a3b1957SMatthias Ringwald     // data
1291a3b1957SMatthias Ringwald     uint8_t  authentication_options;
1301a3b1957SMatthias Ringwald     uint16_t authentication_nonce[16];
1311a3b1957SMatthias Ringwald } pbap_client_obex_auth_parser_t;
1321a3b1957SMatthias Ringwald 
1330e7551b0SMatthias Ringwald typedef struct pbap_client {
134fe072f38SMatthias Ringwald     // pbap client linked list
135fe072f38SMatthias Ringwald     btstack_linked_item_t item;
136fe072f38SMatthias Ringwald 
137fe072f38SMatthias Ringwald     // goep client linked list
1380e7551b0SMatthias Ringwald     goep_client_t goep_client;
1390e7551b0SMatthias Ringwald 
140fe072f38SMatthias Ringwald     pbap_client_state_t state;
1410e7551b0SMatthias Ringwald     bd_addr_t bd_addr;
1420e7551b0SMatthias Ringwald     hci_con_handle_t con_handle;
1430e7551b0SMatthias Ringwald     uint16_t  goep_cid;
1440e7551b0SMatthias Ringwald     btstack_packet_handler_t client_handler;
1450e7551b0SMatthias Ringwald     int request_number;
1460e7551b0SMatthias Ringwald     const char * current_folder;
1470e7551b0SMatthias Ringwald     const char * phone_number;
1480e7551b0SMatthias Ringwald     const char * phonebook_path;
1490e7551b0SMatthias Ringwald     const char * vcard_name;
1500e7551b0SMatthias Ringwald     uint16_t set_path_offset;
1510e7551b0SMatthias Ringwald     /* vcard selector / operator */
1520e7551b0SMatthias Ringwald     uint32_t vcard_selector;
1530e7551b0SMatthias Ringwald     uint8_t  vcard_selector_operator;
1540e7551b0SMatthias Ringwald     uint8_t  vcard_selector_supported;
1550e7551b0SMatthias Ringwald     /* property selector */
1560e7551b0SMatthias Ringwald     uint32_t     property_selector;
1570e7551b0SMatthias Ringwald     uint16_t     list_start_offset;
1580e7551b0SMatthias Ringwald     uint16_t     max_list_count;
1598981e442SMatthias Ringwald     uint8_t      order;
1608981e442SMatthias Ringwald     uint8_t      search_property;
1618981e442SMatthias Ringwald     const char * search_value;
1620e7551b0SMatthias Ringwald     /* abort */
1630e7551b0SMatthias Ringwald     uint8_t  abort_operation;
1640e7551b0SMatthias Ringwald     /* obex parser */
1650e7551b0SMatthias Ringwald     bool obex_parser_waiting_for_response;
1660e7551b0SMatthias Ringwald     obex_parser_t obex_parser;
1670e7551b0SMatthias Ringwald     uint8_t obex_header_buffer[4];
1680e7551b0SMatthias Ringwald     /* authentication */
1691a3b1957SMatthias Ringwald     pbap_client_obex_auth_parser_t obex_auth_parser;
1700e7551b0SMatthias Ringwald     const char * authentication_password;
1710e7551b0SMatthias Ringwald     /* xml parser */
1720e7551b0SMatthias Ringwald     yxml_t  xml_parser;
1730e7551b0SMatthias Ringwald     uint8_t xml_buffer[50];
1740e7551b0SMatthias Ringwald     /* vcard listing parser */
1750e7551b0SMatthias Ringwald     bool parser_card_found;
1760e7551b0SMatthias Ringwald     bool parser_name_found;
1770e7551b0SMatthias Ringwald     bool parser_handle_found;
1780e7551b0SMatthias Ringwald     char parser_name[PBAP_MAX_NAME_LEN];
1790e7551b0SMatthias Ringwald     char parser_handle[PBAP_MAX_HANDLE_LEN];
1800e7551b0SMatthias Ringwald     /* phonebook size */
1810e7551b0SMatthias Ringwald     pbap_client_phonebook_size_parser_t phonebook_size_parser;
1820e7551b0SMatthias Ringwald     /* flow control mode */
1830e7551b0SMatthias Ringwald     uint8_t flow_control_enabled;
1840e7551b0SMatthias Ringwald     uint8_t flow_next_triggered;
1850e7551b0SMatthias Ringwald     bool flow_wait_for_user;
1860e7551b0SMatthias Ringwald     /* srm */
187e14fb63cSMatthias Ringwald     obex_srm_client_t obex_srm;
1880e7551b0SMatthias Ringwald } pbap_client_t;
1890e7551b0SMatthias Ringwald 
190f1b34e8dSMatthias Ringwald /* API_START */
191f1b34e8dSMatthias Ringwald 
192f1b34e8dSMatthias Ringwald /**
193f1b34e8dSMatthias Ringwald  * Setup PhoneBook Access Client
194f1b34e8dSMatthias Ringwald  */
195f1b34e8dSMatthias Ringwald void pbap_client_init(void);
196f1b34e8dSMatthias Ringwald 
197f1b34e8dSMatthias Ringwald /**
1981c7aea60SMilanka Ringwald  * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device.
1991c7aea60SMilanka Ringwald  * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which
2001c7aea60SMilanka Ringwald  * can be answered with pbap_authentication_password(..).
2011c7aea60SMilanka Ringwald  * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event,
2021c7aea60SMilanka Ringwald  * i.e. on success status field is set to ERROR_CODE_SUCCESS.
2031c7aea60SMilanka Ringwald  *
204f3185e85SMatthias Ringwald  * This function allows for multiple parallel connections.
205f3185e85SMatthias Ringwald  *
206f3185e85SMatthias Ringwald  * @param client storage for connection state. Must stay valid until connection closes
2070806590aSMatthias Ringwald  * @param l2cap_ertm_config
2080806590aSMatthias Ringwald  * @param l2cap_ertm_buffer_size
2090806590aSMatthias Ringwald  * @param l2cap_ertm_buffer
210f3185e85SMatthias Ringwald  * @param handler
211f3185e85SMatthias Ringwald  * @param addr
212f3185e85SMatthias Ringwald  * @param out_cid to use for further commands
213f3185e85SMatthias Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists.
214f3185e85SMatthias Ringwald  */
215f3185e85SMatthias Ringwald 
2160806590aSMatthias Ringwald uint8_t pbap_client_connect(pbap_client_t * client, l2cap_ertm_config_t *l2cap_ertm_config, uint8_t *l2cap_ertm_buffer,
2170806590aSMatthias Ringwald                             uint16_t l2cap_ertm_buffer_size, btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid);
218f3185e85SMatthias Ringwald 
219f3185e85SMatthias Ringwald /**
220f3185e85SMatthias Ringwald  * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device.
221f3185e85SMatthias Ringwald  * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which
222f3185e85SMatthias Ringwald  * can be answered with pbap_authentication_password(..).
223f3185e85SMatthias Ringwald  * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event,
224f3185e85SMatthias Ringwald  * i.e. on success status field is set to ERROR_CODE_SUCCESS.
225f3185e85SMatthias Ringwald  *
226dff8de67SMatthias Ringwald  * This function uses a single pbap_client_t and l2cap ertm buffer instance and can only be used for a single connection.
227f3185e85SMatthias Ringwald  * Fur multiple parallel connections, use pbap_client_connect.
228f3185e85SMatthias Ringwald  *
229f1b34e8dSMatthias Ringwald  * @param handler
230f1b34e8dSMatthias Ringwald  * @param addr
231f1b34e8dSMatthias Ringwald  * @param out_cid to use for further commands
2321c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists.
233f1b34e8dSMatthias Ringwald  */
234f1b34e8dSMatthias Ringwald uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid);
235f1b34e8dSMatthias Ringwald 
236f1b34e8dSMatthias Ringwald /**
237*5d59e25aSMatthias Ringwald  * Create SDP Record for Phonebook Access Client
238*5d59e25aSMatthias Ringwald  * @param service
239*5d59e25aSMatthias Ringwald  * @param service_record_handle
240*5d59e25aSMatthias Ringwald  * @param service_name
241*5d59e25aSMatthias Ringwald  */
242*5d59e25aSMatthias Ringwald void pbap_client_create_sdp_record(uint8_t *service, uint32_t service_record_handle, const char *service_name);
243*5d59e25aSMatthias Ringwald 
244*5d59e25aSMatthias Ringwald /**
2451c7aea60SMilanka Ringwald  * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST.
2461c7aea60SMilanka Ringwald  * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event,
2471c7aea60SMilanka Ringwald  * i.e. on success status field is set to ERROR_CODE_SUCCESS.
2481c7aea60SMilanka Ringwald  *
249c1bc0b8eSMatthias Ringwald  * @param pbap_cid
250c1bc0b8eSMatthias Ringwald  * @param password (null terminated string) - not copied, needs to stay valid until connection completed
2511c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
252c1bc0b8eSMatthias Ringwald  */
253c1bc0b8eSMatthias Ringwald uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password);
254c1bc0b8eSMatthias Ringwald 
255c1bc0b8eSMatthias Ringwald /**
256f1b34e8dSMatthias Ringwald  * @brief Disconnects PBAP connection with given identifier.
2571c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_CONNECTION_CLOSED indicates that PBAP connection is closed.
2581c7aea60SMilanka Ringwald  *
259f1b34e8dSMatthias Ringwald  * @param pbap_cid
2601c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
261f1b34e8dSMatthias Ringwald  */
262f1b34e8dSMatthias Ringwald uint8_t pbap_disconnect(uint16_t pbap_cid);
263f1b34e8dSMatthias Ringwald 
264f1b34e8dSMatthias Ringwald /**
2651c7aea60SMilanka Ringwald  * @brief Set current folder on PSE. The status is reported via PBAP_SUBEVENT_OPERATION_COMPLETED event.
2661c7aea60SMilanka Ringwald  *
267f1b34e8dSMatthias Ringwald  * @param pbap_cid
268f1b34e8dSMatthias Ringwald  * @param path - note: path is not copied
2691c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
270f1b34e8dSMatthias Ringwald  */
271f1b34e8dSMatthias Ringwald uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path);
272f1b34e8dSMatthias Ringwald 
273f1b34e8dSMatthias Ringwald /**
2741c7aea60SMilanka Ringwald  * @brief Set vCard Selector for get/pull phonebook. No event is emitted.
2751c7aea60SMilanka Ringwald  *
2763127f224SMatthias Ringwald  * @param pbap_cid
2773127f224SMatthias Ringwald  * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties
2781c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
2793127f224SMatthias Ringwald  */
2803127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector);
2813127f224SMatthias Ringwald 
2823127f224SMatthias Ringwald /**
2831c7aea60SMilanka Ringwald  * @brief Set vCard Selector for get/pull phonebook. No event is emitted.
2841c7aea60SMilanka Ringwald  *
2853127f224SMatthias Ringwald  * @param pbap_cid
2863127f224SMatthias Ringwald  * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND
2871c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
2883127f224SMatthias Ringwald  */
2893127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator);
2903127f224SMatthias Ringwald 
2913127f224SMatthias Ringwald /**
292e9b4d967SMatthias Ringwald  * @brief Set Property Selector. No event is emitted.
293e9b4d967SMatthias Ringwald  * @param pbap_cid
294e9b4d967SMatthias Ringwald  * @param property_selector - combination of PBAP_PROPERTY_MASK_* properties
295e9b4d967SMatthias Ringwald  * @return
296e9b4d967SMatthias Ringwald  */
297e9b4d967SMatthias Ringwald uint8_t pbap_set_property_selector(uint16_t pbap_cid, uint32_t property_selector);
298e9b4d967SMatthias Ringwald 
299e9b4d967SMatthias Ringwald /**
30004f86d08SMatthias Ringwald  * @brief Set number of items returned by pull phonebook.
30104f86d08SMatthias Ringwald  * @param pbap_cid
30204f86d08SMatthias Ringwald  * @param max_list_count
30304f86d08SMatthias Ringwald  * @return
30404f86d08SMatthias Ringwald  */
30504f86d08SMatthias Ringwald uint8_t pbap_set_max_list_count(uint16_t pbap_cid, uint16_t max_list_count);
30604f86d08SMatthias Ringwald 
30704f86d08SMatthias Ringwald /**
30804f86d08SMatthias Ringwald  * @bbrief Set start offset for pull phonebook
30904f86d08SMatthias Ringwald  * @param pbap_cid
31004f86d08SMatthias Ringwald  * @param list_start_offset
31104f86d08SMatthias Ringwald  * @return
31204f86d08SMatthias Ringwald  */
31304f86d08SMatthias Ringwald uint8_t pbap_set_list_start_offset(uint16_t pbap_cid, uint16_t list_start_offset);
31404f86d08SMatthias Ringwald 
31504f86d08SMatthias Ringwald /**
3168981e442SMatthias Ringwald  * @bbrief Set order for pbap_pull_vcard_listing
3178981e442SMatthias Ringwald  * @param pbap_cid
3188981e442SMatthias Ringwald  * @param order
3198981e442SMatthias Ringwald  * @return
3208981e442SMatthias Ringwald  */
3218981e442SMatthias Ringwald uint8_t pbap_set_order(uint16_t pbap_cid, uint8_t order);
3228981e442SMatthias Ringwald 
3238981e442SMatthias Ringwald /**
3248981e442SMatthias Ringwald  * @bbrief Set search property for pbap_pull_vcard_listing
3258981e442SMatthias Ringwald  * @param pbap_cid
3268981e442SMatthias Ringwald  * @param search_property
3278981e442SMatthias Ringwald  * @return
3288981e442SMatthias Ringwald  */
3298981e442SMatthias Ringwald uint8_t pbap_set_search_property(uint16_t pbap_cid, uint8_t search_property);
3308981e442SMatthias Ringwald 
3318981e442SMatthias Ringwald /**
3328981e442SMatthias Ringwald  * @bbrief Set search property for pbap_pull_vcard_listing
3338981e442SMatthias Ringwald  * @param pbap_cid
3348981e442SMatthias Ringwald  * @param search_value
3358981e442SMatthias Ringwald  * @return
3368981e442SMatthias Ringwald  */
3378981e442SMatthias Ringwald uint8_t pbap_set_search_value(uint16_t pbap_cid, const char * search_value);
3388981e442SMatthias Ringwald 
3398981e442SMatthias Ringwald /**
3401c7aea60SMilanka Ringwald  * @brief Get size of phone book from PSE. The result is reported via PBAP_SUBEVENT_PHONEBOOK_SIZE event.
3411c7aea60SMilanka Ringwald  *
3423a7447a3SMatthias Ringwald  * @param pbap_cid
3438c94c044SMatthias Ringwald  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
3441c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
3453a7447a3SMatthias Ringwald  */
3468c94c044SMatthias Ringwald uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path);
3473a7447a3SMatthias Ringwald 
3483a7447a3SMatthias Ringwald /**
3491c7aea60SMilanka Ringwald  * @brief Pull phone book from PSE. The result is reported via registered packet handler (see pbap_connect function),
3501c7aea60SMilanka Ringwald  * with packet type set to PBAP_DATA_PACKET. Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the phone book.
3511c7aea60SMilanka Ringwald  *
352f1b34e8dSMatthias Ringwald  * @param pbap_cid
3538c94c044SMatthias Ringwald  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
3541c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
355f1b34e8dSMatthias Ringwald  */
3568c94c044SMatthias Ringwald uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path);
357e03b79abSMatthias Ringwald 
358e03b79abSMatthias Ringwald /**
3591c7aea60SMilanka Ringwald  * @brief Pull vCard listing. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event.
3601c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of vCard listing.
3611c7aea60SMilanka Ringwald  *
3624687d289SMatthias Ringwald  * @param pbap_cid
3634687d289SMatthias Ringwald  * @param path
3641c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
3654687d289SMatthias Ringwald  */
3664687d289SMatthias Ringwald uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path);
3674687d289SMatthias Ringwald 
3684687d289SMatthias Ringwald /**
3691c7aea60SMilanka Ringwald  * @brief Pull vCard entry. The result is reported via callback (see pbap_connect function),
3701c7aea60SMilanka Ringwald  * with packet type set to PBAP_DATA_PACKET.
3711c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the vCard entry.
3721c7aea60SMilanka Ringwald  *
37316ad3745SMatthias Ringwald  * @param pbap_cid
37416ad3745SMatthias Ringwald  * @param path
3751c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
37616ad3745SMatthias Ringwald  */
37716ad3745SMatthias Ringwald uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path);
37816ad3745SMatthias Ringwald 
37916ad3745SMatthias Ringwald /**
3801c7aea60SMilanka Ringwald  * @brief Lookup contact(s) by phone number. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event.
3811c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the lookup.
3821c7aea60SMilanka Ringwald  *
383e03b79abSMatthias Ringwald  * @param pbap_cid
384e03b79abSMatthias Ringwald  * @param phone_number
3851c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
386e03b79abSMatthias Ringwald  */
387e03b79abSMatthias Ringwald uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number);
388f1b34e8dSMatthias Ringwald 
389d4436ef5SMatthias Ringwald /**
3901c7aea60SMilanka Ringwald  * @brief Abort current operation. No event is emitted.
3911c7aea60SMilanka Ringwald  *
3929eb7827dSMatthias Ringwald  * @param pbap_cid
3931c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
3949eb7827dSMatthias Ringwald  */
3959eb7827dSMatthias Ringwald uint8_t pbap_abort(uint16_t pbap_cid);
3969eb7827dSMatthias Ringwald 
3979eb7827dSMatthias Ringwald 
3989eb7827dSMatthias Ringwald /**
3991c7aea60SMilanka Ringwald  * @brief Set flow control mode - default is off. No event is emitted.
400d4436ef5SMatthias Ringwald  * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one
4011c7aea60SMilanka Ringwald  *
4028854a89dSMatthias Ringwald  * @param pbap_cid
4031c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
404d4436ef5SMatthias Ringwald  */
4058854a89dSMatthias Ringwald uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable);
406d4436ef5SMatthias Ringwald 
407d4436ef5SMatthias Ringwald /**
4081c7aea60SMilanka Ringwald  * @brief Trigger next packet from PSE when Flow Control Mode is enabled.
409d4436ef5SMatthias Ringwald  * @param pbap_cid
4101c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
411d4436ef5SMatthias Ringwald  */
412d4436ef5SMatthias Ringwald uint8_t pbap_next_packet(uint16_t pbap_cid);
413d4436ef5SMatthias Ringwald 
4141d0ae3baSMatthias Ringwald /**
4151d0ae3baSMatthias Ringwald  * @brief De-Init PBAP Client
4161d0ae3baSMatthias Ringwald  */
4171d0ae3baSMatthias Ringwald void pbap_client_deinit(void);
418d4436ef5SMatthias Ringwald 
419f1b34e8dSMatthias Ringwald /* API_END */
420f1b34e8dSMatthias Ringwald 
421f1b34e8dSMatthias Ringwald #if defined __cplusplus
422f1b34e8dSMatthias Ringwald }
423f1b34e8dSMatthias Ringwald #endif
424f1b34e8dSMatthias Ringwald #endif
425