xref: /btstack/src/classic/pbap_client.h (revision 8981e4426650b6cce2b40d219da3f3c5124b02e6)
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"
55f1b34e8dSMatthias Ringwald 
5683f1bca0SMatthias Ringwald // max len of phone number used for lookup in pbap_lookup_by_number
5783f1bca0SMatthias Ringwald #define PBAP_MAX_PHONE_NUMBER_LEN 32
5883f1bca0SMatthias Ringwald 
5983f1bca0SMatthias Ringwald // max len of name reported in PBAP_SUBEVENT_CARD_RESULT
6083f1bca0SMatthias Ringwald #define PBAP_MAX_NAME_LEN   32
6183f1bca0SMatthias Ringwald // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT
6283f1bca0SMatthias Ringwald #define PBAP_MAX_HANDLE_LEN 16
6383f1bca0SMatthias Ringwald 
640e7551b0SMatthias Ringwald 
650e7551b0SMatthias Ringwald typedef enum {
660e7551b0SMatthias Ringwald     PBAP_CLIENT_INIT = 0,
670e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GOEP_CONNECTION,
680e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_CONNECT_REQUEST,
690e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_CONNECT_RESPONSE,
700e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_USER_AUTHENTICATION,
710e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_AUTHENTICATED_CONNECT,
720e7551b0SMatthias Ringwald     PBAP_CLIENT_CONNECTED,
730e7551b0SMatthias Ringwald     //
740e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_DISCONNECT_REQUEST,
750e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_DISCONNECT_RESPONSE,
760e7551b0SMatthias Ringwald     //
770e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_PULL_PHONEBOOK,
780e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_PHONEBOOK,
790e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SET_PATH_ROOT,
800e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_SET_PATH_ROOT_COMPLETE,
810e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SET_PATH_ELEMENT,
820e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_SET_PATH_ELEMENT_COMPLETE,
830e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_PHONEBOOK_SIZE,
840e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_PHONEBOOK_SIZE_COMPLETE,
850e7551b0SMatthias Ringwald     // - pull vacard liast
860e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_CARD_LIST,
870e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_CARD_LIST_COMPLETE,
880e7551b0SMatthias Ringwald     // - pull vcard entry
890e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_CARD_ENTRY,
900e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_CARD_ENTRY_COMPLETE,
910e7551b0SMatthias Ringwald     // abort operation
920e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_ABORT_COMPLETE,
930e7551b0SMatthias Ringwald 
940e7551b0SMatthias Ringwald } pbap_client_state_t;
950e7551b0SMatthias Ringwald 
960e7551b0SMatthias Ringwald typedef enum {
970e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_TYPE = 0,
980e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_LEN,
990e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_VALUE,
1000e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_INVALID,
1010e7551b0SMatthias Ringwald } pbap_client_phonebook_size_parser_state_t;
1020e7551b0SMatthias Ringwald 
1030e7551b0SMatthias Ringwald typedef struct {
1040e7551b0SMatthias Ringwald     // parsing
1050e7551b0SMatthias Ringwald     pbap_client_phonebook_size_parser_state_t state;
1060e7551b0SMatthias Ringwald     uint8_t type;
1070e7551b0SMatthias Ringwald     uint8_t len;
1080e7551b0SMatthias Ringwald     uint8_t pos;
1090e7551b0SMatthias Ringwald     // data
1100e7551b0SMatthias Ringwald     bool have_size;
1110e7551b0SMatthias Ringwald     uint8_t  size_buffer[2];
1120e7551b0SMatthias Ringwald } pbap_client_phonebook_size_parser_t;
1130e7551b0SMatthias Ringwald 
1141a3b1957SMatthias Ringwald typedef enum {
1151a3b1957SMatthias Ringwald     OBEX_AUTH_PARSER_STATE_W4_TYPE = 0,
1161a3b1957SMatthias Ringwald     OBEX_AUTH_PARSER_STATE_W4_LEN,
1171a3b1957SMatthias Ringwald     OBEX_AUTH_PARSER_STATE_W4_VALUE,
1181a3b1957SMatthias Ringwald     OBEX_AUTH_PARSER_STATE_INVALID,
1191a3b1957SMatthias Ringwald } pbap_client_obex_auth_parser_state_t;
1201a3b1957SMatthias Ringwald 
1211a3b1957SMatthias Ringwald typedef struct {
1221a3b1957SMatthias Ringwald     // parsing
1231a3b1957SMatthias Ringwald     pbap_client_obex_auth_parser_state_t state;
1241a3b1957SMatthias Ringwald     uint8_t type;
1251a3b1957SMatthias Ringwald     uint8_t len;
1261a3b1957SMatthias Ringwald     uint8_t pos;
1271a3b1957SMatthias Ringwald     // data
1281a3b1957SMatthias Ringwald     uint8_t  authentication_options;
1291a3b1957SMatthias Ringwald     uint16_t authentication_nonce[16];
1301a3b1957SMatthias Ringwald } pbap_client_obex_auth_parser_t;
1311a3b1957SMatthias Ringwald 
1320e7551b0SMatthias Ringwald typedef struct pbap_client {
133fe072f38SMatthias Ringwald     // pbap client linked list
134fe072f38SMatthias Ringwald     btstack_linked_item_t item;
135fe072f38SMatthias Ringwald 
136fe072f38SMatthias Ringwald     // goep client linked list
1370e7551b0SMatthias Ringwald     goep_client_t goep_client;
1380e7551b0SMatthias Ringwald 
139fe072f38SMatthias Ringwald     pbap_client_state_t state;
1400e7551b0SMatthias Ringwald     bd_addr_t bd_addr;
1410e7551b0SMatthias Ringwald     hci_con_handle_t con_handle;
1420e7551b0SMatthias Ringwald     uint16_t  goep_cid;
1430e7551b0SMatthias Ringwald     btstack_packet_handler_t client_handler;
1440e7551b0SMatthias Ringwald     int request_number;
1450e7551b0SMatthias Ringwald     const char * current_folder;
1460e7551b0SMatthias Ringwald     const char * phone_number;
1470e7551b0SMatthias Ringwald     const char * phonebook_path;
1480e7551b0SMatthias Ringwald     const char * vcard_name;
1490e7551b0SMatthias Ringwald     uint16_t set_path_offset;
1500e7551b0SMatthias Ringwald     /* vcard selector / operator */
1510e7551b0SMatthias Ringwald     uint32_t vcard_selector;
1520e7551b0SMatthias Ringwald     uint8_t  vcard_selector_operator;
1530e7551b0SMatthias Ringwald     uint8_t  vcard_selector_supported;
1540e7551b0SMatthias Ringwald     /* property selector */
1550e7551b0SMatthias Ringwald     uint32_t     property_selector;
1560e7551b0SMatthias Ringwald     uint16_t     list_start_offset;
1570e7551b0SMatthias Ringwald     uint16_t     max_list_count;
158*8981e442SMatthias Ringwald     uint8_t      order;
159*8981e442SMatthias Ringwald     uint8_t      search_property;
160*8981e442SMatthias Ringwald     const char * search_value;
1610e7551b0SMatthias Ringwald     /* abort */
1620e7551b0SMatthias Ringwald     uint8_t  abort_operation;
1630e7551b0SMatthias Ringwald     /* obex parser */
1640e7551b0SMatthias Ringwald     bool obex_parser_waiting_for_response;
1650e7551b0SMatthias Ringwald     obex_parser_t obex_parser;
1660e7551b0SMatthias Ringwald     uint8_t obex_header_buffer[4];
1670e7551b0SMatthias Ringwald     /* authentication */
1681a3b1957SMatthias Ringwald     pbap_client_obex_auth_parser_t obex_auth_parser;
1690e7551b0SMatthias Ringwald     const char * authentication_password;
1700e7551b0SMatthias Ringwald     /* xml parser */
1710e7551b0SMatthias Ringwald     yxml_t  xml_parser;
1720e7551b0SMatthias Ringwald     uint8_t xml_buffer[50];
1730e7551b0SMatthias Ringwald     /* vcard listing parser */
1740e7551b0SMatthias Ringwald     bool parser_card_found;
1750e7551b0SMatthias Ringwald     bool parser_name_found;
1760e7551b0SMatthias Ringwald     bool parser_handle_found;
1770e7551b0SMatthias Ringwald     char parser_name[PBAP_MAX_NAME_LEN];
1780e7551b0SMatthias Ringwald     char parser_handle[PBAP_MAX_HANDLE_LEN];
1790e7551b0SMatthias Ringwald     /* phonebook size */
1800e7551b0SMatthias Ringwald     pbap_client_phonebook_size_parser_t phonebook_size_parser;
1810e7551b0SMatthias Ringwald     /* flow control mode */
1820e7551b0SMatthias Ringwald     uint8_t flow_control_enabled;
1830e7551b0SMatthias Ringwald     uint8_t flow_next_triggered;
1840e7551b0SMatthias Ringwald     bool flow_wait_for_user;
1850e7551b0SMatthias Ringwald     /* srm */
186e14fb63cSMatthias Ringwald     obex_srm_client_t obex_srm;
1870e7551b0SMatthias Ringwald } pbap_client_t;
1880e7551b0SMatthias Ringwald 
189f1b34e8dSMatthias Ringwald /* API_START */
190f1b34e8dSMatthias Ringwald 
191f1b34e8dSMatthias Ringwald /**
192f1b34e8dSMatthias Ringwald  * Setup PhoneBook Access Client
193f1b34e8dSMatthias Ringwald  */
194f1b34e8dSMatthias Ringwald void pbap_client_init(void);
195f1b34e8dSMatthias Ringwald 
196f1b34e8dSMatthias Ringwald /**
1971c7aea60SMilanka Ringwald  * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device.
1981c7aea60SMilanka Ringwald  * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which
1991c7aea60SMilanka Ringwald  * can be answered with pbap_authentication_password(..).
2001c7aea60SMilanka Ringwald  * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event,
2011c7aea60SMilanka Ringwald  * i.e. on success status field is set to ERROR_CODE_SUCCESS.
2021c7aea60SMilanka Ringwald  *
203f3185e85SMatthias Ringwald  * This function allows for multiple parallel connections.
204f3185e85SMatthias Ringwald  *
205f3185e85SMatthias Ringwald  * @param client storage for connection state. Must stay valid until connection closes
2060806590aSMatthias Ringwald  * @param l2cap_ertm_config
2070806590aSMatthias Ringwald  * @param l2cap_ertm_buffer_size
2080806590aSMatthias Ringwald  * @param l2cap_ertm_buffer
209f3185e85SMatthias Ringwald  * @param handler
210f3185e85SMatthias Ringwald  * @param addr
211f3185e85SMatthias Ringwald  * @param out_cid to use for further commands
212f3185e85SMatthias Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists.
213f3185e85SMatthias Ringwald  */
214f3185e85SMatthias Ringwald 
2150806590aSMatthias Ringwald uint8_t pbap_client_connect(pbap_client_t * client, l2cap_ertm_config_t *l2cap_ertm_config, uint8_t *l2cap_ertm_buffer,
2160806590aSMatthias Ringwald                             uint16_t l2cap_ertm_buffer_size, btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid);
217f3185e85SMatthias Ringwald 
218f3185e85SMatthias Ringwald /**
219f3185e85SMatthias Ringwald  * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device.
220f3185e85SMatthias Ringwald  * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which
221f3185e85SMatthias Ringwald  * can be answered with pbap_authentication_password(..).
222f3185e85SMatthias Ringwald  * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event,
223f3185e85SMatthias Ringwald  * i.e. on success status field is set to ERROR_CODE_SUCCESS.
224f3185e85SMatthias Ringwald  *
225dff8de67SMatthias Ringwald  * This function uses a single pbap_client_t and l2cap ertm buffer instance and can only be used for a single connection.
226f3185e85SMatthias Ringwald  * Fur multiple parallel connections, use pbap_client_connect.
227f3185e85SMatthias Ringwald  *
228f1b34e8dSMatthias Ringwald  * @param handler
229f1b34e8dSMatthias Ringwald  * @param addr
230f1b34e8dSMatthias Ringwald  * @param out_cid to use for further commands
2311c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists.
232f1b34e8dSMatthias Ringwald  */
233f1b34e8dSMatthias Ringwald uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid);
234f1b34e8dSMatthias Ringwald 
235f1b34e8dSMatthias Ringwald /**
2361c7aea60SMilanka Ringwald  * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST.
2371c7aea60SMilanka Ringwald  * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event,
2381c7aea60SMilanka Ringwald  * i.e. on success status field is set to ERROR_CODE_SUCCESS.
2391c7aea60SMilanka Ringwald  *
240c1bc0b8eSMatthias Ringwald  * @param pbap_cid
241c1bc0b8eSMatthias Ringwald  * @param password (null terminated string) - not copied, needs to stay valid until connection completed
2421c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
243c1bc0b8eSMatthias Ringwald  */
244c1bc0b8eSMatthias Ringwald uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password);
245c1bc0b8eSMatthias Ringwald 
246c1bc0b8eSMatthias Ringwald /**
247f1b34e8dSMatthias Ringwald  * @brief Disconnects PBAP connection with given identifier.
2481c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_CONNECTION_CLOSED indicates that PBAP connection is closed.
2491c7aea60SMilanka Ringwald  *
250f1b34e8dSMatthias Ringwald  * @param pbap_cid
2511c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
252f1b34e8dSMatthias Ringwald  */
253f1b34e8dSMatthias Ringwald uint8_t pbap_disconnect(uint16_t pbap_cid);
254f1b34e8dSMatthias Ringwald 
255f1b34e8dSMatthias Ringwald /**
2561c7aea60SMilanka Ringwald  * @brief Set current folder on PSE. The status is reported via PBAP_SUBEVENT_OPERATION_COMPLETED event.
2571c7aea60SMilanka Ringwald  *
258f1b34e8dSMatthias Ringwald  * @param pbap_cid
259f1b34e8dSMatthias Ringwald  * @param path - note: path is not copied
2601c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
261f1b34e8dSMatthias Ringwald  */
262f1b34e8dSMatthias Ringwald uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path);
263f1b34e8dSMatthias Ringwald 
264f1b34e8dSMatthias Ringwald /**
2651c7aea60SMilanka Ringwald  * @brief Set vCard Selector for get/pull phonebook. No event is emitted.
2661c7aea60SMilanka Ringwald  *
2673127f224SMatthias Ringwald  * @param pbap_cid
2683127f224SMatthias Ringwald  * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties
2691c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
2703127f224SMatthias Ringwald  */
2713127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector);
2723127f224SMatthias Ringwald 
2733127f224SMatthias 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_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND
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_operator(uint16_t pbap_cid, int vcard_selector_operator);
2813127f224SMatthias Ringwald 
2823127f224SMatthias Ringwald /**
283e9b4d967SMatthias Ringwald  * @brief Set Property Selector. No event is emitted.
284e9b4d967SMatthias Ringwald  * @param pbap_cid
285e9b4d967SMatthias Ringwald  * @param property_selector - combination of PBAP_PROPERTY_MASK_* properties
286e9b4d967SMatthias Ringwald  * @return
287e9b4d967SMatthias Ringwald  */
288e9b4d967SMatthias Ringwald uint8_t pbap_set_property_selector(uint16_t pbap_cid, uint32_t property_selector);
289e9b4d967SMatthias Ringwald 
290e9b4d967SMatthias Ringwald /**
29104f86d08SMatthias Ringwald  * @brief Set number of items returned by pull phonebook.
29204f86d08SMatthias Ringwald  * @param pbap_cid
29304f86d08SMatthias Ringwald  * @param max_list_count
29404f86d08SMatthias Ringwald  * @return
29504f86d08SMatthias Ringwald  */
29604f86d08SMatthias Ringwald uint8_t pbap_set_max_list_count(uint16_t pbap_cid, uint16_t max_list_count);
29704f86d08SMatthias Ringwald 
29804f86d08SMatthias Ringwald /**
29904f86d08SMatthias Ringwald  * @bbrief Set start offset for pull phonebook
30004f86d08SMatthias Ringwald  * @param pbap_cid
30104f86d08SMatthias Ringwald  * @param list_start_offset
30204f86d08SMatthias Ringwald  * @return
30304f86d08SMatthias Ringwald  */
30404f86d08SMatthias Ringwald uint8_t pbap_set_list_start_offset(uint16_t pbap_cid, uint16_t list_start_offset);
30504f86d08SMatthias Ringwald 
30604f86d08SMatthias Ringwald /**
307*8981e442SMatthias Ringwald  * @bbrief Set order for pbap_pull_vcard_listing
308*8981e442SMatthias Ringwald  * @param pbap_cid
309*8981e442SMatthias Ringwald  * @param order
310*8981e442SMatthias Ringwald  * @return
311*8981e442SMatthias Ringwald  */
312*8981e442SMatthias Ringwald uint8_t pbap_set_order(uint16_t pbap_cid, uint8_t order);
313*8981e442SMatthias Ringwald 
314*8981e442SMatthias Ringwald /**
315*8981e442SMatthias Ringwald  * @bbrief Set search property for pbap_pull_vcard_listing
316*8981e442SMatthias Ringwald  * @param pbap_cid
317*8981e442SMatthias Ringwald  * @param search_property
318*8981e442SMatthias Ringwald  * @return
319*8981e442SMatthias Ringwald  */
320*8981e442SMatthias Ringwald uint8_t pbap_set_search_property(uint16_t pbap_cid, uint8_t search_property);
321*8981e442SMatthias Ringwald 
322*8981e442SMatthias Ringwald /**
323*8981e442SMatthias Ringwald  * @bbrief Set search property for pbap_pull_vcard_listing
324*8981e442SMatthias Ringwald  * @param pbap_cid
325*8981e442SMatthias Ringwald  * @param search_value
326*8981e442SMatthias Ringwald  * @return
327*8981e442SMatthias Ringwald  */
328*8981e442SMatthias Ringwald uint8_t pbap_set_search_value(uint16_t pbap_cid, const char * search_value);
329*8981e442SMatthias Ringwald 
330*8981e442SMatthias Ringwald /**
3311c7aea60SMilanka Ringwald  * @brief Get size of phone book from PSE. The result is reported via PBAP_SUBEVENT_PHONEBOOK_SIZE event.
3321c7aea60SMilanka Ringwald  *
3333a7447a3SMatthias Ringwald  * @param pbap_cid
3348c94c044SMatthias Ringwald  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
3351c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
3363a7447a3SMatthias Ringwald  */
3378c94c044SMatthias Ringwald uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path);
3383a7447a3SMatthias Ringwald 
3393a7447a3SMatthias Ringwald /**
3401c7aea60SMilanka Ringwald  * @brief Pull phone book from PSE. The result is reported via registered packet handler (see pbap_connect function),
3411c7aea60SMilanka Ringwald  * with packet type set to PBAP_DATA_PACKET. Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the phone book.
3421c7aea60SMilanka Ringwald  *
343f1b34e8dSMatthias Ringwald  * @param pbap_cid
3448c94c044SMatthias Ringwald  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
3451c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
346f1b34e8dSMatthias Ringwald  */
3478c94c044SMatthias Ringwald uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path);
348e03b79abSMatthias Ringwald 
349e03b79abSMatthias Ringwald /**
3501c7aea60SMilanka Ringwald  * @brief Pull vCard listing. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event.
3511c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of vCard listing.
3521c7aea60SMilanka Ringwald  *
3534687d289SMatthias Ringwald  * @param pbap_cid
3544687d289SMatthias Ringwald  * @param path
3551c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
3564687d289SMatthias Ringwald  */
3574687d289SMatthias Ringwald uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path);
3584687d289SMatthias Ringwald 
3594687d289SMatthias Ringwald /**
3601c7aea60SMilanka Ringwald  * @brief Pull vCard entry. The result is reported via callback (see pbap_connect function),
3611c7aea60SMilanka Ringwald  * with packet type set to PBAP_DATA_PACKET.
3621c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the vCard entry.
3631c7aea60SMilanka Ringwald  *
36416ad3745SMatthias Ringwald  * @param pbap_cid
36516ad3745SMatthias Ringwald  * @param path
3661c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
36716ad3745SMatthias Ringwald  */
36816ad3745SMatthias Ringwald uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path);
36916ad3745SMatthias Ringwald 
37016ad3745SMatthias Ringwald /**
3711c7aea60SMilanka Ringwald  * @brief Lookup contact(s) by phone number. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event.
3721c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the lookup.
3731c7aea60SMilanka Ringwald  *
374e03b79abSMatthias Ringwald  * @param pbap_cid
375e03b79abSMatthias Ringwald  * @param phone_number
3761c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
377e03b79abSMatthias Ringwald  */
378e03b79abSMatthias Ringwald uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number);
379f1b34e8dSMatthias Ringwald 
380d4436ef5SMatthias Ringwald /**
3811c7aea60SMilanka Ringwald  * @brief Abort current operation. No event is emitted.
3821c7aea60SMilanka Ringwald  *
3839eb7827dSMatthias Ringwald  * @param pbap_cid
3841c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
3859eb7827dSMatthias Ringwald  */
3869eb7827dSMatthias Ringwald uint8_t pbap_abort(uint16_t pbap_cid);
3879eb7827dSMatthias Ringwald 
3889eb7827dSMatthias Ringwald 
3899eb7827dSMatthias Ringwald /**
3901c7aea60SMilanka Ringwald  * @brief Set flow control mode - default is off. No event is emitted.
391d4436ef5SMatthias Ringwald  * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one
3921c7aea60SMilanka Ringwald  *
3938854a89dSMatthias Ringwald  * @param pbap_cid
3941c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
395d4436ef5SMatthias Ringwald  */
3968854a89dSMatthias Ringwald uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable);
397d4436ef5SMatthias Ringwald 
398d4436ef5SMatthias Ringwald /**
3991c7aea60SMilanka Ringwald  * @brief Trigger next packet from PSE when Flow Control Mode is enabled.
400d4436ef5SMatthias Ringwald  * @param pbap_cid
4011c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
402d4436ef5SMatthias Ringwald  */
403d4436ef5SMatthias Ringwald uint8_t pbap_next_packet(uint16_t pbap_cid);
404d4436ef5SMatthias Ringwald 
4051d0ae3baSMatthias Ringwald /**
4061d0ae3baSMatthias Ringwald  * @brief De-Init PBAP Client
4071d0ae3baSMatthias Ringwald  */
4081d0ae3baSMatthias Ringwald void pbap_client_deinit(void);
409d4436ef5SMatthias Ringwald 
410f1b34e8dSMatthias Ringwald /* API_END */
411f1b34e8dSMatthias Ringwald 
412f1b34e8dSMatthias Ringwald #if defined __cplusplus
413f1b34e8dSMatthias Ringwald }
414f1b34e8dSMatthias Ringwald #endif
415f1b34e8dSMatthias Ringwald #endif
416