xref: /btstack/src/classic/pbap_client.h (revision 630ffdd469bbec3276322f46b93e6cfdfcb21c27)
1 /*
2  * Copyright (C) 2014 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 #ifndef __GOEP_CLIENT_H
39 
40 #if defined __cplusplus
41 extern "C" {
42 #endif
43 
44 #include "btstack_config.h"
45 #include <stdint.h>
46 
47 // max len of phone number used for lookup in pbap_lookup_by_number
48 #define PBAP_MAX_PHONE_NUMBER_LEN 32
49 
50 // max len of name reported in PBAP_SUBEVENT_CARD_RESULT
51 #define PBAP_MAX_NAME_LEN   32
52 // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT
53 #define PBAP_MAX_HANDLE_LEN 16
54 
55 /* API_START */
56 
57 // PBAP Supported Features
58 
59 #define PBAP_SUPPORTED_FEATURES_DOWNLOAD                        (1<<0)
60 #define PBAP_SUPPORTED_FEATURES_BROWSING                        (1<<1)
61 #define PBAP_SUPPORTED_FEATURES_DATABASE_IDENTIFIER             (1<<2)
62 #define PBAP_SUPPORTED_FEATURES_FOLDER_VERSION_COUNTERS         (1<<3)
63 #define PBAP_SUPPORTED_FEATURES_VCARD_SELECTING                 (1<<4)
64 #define PBAP_SUPPORTED_FEATURES_ENHANCED_MISSED_CALLS           (1<<5)
65 #define PBAP_SUPPORTED_FEATURES_X_BT_UCI_VCARD_PROPERTY         (1<<6)
66 #define PBAP_SUPPORTED_FEATURES_X_BT_UID_VCARD_PROPERTY         (1<<7)
67 #define PBAP_SUPPORTED_FEATURES_CONTACT_REFERENCING             (1<<8)
68 #define PBAP_SUPPORTED_FEATURES_DEFAULT_CONTACT_IMAGE_FORMAT    (1<<9)
69 
70 // PBAP Property Mask - also used for vCardSelector
71 #define PBAP_PROPERTY_MASK_VERSION              (1<< 0) // vCard Version
72 #define PBAP_PROPERTY_MASK_FN                   (1<< 1) // Formatted Name
73 #define PBAP_PROPERTY_MASK_N                    (1<< 2) // Structured Presentation of Name
74 #define PBAP_PROPERTY_MASK_PHOTO                (1<< 3) // Associated Image or Photo
75 #define PBAP_PROPERTY_MASK_BDAY                 (1<< 4) // Birthday
76 #define PBAP_PROPERTY_MASK_ADR                  (1<< 5) // Delivery Address
77 #define PBAP_PROPERTY_MASK_LABEL                (1<< 6) // Delivery
78 #define PBAP_PROPERTY_MASK_TEL                  (1<< 7) // Telephone Number
79 #define PBAP_PROPERTY_MASK_EMAIL                (1<< 8) // Electronic Mail Address
80 #define PBAP_PROPERTY_MASK_MAILER               (1<< 9) // Electronic Mail
81 #define PBAP_PROPERTY_MASK_TZ                   (1<<10) // Time Zone
82 #define PBAP_PROPERTY_MASK_GEO                  (1<<11) // Geographic Position
83 #define PBAP_PROPERTY_MASK_TITLE                (1<<12) // Job
84 #define PBAP_PROPERTY_MASK_ROLE                 (1<<13) // Role within the Organization
85 #define PBAP_PROPERTY_MASK_LOGO                 (1<<14) // Organization Logo
86 #define PBAP_PROPERTY_MASK_AGENT                (1<<15) // vCard of Person Representing
87 #define PBAP_PROPERTY_MASK_ORG                  (1<<16) // Name of Organization
88 #define PBAP_PROPERTY_MASK_NOTE                 (1<<17) // Comments
89 #define PBAP_PROPERTY_MASK_REV                  (1<<18) // Revision
90 #define PBAP_PROPERTY_MASK_SOUND                (1<<19) // Pronunciation of Name
91 #define PBAP_PROPERTY_MASK_URL                  (1<<20) // Uniform Resource Locator
92 #define PBAP_PROPERTY_MASK_UID                  (1<<21) // Unique ID
93 #define PBAP_PROPERTY_MASK_KEY                  (1<<22) // Public Encryption Key
94 #define PBAP_PROPERTY_MASK_NICKNAME             (1<<23) // Nickname
95 #define PBAP_PROPERTY_MASK_CATEGORIES           (1<<24) // Categories
96 #define PBAP_PROPERTY_MASK_PROID                (1<<25) // Product ID
97 #define PBAP_PROPERTY_MASK_CLASS                (1<<26) // Class information
98 #define PBAP_PROPERTY_MASK_SORT_STRING          (1<<27) // String used for sorting operations
99 #define PBAP_PROPERTY_MASK_X_IRMC_CALL_DATETIME (1<<28) // Time stamp
100 #define PBAP_PROPERTY_MASK_X_BT_SPEEDDIALKEY    (1<<29) // Speed-dial shortcut
101 #define PBAP_PROPERTY_MASK_X_BT_UCI             (1<<30) // Uniform Caller Identifier
102 #define PBAP_PROPERTY_MASK_X_BT_UID             (1<<31) // Bluetooth Contact Unique Identifier
103 
104 // PBAP vCardSelectorOperator
105 #define PBAP_VCARD_SELECTOR_OPERATOR_OR          0
106 #define PBAP_VCARD_SELECTOR_OPERATOR_AND         1
107 
108 /**
109  * Setup PhoneBook Access Client
110  */
111 void pbap_client_init(void);
112 
113 /**
114  * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote deivce.
115  * @param handler
116  * @param addr
117  * @param out_cid to use for further commands
118  * @result status
119 */
120 uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid);
121 
122 /**
123  * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST
124  * @param pbap_cid
125  * @param password (null terminated string) - not copied, needs to stay valid until connection completed
126 */
127 uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password);
128 
129 /**
130  * @brief Disconnects PBAP connection with given identifier.
131  * @param pbap_cid
132  * @return status
133  */
134 uint8_t pbap_disconnect(uint16_t pbap_cid);
135 
136 /**
137  * @brief Set current folder on PSE
138  * @param pbap_cid
139  * @param path - note: path is not copied
140  * @return status
141  */
142 uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path);
143 
144 /**
145  * @brief Set vCard Selector for get/pull phonebook
146  * @param pbap_cid
147  * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties
148  * @return status
149  */
150 uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector);
151 
152 /**
153  * @brief Set vCard Selector for get/pull phonebook
154  * @param pbap_cid
155  * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND
156  * @return status
157  */
158 uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator);
159 
160 /**
161  * @brief Get size of phone book from PSE
162  * @param pbap_cid
163  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
164  * @return status
165  */
166 uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path);
167 
168 /**
169  * @brief Pull phone book from PSE
170  * @param pbap_cid
171  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
172  * @return status
173  */
174 uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path);
175 
176 /**
177  * @brief Pull vCard listing
178  * @param pbap_cid
179  * @param path
180  * @return status
181  */
182 uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path);
183 
184 /**
185  * @brief Pull vCard entry
186  * @param pbap_cid
187  * @param path
188  * @return status
189  */
190 uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path);
191 
192 /**
193  * @brief Lookup contact(s) by phone number
194  * @param pbap_cid
195  * @param phone_number
196  * @return status
197  */
198 uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number);
199 
200 /**
201  * @brief Abort current operation
202  * @param pbap_cid
203  * @return status
204  */
205 uint8_t pbap_abort(uint16_t pbap_cid);
206 
207 
208 /**
209  * @brief Set flow control mode - default is off
210  * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one
211  * @param pbap_cid
212  * @return status
213  */
214 uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable);
215 
216 /**
217  * @brief Prigger next packet from PSE when Flow Control Mode is enabled
218  * @param pbap_cid
219  * @return status
220  */
221 uint8_t pbap_next_packet(uint16_t pbap_cid);
222 
223 
224 /* API_END */
225 
226 #if defined __cplusplus
227 }
228 #endif
229 #endif
230