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" 510e7551b0SMatthias Ringwald #include "yxml.h" 52f1b34e8dSMatthias Ringwald #include <stdint.h> 53f1b34e8dSMatthias Ringwald 5483f1bca0SMatthias Ringwald // max len of phone number used for lookup in pbap_lookup_by_number 5583f1bca0SMatthias Ringwald #define PBAP_MAX_PHONE_NUMBER_LEN 32 5683f1bca0SMatthias Ringwald 5783f1bca0SMatthias Ringwald // max len of name reported in PBAP_SUBEVENT_CARD_RESULT 5883f1bca0SMatthias Ringwald #define PBAP_MAX_NAME_LEN 32 5983f1bca0SMatthias Ringwald // max len of vcard handle reported in PBAP_SUBEVENT_CARD_RESULT 6083f1bca0SMatthias Ringwald #define PBAP_MAX_HANDLE_LEN 16 6183f1bca0SMatthias Ringwald 620e7551b0SMatthias Ringwald 630e7551b0SMatthias Ringwald typedef enum { 640e7551b0SMatthias Ringwald PBAP_CLIENT_INIT = 0, 650e7551b0SMatthias Ringwald PBAP_CLIENT_W4_GOEP_CONNECTION, 660e7551b0SMatthias Ringwald PBAP_CLIENT_W2_SEND_CONNECT_REQUEST, 670e7551b0SMatthias Ringwald PBAP_CLIENT_W4_CONNECT_RESPONSE, 680e7551b0SMatthias Ringwald PBAP_CLIENT_W4_USER_AUTHENTICATION, 690e7551b0SMatthias Ringwald PBAP_CLIENT_W2_SEND_AUTHENTICATED_CONNECT, 700e7551b0SMatthias Ringwald PBAP_CLIENT_CONNECTED, 710e7551b0SMatthias Ringwald // 720e7551b0SMatthias Ringwald PBAP_CLIENT_W2_SEND_DISCONNECT_REQUEST, 730e7551b0SMatthias Ringwald PBAP_CLIENT_W4_DISCONNECT_RESPONSE, 740e7551b0SMatthias Ringwald // 750e7551b0SMatthias Ringwald PBAP_CLIENT_W2_PULL_PHONEBOOK, 760e7551b0SMatthias Ringwald PBAP_CLIENT_W4_PHONEBOOK, 770e7551b0SMatthias Ringwald PBAP_CLIENT_W2_SET_PATH_ROOT, 780e7551b0SMatthias Ringwald PBAP_CLIENT_W4_SET_PATH_ROOT_COMPLETE, 790e7551b0SMatthias Ringwald PBAP_CLIENT_W2_SET_PATH_ELEMENT, 800e7551b0SMatthias Ringwald PBAP_CLIENT_W4_SET_PATH_ELEMENT_COMPLETE, 810e7551b0SMatthias Ringwald PBAP_CLIENT_W2_GET_PHONEBOOK_SIZE, 820e7551b0SMatthias Ringwald PBAP_CLIENT_W4_GET_PHONEBOOK_SIZE_COMPLETE, 830e7551b0SMatthias Ringwald // - pull vacard liast 840e7551b0SMatthias Ringwald PBAP_CLIENT_W2_GET_CARD_LIST, 850e7551b0SMatthias Ringwald PBAP_CLIENT_W4_GET_CARD_LIST_COMPLETE, 860e7551b0SMatthias Ringwald // - pull vcard entry 870e7551b0SMatthias Ringwald PBAP_CLIENT_W2_GET_CARD_ENTRY, 880e7551b0SMatthias Ringwald PBAP_CLIENT_W4_GET_CARD_ENTRY_COMPLETE, 890e7551b0SMatthias Ringwald // abort operation 900e7551b0SMatthias Ringwald PBAP_CLIENT_W4_ABORT_COMPLETE, 910e7551b0SMatthias Ringwald 920e7551b0SMatthias Ringwald } pbap_client_state_t; 930e7551b0SMatthias Ringwald 940e7551b0SMatthias Ringwald typedef enum { 950e7551b0SMatthias Ringwald PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_TYPE = 0, 960e7551b0SMatthias Ringwald PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_LEN, 970e7551b0SMatthias Ringwald PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_W4_VALUE, 980e7551b0SMatthias Ringwald PBAP_CLIENT_PHONEBOOK_SIZE_PARSER_STATE_INVALID, 990e7551b0SMatthias Ringwald } pbap_client_phonebook_size_parser_state_t; 1000e7551b0SMatthias Ringwald 1010e7551b0SMatthias Ringwald typedef struct { 1020e7551b0SMatthias Ringwald // parsing 1030e7551b0SMatthias Ringwald pbap_client_phonebook_size_parser_state_t state; 1040e7551b0SMatthias Ringwald uint8_t type; 1050e7551b0SMatthias Ringwald uint8_t len; 1060e7551b0SMatthias Ringwald uint8_t pos; 1070e7551b0SMatthias Ringwald // data 1080e7551b0SMatthias Ringwald bool have_size; 1090e7551b0SMatthias Ringwald uint8_t size_buffer[2]; 1100e7551b0SMatthias Ringwald } pbap_client_phonebook_size_parser_t; 1110e7551b0SMatthias Ringwald 112*1a3b1957SMatthias Ringwald typedef enum { 113*1a3b1957SMatthias Ringwald PBAP_CLIENT_SRM_DISABLED, 114*1a3b1957SMatthias Ringwald PBAP_CLIENT_SRM_W4_CONFIRM, 115*1a3b1957SMatthias Ringwald PBAP_CLIENT_SRM_ENABLED_BUT_WAITING, 116*1a3b1957SMatthias Ringwald PBAP_CLIENT_SRM_ENABLED 117*1a3b1957SMatthias Ringwald } pbap_client_obex_srm_state_t; 118*1a3b1957SMatthias Ringwald 119*1a3b1957SMatthias Ringwald typedef struct { 120*1a3b1957SMatthias Ringwald uint8_t srm_value; 121*1a3b1957SMatthias Ringwald uint8_t srmp_value; 122*1a3b1957SMatthias Ringwald } pbap_client_obex_srm_t; 123*1a3b1957SMatthias Ringwald 124*1a3b1957SMatthias Ringwald typedef enum { 125*1a3b1957SMatthias Ringwald OBEX_AUTH_PARSER_STATE_W4_TYPE = 0, 126*1a3b1957SMatthias Ringwald OBEX_AUTH_PARSER_STATE_W4_LEN, 127*1a3b1957SMatthias Ringwald OBEX_AUTH_PARSER_STATE_W4_VALUE, 128*1a3b1957SMatthias Ringwald OBEX_AUTH_PARSER_STATE_INVALID, 129*1a3b1957SMatthias Ringwald } pbap_client_obex_auth_parser_state_t; 130*1a3b1957SMatthias Ringwald 131*1a3b1957SMatthias Ringwald typedef struct { 132*1a3b1957SMatthias Ringwald // parsing 133*1a3b1957SMatthias Ringwald pbap_client_obex_auth_parser_state_t state; 134*1a3b1957SMatthias Ringwald uint8_t type; 135*1a3b1957SMatthias Ringwald uint8_t len; 136*1a3b1957SMatthias Ringwald uint8_t pos; 137*1a3b1957SMatthias Ringwald // data 138*1a3b1957SMatthias Ringwald uint8_t authentication_options; 139*1a3b1957SMatthias Ringwald uint16_t authentication_nonce[16]; 140*1a3b1957SMatthias Ringwald } pbap_client_obex_auth_parser_t; 141*1a3b1957SMatthias Ringwald 1420e7551b0SMatthias Ringwald typedef struct pbap_client { 143fe072f38SMatthias Ringwald // pbap client linked list 144fe072f38SMatthias Ringwald btstack_linked_item_t item; 145fe072f38SMatthias Ringwald 146fe072f38SMatthias Ringwald // goep client linked list 1470e7551b0SMatthias Ringwald goep_client_t goep_client; 1480e7551b0SMatthias Ringwald 149fe072f38SMatthias Ringwald pbap_client_state_t state; 1500e7551b0SMatthias Ringwald bd_addr_t bd_addr; 1510e7551b0SMatthias Ringwald hci_con_handle_t con_handle; 1520e7551b0SMatthias Ringwald uint16_t goep_cid; 1530e7551b0SMatthias Ringwald btstack_packet_handler_t client_handler; 1540e7551b0SMatthias Ringwald int request_number; 1550e7551b0SMatthias Ringwald const char * current_folder; 1560e7551b0SMatthias Ringwald const char * phone_number; 1570e7551b0SMatthias Ringwald const char * phonebook_path; 1580e7551b0SMatthias Ringwald const char * vcard_name; 1590e7551b0SMatthias Ringwald uint16_t set_path_offset; 1600e7551b0SMatthias Ringwald /* vcard selector / operator */ 1610e7551b0SMatthias Ringwald uint32_t vcard_selector; 1620e7551b0SMatthias Ringwald uint8_t vcard_selector_operator; 1630e7551b0SMatthias Ringwald uint8_t vcard_selector_supported; 1640e7551b0SMatthias Ringwald /* property selector */ 1650e7551b0SMatthias Ringwald uint32_t property_selector; 1660e7551b0SMatthias Ringwald uint16_t list_start_offset; 1670e7551b0SMatthias Ringwald uint16_t max_list_count; 1680e7551b0SMatthias Ringwald /* abort */ 1690e7551b0SMatthias Ringwald uint8_t abort_operation; 1700e7551b0SMatthias Ringwald /* obex parser */ 1710e7551b0SMatthias Ringwald bool obex_parser_waiting_for_response; 1720e7551b0SMatthias Ringwald obex_parser_t obex_parser; 1730e7551b0SMatthias Ringwald uint8_t obex_header_buffer[4]; 1740e7551b0SMatthias Ringwald /* authentication */ 175*1a3b1957SMatthias Ringwald pbap_client_obex_auth_parser_t obex_auth_parser; 1760e7551b0SMatthias Ringwald const char * authentication_password; 1770e7551b0SMatthias Ringwald /* xml parser */ 1780e7551b0SMatthias Ringwald yxml_t xml_parser; 1790e7551b0SMatthias Ringwald uint8_t xml_buffer[50]; 1800e7551b0SMatthias Ringwald /* vcard listing parser */ 1810e7551b0SMatthias Ringwald bool parser_card_found; 1820e7551b0SMatthias Ringwald bool parser_name_found; 1830e7551b0SMatthias Ringwald bool parser_handle_found; 1840e7551b0SMatthias Ringwald char parser_name[PBAP_MAX_NAME_LEN]; 1850e7551b0SMatthias Ringwald char parser_handle[PBAP_MAX_HANDLE_LEN]; 1860e7551b0SMatthias Ringwald /* phonebook size */ 1870e7551b0SMatthias Ringwald pbap_client_phonebook_size_parser_t phonebook_size_parser; 1880e7551b0SMatthias Ringwald /* flow control mode */ 1890e7551b0SMatthias Ringwald uint8_t flow_control_enabled; 1900e7551b0SMatthias Ringwald uint8_t flow_next_triggered; 1910e7551b0SMatthias Ringwald bool flow_wait_for_user; 1920e7551b0SMatthias Ringwald /* srm */ 193*1a3b1957SMatthias Ringwald pbap_client_obex_srm_t obex_srm; 194*1a3b1957SMatthias Ringwald pbap_client_obex_srm_state_t srm_state; 1950e7551b0SMatthias Ringwald } pbap_client_t; 1960e7551b0SMatthias Ringwald 197f1b34e8dSMatthias Ringwald /* API_START */ 198f1b34e8dSMatthias Ringwald 199f1b34e8dSMatthias Ringwald /** 200f1b34e8dSMatthias Ringwald * Setup PhoneBook Access Client 201f1b34e8dSMatthias Ringwald */ 202f1b34e8dSMatthias Ringwald void pbap_client_init(void); 203f1b34e8dSMatthias Ringwald 204f1b34e8dSMatthias Ringwald /** 2051c7aea60SMilanka Ringwald * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device. 2061c7aea60SMilanka Ringwald * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which 2071c7aea60SMilanka Ringwald * can be answered with pbap_authentication_password(..). 2081c7aea60SMilanka Ringwald * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, 2091c7aea60SMilanka Ringwald * i.e. on success status field is set to ERROR_CODE_SUCCESS. 2101c7aea60SMilanka Ringwald * 211f3185e85SMatthias Ringwald * This function allows for multiple parallel connections. 212f3185e85SMatthias Ringwald * 213f3185e85SMatthias Ringwald * @param client storage for connection state. Must stay valid until connection closes 2140806590aSMatthias Ringwald * @param l2cap_ertm_config 2150806590aSMatthias Ringwald * @param l2cap_ertm_buffer_size 2160806590aSMatthias Ringwald * @param l2cap_ertm_buffer 217f3185e85SMatthias Ringwald * @param handler 218f3185e85SMatthias Ringwald * @param addr 219f3185e85SMatthias Ringwald * @param out_cid to use for further commands 220f3185e85SMatthias Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists. 221f3185e85SMatthias Ringwald */ 222f3185e85SMatthias Ringwald 2230806590aSMatthias Ringwald uint8_t pbap_client_connect(pbap_client_t * client, l2cap_ertm_config_t *l2cap_ertm_config, uint8_t *l2cap_ertm_buffer, 2240806590aSMatthias Ringwald uint16_t l2cap_ertm_buffer_size, btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid); 225f3185e85SMatthias Ringwald 226f3185e85SMatthias Ringwald /** 227f3185e85SMatthias Ringwald * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device. 228f3185e85SMatthias Ringwald * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which 229f3185e85SMatthias Ringwald * can be answered with pbap_authentication_password(..). 230f3185e85SMatthias Ringwald * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, 231f3185e85SMatthias Ringwald * i.e. on success status field is set to ERROR_CODE_SUCCESS. 232f3185e85SMatthias Ringwald * 233dff8de67SMatthias Ringwald * This function uses a single pbap_client_t and l2cap ertm buffer instance and can only be used for a single connection. 234f3185e85SMatthias Ringwald * Fur multiple parallel connections, use pbap_client_connect. 235f3185e85SMatthias Ringwald * 236f1b34e8dSMatthias Ringwald * @param handler 237f1b34e8dSMatthias Ringwald * @param addr 238f1b34e8dSMatthias Ringwald * @param out_cid to use for further commands 2391c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists. 240f1b34e8dSMatthias Ringwald */ 241f1b34e8dSMatthias Ringwald uint8_t pbap_connect(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid); 242f1b34e8dSMatthias Ringwald 243f1b34e8dSMatthias Ringwald /** 2441c7aea60SMilanka Ringwald * @brief Provide password for OBEX Authentication after receiving PBAP_SUBEVENT_AUTHENTICATION_REQUEST. 2451c7aea60SMilanka Ringwald * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, 2461c7aea60SMilanka Ringwald * i.e. on success status field is set to ERROR_CODE_SUCCESS. 2471c7aea60SMilanka Ringwald * 248c1bc0b8eSMatthias Ringwald * @param pbap_cid 249c1bc0b8eSMatthias Ringwald * @param password (null terminated string) - not copied, needs to stay valid until connection completed 2501c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 251c1bc0b8eSMatthias Ringwald */ 252c1bc0b8eSMatthias Ringwald uint8_t pbap_authentication_password(uint16_t pbap_cid, const char * password); 253c1bc0b8eSMatthias Ringwald 254c1bc0b8eSMatthias Ringwald /** 255f1b34e8dSMatthias Ringwald * @brief Disconnects PBAP connection with given identifier. 2561c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_CONNECTION_CLOSED indicates that PBAP connection is closed. 2571c7aea60SMilanka Ringwald * 258f1b34e8dSMatthias Ringwald * @param pbap_cid 2591c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 260f1b34e8dSMatthias Ringwald */ 261f1b34e8dSMatthias Ringwald uint8_t pbap_disconnect(uint16_t pbap_cid); 262f1b34e8dSMatthias Ringwald 263f1b34e8dSMatthias Ringwald /** 2641c7aea60SMilanka Ringwald * @brief Set current folder on PSE. The status is reported via PBAP_SUBEVENT_OPERATION_COMPLETED event. 2651c7aea60SMilanka Ringwald * 266f1b34e8dSMatthias Ringwald * @param pbap_cid 267f1b34e8dSMatthias Ringwald * @param path - note: path is not copied 2681c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 269f1b34e8dSMatthias Ringwald */ 270f1b34e8dSMatthias Ringwald uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path); 271f1b34e8dSMatthias Ringwald 272f1b34e8dSMatthias Ringwald /** 2731c7aea60SMilanka Ringwald * @brief Set vCard Selector for get/pull phonebook. No event is emitted. 2741c7aea60SMilanka Ringwald * 2753127f224SMatthias Ringwald * @param pbap_cid 2763127f224SMatthias Ringwald * @param vcard_selector - combination of PBAP_PROPERTY_MASK_* properties 2771c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 2783127f224SMatthias Ringwald */ 2793127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector(uint16_t pbap_cid, uint32_t vcard_selector); 2803127f224SMatthias Ringwald 2813127f224SMatthias Ringwald /** 2821c7aea60SMilanka Ringwald * @brief Set vCard Selector for get/pull phonebook. No event is emitted. 2831c7aea60SMilanka Ringwald * 2843127f224SMatthias Ringwald * @param pbap_cid 2853127f224SMatthias Ringwald * @param vcard_selector_operator - PBAP_VCARD_SELECTOR_OPERATOR_OR (default) or PBAP_VCARD_SELECTOR_OPERATOR_AND 2861c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 2873127f224SMatthias Ringwald */ 2883127f224SMatthias Ringwald uint8_t pbap_set_vcard_selector_operator(uint16_t pbap_cid, int vcard_selector_operator); 2893127f224SMatthias Ringwald 2903127f224SMatthias Ringwald /** 291e9b4d967SMatthias Ringwald * @brief Set Property Selector. No event is emitted. 292e9b4d967SMatthias Ringwald * @param pbap_cid 293e9b4d967SMatthias Ringwald * @param property_selector - combination of PBAP_PROPERTY_MASK_* properties 294e9b4d967SMatthias Ringwald * @return 295e9b4d967SMatthias Ringwald */ 296e9b4d967SMatthias Ringwald uint8_t pbap_set_property_selector(uint16_t pbap_cid, uint32_t property_selector); 297e9b4d967SMatthias Ringwald 298e9b4d967SMatthias Ringwald /** 29904f86d08SMatthias Ringwald * @brief Set number of items returned by pull phonebook. 30004f86d08SMatthias Ringwald * @param pbap_cid 30104f86d08SMatthias Ringwald * @param max_list_count 30204f86d08SMatthias Ringwald * @return 30304f86d08SMatthias Ringwald */ 30404f86d08SMatthias Ringwald uint8_t pbap_set_max_list_count(uint16_t pbap_cid, uint16_t max_list_count); 30504f86d08SMatthias Ringwald 30604f86d08SMatthias Ringwald /** 30704f86d08SMatthias Ringwald * @bbrief Set start offset for pull phonebook 30804f86d08SMatthias Ringwald * @param pbap_cid 30904f86d08SMatthias Ringwald * @param list_start_offset 31004f86d08SMatthias Ringwald * @return 31104f86d08SMatthias Ringwald */ 31204f86d08SMatthias Ringwald uint8_t pbap_set_list_start_offset(uint16_t pbap_cid, uint16_t list_start_offset); 31304f86d08SMatthias Ringwald 31404f86d08SMatthias Ringwald /** 3151c7aea60SMilanka Ringwald * @brief Get size of phone book from PSE. The result is reported via PBAP_SUBEVENT_PHONEBOOK_SIZE event. 3161c7aea60SMilanka Ringwald * 3173a7447a3SMatthias Ringwald * @param pbap_cid 3188c94c044SMatthias Ringwald * @param path - note: path is not copied, common path 'telecom/pb.vcf' 3191c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 3203a7447a3SMatthias Ringwald */ 3218c94c044SMatthias Ringwald uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path); 3223a7447a3SMatthias Ringwald 3233a7447a3SMatthias Ringwald /** 3241c7aea60SMilanka Ringwald * @brief Pull phone book from PSE. The result is reported via registered packet handler (see pbap_connect function), 3251c7aea60SMilanka Ringwald * with packet type set to PBAP_DATA_PACKET. Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the phone book. 3261c7aea60SMilanka Ringwald * 327f1b34e8dSMatthias Ringwald * @param pbap_cid 3288c94c044SMatthias Ringwald * @param path - note: path is not copied, common path 'telecom/pb.vcf' 3291c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 330f1b34e8dSMatthias Ringwald */ 3318c94c044SMatthias Ringwald uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path); 332e03b79abSMatthias Ringwald 333e03b79abSMatthias Ringwald /** 3341c7aea60SMilanka Ringwald * @brief Pull vCard listing. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event. 3351c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of vCard listing. 3361c7aea60SMilanka Ringwald * 3374687d289SMatthias Ringwald * @param pbap_cid 3384687d289SMatthias Ringwald * @param path 3391c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 3404687d289SMatthias Ringwald */ 3414687d289SMatthias Ringwald uint8_t pbap_pull_vcard_listing(uint16_t pbap_cid, const char * path); 3424687d289SMatthias Ringwald 3434687d289SMatthias Ringwald /** 3441c7aea60SMilanka Ringwald * @brief Pull vCard entry. The result is reported via callback (see pbap_connect function), 3451c7aea60SMilanka Ringwald * with packet type set to PBAP_DATA_PACKET. 3461c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the vCard entry. 3471c7aea60SMilanka Ringwald * 34816ad3745SMatthias Ringwald * @param pbap_cid 34916ad3745SMatthias Ringwald * @param path 3501c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 35116ad3745SMatthias Ringwald */ 35216ad3745SMatthias Ringwald uint8_t pbap_pull_vcard_entry(uint16_t pbap_cid, const char * path); 35316ad3745SMatthias Ringwald 35416ad3745SMatthias Ringwald /** 3551c7aea60SMilanka Ringwald * @brief Lookup contact(s) by phone number. vCard data is emitted via PBAP_SUBEVENT_CARD_RESULT event. 3561c7aea60SMilanka Ringwald * Event PBAP_SUBEVENT_OPERATION_COMPLETED marks the end of the lookup. 3571c7aea60SMilanka Ringwald * 358e03b79abSMatthias Ringwald * @param pbap_cid 359e03b79abSMatthias Ringwald * @param phone_number 3601c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 361e03b79abSMatthias Ringwald */ 362e03b79abSMatthias Ringwald uint8_t pbap_lookup_by_number(uint16_t pbap_cid, const char * phone_number); 363f1b34e8dSMatthias Ringwald 364d4436ef5SMatthias Ringwald /** 3651c7aea60SMilanka Ringwald * @brief Abort current operation. No event is emitted. 3661c7aea60SMilanka Ringwald * 3679eb7827dSMatthias Ringwald * @param pbap_cid 3681c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 3699eb7827dSMatthias Ringwald */ 3709eb7827dSMatthias Ringwald uint8_t pbap_abort(uint16_t pbap_cid); 3719eb7827dSMatthias Ringwald 3729eb7827dSMatthias Ringwald 3739eb7827dSMatthias Ringwald /** 3741c7aea60SMilanka Ringwald * @brief Set flow control mode - default is off. No event is emitted. 375d4436ef5SMatthias Ringwald * @note When enabled, pbap_next_packet needs to be called after a packet was processed to receive the next one 3761c7aea60SMilanka Ringwald * 3778854a89dSMatthias Ringwald * @param pbap_cid 3781c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 379d4436ef5SMatthias Ringwald */ 3808854a89dSMatthias Ringwald uint8_t pbap_set_flow_control_mode(uint16_t pbap_cid, int enable); 381d4436ef5SMatthias Ringwald 382d4436ef5SMatthias Ringwald /** 3831c7aea60SMilanka Ringwald * @brief Trigger next packet from PSE when Flow Control Mode is enabled. 384d4436ef5SMatthias Ringwald * @param pbap_cid 3851c7aea60SMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_BUSY if in a wrong state. 386d4436ef5SMatthias Ringwald */ 387d4436ef5SMatthias Ringwald uint8_t pbap_next_packet(uint16_t pbap_cid); 388d4436ef5SMatthias Ringwald 3891d0ae3baSMatthias Ringwald /** 3901d0ae3baSMatthias Ringwald * @brief De-Init PBAP Client 3911d0ae3baSMatthias Ringwald */ 3921d0ae3baSMatthias Ringwald void pbap_client_deinit(void); 393d4436ef5SMatthias Ringwald 394f1b34e8dSMatthias Ringwald /* API_END */ 395f1b34e8dSMatthias Ringwald 396f1b34e8dSMatthias Ringwald #if defined __cplusplus 397f1b34e8dSMatthias Ringwald } 398f1b34e8dSMatthias Ringwald #endif 399f1b34e8dSMatthias Ringwald #endif 400