mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
example/pbap_client_demo: allow to pull vCard Listing from all folders
This commit is contained in:
parent
4687d28996
commit
0928fcb216
@ -76,23 +76,22 @@ static char * remote_addr_string = "001BDC080AA5";
|
||||
|
||||
static char * phone_number = "911";
|
||||
|
||||
static const char * t_pb_path = "telecom/pb.vcf";
|
||||
static const char * t_fav_path = "telecom/fav.vcf";
|
||||
static const char * t_ich_path = "telecom/ich.vcf";
|
||||
static const char * t_och_path = "telecom/och.vcf";
|
||||
static const char * t_mch_path = "telecom/mch.vcf";
|
||||
static const char * t_cch_path = "telecom/cch.vcf";
|
||||
static const char * t_spd_path = "telecom/spd.vcf";
|
||||
static const char * pb_name = "pb";
|
||||
static const char * fav_name = "fav";
|
||||
static const char * ich_name = "ich";
|
||||
static const char * och_name = "och";
|
||||
static const char * mch_name = "mch";
|
||||
static const char * cch_name = "cch";
|
||||
static const char * spd_name = "spd";
|
||||
|
||||
static const char * st_pb_path = "SIM1/telecom/pb.vcf";
|
||||
static const char * st_ich_path = "SIM1/telecom/ich.vcf";
|
||||
static const char * st_och_path = "SIM1/telecom/och.vcf";
|
||||
static const char * st_mch_path = "SIM1/telecom/mch.vcf";
|
||||
static const char * st_cch_path = "SIM1/telecom/cch.vcf";
|
||||
static const char * phonebook_folder;
|
||||
static char phonebook_path[30];
|
||||
|
||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
static uint16_t pbap_cid;
|
||||
|
||||
static int sim1_selected;
|
||||
|
||||
#ifdef HAVE_BTSTACK_STDIN
|
||||
|
||||
// Testig User Interface
|
||||
@ -101,37 +100,44 @@ static void show_usage(void){
|
||||
gap_local_bd_addr(iut_address);
|
||||
|
||||
printf("\n--- Bluetooth PBAP Client (HF) Test Console %s ---\n", bd_addr_to_str(iut_address));
|
||||
printf("Phonebook: '%s'\n", phonebook_folder);
|
||||
// printf("Phonebook folder '%s'\n", phonebook_folder);
|
||||
printf("Phonebook path '%s'\n", phonebook_path);
|
||||
printf("\n");
|
||||
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("r - set path to '/root/telecom'\n");
|
||||
printf("v - set vCardSelector to FN\n");
|
||||
printf("b - select SIM1\n");
|
||||
printf("r - set path to '/telecom'\n");
|
||||
printf("R - set path to '/SIM1/telecom'\n");
|
||||
printf("v - set vCardSelector to N and TEL\n");
|
||||
printf("V - set vCardSelectorOperator to AND\n");
|
||||
printf("d - get size of '%s'\n", t_pb_path);
|
||||
|
||||
printf("e - pull phonebook '%s'\n", t_pb_path);
|
||||
printf("f - pull phonebook '%s'\n", t_fav_path);
|
||||
printf("i - pull phonebook '%s'\n", t_ich_path);
|
||||
printf("o - pull phonebook '%s'\n", t_och_path);
|
||||
printf("m - pull phonebook '%s'\n", t_mch_path);
|
||||
printf("c - pull phonebook '%s'\n", t_cch_path);
|
||||
printf("s - pull phonebook '%s'\n", t_spd_path);
|
||||
printf("e - select phonebook '%s'\n", pb_name);
|
||||
printf("f - select phonebook '%s'\n", fav_name);
|
||||
printf("i - select phonebook '%s'\n", ich_name);
|
||||
printf("o - select phonebook '%s'\n", och_name);
|
||||
printf("m - select phonebook '%s'\n", mch_name);
|
||||
printf("c - select phonebook '%s'\n", cch_name);
|
||||
printf("s - select phonebook '%s'\n", spd_name);
|
||||
|
||||
printf("E - pull phonebook '%s'\n", st_pb_path);
|
||||
printf("I - pull phonebook '%s'\n", st_ich_path);
|
||||
printf("O - pull phonebook '%s'\n", st_och_path);
|
||||
printf("M - pull phonebook '%s'\n", st_mch_path);
|
||||
printf("C - pull phonebook '%s'\n", st_cch_path);
|
||||
printf("d - get size of '%s'\n", phonebook_path);
|
||||
printf("g - pull phonebook '%s'\n", phonebook_path);
|
||||
printf("h - Lookup contact with number '%s'\n", phone_number);
|
||||
printf("l - pull vCard listing '%s'\n", phonebook_folder);
|
||||
|
||||
printf("t - disconnnect\n");
|
||||
printf("g - Lookup contact with number '%s'\n", phone_number);
|
||||
printf("p - authenticate using password '0000'\n");
|
||||
printf("r - set path to 'telecom'\n");
|
||||
printf("x - abort operation\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void select_phonebook(const char * phonebook){
|
||||
phonebook_folder = phonebook;
|
||||
sprintf(phonebook_path, "%s%s.vcf", sim1_selected ? "SIM1/telecom/" : "telecom/", phonebook);
|
||||
printf("[-] Phonebook folder '%s'\n", phonebook_folder);
|
||||
printf("[-] Phonebook path '%s'\n", phonebook_path);
|
||||
}
|
||||
|
||||
static void stdin_process(char c){
|
||||
switch (c){
|
||||
case 'a':
|
||||
@ -139,86 +145,76 @@ static void stdin_process(char c){
|
||||
pbap_connect(&packet_handler, remote_addr, &pbap_cid);
|
||||
break;
|
||||
case 'b':
|
||||
printf("[+] Set phonebook 'telecom/pb'\n");
|
||||
pbap_set_phonebook(pbap_cid, "telecom/pb");
|
||||
printf("[+] SIM1 selected'\n");
|
||||
sim1_selected = 1;
|
||||
select_phonebook(phonebook_folder);
|
||||
break;
|
||||
// case 'c':
|
||||
// printf("[+] Set phonebook 'SIM1/telecom/pb'\n");
|
||||
// pbap_set_phonebook(pbap_cid, "SIM1/telecom/pb");
|
||||
// break;
|
||||
|
||||
case 'd':
|
||||
printf("[+] Get size of phonebook '%s'\n", t_pb_path);
|
||||
pbap_get_phonebook_size(pbap_cid, t_pb_path);
|
||||
printf("[+] Get size of phonebook '%s'\n", phonebook_path);
|
||||
pbap_get_phonebook_size(pbap_cid, phonebook_path);
|
||||
break;
|
||||
case 'g':
|
||||
printf("[+] Pull phonebook '%s'\n", phonebook_path);
|
||||
pbap_pull_phonebook(pbap_cid, phonebook_path);
|
||||
break;
|
||||
case 'h':
|
||||
printf("[+] Pull vCard '%s'\n", phone_number);
|
||||
pbap_lookup_by_number(pbap_cid, phone_number);
|
||||
break;
|
||||
case 'l':
|
||||
printf("[+] Pull vCard list for '%s'\n", phonebook_folder);
|
||||
pbap_pull_vcard_listing(pbap_cid, phonebook_folder);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf("[+] Get phonebook '%s'\n", t_cch_path);
|
||||
pbap_pull_phonebook(pbap_cid, t_cch_path);
|
||||
printf("[+] Select phonebook '%s'\n", cch_name);
|
||||
select_phonebook(cch_name);
|
||||
break;
|
||||
case 'e':
|
||||
printf("[+] Get phonebook '%s'\n", t_pb_path);
|
||||
pbap_pull_phonebook(pbap_cid, t_pb_path);
|
||||
printf("[+] Select phonebook '%s'\n", pb_name);
|
||||
select_phonebook(pb_name);
|
||||
break;
|
||||
case 'f':
|
||||
printf("[+] Get phonebook '%s'\n", t_fav_path);
|
||||
pbap_pull_phonebook(pbap_cid, t_fav_path);
|
||||
printf("[+] Select phonebook '%s'\n", fav_name);
|
||||
select_phonebook(fav_name);
|
||||
break;
|
||||
case 'i':
|
||||
printf("[+] Get phonebook '%s'\n", t_ich_path);
|
||||
pbap_pull_phonebook(pbap_cid, t_ich_path);
|
||||
printf("[+] Select phonebook '%s'\n", ich_name);
|
||||
select_phonebook(ich_name);
|
||||
break;
|
||||
case 'm':
|
||||
printf("[+] Get phonebook '%s'\n", t_mch_path);
|
||||
pbap_pull_phonebook(pbap_cid, t_mch_path);
|
||||
printf("[+] Select phonebook '%s'\n", mch_name);
|
||||
select_phonebook(mch_name);
|
||||
break;
|
||||
case 'o':
|
||||
printf("[+] Get phonebook '%s'\n", t_och_path);
|
||||
pbap_pull_phonebook(pbap_cid, t_och_path);
|
||||
printf("[+] Select phonebook '%s'\n", och_name);
|
||||
select_phonebook(och_name);
|
||||
break;
|
||||
case 's':
|
||||
printf("[+] Get phonebook '%s'\n", t_spd_path);
|
||||
pbap_pull_phonebook(pbap_cid, t_spd_path);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
printf("[+] Get phonebook '%s'\n", st_cch_path);
|
||||
pbap_pull_phonebook(pbap_cid, st_cch_path);
|
||||
break;
|
||||
case 'E':
|
||||
printf("[+] Get phonebook '%s'\n", st_pb_path);
|
||||
pbap_pull_phonebook(pbap_cid, st_pb_path);
|
||||
break;
|
||||
case 'I':
|
||||
printf("[+] Get phonebook '%s'\n", st_ich_path);
|
||||
pbap_pull_phonebook(pbap_cid, st_ich_path);
|
||||
break;
|
||||
case 'M':
|
||||
printf("[+] Get phonebook '%s'\n", st_mch_path);
|
||||
pbap_pull_phonebook(pbap_cid, st_mch_path);
|
||||
break;
|
||||
case 'O':
|
||||
printf("[+] Get phonebook '%s'\n", st_och_path);
|
||||
pbap_pull_phonebook(pbap_cid, st_och_path);
|
||||
printf("[+] Select phonebook '%s'\n", spd_name);
|
||||
select_phonebook(spd_name);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
pbap_authentication_password(pbap_cid, "0000");
|
||||
break;
|
||||
case 'v':
|
||||
printf("[+] Set vCardSelector 'FN'\n");
|
||||
pbap_set_vcard_selector(pbap_cid, PBAP_PROPERTY_MASK_FN);
|
||||
printf("[+] Set vCardSelector 'N' and 'TEL'\n");
|
||||
pbap_set_vcard_selector(pbap_cid, PBAP_PROPERTY_MASK_N | PBAP_PROPERTY_MASK_TEL);
|
||||
break;
|
||||
case 'V':
|
||||
printf("[+] Set vCardSelectorOperator 'AND'\n");
|
||||
pbap_set_vcard_selector_operator(pbap_cid, PBAP_VCARD_SELECTOR_OPERATOR_AND);
|
||||
break;
|
||||
case 'r':
|
||||
printf("[+] Set path to 'telecom'\n");
|
||||
printf("[+] Set path to '/telecom'\n");
|
||||
pbap_set_phonebook(pbap_cid, "telecom");
|
||||
break;
|
||||
case 'R':
|
||||
printf("[+] Set path to '/SIM1/telecom'\n");
|
||||
pbap_set_phonebook(pbap_cid, "SIM1/telecom");
|
||||
break;
|
||||
case 'x':
|
||||
printf("[+] Abort'\n");
|
||||
pbap_abort(pbap_cid);
|
||||
@ -375,6 +371,8 @@ int btstack_main(int argc, const char * argv[]){
|
||||
|
||||
sscanf_bd_addr(remote_addr_string, remote_addr);
|
||||
|
||||
select_phonebook(pb_name);
|
||||
|
||||
#ifdef HAVE_BTSTACK_STDIN
|
||||
btstack_stdin_setup(stdin_process);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user