pbap_client: allow to specify phonebook path with pbap_pull_phonebook and pbap_get_phonebook_size

This commit is contained in:
Matthias Ringwald 2018-10-09 12:29:07 +02:00
parent a78157dda1
commit 8c94c0448e
3 changed files with 20 additions and 14 deletions

View File

@ -72,10 +72,12 @@ static bd_addr_t remote_addr;
// Nexus 7 "30-85-A9-54-2E-78" // Nexus 7 "30-85-A9-54-2E-78"
// iPhone SE "BC:EC:5D:E6:15:03" // iPhone SE "BC:EC:5D:E6:15:03"
// PTS "001BDC080AA5" // PTS "001BDC080AA5"
static char * remote_addr_string = "BC:EC:5D:E6:15:03"; static char * remote_addr_string = "001BDC080AA5";
static char * phone_number = "911"; static char * phone_number = "911";
static const char * phonebook_path = "telecom/pb.vcf";
static btstack_packet_callback_registration_t hci_event_callback_registration; static btstack_packet_callback_registration_t hci_event_callback_registration;
static uint16_t pbap_cid; static uint16_t pbap_cid;
@ -89,11 +91,11 @@ static void show_usage(void){
printf("\n--- Bluetooth PBAP Client (HF) Test Console %s ---\n", bd_addr_to_str(iut_address)); printf("\n--- Bluetooth PBAP Client (HF) Test Console %s ---\n", bd_addr_to_str(iut_address));
printf("\n"); printf("\n");
printf("a - establish PBAP connection to %s\n", bd_addr_to_str(remote_addr)); printf("a - establish PBAP connection to %s\n", bd_addr_to_str(remote_addr));
printf("b - set phonebook '/telecom/pb'\n"); printf("b - set phonebook '/telecom/pb'\n");
printf("c - set phonebook '/SIM1/telecom/pb'\n"); printf("c - set phonebook '/SIM1/telecom/pb'\n");
printf("r - set path to '/root/telecom'\n"); printf("r - set path to '/root/telecom'\n");
printf("d - get phonebook size\n"); printf("d - get size of '%s'\n", phonebook_path);
printf("e - pull phonebook\n"); printf("e - pull phonebook '%s'\n", phonebook_path);
printf("f - disconnnect\n"); printf("f - disconnnect\n");
printf("g - Lookup contact with number '%s'\n", phone_number); printf("g - Lookup contact with number '%s'\n", phone_number);
printf("p - authenticate using password '0000'\n"); printf("p - authenticate using password '0000'\n");
@ -116,10 +118,10 @@ static void stdin_process(char c){
pbap_set_phonebook(pbap_cid, "SIM1/telecom/pb"); pbap_set_phonebook(pbap_cid, "SIM1/telecom/pb");
break; break;
case 'd': case 'd':
pbap_get_phonebook_size(pbap_cid); pbap_get_phonebook_size(pbap_cid, phonebook_path);
break; break;
case 'e': case 'e':
pbap_pull_phonebook(pbap_cid); pbap_pull_phonebook(pbap_cid, phonebook_path);
break; break;
case 'f': case 'f':
pbap_disconnect(pbap_cid); pbap_disconnect(pbap_cid);

View File

@ -66,7 +66,6 @@
static const uint8_t pbap_uuid[] = { 0x79, 0x61, 0x35, 0xf0, 0xf0, 0xc5, 0x11, 0xd8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66}; static const uint8_t pbap_uuid[] = { 0x79, 0x61, 0x35, 0xf0, 0xf0, 0xc5, 0x11, 0xd8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66};
const char * pbap_phonebook_type = "x-bt/phonebook"; const char * pbap_phonebook_type = "x-bt/phonebook";
const char * pbap_phonebook_name = "pb.vcf";
const char * pbap_vcard_listing_type = "x-bt/vcard-listing"; const char * pbap_vcard_listing_type = "x-bt/vcard-listing";
const char * pbap_vcard_listing_name = "pb"; const char * pbap_vcard_listing_name = "pb";
@ -121,6 +120,7 @@ typedef struct pbap_client {
int single_response_mode_parameter; int single_response_mode_parameter;
const char * current_folder; const char * current_folder;
const char * phone_number; const char * phone_number;
const char * phonebook_path;
uint16_t set_path_offset; uint16_t set_path_offset;
uint8_t authentication_options; uint8_t authentication_options;
uint16_t authentication_nonce[16]; uint16_t authentication_nonce[16];
@ -293,7 +293,7 @@ static void pbap_handle_can_send_now(void){
goep_client_add_header_srm_enable(pbap_client->goep_cid); goep_client_add_header_srm_enable(pbap_client->goep_cid);
pbap_client->srm_state = SRM_W4_CONFIRM; pbap_client->srm_state = SRM_W4_CONFIRM;
goep_client_add_header_type(pbap_client->goep_cid, pbap_phonebook_type); goep_client_add_header_type(pbap_client->goep_cid, pbap_phonebook_type);
goep_client_add_header_name(pbap_client->goep_cid, pbap_phonebook_name); goep_client_add_header_name(pbap_client->goep_cid, pbap_client->phonebook_path);
if (pbap_client->state == PBAP_W2_GET_PHONEBOOK_SIZE){ if (pbap_client->state == PBAP_W2_GET_PHONEBOOK_SIZE){
// Regular TLV wih 1-byte len // Regular TLV wih 1-byte len
application_parameters[0] = PBAP_APPLICATION_PARAMETER_MAX_LIST_COUNT; application_parameters[0] = PBAP_APPLICATION_PARAMETER_MAX_LIST_COUNT;
@ -733,19 +733,21 @@ uint8_t pbap_disconnect(uint16_t pbap_cid){
return 0; return 0;
} }
uint8_t pbap_get_phonebook_size(uint16_t pbap_cid){ uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path){
UNUSED(pbap_cid); UNUSED(pbap_cid);
if (pbap_client->state != PBAP_CONNECTED) return BTSTACK_BUSY; if (pbap_client->state != PBAP_CONNECTED) return BTSTACK_BUSY;
pbap_client->state = PBAP_W2_GET_PHONEBOOK_SIZE; pbap_client->state = PBAP_W2_GET_PHONEBOOK_SIZE;
pbap_client->phonebook_path = path;
pbap_client->request_number = 0; pbap_client->request_number = 0;
goep_client_request_can_send_now(pbap_client->goep_cid); goep_client_request_can_send_now(pbap_client->goep_cid);
return 0; return 0;
} }
uint8_t pbap_pull_phonebook(uint16_t pbap_cid){ uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path){
UNUSED(pbap_cid); UNUSED(pbap_cid);
if (pbap_client->state != PBAP_CONNECTED) return BTSTACK_BUSY; if (pbap_client->state != PBAP_CONNECTED) return BTSTACK_BUSY;
pbap_client->state = PBAP_W2_PULL_PHONEBOOK; pbap_client->state = PBAP_W2_PULL_PHONEBOOK;
pbap_client->phonebook_path = path;
pbap_client->request_number = 0; pbap_client->request_number = 0;
goep_client_request_can_send_now(pbap_client->goep_cid); goep_client_request_can_send_now(pbap_client->goep_cid);
return 0; return 0;

View File

@ -93,16 +93,18 @@ uint8_t pbap_set_phonebook(uint16_t pbap_cid, const char * path);
/** /**
* @brief Get size of phone book from PSE * @brief Get size of phone book from PSE
* @param pbap_cid * @param pbap_cid
* @param path - note: path is not copied, common path 'telecom/pb.vcf'
* @return status * @return status
*/ */
uint8_t pbap_get_phonebook_size(uint16_t pbap_cid); uint8_t pbap_get_phonebook_size(uint16_t pbap_cid, const char * path);
/** /**
* @brief Pull phone book from PSE * @brief Pull phone book from PSE
* @param pbap_cid * @param pbap_cid
* @param path - note: path is not copied, common path 'telecom/pb.vcf'
* @return status * @return status
*/ */
uint8_t pbap_pull_phonebook(uint16_t pbap_cid); uint8_t pbap_pull_phonebook(uint16_t pbap_cid, const char * path);
/** /**
* @brief Lookup contact(s) by phone number * @brief Lookup contact(s) by phone number