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 232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 242fca4dadSMilanka Ringwald * GMBH 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 63f1b34e8dSMatthias Ringwald /** 64f1b34e8dSMatthias Ringwald * Setup PhoneBook Access Client 65f1b34e8dSMatthias Ringwald */ 66f1b34e8dSMatthias Ringwald void pbap_client_init(void); 67f1b34e8dSMatthias Ringwald 68f1b34e8dSMatthias Ringwald /** 691c7aea60SMilanka Ringwald * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device. 701c7aea60SMilanka Ringwald * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which 711c7aea60SMilanka Ringwald * can be answered with pbap_authentication_password(..). 721c7aea60SMilanka Ringwald * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, 731c7aea60SMilanka Ringwald * i.e. on success status field is set to ERROR_CODE_SUCCESS. 741c7aea60SMilanka Ringwald * 75f1b34e8dSMatthias Ringwald * @param handler 76f1b34e8dSMatthias Ringwald * @param addr 77f1b34e8dSMatthias Ringwald * @param out_cid to use for further commands 781c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists. 79f1b34e8dSMatthias Ringwald */ 80f1b34e8dSMatthias Ringwald uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid); 81f1b34e8dSMatthias Ringwald 82f1b34e8dSMatthias Ringwald /** 831c7aea60SMilanka Ringwald * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST. 841c7aea60SMilanka Ringwald * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, 851c7aea60SMilanka Ringwald * i.e. on success status field is set to ERROR_CODE_SUCCESS. 861c7aea60SMilanka Ringwald * 87c1bc0b8eSMatthias Ringwald * @param pbap_cid 88c1bc0b8eSMatthias Ringwald * @param password (null terminated string) - not copied, needs to stay valid until connection completed 891c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 90c1bc0b8eSMatthias Ringwald */ 91c1bc0b8eSMatthias Ringwald uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password); 92c1bc0b8eSMatthias Ringwald 93c1bc0b8eSMatthias Ringwald /** 94f1b34e8dSMatthias Ringwald * @brief Disconnects PBAP connection with given identifier. 951c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_CONNECTION_CLOSED indicates that PBAP connection is closed. 961c7aea60SMilanka Ringwald * 97f1b34e8dSMatthias Ringwald * @param pbap_cid 981c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 99f1b34e8dSMatthias Ringwald */ 100f1b34e8dSMatthias Ringwald uint8_t pbap_disconnect(uint16_t pbap_cid); 101f1b34e8dSMatthias Ringwald 102f1b34e8dSMatthias Ringwald /** 1031c7aea60SMilanka Ringwald * @brief Set current folder on PSE. The status is reported via PBAP_SUBEVENT_OPERATION_COMPLETED event. 1041c7aea60SMilanka Ringwald * 105f1b34e8dSMatthias Ringwald * @param pbap_cid 106f1b34e8dSMatthias Ringwald * @param path - note: path is not copied 1071c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 108f1b34e8dSMatthias Ringwald */ 109f1b34e8dSMatthias Ringwald uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path); 110f1b34e8dSMatthias Ringwald 111f1b34e8dSMatthias Ringwald /** 1121c7aea60SMilanka Ringwald * @brief Set vCard Selector for get/pull phonebook. No event is emitted. 1131c7aea60SMilanka Ringwald * 1143127f224SMatthias Ringwald * @param pbap_cid 1153127f224SMatthias Ringwald * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties 1161c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 1173127f224SMatthias Ringwald */ 1183127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector); 1193127f224SMatthias Ringwald 1203127f224SMatthias Ringwald /** 1211c7aea60SMilanka Ringwald * @brief Set vCard Selector for get/pull phonebook. No event is emitted. 1221c7aea60SMilanka Ringwald * 1233127f224SMatthias Ringwald * @param pbap_cid 1243127f224SMatthias Ringwald * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND 1251c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 1263127f224SMatthias Ringwald */ 1273127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator); 1283127f224SMatthias Ringwald 1293127f224SMatthias Ringwald /** 130e9b4d967SMatthias Ringwald * @brief Set Property Selector. No event is emitted. 131e9b4d967SMatthias Ringwald * @param pbap_cid 132e9b4d967SMatthias Ringwald * @param property_selector - combination of PBAP_PROPERTY_MASK_* properties 133e9b4d967SMatthias Ringwald * @return 134e9b4d967SMatthias Ringwald */ 135e9b4d967SMatthias Ringwald uint8_t pbap_set_property_selector(uint16_t pbap_cid, uint32_t property_selector); 136e9b4d967SMatthias Ringwald 137e9b4d967SMatthias Ringwald /** 138*04f86d08SMatthias Ringwald * @brief Set number of items returned by pull phonebook. 139*04f86d08SMatthias Ringwald * @param pbap_cid 140*04f86d08SMatthias Ringwald * @param max_list_count 141*04f86d08SMatthias Ringwald * @return 142*04f86d08SMatthias Ringwald */ 143*04f86d08SMatthias Ringwald uint8_t pbap_set_max_list_count(uint16_t pbap_cid, uint16_t max_list_count); 144*04f86d08SMatthias Ringwald 145*04f86d08SMatthias Ringwald /** 146*04f86d08SMatthias Ringwald * @bbrief Set start offset for pull phonebook 147*04f86d08SMatthias Ringwald * @param pbap_cid 148*04f86d08SMatthias Ringwald * @param list_start_offset 149*04f86d08SMatthias Ringwald * @return 150*04f86d08SMatthias Ringwald */ 151*04f86d08SMatthias Ringwald uint8_t pbap_set_list_start_offset(uint16_t pbap_cid, uint16_t list_start_offset); 152*04f86d08SMatthias Ringwald 153*04f86d08SMatthias Ringwald /** 1541c7aea60SMilanka Ringwald * @brief Get size of phone book from PSE. The result is reported via PBAP_SUBEVENT_PHONEBOOK_SIZE event. 1551c7aea60SMilanka Ringwald * 1563a7447a3SMatthias Ringwald * @param pbap_cid 1578c94c044SMatthias Ringwald * @param path - note: path is not copied, common path 'telecom/pb.vcf' 1581c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 1593a7447a3SMatthias Ringwald */ 1608c94c044SMatthias Ringwald uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path); 1613a7447a3SMatthias Ringwald 1623a7447a3SMatthias Ringwald /** 1631c7aea60SMilanka Ringwald * @brief Pull phone book from PSE. The result is reported via registered packet handler (see pbap_connect function), 1641c7aea60SMilanka Ringwald * with packet type set to PBAP_DATA_PACKET. Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the phone book. 1651c7aea60SMilanka Ringwald * 166f1b34e8dSMatthias Ringwald * @param pbap_cid 1678c94c044SMatthias Ringwald * @param path - note: path is not copied, common path 'telecom/pb.vcf' 1681c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 169f1b34e8dSMatthias Ringwald */ 1708c94c044SMatthias Ringwald uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path); 171e03b79abSMatthias Ringwald 172e03b79abSMatthias Ringwald /** 1731c7aea60SMilanka Ringwald * @brief Pull vCard listing. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event. 1741c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of vCard listing. 1751c7aea60SMilanka Ringwald * 1764687d289SMatthias Ringwald * @param pbap_cid 1774687d289SMatthias Ringwald * @param path 1781c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 1794687d289SMatthias Ringwald */ 1804687d289SMatthias Ringwald uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path); 1814687d289SMatthias Ringwald 1824687d289SMatthias Ringwald /** 1831c7aea60SMilanka Ringwald * @brief Pull vCard entry. The result is reported via callback (see pbap_connect function), 1841c7aea60SMilanka Ringwald * with packet type set to PBAP_DATA_PACKET. 1851c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the vCard entry. 1861c7aea60SMilanka Ringwald * 18716ad3745SMatthias Ringwald * @param pbap_cid 18816ad3745SMatthias Ringwald * @param path 1891c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 19016ad3745SMatthias Ringwald */ 19116ad3745SMatthias Ringwald uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path); 19216ad3745SMatthias Ringwald 19316ad3745SMatthias Ringwald /** 1941c7aea60SMilanka Ringwald * @brief Lookup contact(s) by phone number. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event. 1951c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the lookup. 1961c7aea60SMilanka Ringwald * 197e03b79abSMatthias Ringwald * @param pbap_cid 198e03b79abSMatthias Ringwald * @param phone_number 1991c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 200e03b79abSMatthias Ringwald */ 201e03b79abSMatthias Ringwald uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number); 202f1b34e8dSMatthias Ringwald 203d4436ef5SMatthias Ringwald /** 2041c7aea60SMilanka Ringwald * @brief Abort current operation. No event is emitted. 2051c7aea60SMilanka Ringwald * 2069eb7827dSMatthias Ringwald * @param pbap_cid 2071c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 2089eb7827dSMatthias Ringwald */ 2099eb7827dSMatthias Ringwald uint8_t pbap_abort(uint16_t pbap_cid); 2109eb7827dSMatthias Ringwald 2119eb7827dSMatthias Ringwald 2129eb7827dSMatthias Ringwald /** 2131c7aea60SMilanka Ringwald * @brief Set flow control mode - default is off. No event is emitted. 214d4436ef5SMatthias Ringwald * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one 2151c7aea60SMilanka Ringwald * 2168854a89dSMatthias Ringwald * @param pbap_cid 2171c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 218d4436ef5SMatthias Ringwald */ 2198854a89dSMatthias Ringwald uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable); 220d4436ef5SMatthias Ringwald 221d4436ef5SMatthias Ringwald /** 2221c7aea60SMilanka Ringwald * @brief Trigger next packet from PSE when Flow Control Mode is enabled. 223d4436ef5SMatthias Ringwald * @param pbap_cid 2241c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 225d4436ef5SMatthias Ringwald */ 226d4436ef5SMatthias Ringwald uint8_t pbap_next_packet(uint16_t pbap_cid); 227d4436ef5SMatthias Ringwald 2281d0ae3baSMatthias Ringwald /** 2291d0ae3baSMatthias Ringwald * @brief De-Init PBAP Client 2301d0ae3baSMatthias Ringwald */ 2311d0ae3baSMatthias Ringwald void pbap_client_deinit(void); 232d4436ef5SMatthias Ringwald 233f1b34e8dSMatthias Ringwald /* API_END */ 234f1b34e8dSMatthias Ringwald 235f1b34e8dSMatthias Ringwald #if defined __cplusplus 236f1b34e8dSMatthias Ringwald } 237f1b34e8dSMatthias Ringwald #endif 238f1b34e8dSMatthias Ringwald #endif 239