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 PBAP_CLIENT_H 39 #define PBAP_CLIENT_H 40 41 #if defined __cplusplus 42 extern "C" { 43 #endif 44 45 #include "btstack_config.h" 46 #include <stdint.h> 47 48 // max len of phone number used for lookup in pbap_lookup_by_number 49 #define PBAP_MAX_PHONE_NUMBER_LEN 32 50 51 // max len of name reported in PBAP_SUBEVENT_CARD_RESULT 52 #define PBAP_MAX_NAME_LEN 32 53 // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT 54 #define PBAP_MAX_HANDLE_LEN 16 55 56 /* API_START */ 57 58 // PBAP Supported Features 59 60 #define PBAP_SUPPORTED_FEATURES_DOWNLOAD (1<<0) 61 #define PBAP_SUPPORTED_FEATURES_BROWSING (1<<1) 62 #define PBAP_SUPPORTED_FEATURES_DATABASE_IDENTIFIER (1<<2) 63 #define PBAP_SUPPORTED_FEATURES_FOLDER_VERSION_COUNTERS (1<<3) 64 #define PBAP_SUPPORTED_FEATURES_VCARD_SELECTING (1<<4) 65 #define PBAP_SUPPORTED_FEATURES_ENHANCED_MISSED_CALLS (1<<5) 66 #define PBAP_SUPPORTED_FEATURES_X_BT_UCI_VCARD_PROPERTY (1<<6) 67 #define PBAP_SUPPORTED_FEATURES_X_BT_UID_VCARD_PROPERTY (1<<7) 68 #define PBAP_SUPPORTED_FEATURES_CONTACT_REFERENCING (1<<8) 69 #define PBAP_SUPPORTED_FEATURES_DEFAULT_CONTACT_IMAGE_FORMAT (1<<9) 70 71 // PBAP Property Mask - also used for vCardSelector 72 #define PBAP_PROPERTY_MASK_VERSION (1<< 0) // vCard Version 73 #define PBAP_PROPERTY_MASK_FN (1<< 1) // Formatted Name 74 #define PBAP_PROPERTY_MASK_N (1<< 2) // Structured Presentation of Name 75 #define PBAP_PROPERTY_MASK_PHOTO (1<< 3) // Associated Image or Photo 76 #define PBAP_PROPERTY_MASK_BDAY (1<< 4) // Birthday 77 #define PBAP_PROPERTY_MASK_ADR (1<< 5) // Delivery Address 78 #define PBAP_PROPERTY_MASK_LABEL (1<< 6) // Delivery 79 #define PBAP_PROPERTY_MASK_TEL (1<< 7) // Telephone Number 80 #define PBAP_PROPERTY_MASK_EMAIL (1<< 8) // Electronic Mail Address 81 #define PBAP_PROPERTY_MASK_MAILER (1<< 9) // Electronic Mail 82 #define PBAP_PROPERTY_MASK_TZ (1<<10) // Time Zone 83 #define PBAP_PROPERTY_MASK_GEO (1<<11) // Geographic Position 84 #define PBAP_PROPERTY_MASK_TITLE (1<<12) // Job 85 #define PBAP_PROPERTY_MASK_ROLE (1<<13) // Role within the Organization 86 #define PBAP_PROPERTY_MASK_LOGO (1<<14) // Organization Logo 87 #define PBAP_PROPERTY_MASK_AGENT (1<<15) // vCard of Person Representing 88 #define PBAP_PROPERTY_MASK_ORG (1<<16) // Name of Organization 89 #define PBAP_PROPERTY_MASK_NOTE (1<<17) // Comments 90 #define PBAP_PROPERTY_MASK_REV (1<<18) // Revision 91 #define PBAP_PROPERTY_MASK_SOUND (1<<19) // Pronunciation of Name 92 #define PBAP_PROPERTY_MASK_URL (1<<20) // Uniform Resource Locator 93 #define PBAP_PROPERTY_MASK_UID (1<<21) // Unique ID 94 #define PBAP_PROPERTY_MASK_KEY (1<<22) // Public Encryption Key 95 #define PBAP_PROPERTY_MASK_NICKNAME (1<<23) // Nickname 96 #define PBAP_PROPERTY_MASK_CATEGORIES (1<<24) // Categories 97 #define PBAP_PROPERTY_MASK_PROID (1<<25) // Product ID 98 #define PBAP_PROPERTY_MASK_CLASS (1<<26) // Class information 99 #define PBAP_PROPERTY_MASK_SORT_STRING (1<<27) // String used for sorting operations 100 #define PBAP_PROPERTY_MASK_X_IRMC_CALL_DATETIME (1<<28) // Time stamp 101 #define PBAP_PROPERTY_MASK_X_BT_SPEEDDIALKEY (1<<29) // Speed-dial shortcut 102 #define PBAP_PROPERTY_MASK_X_BT_UCI (1<<30) // Uniform Caller Identifier 103 #define PBAP_PROPERTY_MASK_X_BT_UID (1<<31) // Bluetooth Contact Unique Identifier 104 105 // PBAP vCardSelectorOperator 106 #define PBAP_VCARD_SELECTOR_OPERATOR_OR 0 107 #define PBAP_VCARD_SELECTOR_OPERATOR_AND 1 108 109 /** 110 * Setup PhoneBook Access Client 111 */ 112 void pbap_client_init(void); 113 114 /** 115 * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote deivce. 116 * @param handler 117 * @param addr 118 * @param out_cid to use for further commands 119 * @result status 120 */ 121 uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid); 122 123 /** 124 * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST 125 * @param pbap_cid 126 * @param password (null terminated string) - not copied, needs to stay valid until connection completed 127 */ 128 uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password); 129 130 /** 131 * @brief Disconnects PBAP connection with given identifier. 132 * @param pbap_cid 133 * @return status 134 */ 135 uint8_t pbap_disconnect(uint16_t pbap_cid); 136 137 /** 138 * @brief Set current folder on PSE 139 * @param pbap_cid 140 * @param path - note: path is not copied 141 * @return status 142 */ 143 uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path); 144 145 /** 146 * @brief Set vCard Selector for get/pull phonebook 147 * @param pbap_cid 148 * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties 149 * @return status 150 */ 151 uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector); 152 153 /** 154 * @brief Set vCard Selector for get/pull phonebook 155 * @param pbap_cid 156 * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND 157 * @return status 158 */ 159 uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator); 160 161 /** 162 * @brief Get size of phone book from PSE 163 * @param pbap_cid 164 * @param path - note: path is not copied, common path 'telecom/pb.vcf' 165 * @return status 166 */ 167 uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path); 168 169 /** 170 * @brief Pull phone book from PSE 171 * @param pbap_cid 172 * @param path - note: path is not copied, common path 'telecom/pb.vcf' 173 * @return status 174 */ 175 uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path); 176 177 /** 178 * @brief Pull vCard listing 179 * @param pbap_cid 180 * @param path 181 * @return status 182 */ 183 uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path); 184 185 /** 186 * @brief Pull vCard entry 187 * @param pbap_cid 188 * @param path 189 * @return status 190 */ 191 uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path); 192 193 /** 194 * @brief Lookup contact(s) by phone number 195 * @param pbap_cid 196 * @param phone_number 197 * @return status 198 */ 199 uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number); 200 201 /** 202 * @brief Abort current operation 203 * @param pbap_cid 204 * @return status 205 */ 206 uint8_t pbap_abort(uint16_t pbap_cid); 207 208 209 /** 210 * @brief Set flow control mode - default is off 211 * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one 212 * @param pbap_cid 213 * @return status 214 */ 215 uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable); 216 217 /** 218 * @brief Prigger next packet from PSE when Flow Control Mode is enabled 219 * @param pbap_cid 220 * @return status 221 */ 222 uint8_t pbap_next_packet(uint16_t pbap_cid); 223 224 /** 225 * @brief De-Init PBAP Client 226 */ 227 void pbap_client_deinit(void); 228 229 /* API_END */ 230 231 #if defined __cplusplus 232 } 233 #endif 234 #endif 235