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