sm.c (916ea5b20b33cb81200d64c51271e261a4dd9d8f) | sm.c (74b4d42a0c2f4faeaa3f0853af78f236a61a31c7) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 1011 unchanged lines hidden (view full) --- 1020static void sm_trigger_user_response_basic(sm_connection_t * sm_conn, uint8_t event_type){ 1021 setup->sm_user_response = SM_USER_RESPONSE_PENDING; 1022 uint8_t event[12]; 1023 sm_setup_event_base(event, sizeof(event), event_type, sm_conn->sm_handle, sm_conn->sm_peer_addr_type, sm_conn->sm_peer_address); 1024 event[11] = setup->sm_use_secure_connections ? 1 : 0; 1025 sm_dispatch_event(HCI_EVENT_PACKET, 0, event, sizeof(event)); 1026} 1027 | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 1011 unchanged lines hidden (view full) --- 1020static void sm_trigger_user_response_basic(sm_connection_t * sm_conn, uint8_t event_type){ 1021 setup->sm_user_response = SM_USER_RESPONSE_PENDING; 1022 uint8_t event[12]; 1023 sm_setup_event_base(event, sizeof(event), event_type, sm_conn->sm_handle, sm_conn->sm_peer_addr_type, sm_conn->sm_peer_address); 1024 event[11] = setup->sm_use_secure_connections ? 1 : 0; 1025 sm_dispatch_event(HCI_EVENT_PACKET, 0, event, sizeof(event)); 1026} 1027 |
1028static void sm_trigger_user_response_passkey(sm_connection_t * sm_conn){ | 1028static void sm_trigger_user_response_passkey(sm_connection_t * sm_conn, uint8_t event_type){ |
1029 uint8_t event[16]; 1030 uint32_t passkey = big_endian_read_32(setup->sm_tk, 12); | 1029 uint8_t event[16]; 1030 uint32_t passkey = big_endian_read_32(setup->sm_tk, 12); |
1031 sm_setup_event_base(event, sizeof(event), SM_EVENT_PASSKEY_DISPLAY_NUMBER, sm_conn->sm_handle, | 1031 sm_setup_event_base(event, sizeof(event), event_type, sm_conn->sm_handle, |
1032 sm_conn->sm_peer_addr_type, sm_conn->sm_peer_address); 1033 event[11] = setup->sm_use_secure_connections ? 1 : 0; 1034 little_endian_store_32(event, 12, passkey); 1035 sm_dispatch_event(HCI_EVENT_PACKET, 0, event, sizeof(event)); 1036} 1037 1038static void sm_trigger_user_response(sm_connection_t * sm_conn){ 1039 // notify client for: JUST WORKS confirm, Numeric comparison confirm, PASSKEY display or input 1040 setup->sm_user_response = SM_USER_RESPONSE_IDLE; 1041 sm_conn->sm_pairing_active = true; 1042 switch (setup->sm_stk_generation_method){ 1043 case PK_RESP_INPUT: 1044 if (IS_RESPONDER(sm_conn->sm_role)){ 1045 sm_trigger_user_response_basic(sm_conn, SM_EVENT_PASSKEY_INPUT_NUMBER); 1046 } else { | 1032 sm_conn->sm_peer_addr_type, sm_conn->sm_peer_address); 1033 event[11] = setup->sm_use_secure_connections ? 1 : 0; 1034 little_endian_store_32(event, 12, passkey); 1035 sm_dispatch_event(HCI_EVENT_PACKET, 0, event, sizeof(event)); 1036} 1037 1038static void sm_trigger_user_response(sm_connection_t * sm_conn){ 1039 // notify client for: JUST WORKS confirm, Numeric comparison confirm, PASSKEY display or input 1040 setup->sm_user_response = SM_USER_RESPONSE_IDLE; 1041 sm_conn->sm_pairing_active = true; 1042 switch (setup->sm_stk_generation_method){ 1043 case PK_RESP_INPUT: 1044 if (IS_RESPONDER(sm_conn->sm_role)){ 1045 sm_trigger_user_response_basic(sm_conn, SM_EVENT_PASSKEY_INPUT_NUMBER); 1046 } else { |
1047 sm_trigger_user_response_passkey(sm_conn); | 1047 sm_trigger_user_response_passkey(sm_conn, SM_EVENT_PASSKEY_DISPLAY_NUMBER); |
1048 } 1049 break; 1050 case PK_INIT_INPUT: 1051 if (IS_RESPONDER(sm_conn->sm_role)){ | 1048 } 1049 break; 1050 case PK_INIT_INPUT: 1051 if (IS_RESPONDER(sm_conn->sm_role)){ |
1052 sm_trigger_user_response_passkey(sm_conn); | 1052 sm_trigger_user_response_passkey(sm_conn, SM_EVENT_PASSKEY_DISPLAY_NUMBER); |
1053 } else { 1054 sm_trigger_user_response_basic(sm_conn, SM_EVENT_PASSKEY_INPUT_NUMBER); 1055 } 1056 break; 1057 case PK_BOTH_INPUT: 1058 sm_trigger_user_response_basic(sm_conn, SM_EVENT_PASSKEY_INPUT_NUMBER); 1059 break; 1060 case NUMERIC_COMPARISON: | 1053 } else { 1054 sm_trigger_user_response_basic(sm_conn, SM_EVENT_PASSKEY_INPUT_NUMBER); 1055 } 1056 break; 1057 case PK_BOTH_INPUT: 1058 sm_trigger_user_response_basic(sm_conn, SM_EVENT_PASSKEY_INPUT_NUMBER); 1059 break; 1060 case NUMERIC_COMPARISON: |
1061 sm_trigger_user_response_basic(sm_conn, SM_EVENT_NUMERIC_COMPARISON_REQUEST); | 1061 sm_trigger_user_response_passkey(sm_conn, SM_EVENT_NUMERIC_COMPARISON_REQUEST); |
1062 break; 1063 case JUST_WORKS: 1064 sm_trigger_user_response_basic(sm_conn, SM_EVENT_JUST_WORKS_REQUEST); 1065 break; 1066 case OOB: 1067 // client already provided OOB data, let's skip notification. 1068 break; 1069 default: --- 4250 unchanged lines hidden --- | 1062 break; 1063 case JUST_WORKS: 1064 sm_trigger_user_response_basic(sm_conn, SM_EVENT_JUST_WORKS_REQUEST); 1065 break; 1066 case OOB: 1067 // client already provided OOB data, let's skip notification. 1068 break; 1069 default: --- 4250 unchanged lines hidden --- |