xref: /btstack/src/classic/pbap_client.h (revision 0e7551b04b019c6cc0939abb4c26ccb398dccc6c)
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 
50f1b34e8dSMatthias Ringwald #include "btstack_config.h"
51*0e7551b0SMatthias Ringwald #include "yxml.h"
52f1b34e8dSMatthias Ringwald #include <stdint.h>
53f1b34e8dSMatthias Ringwald 
5483f1bca0SMatthias Ringwald // max len of phone number used for lookup in pbap_lookup_by_number
5583f1bca0SMatthias Ringwald #define PBAP_MAX_PHONE_NUMBER_LEN 32
5683f1bca0SMatthias Ringwald 
5783f1bca0SMatthias Ringwald // max len of name reported in PBAP_SUBEVENT_CARD_RESULT
5883f1bca0SMatthias Ringwald #define PBAP_MAX_NAME_LEN   32
5983f1bca0SMatthias Ringwald // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT
6083f1bca0SMatthias Ringwald #define PBAP_MAX_HANDLE_LEN 16
6183f1bca0SMatthias Ringwald 
62*0e7551b0SMatthias Ringwald 
63*0e7551b0SMatthias Ringwald typedef enum {
64*0e7551b0SMatthias Ringwald     PBAP_CLIENT_INIT = 0,
65*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GOEP_CONNECTION,
66*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_CONNECT_REQUEST,
67*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_CONNECT_RESPONSE,
68*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_USER_AUTHENTICATION,
69*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_AUTHENTICATED_CONNECT,
70*0e7551b0SMatthias Ringwald     PBAP_CLIENT_CONNECTED,
71*0e7551b0SMatthias Ringwald     //
72*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SEND_DISCONNECT_REQUEST,
73*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_DISCONNECT_RESPONSE,
74*0e7551b0SMatthias Ringwald     //
75*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_PULL_PHONEBOOK,
76*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_PHONEBOOK,
77*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SET_PATH_ROOT,
78*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_SET_PATH_ROOT_COMPLETE,
79*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_SET_PATH_ELEMENT,
80*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_SET_PATH_ELEMENT_COMPLETE,
81*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_PHONEBOOK_SIZE,
82*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_PHONEBOOK_SIZE_COMPLETE,
83*0e7551b0SMatthias Ringwald     // - pull vacard liast
84*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_CARD_LIST,
85*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_CARD_LIST_COMPLETE,
86*0e7551b0SMatthias Ringwald     // - pull vcard entry
87*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W2_GET_CARD_ENTRY,
88*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_GET_CARD_ENTRY_COMPLETE,
89*0e7551b0SMatthias Ringwald     // abort operation
90*0e7551b0SMatthias Ringwald     PBAP_CLIENT_W4_ABORT_COMPLETE,
91*0e7551b0SMatthias Ringwald 
92*0e7551b0SMatthias Ringwald } pbap_client_state_t;
93*0e7551b0SMatthias Ringwald 
94*0e7551b0SMatthias Ringwald typedef enum {
95*0e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_TYPE = 0,
96*0e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_LEN,
97*0e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_VALUE,
98*0e7551b0SMatthias Ringwald     PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_INVALID,
99*0e7551b0SMatthias Ringwald } pbap_client_phonebook_size_parser_state_t;
100*0e7551b0SMatthias Ringwald 
101*0e7551b0SMatthias Ringwald typedef struct {
102*0e7551b0SMatthias Ringwald     // parsing
103*0e7551b0SMatthias Ringwald     pbap_client_phonebook_size_parser_state_t state;
104*0e7551b0SMatthias Ringwald     uint8_t type;
105*0e7551b0SMatthias Ringwald     uint8_t len;
106*0e7551b0SMatthias Ringwald     uint8_t pos;
107*0e7551b0SMatthias Ringwald     // data
108*0e7551b0SMatthias Ringwald     bool have_size;
109*0e7551b0SMatthias Ringwald     uint8_t  size_buffer[2];
110*0e7551b0SMatthias Ringwald } pbap_client_phonebook_size_parser_t;
111*0e7551b0SMatthias Ringwald 
112*0e7551b0SMatthias Ringwald typedef struct pbap_client {
113*0e7551b0SMatthias Ringwald     goep_client_t goep_client;
114*0e7551b0SMatthias Ringwald 
115*0e7551b0SMatthias Ringwald     pbap_client_state_t state;
116*0e7551b0SMatthias Ringwald     uint16_t  cid;
117*0e7551b0SMatthias Ringwald     bd_addr_t bd_addr;
118*0e7551b0SMatthias Ringwald     hci_con_handle_t con_handle;
119*0e7551b0SMatthias Ringwald     uint8_t   incoming;
120*0e7551b0SMatthias Ringwald     uint16_t  goep_cid;
121*0e7551b0SMatthias Ringwald     btstack_packet_handler_t client_handler;
122*0e7551b0SMatthias Ringwald     int request_number;
123*0e7551b0SMatthias Ringwald     const char * current_folder;
124*0e7551b0SMatthias Ringwald     const char * phone_number;
125*0e7551b0SMatthias Ringwald     const char * phonebook_path;
126*0e7551b0SMatthias Ringwald     const char * vcard_name;
127*0e7551b0SMatthias Ringwald     uint16_t set_path_offset;
128*0e7551b0SMatthias Ringwald     /* vcard selector / operator */
129*0e7551b0SMatthias Ringwald     uint32_t vcard_selector;
130*0e7551b0SMatthias Ringwald     uint8_t  vcard_selector_operator;
131*0e7551b0SMatthias Ringwald     uint8_t  vcard_selector_supported;
132*0e7551b0SMatthias Ringwald     /* property selector */
133*0e7551b0SMatthias Ringwald     uint32_t property_selector;
134*0e7551b0SMatthias Ringwald     uint16_t list_start_offset;
135*0e7551b0SMatthias Ringwald     uint16_t max_list_count;
136*0e7551b0SMatthias Ringwald     /* abort */
137*0e7551b0SMatthias Ringwald     uint8_t  abort_operation;
138*0e7551b0SMatthias Ringwald     /* obex parser */
139*0e7551b0SMatthias Ringwald     bool obex_parser_waiting_for_response;
140*0e7551b0SMatthias Ringwald     obex_parser_t obex_parser;
141*0e7551b0SMatthias Ringwald     uint8_t obex_header_buffer[4];
142*0e7551b0SMatthias Ringwald     /* authentication */
143*0e7551b0SMatthias Ringwald     obex_auth_parser_t obex_auth_parser;
144*0e7551b0SMatthias Ringwald     const char * authentication_password;
145*0e7551b0SMatthias Ringwald     /* xml parser */
146*0e7551b0SMatthias Ringwald     yxml_t  xml_parser;
147*0e7551b0SMatthias Ringwald     uint8_t xml_buffer[50];
148*0e7551b0SMatthias Ringwald     /* vcard listing parser */
149*0e7551b0SMatthias Ringwald     bool parser_card_found;
150*0e7551b0SMatthias Ringwald     bool parser_name_found;
151*0e7551b0SMatthias Ringwald     bool parser_handle_found;
152*0e7551b0SMatthias Ringwald     char parser_name[PBAP_MAX_NAME_LEN];
153*0e7551b0SMatthias Ringwald     char parser_handle[PBAP_MAX_HANDLE_LEN];
154*0e7551b0SMatthias Ringwald     /* phonebook size */
155*0e7551b0SMatthias Ringwald     pbap_client_phonebook_size_parser_t phonebook_size_parser;
156*0e7551b0SMatthias Ringwald     /* flow control mode */
157*0e7551b0SMatthias Ringwald     uint8_t flow_control_enabled;
158*0e7551b0SMatthias Ringwald     uint8_t flow_next_triggered;
159*0e7551b0SMatthias Ringwald     bool flow_wait_for_user;
160*0e7551b0SMatthias Ringwald     /* srm */
161*0e7551b0SMatthias Ringwald     obex_srm_t obex_srm;
162*0e7551b0SMatthias Ringwald     obex_srm_state_t srm_state;
163*0e7551b0SMatthias Ringwald } pbap_client_t;
164*0e7551b0SMatthias Ringwald 
165f1b34e8dSMatthias Ringwald /* API_START */
166f1b34e8dSMatthias Ringwald 
167f1b34e8dSMatthias Ringwald /**
168f1b34e8dSMatthias Ringwald  * Setup PhoneBook Access Client
169f1b34e8dSMatthias Ringwald  */
170f1b34e8dSMatthias Ringwald void pbap_client_init(void);
171f1b34e8dSMatthias Ringwald 
172f1b34e8dSMatthias Ringwald /**
1731c7aea60SMilanka Ringwald  * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device.
1741c7aea60SMilanka Ringwald  * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which
1751c7aea60SMilanka Ringwald  * can be answered with pbap_authentication_password(..).
1761c7aea60SMilanka Ringwald  * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event,
1771c7aea60SMilanka Ringwald  * i.e. on success status field is set to ERROR_CODE_SUCCESS.
1781c7aea60SMilanka Ringwald  *
179f1b34e8dSMatthias Ringwald  * @param handler
180f1b34e8dSMatthias Ringwald  * @param addr
181f1b34e8dSMatthias Ringwald  * @param out_cid to use for further commands
1821c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists.
183f1b34e8dSMatthias Ringwald  */
184f1b34e8dSMatthias Ringwald uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid);
185f1b34e8dSMatthias Ringwald 
186f1b34e8dSMatthias Ringwald /**
1871c7aea60SMilanka Ringwald  * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST.
1881c7aea60SMilanka Ringwald  * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event,
1891c7aea60SMilanka Ringwald  * i.e. on success status field is set to ERROR_CODE_SUCCESS.
1901c7aea60SMilanka Ringwald  *
191c1bc0b8eSMatthias Ringwald  * @param pbap_cid
192c1bc0b8eSMatthias Ringwald  * @param password (null terminated string) - not copied, needs to stay valid until connection completed
1931c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
194c1bc0b8eSMatthias Ringwald  */
195c1bc0b8eSMatthias Ringwald uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password);
196c1bc0b8eSMatthias Ringwald 
197c1bc0b8eSMatthias Ringwald /**
198f1b34e8dSMatthias Ringwald  * @brief Disconnects PBAP connection with given identifier.
1991c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_CONNECTION_CLOSED indicates that PBAP connection is closed.
2001c7aea60SMilanka Ringwald  *
201f1b34e8dSMatthias Ringwald  * @param pbap_cid
2021c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
203f1b34e8dSMatthias Ringwald  */
204f1b34e8dSMatthias Ringwald uint8_t pbap_disconnect(uint16_t pbap_cid);
205f1b34e8dSMatthias Ringwald 
206f1b34e8dSMatthias Ringwald /**
2071c7aea60SMilanka Ringwald  * @brief Set current folder on PSE. The status is reported via PBAP_SUBEVENT_OPERATION_COMPLETED event.
2081c7aea60SMilanka Ringwald  *
209f1b34e8dSMatthias Ringwald  * @param pbap_cid
210f1b34e8dSMatthias Ringwald  * @param path - note: path is not copied
2111c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
212f1b34e8dSMatthias Ringwald  */
213f1b34e8dSMatthias Ringwald uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path);
214f1b34e8dSMatthias Ringwald 
215f1b34e8dSMatthias Ringwald /**
2161c7aea60SMilanka Ringwald  * @brief Set vCard Selector for get/pull phonebook. No event is emitted.
2171c7aea60SMilanka Ringwald  *
2183127f224SMatthias Ringwald  * @param pbap_cid
2193127f224SMatthias Ringwald  * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties
2201c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
2213127f224SMatthias Ringwald  */
2223127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector);
2233127f224SMatthias Ringwald 
2243127f224SMatthias Ringwald /**
2251c7aea60SMilanka Ringwald  * @brief Set vCard Selector for get/pull phonebook. No event is emitted.
2261c7aea60SMilanka Ringwald  *
2273127f224SMatthias Ringwald  * @param pbap_cid
2283127f224SMatthias Ringwald  * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND
2291c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
2303127f224SMatthias Ringwald  */
2313127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator);
2323127f224SMatthias Ringwald 
2333127f224SMatthias Ringwald /**
234e9b4d967SMatthias Ringwald  * @brief Set Property Selector. No event is emitted.
235e9b4d967SMatthias Ringwald  * @param pbap_cid
236e9b4d967SMatthias Ringwald  * @param property_selector - combination of PBAP_PROPERTY_MASK_* properties
237e9b4d967SMatthias Ringwald  * @return
238e9b4d967SMatthias Ringwald  */
239e9b4d967SMatthias Ringwald uint8_t pbap_set_property_selector(uint16_t pbap_cid, uint32_t property_selector);
240e9b4d967SMatthias Ringwald 
241e9b4d967SMatthias Ringwald /**
24204f86d08SMatthias Ringwald  * @brief Set number of items returned by pull phonebook.
24304f86d08SMatthias Ringwald  * @param pbap_cid
24404f86d08SMatthias Ringwald  * @param max_list_count
24504f86d08SMatthias Ringwald  * @return
24604f86d08SMatthias Ringwald  */
24704f86d08SMatthias Ringwald uint8_t pbap_set_max_list_count(uint16_t pbap_cid, uint16_t max_list_count);
24804f86d08SMatthias Ringwald 
24904f86d08SMatthias Ringwald /**
25004f86d08SMatthias Ringwald  * @bbrief Set start offset for pull phonebook
25104f86d08SMatthias Ringwald  * @param pbap_cid
25204f86d08SMatthias Ringwald  * @param list_start_offset
25304f86d08SMatthias Ringwald  * @return
25404f86d08SMatthias Ringwald  */
25504f86d08SMatthias Ringwald uint8_t pbap_set_list_start_offset(uint16_t pbap_cid, uint16_t list_start_offset);
25604f86d08SMatthias Ringwald 
25704f86d08SMatthias Ringwald /**
2581c7aea60SMilanka Ringwald  * @brief Get size of phone book from PSE. The result is reported via PBAP_SUBEVENT_PHONEBOOK_SIZE event.
2591c7aea60SMilanka Ringwald  *
2603a7447a3SMatthias Ringwald  * @param pbap_cid
2618c94c044SMatthias Ringwald  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
2621c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
2633a7447a3SMatthias Ringwald  */
2648c94c044SMatthias Ringwald uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path);
2653a7447a3SMatthias Ringwald 
2663a7447a3SMatthias Ringwald /**
2671c7aea60SMilanka Ringwald  * @brief Pull phone book from PSE. The result is reported via registered packet handler (see pbap_connect function),
2681c7aea60SMilanka Ringwald  * with packet type set to PBAP_DATA_PACKET. Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the phone book.
2691c7aea60SMilanka Ringwald  *
270f1b34e8dSMatthias Ringwald  * @param pbap_cid
2718c94c044SMatthias Ringwald  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
2721c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
273f1b34e8dSMatthias Ringwald  */
2748c94c044SMatthias Ringwald uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path);
275e03b79abSMatthias Ringwald 
276e03b79abSMatthias Ringwald /**
2771c7aea60SMilanka Ringwald  * @brief Pull vCard listing. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event.
2781c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of vCard listing.
2791c7aea60SMilanka Ringwald  *
2804687d289SMatthias Ringwald  * @param pbap_cid
2814687d289SMatthias Ringwald  * @param path
2821c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
2834687d289SMatthias Ringwald  */
2844687d289SMatthias Ringwald uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path);
2854687d289SMatthias Ringwald 
2864687d289SMatthias Ringwald /**
2871c7aea60SMilanka Ringwald  * @brief Pull vCard entry. The result is reported via callback (see pbap_connect function),
2881c7aea60SMilanka Ringwald  * with packet type set to PBAP_DATA_PACKET.
2891c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the vCard entry.
2901c7aea60SMilanka Ringwald  *
29116ad3745SMatthias Ringwald  * @param pbap_cid
29216ad3745SMatthias Ringwald  * @param path
2931c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
29416ad3745SMatthias Ringwald  */
29516ad3745SMatthias Ringwald uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path);
29616ad3745SMatthias Ringwald 
29716ad3745SMatthias Ringwald /**
2981c7aea60SMilanka Ringwald  * @brief Lookup contact(s) by phone number. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event.
2991c7aea60SMilanka Ringwald  * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the lookup.
3001c7aea60SMilanka Ringwald  *
301e03b79abSMatthias Ringwald  * @param pbap_cid
302e03b79abSMatthias Ringwald  * @param phone_number
3031c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
304e03b79abSMatthias Ringwald  */
305e03b79abSMatthias Ringwald uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number);
306f1b34e8dSMatthias Ringwald 
307d4436ef5SMatthias Ringwald /**
3081c7aea60SMilanka Ringwald  * @brief Abort current operation. No event is emitted.
3091c7aea60SMilanka Ringwald  *
3109eb7827dSMatthias Ringwald  * @param pbap_cid
3111c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
3129eb7827dSMatthias Ringwald  */
3139eb7827dSMatthias Ringwald uint8_t pbap_abort(uint16_t pbap_cid);
3149eb7827dSMatthias Ringwald 
3159eb7827dSMatthias Ringwald 
3169eb7827dSMatthias Ringwald /**
3171c7aea60SMilanka Ringwald  * @brief Set flow control mode - default is off. No event is emitted.
318d4436ef5SMatthias Ringwald  * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one
3191c7aea60SMilanka Ringwald  *
3208854a89dSMatthias Ringwald  * @param pbap_cid
3211c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
322d4436ef5SMatthias Ringwald  */
3238854a89dSMatthias Ringwald uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable);
324d4436ef5SMatthias Ringwald 
325d4436ef5SMatthias Ringwald /**
3261c7aea60SMilanka Ringwald  * @brief Trigger next packet from PSE when Flow Control Mode is enabled.
327d4436ef5SMatthias Ringwald  * @param pbap_cid
3281c7aea60SMilanka Ringwald  * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state.
329d4436ef5SMatthias Ringwald  */
330d4436ef5SMatthias Ringwald uint8_t pbap_next_packet(uint16_t pbap_cid);
331d4436ef5SMatthias Ringwald 
3321d0ae3baSMatthias Ringwald /**
3331d0ae3baSMatthias Ringwald  * @brief De-Init PBAP Client
3341d0ae3baSMatthias Ringwald  */
3351d0ae3baSMatthias Ringwald void pbap_client_deinit(void);
336d4436ef5SMatthias Ringwald 
337f1b34e8dSMatthias Ringwald /* API_END */
338f1b34e8dSMatthias Ringwald 
339f1b34e8dSMatthias Ringwald #if defined __cplusplus
340f1b34e8dSMatthias Ringwald }
341f1b34e8dSMatthias Ringwald #endif
342f1b34e8dSMatthias Ringwald #endif
343