mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-09 21:45:54 +00:00
pts/sm_test: drop simulation of delayed key notifications
This commit is contained in:
parent
d7ffd3a975
commit
1a9063585d
@ -278,7 +278,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
|||||||
printf("PASSKEY_INPUT_NUMBER\n");
|
printf("PASSKEY_INPUT_NUMBER\n");
|
||||||
ui_passkey = 0;
|
ui_passkey = 0;
|
||||||
ui_digits_for_passkey = 6;
|
ui_digits_for_passkey = 6;
|
||||||
// sm_keypress_notification(connection_handle, SM_KEYPRESS_PASSKEY_ENTRY_STARTED);
|
sm_keypress_notification(connection_handle, SM_KEYPRESS_PASSKEY_ENTRY_STARTED);
|
||||||
break;
|
break;
|
||||||
case SM_EVENT_PASSKEY_DISPLAY_NUMBER:
|
case SM_EVENT_PASSKEY_DISPLAY_NUMBER:
|
||||||
// display number
|
// display number
|
||||||
@ -309,33 +309,6 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define KEYPRESS_DELAY 100
|
|
||||||
static btstack_timer_source_t passkey_timer;
|
|
||||||
static int num_keypresses_to_send;
|
|
||||||
|
|
||||||
static void passkey_entry_complete(btstack_timer_source_t * ts){
|
|
||||||
if (num_keypresses_to_send > 0){
|
|
||||||
num_keypresses_to_send--;
|
|
||||||
// sm_keypress_notification(connection_handle, SM_KEYPRESS_PASSKEY_DIGIT_ENTERED);
|
|
||||||
btstack_run_loop_set_timer(ts, KEYPRESS_DELAY);
|
|
||||||
btstack_run_loop_add_timer(ts);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (num_keypresses_to_send == 0){
|
|
||||||
num_keypresses_to_send--;
|
|
||||||
// sm_keypress_notification(connection_handle, SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED);
|
|
||||||
btstack_run_loop_set_timer(ts, KEYPRESS_DELAY);
|
|
||||||
btstack_run_loop_add_timer(ts);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf("\nSending Passkey '%06u'\n", ui_passkey);
|
|
||||||
if (sm_failure == SM_REASON_PASSKEY_ENTRY_FAILED){
|
|
||||||
// simulate passkey failure
|
|
||||||
ui_passkey--;
|
|
||||||
}
|
|
||||||
sm_passkey_input(connection_handle, ui_passkey);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void stdin_process(char c){
|
static void stdin_process(char c){
|
||||||
// passkey input
|
// passkey input
|
||||||
if (ui_digits_for_passkey){
|
if (ui_digits_for_passkey){
|
||||||
@ -344,13 +317,13 @@ static void stdin_process(char c){
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
ui_passkey = ui_passkey * 10 + c - '0';
|
ui_passkey = ui_passkey * 10 + c - '0';
|
||||||
ui_digits_for_passkey--;
|
ui_digits_for_passkey--;
|
||||||
|
sm_keypress_notification(connection_handle, SM_KEYPRESS_PASSKEY_DIGIT_ENTERED);
|
||||||
if (ui_digits_for_passkey == 0){
|
if (ui_digits_for_passkey == 0){
|
||||||
num_keypresses_to_send = 6;
|
printf("\n");
|
||||||
// set one-shot timer
|
fflush(stdout);
|
||||||
passkey_timer.process = &passkey_entry_complete;
|
sm_keypress_notification(connection_handle, SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED);
|
||||||
btstack_run_loop_set_timer(&passkey_timer, KEYPRESS_DELAY);
|
sm_passkey_input(connection_handle, ui_passkey);
|
||||||
btstack_run_loop_add_timer(&passkey_timer);
|
}
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user