xref: /btstack/src/classic/pbap_client.h (revision 4687d289967cf8ce2319b78de48d8ff253bf6d91)
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
23f1b34e8dSMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24f1b34e8dSMatthias Ringwald  * RINGWALD 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 
38f1b34e8dSMatthias Ringwald #ifndef __GOEP_CLIENT_H
39f1b34e8dSMatthias Ringwald 
40f1b34e8dSMatthias Ringwald #if defined __cplusplus
41f1b34e8dSMatthias Ringwald extern "C" {
42f1b34e8dSMatthias Ringwald #endif
43f1b34e8dSMatthias Ringwald 
44f1b34e8dSMatthias Ringwald #include "btstack_config.h"
45f1b34e8dSMatthias Ringwald #include <stdint.h>
46f1b34e8dSMatthias Ringwald 
4783f1bca0SMatthias Ringwald // max len of phone number used for lookup in pbap_lookup_by_number
4883f1bca0SMatthias Ringwald #define PBAP_MAX_PHONE_NUMBER_LEN 32
4983f1bca0SMatthias Ringwald 
5083f1bca0SMatthias Ringwald // max len of name reported in PBAP_SUBEVENT_CARD_RESULT
5183f1bca0SMatthias Ringwald #define PBAP_MAX_NAME_LEN   32
5283f1bca0SMatthias Ringwald // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT
5383f1bca0SMatthias Ringwald #define PBAP_MAX_HANDLE_LEN 16
5483f1bca0SMatthias Ringwald 
55f1b34e8dSMatthias Ringwald /* API_START */
56f1b34e8dSMatthias Ringwald 
5760dfc259SMatthias Ringwald // PBAP Supported Features
5860dfc259SMatthias Ringwald 
5960dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DOWNLOAD                        (1<<0)
6060dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_BROWSING                        (1<<1)
6160dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DATABASE_IDENTIFIER             (1<<2)
6260dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_FOLDER_VERSION_COUNTERS         (1<<3)
6360dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_VCARD_SELECTING                 (1<<4)
6460dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_ENHANCED_MISSED_CALLS           (1<<5)
6560dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_X_BT_UCI_VCARD_PROPERTY         (1<<6)
6660dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_X_BT_UID_VCARD_PROPERTY         (1<<7)
6760dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_CONTACT_REFERENCING             (1<<8)
6860dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DEFAULT_CONTACT_IMAGE_FORMAT    (1<<9)
6960dfc259SMatthias Ringwald 
7060dfc259SMatthias Ringwald // PBAP Property Mask - also used for vCardSelector
7160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_VERSION              (1<< 0) // vCard Version
7260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_FN                   (1<< 1) // Formatted Name
7360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_N                    (1<< 2) // Structured Presentation of Name
7460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_PHOTO                (1<< 3) // Associated Image or Photo
7560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_BDAY                 (1<< 4) // Birthday
7660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ADR                  (1<< 5) // Delivery Address
7760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_LABEL                (1<< 6) // Delivery
7860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TEL                  (1<< 7) // Telephone Number
7960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_EMAIL                (1<< 8) // Electronic Mail Address
8060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_MAILER               (1<< 9) // Electronic Mail
8160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TZ                   (1<<10) // Time Zone
8260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_GEO                  (1<<11) // Geographic Position
8360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TITLE                (1<<12) // Job
8460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ROLE                 (1<<13) // Role within the Organization
8560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_LOGO                 (1<<14) // Organization Logo
8660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_AGENT                (1<<15) // vCard of Person Representing
8760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ORG                  (1<<16) // Name of Organization
8860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_NOTE                 (1<<17) // Comments
8960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_REV                  (1<<18) // Revision
9060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_SOUND                (1<<19) // Pronunciation of Name
9160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_URL                  (1<<20) // Uniform Resource Locator
9260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_UID                  (1<<21) // Unique ID
9360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_KEY                  (1<<22) // Public Encryption Key
9460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_NICKNAME             (1<<23) // Nickname
9560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_CATEGORIES           (1<<24) // Categories
9660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_PROID                (1<<25) // Product ID
9760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_CLASS                (1<<26) // Class information
9860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_SORT_STRING          (1<<27) // String used for sorting operations
9960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_IRMC_CALL_DATETIME (1<<28) // Time stamp
10060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_SPEEDDIALKEY    (1<<29) // Speed-dial shortcut
10160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_UCI             (1<<30) // Uniform Caller Identifier
10260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_UID             (1<<31) // Bluetooth Contact Unique Identifier
10360dfc259SMatthias Ringwald 
10460dfc259SMatthias Ringwald // PBAP vCardSelectorOperator
10560dfc259SMatthias Ringwald #define PBAP_VCARD_SELECTOR_OPERATOR_OR          0
10660dfc259SMatthias Ringwald #define PBAP_VCARD_SELECTOR_OPERATOR_AND         1
10760dfc259SMatthias Ringwald 
108f1b34e8dSMatthias Ringwald /**
109f1b34e8dSMatthias Ringwald  * Setup PhoneBook Access Client
110f1b34e8dSMatthias Ringwald  */
111f1b34e8dSMatthias Ringwald void pbap_client_init(void);
112f1b34e8dSMatthias Ringwald 
113f1b34e8dSMatthias Ringwald /**
114f1b34e8dSMatthias Ringwald  * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote deivce.
115f1b34e8dSMatthias Ringwald  * @param handler
116f1b34e8dSMatthias Ringwald  * @param addr
117f1b34e8dSMatthias Ringwald  * @param out_cid to use for further commands
118f1b34e8dSMatthias Ringwald  * @result status
119f1b34e8dSMatthias Ringwald */
120f1b34e8dSMatthias Ringwald uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid);
121f1b34e8dSMatthias Ringwald 
122f1b34e8dSMatthias Ringwald /**
123c1bc0b8eSMatthias Ringwald  * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST
124c1bc0b8eSMatthias Ringwald  * @param pbap_cid
125c1bc0b8eSMatthias Ringwald  * @param password (null terminated string) - not copied, needs to stay valid until connection completed
126c1bc0b8eSMatthias Ringwald */
127c1bc0b8eSMatthias Ringwald uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password);
128c1bc0b8eSMatthias Ringwald 
129c1bc0b8eSMatthias Ringwald /**
130f1b34e8dSMatthias Ringwald  * @brief Disconnects PBAP connection with given identifier.
131f1b34e8dSMatthias Ringwald  * @param pbap_cid
132f1b34e8dSMatthias Ringwald  * @return status
133f1b34e8dSMatthias Ringwald  */
134f1b34e8dSMatthias Ringwald uint8_t pbap_disconnect(uint16_t pbap_cid);
135f1b34e8dSMatthias Ringwald 
136f1b34e8dSMatthias Ringwald /**
137f1b34e8dSMatthias Ringwald  * @brief Set current folder on PSE
138f1b34e8dSMatthias Ringwald  * @param pbap_cid
139f1b34e8dSMatthias Ringwald  * @param path - note: path is not copied
140f1b34e8dSMatthias Ringwald  * @return status
141f1b34e8dSMatthias Ringwald  */
142f1b34e8dSMatthias Ringwald uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path);
143f1b34e8dSMatthias Ringwald 
144f1b34e8dSMatthias Ringwald /**
1453127f224SMatthias Ringwald  * @brief Set vCard Selector for get/pull phonebook
1463127f224SMatthias Ringwald  * @param pbap_cid
1473127f224SMatthias Ringwald  * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties
1483127f224SMatthias Ringwald  * @return status
1493127f224SMatthias Ringwald  */
1503127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector);
1513127f224SMatthias Ringwald 
1523127f224SMatthias Ringwald /**
1533127f224SMatthias Ringwald  * @brief Set vCard Selector for get/pull phonebook
1543127f224SMatthias Ringwald  * @param pbap_cid
1553127f224SMatthias Ringwald  * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND
1563127f224SMatthias Ringwald  * @return status
1573127f224SMatthias Ringwald  */
1583127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator);
1593127f224SMatthias Ringwald 
1603127f224SMatthias Ringwald /**
1613a7447a3SMatthias Ringwald  * @brief Get size of phone book from PSE
1623a7447a3SMatthias Ringwald  * @param pbap_cid
1638c94c044SMatthias Ringwald  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
1643a7447a3SMatthias Ringwald  * @return status
1653a7447a3SMatthias Ringwald  */
1668c94c044SMatthias Ringwald uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path);
1673a7447a3SMatthias Ringwald 
1683a7447a3SMatthias Ringwald /**
169f1b34e8dSMatthias Ringwald  * @brief Pull phone book from PSE
170f1b34e8dSMatthias Ringwald  * @param pbap_cid
1718c94c044SMatthias Ringwald  * @param path - note: path is not copied, common path 'telecom/pb.vcf'
172f1b34e8dSMatthias Ringwald  * @return status
173f1b34e8dSMatthias Ringwald  */
1748c94c044SMatthias Ringwald uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path);
175e03b79abSMatthias Ringwald 
176e03b79abSMatthias Ringwald /**
177*4687d289SMatthias Ringwald  * @brief Pull vCard listing
178*4687d289SMatthias Ringwald  * @param pbap_cid
179*4687d289SMatthias Ringwald  * @param path
180*4687d289SMatthias Ringwald  * @return status
181*4687d289SMatthias Ringwald  */
182*4687d289SMatthias Ringwald uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path);
183*4687d289SMatthias Ringwald 
184*4687d289SMatthias Ringwald /**
185e03b79abSMatthias Ringwald  * @brief Lookup contact(s) by phone number
186e03b79abSMatthias Ringwald  * @param pbap_cid
187e03b79abSMatthias Ringwald  * @param phone_number
188e03b79abSMatthias Ringwald  * @return status
189e03b79abSMatthias Ringwald  */
190e03b79abSMatthias Ringwald uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number);
191f1b34e8dSMatthias Ringwald 
192d4436ef5SMatthias Ringwald /**
1939eb7827dSMatthias Ringwald  * @brief Abort current operation
1949eb7827dSMatthias Ringwald  * @param pbap_cid
1959eb7827dSMatthias Ringwald  * @return status
1969eb7827dSMatthias Ringwald  */
1979eb7827dSMatthias Ringwald uint8_t pbap_abort(uint16_t pbap_cid);
1989eb7827dSMatthias Ringwald 
1999eb7827dSMatthias Ringwald 
2009eb7827dSMatthias Ringwald /**
201d4436ef5SMatthias Ringwald  * @brief Set flow control mode - default is off
202d4436ef5SMatthias Ringwald  * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one
2038854a89dSMatthias Ringwald  * @param pbap_cid
2048854a89dSMatthias Ringwald  * @return status
205d4436ef5SMatthias Ringwald  */
2068854a89dSMatthias Ringwald uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable);
207d4436ef5SMatthias Ringwald 
208d4436ef5SMatthias Ringwald /**
209d4436ef5SMatthias Ringwald  * @brief Prigger next packet from PSE when Flow Control Mode is enabled
210d4436ef5SMatthias Ringwald  * @param pbap_cid
211d4436ef5SMatthias Ringwald  * @return status
212d4436ef5SMatthias Ringwald  */
213d4436ef5SMatthias Ringwald uint8_t pbap_next_packet(uint16_t pbap_cid);
214d4436ef5SMatthias Ringwald 
215d4436ef5SMatthias Ringwald 
216f1b34e8dSMatthias Ringwald /* API_END */
217f1b34e8dSMatthias Ringwald 
218f1b34e8dSMatthias Ringwald #if defined __cplusplus
219f1b34e8dSMatthias Ringwald }
220f1b34e8dSMatthias Ringwald #endif
221f1b34e8dSMatthias Ringwald #endif
222