diff --git a/CHANGELOG.md b/CHANGELOG.md index c3e0daa09..7a791a84b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - PBAP Client: allow to set start offset and max list count for pull phonebook operation +- PBAP Client: support multiple parallel connections ### Fixed - RFCOMM: shut down multiplexer after closing last channel instead of multiplexer idle timer diff --git a/src/classic/pbap_client.c b/src/classic/pbap_client.c index 936cbf4bc..436dca627 100644 --- a/src/classic/pbap_client.c +++ b/src/classic/pbap_client.c @@ -1080,7 +1080,7 @@ void pbap_client_init(void){ void pbap_client_deinit(void){ } -static uint8_t pbap_client_connect(pbap_client_t * client, btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid) { +uint8_t pbap_client_connect(pbap_client_t * client, btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid) { client->state = PBAP_CLIENT_W4_GOEP_CONNECTION; client->client_handler = handler; client->vcard_selector = 0; diff --git a/src/classic/pbap_client.h b/src/classic/pbap_client.h index dcac473ac..f934bf36d 100644 --- a/src/classic/pbap_client.h +++ b/src/classic/pbap_client.h @@ -171,13 +171,34 @@ typedef struct pbap_client { */ void pbap_client_init(void); +/** + * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device. + * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which + * can be answered with pbap_authentication_password(..). + * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, + * i.e. on success status field is set to ERROR_CODE_SUCCESS. + * + * This function allows for multiple parallel connections. + * + * @param client storage for connection state. Must stay valid until connection closes + * @param handler + * @param addr + * @param out_cid to use for further commands + * @return status ERROR_CODE_SUCCESS on success, otherwise BTSTACK_MEMORY_ALLOC_FAILED if PBAP or GOEP connection already exists. + */ + +uint8_t pbap_client_connect(pbap_client_t * client, btstack_packet_handler_t handler, bd_addr_t addr, uint16_t * out_cid); + /** * @brief Create PBAP connection to a Phone Book Server (PSE) server on a remote device. * If the server requires authentication, a PBAP_SUBEVENT_AUTHENTICATION_REQUEST is emitted, which * can be answered with pbap_authentication_password(..). * The status of PBAP connection establishment is reported via PBAP_SUBEVENT_CONNECTION_OPENED event, * i.e. on success status field is set to ERROR_CODE_SUCCESS. - * + * + * This function uses a single pbap_client_t instance and can only be used for a single connection. + * Fur multiple parallel connections, use pbap_client_connect. + * * @param handler * @param addr * @param out_cid to use for further commands