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 3880e33422SMatthias Ringwald #ifndef PBAP_CLIENT_H 3980e33422SMatthias Ringwald #define PBAP_CLIENT_H 40f1b34e8dSMatthias Ringwald 41f1b34e8dSMatthias Ringwald #if defined __cplusplus 42f1b34e8dSMatthias Ringwald extern "C" { 43f1b34e8dSMatthias Ringwald #endif 44f1b34e8dSMatthias Ringwald 45f1b34e8dSMatthias Ringwald #include "btstack_config.h" 46f1b34e8dSMatthias Ringwald #include <stdint.h> 47f1b34e8dSMatthias Ringwald 4883f1bca0SMatthias Ringwald // max len of phone number used for lookup in pbap_lookup_by_number 4983f1bca0SMatthias Ringwald #define PBAP_MAX_PHONE_NUMBER_LEN 32 5083f1bca0SMatthias Ringwald 5183f1bca0SMatthias Ringwald // max len of name reported in PBAP_SUBEVENT_CARD_RESULT 5283f1bca0SMatthias Ringwald #define PBAP_MAX_NAME_LEN 32 5383f1bca0SMatthias Ringwald // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT 5483f1bca0SMatthias Ringwald #define PBAP_MAX_HANDLE_LEN 16 5583f1bca0SMatthias Ringwald 56f1b34e8dSMatthias Ringwald /* API_START */ 57f1b34e8dSMatthias Ringwald 5860dfc259SMatthias Ringwald // PBAP Supported Features 5960dfc259SMatthias Ringwald 6060dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DOWNLOAD (1<<0) 6160dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_BROWSING (1<<1) 6260dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DATABASE_IDENTIFIER (1<<2) 6360dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_FOLDER_VERSION_COUNTERS (1<<3) 6460dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_VCARD_SELECTING (1<<4) 6560dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_ENHANCED_MISSED_CALLS (1<<5) 6660dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_X_BT_UCI_VCARD_PROPERTY (1<<6) 6760dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_X_BT_UID_VCARD_PROPERTY (1<<7) 6860dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_CONTACT_REFERENCING (1<<8) 6960dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DEFAULT_CONTACT_IMAGE_FORMAT (1<<9) 7060dfc259SMatthias Ringwald 7160dfc259SMatthias Ringwald // PBAP Property Mask - also used for vCardSelector 7260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_VERSION (1<< 0) // vCard Version 7360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_FN (1<< 1) // Formatted Name 7460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_N (1<< 2) // Structured Presentation of Name 7560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_PHOTO (1<< 3) // Associated Image or Photo 7660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_BDAY (1<< 4) // Birthday 7760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ADR (1<< 5) // Delivery Address 7860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_LABEL (1<< 6) // Delivery 7960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TEL (1<< 7) // Telephone Number 8060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_EMAIL (1<< 8) // Electronic Mail Address 8160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_MAILER (1<< 9) // Electronic Mail 8260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TZ (1<<10) // Time Zone 8360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_GEO (1<<11) // Geographic Position 8460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TITLE (1<<12) // Job 8560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ROLE (1<<13) // Role within the Organization 8660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_LOGO (1<<14) // Organization Logo 8760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_AGENT (1<<15) // vCard of Person Representing 8860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ORG (1<<16) // Name of Organization 8960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_NOTE (1<<17) // Comments 9060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_REV (1<<18) // Revision 9160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_SOUND (1<<19) // Pronunciation of Name 9260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_URL (1<<20) // Uniform Resource Locator 9360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_UID (1<<21) // Unique ID 9460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_KEY (1<<22) // Public Encryption Key 9560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_NICKNAME (1<<23) // Nickname 9660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_CATEGORIES (1<<24) // Categories 9760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_PROID (1<<25) // Product ID 9860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_CLASS (1<<26) // Class information 9960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_SORT_STRING (1<<27) // String used for sorting operations 10060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_IRMC_CALL_DATETIME (1<<28) // Time stamp 10160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_SPEEDDIALKEY (1<<29) // Speed-dial shortcut 10260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_UCI (1<<30) // Uniform Caller Identifier 10360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_UID (1<<31) // Bluetooth Contact Unique Identifier 10460dfc259SMatthias Ringwald 10560dfc259SMatthias Ringwald // PBAP vCardSelectorOperator 10660dfc259SMatthias Ringwald #define PBAP_VCARD_SELECTOR_OPERATOR_OR 0 10760dfc259SMatthias Ringwald #define PBAP_VCARD_SELECTOR_OPERATOR_AND 1 10860dfc259SMatthias Ringwald 109f1b34e8dSMatthias Ringwald /** 110f1b34e8dSMatthias Ringwald * Setup PhoneBook Access Client 111f1b34e8dSMatthias Ringwald */ 112f1b34e8dSMatthias Ringwald void pbap_client_init(void); 113f1b34e8dSMatthias Ringwald 114f1b34e8dSMatthias Ringwald /** 115f1b34e8dSMatthias Ringwald * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote deivce. 116f1b34e8dSMatthias Ringwald * @param handler 117f1b34e8dSMatthias Ringwald * @param addr 118f1b34e8dSMatthias Ringwald * @param out_cid to use for further commands 119f1b34e8dSMatthias Ringwald * @result status 120f1b34e8dSMatthias Ringwald */ 121f1b34e8dSMatthias Ringwald uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid); 122f1b34e8dSMatthias Ringwald 123f1b34e8dSMatthias Ringwald /** 124c1bc0b8eSMatthias Ringwald * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST 125c1bc0b8eSMatthias Ringwald * @param pbap_cid 126c1bc0b8eSMatthias Ringwald * @param password (null terminated string) - not copied, needs to stay valid until connection completed 127c1bc0b8eSMatthias Ringwald */ 128c1bc0b8eSMatthias Ringwald uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password); 129c1bc0b8eSMatthias Ringwald 130c1bc0b8eSMatthias Ringwald /** 131f1b34e8dSMatthias Ringwald * @brief Disconnects PBAP connection with given identifier. 132f1b34e8dSMatthias Ringwald * @param pbap_cid 133f1b34e8dSMatthias Ringwald * @return status 134f1b34e8dSMatthias Ringwald */ 135f1b34e8dSMatthias Ringwald uint8_t pbap_disconnect(uint16_t pbap_cid); 136f1b34e8dSMatthias Ringwald 137f1b34e8dSMatthias Ringwald /** 138f1b34e8dSMatthias Ringwald * @brief Set current folder on PSE 139f1b34e8dSMatthias Ringwald * @param pbap_cid 140f1b34e8dSMatthias Ringwald * @param path - note: path is not copied 141f1b34e8dSMatthias Ringwald * @return status 142f1b34e8dSMatthias Ringwald */ 143f1b34e8dSMatthias Ringwald uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path); 144f1b34e8dSMatthias Ringwald 145f1b34e8dSMatthias Ringwald /** 1463127f224SMatthias Ringwald * @brief Set vCard Selector for get/pull phonebook 1473127f224SMatthias Ringwald * @param pbap_cid 1483127f224SMatthias Ringwald * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties 1493127f224SMatthias Ringwald * @return status 1503127f224SMatthias Ringwald */ 1513127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector); 1523127f224SMatthias Ringwald 1533127f224SMatthias Ringwald /** 1543127f224SMatthias Ringwald * @brief Set vCard Selector for get/pull phonebook 1553127f224SMatthias Ringwald * @param pbap_cid 1563127f224SMatthias Ringwald * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND 1573127f224SMatthias Ringwald * @return status 1583127f224SMatthias Ringwald */ 1593127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator); 1603127f224SMatthias Ringwald 1613127f224SMatthias Ringwald /** 1623a7447a3SMatthias Ringwald * @brief Get size of phone book from PSE 1633a7447a3SMatthias Ringwald * @param pbap_cid 1648c94c044SMatthias Ringwald * @param path - note: path is not copied, common path 'telecom/pb.vcf' 1653a7447a3SMatthias Ringwald * @return status 1663a7447a3SMatthias Ringwald */ 1678c94c044SMatthias Ringwald uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path); 1683a7447a3SMatthias Ringwald 1693a7447a3SMatthias Ringwald /** 170f1b34e8dSMatthias Ringwald * @brief Pull phone book from PSE 171f1b34e8dSMatthias Ringwald * @param pbap_cid 1728c94c044SMatthias Ringwald * @param path - note: path is not copied, common path 'telecom/pb.vcf' 173f1b34e8dSMatthias Ringwald * @return status 174f1b34e8dSMatthias Ringwald */ 1758c94c044SMatthias Ringwald uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path); 176e03b79abSMatthias Ringwald 177e03b79abSMatthias Ringwald /** 1784687d289SMatthias Ringwald * @brief Pull vCard listing 1794687d289SMatthias Ringwald * @param pbap_cid 1804687d289SMatthias Ringwald * @param path 1814687d289SMatthias Ringwald * @return status 1824687d289SMatthias Ringwald */ 1834687d289SMatthias Ringwald uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path); 1844687d289SMatthias Ringwald 1854687d289SMatthias Ringwald /** 18616ad3745SMatthias Ringwald * @brief Pull vCard entry 18716ad3745SMatthias Ringwald * @param pbap_cid 18816ad3745SMatthias Ringwald * @param path 18916ad3745SMatthias Ringwald * @return status 19016ad3745SMatthias Ringwald */ 19116ad3745SMatthias Ringwald uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path); 19216ad3745SMatthias Ringwald 19316ad3745SMatthias Ringwald /** 194e03b79abSMatthias Ringwald * @brief Lookup contact(s) by phone number 195e03b79abSMatthias Ringwald * @param pbap_cid 196e03b79abSMatthias Ringwald * @param phone_number 197e03b79abSMatthias Ringwald * @return status 198e03b79abSMatthias Ringwald */ 199e03b79abSMatthias Ringwald uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number); 200f1b34e8dSMatthias Ringwald 201d4436ef5SMatthias Ringwald /** 2029eb7827dSMatthias Ringwald * @brief Abort current operation 2039eb7827dSMatthias Ringwald * @param pbap_cid 2049eb7827dSMatthias Ringwald * @return status 2059eb7827dSMatthias Ringwald */ 2069eb7827dSMatthias Ringwald uint8_t pbap_abort(uint16_t pbap_cid); 2079eb7827dSMatthias Ringwald 2089eb7827dSMatthias Ringwald 2099eb7827dSMatthias Ringwald /** 210d4436ef5SMatthias Ringwald * @brief Set flow control mode - default is off 211d4436ef5SMatthias Ringwald * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one 2128854a89dSMatthias Ringwald * @param pbap_cid 2138854a89dSMatthias Ringwald * @return status 214d4436ef5SMatthias Ringwald */ 2158854a89dSMatthias Ringwald uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable); 216d4436ef5SMatthias Ringwald 217d4436ef5SMatthias Ringwald /** 218d4436ef5SMatthias Ringwald * @brief Prigger next packet from PSE when Flow Control Mode is enabled 219d4436ef5SMatthias Ringwald * @param pbap_cid 220d4436ef5SMatthias Ringwald * @return status 221d4436ef5SMatthias Ringwald */ 222d4436ef5SMatthias Ringwald uint8_t pbap_next_packet(uint16_t pbap_cid); 223d4436ef5SMatthias Ringwald 224*1d0ae3baSMatthias Ringwald /** 225*1d0ae3baSMatthias Ringwald * @brief De-Init PBAP Client 226*1d0ae3baSMatthias Ringwald */ 227*1d0ae3baSMatthias Ringwald void pbap_client_deinit(void); 228d4436ef5SMatthias Ringwald 229f1b34e8dSMatthias Ringwald /* API_END */ 230f1b34e8dSMatthias Ringwald 231f1b34e8dSMatthias Ringwald #if defined __cplusplus 232f1b34e8dSMatthias Ringwald } 233f1b34e8dSMatthias Ringwald #endif 234f1b34e8dSMatthias Ringwald #endif 235