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 38fe5a6c4eSMilanka Ringwald /** 39fe5a6c4eSMilanka Ringwald * @title PBAP Client 40fe5a6c4eSMilanka Ringwald * 41fe5a6c4eSMilanka Ringwald */ 42fe5a6c4eSMilanka Ringwald 4380e33422SMatthias Ringwald #ifndef PBAP_CLIENT_H 4480e33422SMatthias Ringwald #define PBAP_CLIENT_H 45f1b34e8dSMatthias Ringwald 46f1b34e8dSMatthias Ringwald #if defined __cplusplus 47f1b34e8dSMatthias Ringwald extern "C" { 48f1b34e8dSMatthias Ringwald #endif 49f1b34e8dSMatthias Ringwald 50f1b34e8dSMatthias Ringwald #include "btstack_config.h" 51f1b34e8dSMatthias Ringwald #include <stdint.h> 52f1b34e8dSMatthias Ringwald 5383f1bca0SMatthias Ringwald // max len of phone number used for lookup in pbap_lookup_by_number 5483f1bca0SMatthias Ringwald #define PBAP_MAX_PHONE_NUMBER_LEN 32 5583f1bca0SMatthias Ringwald 5683f1bca0SMatthias Ringwald // max len of name reported in PBAP_SUBEVENT_CARD_RESULT 5783f1bca0SMatthias Ringwald #define PBAP_MAX_NAME_LEN 32 5883f1bca0SMatthias Ringwald // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT 5983f1bca0SMatthias Ringwald #define PBAP_MAX_HANDLE_LEN 16 6083f1bca0SMatthias Ringwald 61f1b34e8dSMatthias Ringwald /* API_START */ 62f1b34e8dSMatthias Ringwald 6360dfc259SMatthias Ringwald // PBAP Supported Features 6460dfc259SMatthias Ringwald 6560dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DOWNLOAD (1<<0) 6660dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_BROWSING (1<<1) 6760dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DATABASE_IDENTIFIER (1<<2) 6860dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_FOLDER_VERSION_COUNTERS (1<<3) 6960dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_VCARD_SELECTING (1<<4) 7060dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_ENHANCED_MISSED_CALLS (1<<5) 7160dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_X_BT_UCI_VCARD_PROPERTY (1<<6) 7260dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_X_BT_UID_VCARD_PROPERTY (1<<7) 7360dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_CONTACT_REFERENCING (1<<8) 7460dfc259SMatthias Ringwald #define PBAP_SUPPORTED_FEATURES_DEFAULT_CONTACT_IMAGE_FORMAT (1<<9) 7560dfc259SMatthias Ringwald 7660dfc259SMatthias Ringwald // PBAP Property Mask - also used for vCardSelector 7760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_VERSION (1<< 0) // vCard Version 7860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_FN (1<< 1) // Formatted Name 7960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_N (1<< 2) // Structured Presentation of Name 8060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_PHOTO (1<< 3) // Associated Image or Photo 8160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_BDAY (1<< 4) // Birthday 8260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ADR (1<< 5) // Delivery Address 8360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_LABEL (1<< 6) // Delivery 8460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TEL (1<< 7) // Telephone Number 8560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_EMAIL (1<< 8) // Electronic Mail Address 8660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_MAILER (1<< 9) // Electronic Mail 8760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TZ (1<<10) // Time Zone 8860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_GEO (1<<11) // Geographic Position 8960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_TITLE (1<<12) // Job 9060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ROLE (1<<13) // Role within the Organization 9160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_LOGO (1<<14) // Organization Logo 9260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_AGENT (1<<15) // vCard of Person Representing 9360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_ORG (1<<16) // Name of Organization 9460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_NOTE (1<<17) // Comments 9560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_REV (1<<18) // Revision 9660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_SOUND (1<<19) // Pronunciation of Name 9760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_URL (1<<20) // Uniform Resource Locator 9860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_UID (1<<21) // Unique ID 9960dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_KEY (1<<22) // Public Encryption Key 10060dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_NICKNAME (1<<23) // Nickname 10160dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_CATEGORIES (1<<24) // Categories 10260dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_PROID (1<<25) // Product ID 10360dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_CLASS (1<<26) // Class information 10460dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_SORT_STRING (1<<27) // String used for sorting operations 10560dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_IRMC_CALL_DATETIME (1<<28) // Time stamp 10660dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_SPEEDDIALKEY (1<<29) // Speed-dial shortcut 10760dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_UCI (1<<30) // Uniform Caller Identifier 10860dfc259SMatthias Ringwald #define PBAP_PROPERTY_MASK_X_BT_UID (1<<31) // Bluetooth Contact Unique Identifier 10960dfc259SMatthias Ringwald 11060dfc259SMatthias Ringwald // PBAP vCardSelectorOperator 11160dfc259SMatthias Ringwald #define PBAP_VCARD_SELECTOR_OPERATOR_OR 0 11260dfc259SMatthias Ringwald #define PBAP_VCARD_SELECTOR_OPERATOR_AND 1 11360dfc259SMatthias Ringwald 114f1b34e8dSMatthias Ringwald /** 115f1b34e8dSMatthias Ringwald * Setup PhoneBook Access Client 116f1b34e8dSMatthias Ringwald */ 117f1b34e8dSMatthias Ringwald void pbap_client_init(void); 118f1b34e8dSMatthias Ringwald 119f1b34e8dSMatthias Ringwald /** 120*1c7aea60SMilanka Ringwald * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device. 121*1c7aea60SMilanka Ringwald * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which 122*1c7aea60SMilanka Ringwald * can be answered with pbap_authentication_password(..). 123*1c7aea60SMilanka Ringwald * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, 124*1c7aea60SMilanka Ringwald * i.e. on success status field is set to ERROR_CODE_SUCCESS. 125*1c7aea60SMilanka Ringwald * 126f1b34e8dSMatthias Ringwald * @param handler 127f1b34e8dSMatthias Ringwald * @param addr 128f1b34e8dSMatthias Ringwald * @param out_cid to use for further commands 129*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists. 130f1b34e8dSMatthias Ringwald */ 131f1b34e8dSMatthias Ringwald uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid); 132f1b34e8dSMatthias Ringwald 133f1b34e8dSMatthias Ringwald /** 134*1c7aea60SMilanka Ringwald * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST. 135*1c7aea60SMilanka Ringwald * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, 136*1c7aea60SMilanka Ringwald * i.e. on success status field is set to ERROR_CODE_SUCCESS. 137*1c7aea60SMilanka Ringwald * 138c1bc0b8eSMatthias Ringwald * @param pbap_cid 139c1bc0b8eSMatthias Ringwald * @param password (null terminated string) - not copied, needs to stay valid until connection completed 140*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 141c1bc0b8eSMatthias Ringwald */ 142c1bc0b8eSMatthias Ringwald uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password); 143c1bc0b8eSMatthias Ringwald 144c1bc0b8eSMatthias Ringwald /** 145f1b34e8dSMatthias Ringwald * @brief Disconnects PBAP connection with given identifier. 146*1c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_CONNECTION_CLOSED indicates that PBAP connection is closed. 147*1c7aea60SMilanka Ringwald * 148f1b34e8dSMatthias Ringwald * @param pbap_cid 149*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 150f1b34e8dSMatthias Ringwald */ 151f1b34e8dSMatthias Ringwald uint8_t pbap_disconnect(uint16_t pbap_cid); 152f1b34e8dSMatthias Ringwald 153f1b34e8dSMatthias Ringwald /** 154*1c7aea60SMilanka Ringwald * @brief Set current folder on PSE. The status is reported via PBAP_SUBEVENT_OPERATION_COMPLETED event. 155*1c7aea60SMilanka Ringwald * 156f1b34e8dSMatthias Ringwald * @param pbap_cid 157f1b34e8dSMatthias Ringwald * @param path - note: path is not copied 158*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 159f1b34e8dSMatthias Ringwald */ 160f1b34e8dSMatthias Ringwald uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path); 161f1b34e8dSMatthias Ringwald 162f1b34e8dSMatthias Ringwald /** 163*1c7aea60SMilanka Ringwald * @brief Set vCard Selector for get/pull phonebook. No event is emitted. 164*1c7aea60SMilanka Ringwald * 1653127f224SMatthias Ringwald * @param pbap_cid 1663127f224SMatthias Ringwald * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties 167*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 1683127f224SMatthias Ringwald */ 1693127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector); 1703127f224SMatthias Ringwald 1713127f224SMatthias Ringwald /** 172*1c7aea60SMilanka Ringwald * @brief Set vCard Selector for get/pull phonebook. No event is emitted. 173*1c7aea60SMilanka Ringwald * 1743127f224SMatthias Ringwald * @param pbap_cid 1753127f224SMatthias Ringwald * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND 176*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 1773127f224SMatthias Ringwald */ 1783127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator); 1793127f224SMatthias Ringwald 1803127f224SMatthias Ringwald /** 181*1c7aea60SMilanka Ringwald * @brief Get size of phone book from PSE. The result is reported via PBAP_SUBEVENT_PHONEBOOK_SIZE event. 182*1c7aea60SMilanka Ringwald * 1833a7447a3SMatthias Ringwald * @param pbap_cid 1848c94c044SMatthias Ringwald * @param path - note: path is not copied, common path 'telecom/pb.vcf' 185*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 1863a7447a3SMatthias Ringwald */ 1878c94c044SMatthias Ringwald uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path); 1883a7447a3SMatthias Ringwald 1893a7447a3SMatthias Ringwald /** 190*1c7aea60SMilanka Ringwald * @brief Pull phone book from PSE. The result is reported via registered packet handler (see pbap_connect function), 191*1c7aea60SMilanka Ringwald * with packet type set to PBAP_DATA_PACKET. Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the phone book. 192*1c7aea60SMilanka Ringwald * 193f1b34e8dSMatthias Ringwald * @param pbap_cid 1948c94c044SMatthias Ringwald * @param path - note: path is not copied, common path 'telecom/pb.vcf' 195*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 196f1b34e8dSMatthias Ringwald */ 1978c94c044SMatthias Ringwald uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path); 198e03b79abSMatthias Ringwald 199e03b79abSMatthias Ringwald /** 200*1c7aea60SMilanka Ringwald * @brief Pull vCard listing. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event. 201*1c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of vCard listing. 202*1c7aea60SMilanka Ringwald * 2034687d289SMatthias Ringwald * @param pbap_cid 2044687d289SMatthias Ringwald * @param path 205*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 2064687d289SMatthias Ringwald */ 2074687d289SMatthias Ringwald uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path); 2084687d289SMatthias Ringwald 2094687d289SMatthias Ringwald /** 210*1c7aea60SMilanka Ringwald * @brief Pull vCard entry. The result is reported via callback (see pbap_connect function), 211*1c7aea60SMilanka Ringwald * with packet type set to PBAP_DATA_PACKET. 212*1c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the vCard entry. 213*1c7aea60SMilanka Ringwald * 21416ad3745SMatthias Ringwald * @param pbap_cid 21516ad3745SMatthias Ringwald * @param path 216*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 21716ad3745SMatthias Ringwald */ 21816ad3745SMatthias Ringwald uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path); 21916ad3745SMatthias Ringwald 22016ad3745SMatthias Ringwald /** 221*1c7aea60SMilanka Ringwald * @brief Lookup contact(s) by phone number. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event. 222*1c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the lookup. 223*1c7aea60SMilanka Ringwald * 224e03b79abSMatthias Ringwald * @param pbap_cid 225e03b79abSMatthias Ringwald * @param phone_number 226*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 227e03b79abSMatthias Ringwald */ 228e03b79abSMatthias Ringwald uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number); 229f1b34e8dSMatthias Ringwald 230d4436ef5SMatthias Ringwald /** 231*1c7aea60SMilanka Ringwald * @brief Abort current operation. No event is emitted. 232*1c7aea60SMilanka Ringwald * 2339eb7827dSMatthias Ringwald * @param pbap_cid 234*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 2359eb7827dSMatthias Ringwald */ 2369eb7827dSMatthias Ringwald uint8_t pbap_abort(uint16_t pbap_cid); 2379eb7827dSMatthias Ringwald 2389eb7827dSMatthias Ringwald 2399eb7827dSMatthias Ringwald /** 240*1c7aea60SMilanka Ringwald * @brief Set flow control mode - default is off. No event is emitted. 241d4436ef5SMatthias Ringwald * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one 242*1c7aea60SMilanka Ringwald * 2438854a89dSMatthias Ringwald * @param pbap_cid 244*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 245d4436ef5SMatthias Ringwald */ 2468854a89dSMatthias Ringwald uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable); 247d4436ef5SMatthias Ringwald 248d4436ef5SMatthias Ringwald /** 249*1c7aea60SMilanka Ringwald * @brief Trigger next packet from PSE when Flow Control Mode is enabled. 250d4436ef5SMatthias Ringwald * @param pbap_cid 251*1c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 252d4436ef5SMatthias Ringwald */ 253d4436ef5SMatthias Ringwald uint8_t pbap_next_packet(uint16_t pbap_cid); 254d4436ef5SMatthias Ringwald 2551d0ae3baSMatthias Ringwald /** 2561d0ae3baSMatthias Ringwald * @brief De-Init PBAP Client 2571d0ae3baSMatthias Ringwald */ 2581d0ae3baSMatthias Ringwald void pbap_client_deinit(void); 259d4436ef5SMatthias Ringwald 260f1b34e8dSMatthias Ringwald /* API_END */ 261f1b34e8dSMatthias Ringwald 262f1b34e8dSMatthias Ringwald #if defined __cplusplus 263f1b34e8dSMatthias Ringwald } 264f1b34e8dSMatthias Ringwald #endif 265f1b34e8dSMatthias Ringwald #endif 266