gap-conn-ncon-bv-1, gap-conn-acep-bv-1

This commit is contained in:
Matthias Ringwald 2015-07-29 11:37:13 +02:00
parent 91915b0b4c
commit 345ba39456

View File

@ -193,8 +193,9 @@ static uint8_t gap_adv_type(void){
return 0x00; return 0x00;
} }
static void test_set_advertisment_params(void){ static void update_advertisment_params(void){
uint8_t adv_type = gap_adv_type(); uint8_t adv_type = gap_adv_type();
printf("GAP: Connectable = %u -> advertising_type %u (%s)\n", gap_connectable, adv_type, ad_event_types[adv_type]);
bd_addr_t null_addr; bd_addr_t null_addr;
memset(null_addr, 0, 6); memset(null_addr, 0, 6);
uint16_t adv_int_min = 0x800; uint16_t adv_int_min = 0x800;
@ -203,11 +204,11 @@ static void test_set_advertisment_params(void){
case 0: case 0:
case 2: case 2:
case 3: case 3:
hci_le_advertisements_set_params(&hci_le_set_advertising_parameters, adv_int_min, adv_int_max, adv_type, 0, &null_addr, 0x07, 0x00); gap_advertisements_set_params(adv_int_min, adv_int_max, adv_type, 0, &null_addr, 0x07, 0x00);
break; break;
case 1: case 1:
case 4: case 4:
hci_le_advertisements_set_params(&hci_le_set_advertising_parameters, adv_int_min, adv_int_max, adv_type, tester_address_type, &tester_address, 0x07, 0x00); gap_advertisements_set_params(adv_int_min, adv_int_max, adv_type, tester_address_type, &tester_address, 0x07, 0x00);
break; break;
} }
} }
@ -345,7 +346,7 @@ int scanning_active = 0;
void show_usage(void){ void show_usage(void){
printf("\e[1;1H\e[2J"); printf("\e[1;1H\e[2J");
printf("--- CLI for LE Central ---\n"); printf("--- CLI for LE Central ---\n");
printf("GAP: connectable %u\n"); printf("GAP: connectable %u\n", gap_connectable);
printf("SM: %s, MITM protection %u, OOB data %u, key range [%u..16]\n", printf("SM: %s, MITM protection %u, OOB data %u, key range [%u..16]\n",
sm_io_capabilities, sm_mitm_protection, sm_have_oob_data, sm_min_key_size); sm_io_capabilities, sm_mitm_protection, sm_have_oob_data, sm_min_key_size);
printf("Privacy %u\n", gap_privacy); printf("Privacy %u\n", gap_privacy);
@ -361,24 +362,6 @@ void show_usage(void){
printf("t - terminate connection, stop connecting\n"); printf("t - terminate connection, stop connecting\n");
printf("p - auto connect to PTS\n"); printf("p - auto connect to PTS\n");
printf("P - direct connect to PTS\n"); printf("P - direct connect to PTS\n");
#if 0
printf("p/P - privacy flag off\n");
printf("z - send Connection Parameter Update Request\n");
printf("j - create L2CAP LE connection to %s\n", bd_addr_to_str(tester_address));
printf("---\n");
printf("d - discover all services\n");
printf("v - set value handle\n");
printf("s - set attribute size\n");
printf("---\n");
printf("e - IO_CAPABILITY_DISPLAY_ONLY\n");
printf("f - IO_CAPABILITY_DISPLAY_YES_NO\n");
printf("g - IO_CAPABILITY_NO_INPUT_NO_OUTPUT\n");
printf("h - IO_CAPABILITY_KEYBOARD_ONLY\n");
printf("i - IO_CAPABILITY_KEYBOARD_DISPLAY\n");
printf("o/O - OOB data off/on ('%s')\n", sm_oob_data);
printf("m/M - MITM protection off\n");
printf("k/k - encryption key range [7..16]/[16..16]\n");
#endif
printf("---\n"); printf("---\n");
printf("Ctrl-c - exit\n"); printf("Ctrl-c - exit\n");
printf("---\n"); printf("---\n");
@ -387,6 +370,7 @@ void show_usage(void){
int stdin_process(struct data_source *ds){ int stdin_process(struct data_source *ds){
char buffer; char buffer;
read(ds->fd, &buffer, 1); read(ds->fd, &buffer, 1);
int res;
// passkey input // passkey input
if (ui_digits_for_passkey){ if (ui_digits_for_passkey){
@ -403,98 +387,24 @@ int stdin_process(struct data_source *ds){
} }
switch (buffer){ switch (buffer){
#if 0
case 'e':
sm_io_capabilities = "IO_CAPABILITY_DISPLAY_ONLY";
sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY);
show_usage();
break;
case 'f':
sm_io_capabilities = "IO_CAPABILITY_DISPLAY_YES_NO";
sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_YES_NO);
show_usage();
break;
case 'g':
sm_io_capabilities = "IO_CAPABILITY_NO_INPUT_NO_OUTPUT";
sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
show_usage();
break;
case 'h':
sm_io_capabilities = "IO_CAPABILITY_KEYBOARD_ONLY";
sm_set_io_capabilities(IO_CAPABILITY_KEYBOARD_ONLY);
show_usage();
break;
case 'i':
sm_io_capabilities = "IO_CAPABILITY_KEYBOARD_DISPLAY";
sm_set_io_capabilities(IO_CAPABILITY_KEYBOARD_DISPLAY);
show_usage();
break;
case 'o':
sm_have_oob_data = 0;
show_usage();
break;
case 'O':
sm_have_oob_data = 1;
show_usage();
break;
case 'k':
sm_min_key_size = 7;
sm_set_encryption_key_size_range(7, 16);
show_usage();
break;
case 'K':
sm_min_key_size = 16;
sm_set_encryption_key_size_range(16, 16);
show_usage();
break;
case 'm':
sm_mitm_protection = 0;
update_auth_req();
show_usage();
break;
case 'M':
sm_mitm_protection = 1;
update_auth_req();
show_usage();
break;
case 'z':
printf("Sending l2cap connection update parameter request\n");
l2cap_le_request_connection_parameter_update(handle, 50, 120, 0, 550);
break;
case 'd':
printf("Discover all primary services\n");
gatt_client_discover_primary_services(gc_id, handle);
break;
case 's':
attribute_size = btstack_stdin_query_int("Attrbute Size");
show_usage();
break;
case 'v':
value_handle = btstack_stdin_query_hex("Value Handle");
show_usage();
break;
#endif
case 'a': case 'a':
hci_send_cmd(&hci_le_set_advertise_enable, 1); hci_send_cmd(&hci_le_set_advertise_enable, 1);
break; break;
case 'c': case 'c':
printf("GAP: Connectable = 1\n");
gap_connectable = 1; gap_connectable = 1;
test_set_advertisment_params(); update_advertisment_params();
break; break;
case 'C': case 'C':
printf("GAP: Connectable = 0\n");
gap_connectable = 0; gap_connectable = 0;
test_set_advertisment_params(); update_advertisment_params();
break; break;
case 'n': case 'n':
central_state = CENTRAL_W4_NAME_QUERY_COMPLETE; central_state = CENTRAL_W4_NAME_QUERY_COMPLETE;
gatt_client_discover_characteristics_for_handle_range_by_uuid16(gc_id, handle, 1, 0xffff, 0x2a00); gatt_client_discover_characteristics_for_handle_range_by_uuid16(gc_id, handle, 1, 0xffff, 0x2a00);
break; break;
case 'p': case 'p':
printf("Auto Connection Establishment to type %u, addr %s\n", tester_address_type, bd_addr_to_str(tester_address)); res = gap_auto_connection_start(tester_address_type, tester_address);
gap_auto_connection_start(tester_address_type, tester_address); printf("Auto Connection Establishment to type %u, addr %s -> %x\n", tester_address_type, bd_addr_to_str(tester_address), res);
break; break;
case 'P': case 'P':
printf("Direct Connection Establishment to type %u, addr %s\n", tester_address_type, bd_addr_to_str(tester_address)); printf("Direct Connection Establishment to type %u, addr %s\n", tester_address_type, bd_addr_to_str(tester_address));
@ -607,6 +517,9 @@ int btstack_main(int argc, const char * argv[]){
// gap_random_address_set_update_period(300000); // gap_random_address_set_update_period(300000);
// gap_random_address_set_mode(GAP_RANDOM_ADDRESS_RESOLVABLE); // gap_random_address_set_mode(GAP_RANDOM_ADDRESS_RESOLVABLE);
// set adv params
update_advertisment_params();
// allow foor terminal input // allow foor terminal input
btstack_stdin_setup(stdin_process); btstack_stdin_setup(stdin_process);