example/pbap_client_demo: add pbap_get_phonebook_size

This commit is contained in:
Matthias Ringwald 2018-08-20 20:36:34 +02:00
parent 3a7447a300
commit 6ff88f1f26

View File

@ -70,7 +70,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
static bd_addr_t remote_addr;
// MBP2016 "F4-0F-24-3B-1B-E1"
// Nexus 7 "30-85-A9-54-2E-78"
static const char * remote_addr_string = "30-85-A9-54-2E-78";
static const char * remote_addr_string = "BC:EC:5D:E6:15:03";
static btstack_packet_callback_registration_t hci_event_callback_registration;
static uint16_t pbap_cid;
@ -87,8 +87,9 @@ static void show_usage(void){
printf("a - establish PBAP connection to %s\n", bd_addr_to_str(remote_addr));
printf("b - set phonebook '/telecom/pb'\n");
printf("c - set phonebook '/SIM1/telecom/pb'\n");
printf("d - pull phonebook\n");
printf("e - disconnnect\n");
printf("d - get phonebook size\n");
printf("e - pull phonebook\n");
printf("f - disconnnect\n");
printf("\n");
}
@ -107,9 +108,12 @@ static void stdin_process(char c){
pbap_set_phonebook(pbap_cid, "SIM1/telecom/pb");
break;
case 'd':
pbap_pull_phonebook(pbap_cid);
pbap_get_phonebook_size(pbap_cid);
break;
case 'e':
pbap_pull_phonebook(pbap_cid);
break;
case 'f':
pbap_disconnect(pbap_cid);
break;
default:
@ -123,6 +127,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
UNUSED(channel);
UNUSED(size);
int i;
uint8_t status;
switch (packet_type){
case HCI_EVENT_PACKET:
switch (hci_event_packet_get_type(packet)) {
@ -143,6 +148,14 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
case PBAP_SUBEVENT_OPERATION_COMPLETED:
printf("[+] Operation complete\n");
break;
case PBAP_SUBEVENT_PHONEBOOK_SIZE:
status = pbap_subevent_phonebook_size_get_status(packet);
if (status){
printf("[+] Get Phonebook size error: 0x%x\n", status);
} else {
printf("[+] Phonebook size: %u\n", pbap_subevent_phonebook_size_get_phoneboook_size(packet));
}
break;
default:
break;
}