mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 08:42:28 +00:00
emit event for identify resolving
This commit is contained in:
parent
b18000f8c2
commit
1e57f667d3
@ -494,19 +494,32 @@ static void sm_s1_r_prime(sm_key_t r1, sm_key_t r2, sm_key_t r_prime){
|
|||||||
memcpy(&r_prime[0], &r1[8], 8);
|
memcpy(&r_prime[0], &r1[8], 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sm_notify_client(uint8_t type, uint8_t addr_type, bd_addr_t address, uint32_t passkey){
|
static void sm_notify_client_identity_resolving(uint8_t type, uint16_t index){
|
||||||
|
sm_event_identity_resolving_t event;
|
||||||
|
event.type = type;
|
||||||
|
event.central_device_db_index = index;
|
||||||
|
|
||||||
sm_event_t event;
|
// dummy implementation
|
||||||
|
log_info("sm_notify_client_identity_resolving: event 0x%02x, index %u", type, index);
|
||||||
|
|
||||||
|
if (!sm_client_packet_handler) return;
|
||||||
|
sm_client_packet_handler(HCI_EVENT_PACKET, 0, (uint8_t*) &event, sizeof(sm_event_identity_resolving_t));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sm_notify_client_bonding(uint8_t type, uint8_t addr_type, bd_addr_t address, uint32_t passkey){
|
||||||
|
|
||||||
|
sm_event_bonding_t event;
|
||||||
event.type = type;
|
event.type = type;
|
||||||
event.addr_type = addr_type;
|
event.addr_type = addr_type;
|
||||||
BD_ADDR_COPY(event.address, address);
|
BD_ADDR_COPY(event.address, address);
|
||||||
event.passkey = passkey;
|
event.passkey = passkey;
|
||||||
|
|
||||||
// dummy implementation
|
// dummy implementation
|
||||||
printf("sm_notify_client: event 0x%02x, addres_type %u, address (), num '%06u'", event.type, event.addr_type, event.passkey);
|
log_info("sm_notify_client_bonding: event 0x%02x, addres_type %u, address (), num '%06u'", event.type, event.addr_type, event.passkey);
|
||||||
|
|
||||||
if (!sm_client_packet_handler) return;
|
if (!sm_client_packet_handler) return;
|
||||||
sm_client_packet_handler(HCI_EVENT_PACKET, 0, (uint8_t*) &event, sizeof(sm_event_t));
|
sm_client_packet_handler(HCI_EVENT_PACKET, 0, (uint8_t*) &event, sizeof(sm_event_bonding_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
// decide on stk generation based on
|
// decide on stk generation based on
|
||||||
@ -801,6 +814,7 @@ static void sm_run(void){
|
|||||||
sm_central_device_matched = sm_central_device_test;
|
sm_central_device_matched = sm_central_device_test;
|
||||||
sm_central_device_test = -1;
|
sm_central_device_test = -1;
|
||||||
central_device_db_csrk(sm_central_device_matched, sm_m_csrk);
|
central_device_db_csrk(sm_central_device_matched, sm_m_csrk);
|
||||||
|
sm_notify_client_identity_resolving(SM_IDENTITY_RESOLVING_SUCCEEDED, sm_central_device_matched);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,6 +838,7 @@ static void sm_run(void){
|
|||||||
if (sm_central_device_test >= central_device_db_count()){
|
if (sm_central_device_test >= central_device_db_count()){
|
||||||
printf("Central Device Lookup: not found\n");
|
printf("Central Device Lookup: not found\n");
|
||||||
sm_central_device_test = -1;
|
sm_central_device_test = -1;
|
||||||
|
sm_notify_client_identity_resolving(SM_IDENTITY_RESOLVING_FAILED, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,17 +890,17 @@ static void sm_run(void){
|
|||||||
switch (sm_stk_generation_method){
|
switch (sm_stk_generation_method){
|
||||||
case PK_RESP_INPUT:
|
case PK_RESP_INPUT:
|
||||||
sm_user_response = SM_USER_RESPONSE_PENDING;
|
sm_user_response = SM_USER_RESPONSE_PENDING;
|
||||||
sm_notify_client(SM_PASSKEY_INPUT_NUMBER, sm_m_addr_type, sm_m_address, 0);
|
sm_notify_client_bonding(SM_PASSKEY_INPUT_NUMBER, sm_m_addr_type, sm_m_address, 0);
|
||||||
break;
|
break;
|
||||||
case PK_INIT_INPUT:
|
case PK_INIT_INPUT:
|
||||||
sm_notify_client(SM_PASSKEY_DISPLAY_NUMBER, sm_m_addr_type, sm_m_address, READ_NET_32(sm_tk, 12));
|
sm_notify_client_bonding(SM_PASSKEY_DISPLAY_NUMBER, sm_m_addr_type, sm_m_address, READ_NET_32(sm_tk, 12));
|
||||||
break;
|
break;
|
||||||
case JUST_WORKS:
|
case JUST_WORKS:
|
||||||
switch (sm_s_io_capabilities){
|
switch (sm_s_io_capabilities){
|
||||||
case IO_CAPABILITY_KEYBOARD_DISPLAY:
|
case IO_CAPABILITY_KEYBOARD_DISPLAY:
|
||||||
case IO_CAPABILITY_DISPLAY_YES_NO:
|
case IO_CAPABILITY_DISPLAY_YES_NO:
|
||||||
sm_user_response = SM_USER_RESPONSE_PENDING;
|
sm_user_response = SM_USER_RESPONSE_PENDING;
|
||||||
sm_notify_client(SM_JUST_WORKS_REQUEST, sm_m_addr_type, sm_m_address, READ_NET_32(sm_tk, 12));
|
sm_notify_client_bonding(SM_JUST_WORKS_REQUEST, sm_m_addr_type, sm_m_address, READ_NET_32(sm_tk, 12));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// cannot ask user
|
// cannot ask user
|
||||||
@ -1133,7 +1148,7 @@ static void sm_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pac
|
|||||||
|
|
||||||
// notify client to hide shown passkey
|
// notify client to hide shown passkey
|
||||||
if (sm_stk_generation_method == PK_INIT_INPUT){
|
if (sm_stk_generation_method == PK_INIT_INPUT){
|
||||||
sm_notify_client(SM_PASSKEY_DISPLAY_CANCEL, sm_m_addr_type, sm_m_address, 0);
|
sm_notify_client_bonding(SM_PASSKEY_DISPLAY_CANCEL, sm_m_addr_type, sm_m_address, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle user cancel pairing?
|
// handle user cancel pairing?
|
||||||
@ -1348,7 +1363,8 @@ static void sm_event_packet_handler (void * connection, uint8_t packet_type, uin
|
|||||||
sm_central_device_matched = sm_central_device_test;
|
sm_central_device_matched = sm_central_device_test;
|
||||||
sm_central_device_test = -1;
|
sm_central_device_test = -1;
|
||||||
central_device_db_csrk(sm_central_device_matched, sm_m_csrk);
|
central_device_db_csrk(sm_central_device_matched, sm_m_csrk);
|
||||||
printf("Central Device Lookup: matched resolvable private address\n");
|
sm_notify_client_identity_resolving(SM_IDENTITY_RESOLVING_SUCCEEDED, sm_central_device_matched);
|
||||||
|
log_info("Central Device Lookup: matched resolvable private address");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// no match
|
// no match
|
||||||
|
@ -106,14 +106,6 @@ typedef enum {
|
|||||||
// also, invalid parameters
|
// also, invalid parameters
|
||||||
// and reserved
|
// and reserved
|
||||||
|
|
||||||
// pairing user interacation
|
|
||||||
typedef struct sm_event {
|
|
||||||
uint8_t type; // see <btstack/hci_cmds.h> SM_...
|
|
||||||
uint8_t addr_type;
|
|
||||||
bd_addr_t address;
|
|
||||||
uint32_t passkey; // only used for SM_PASSKEY_DISPLAY_NUMBER
|
|
||||||
} sm_event_t;
|
|
||||||
|
|
||||||
// address type
|
// address type
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GAP_RANDOM_ADDRESS_TYPE_OFF = 0,
|
GAP_RANDOM_ADDRESS_TYPE_OFF = 0,
|
||||||
@ -121,6 +113,19 @@ typedef enum {
|
|||||||
GAP_RANDOM_ADDRESS_RESOLVABLE,
|
GAP_RANDOM_ADDRESS_RESOLVABLE,
|
||||||
} gap_random_address_type_t;
|
} gap_random_address_type_t;
|
||||||
|
|
||||||
|
// Security Manager Events
|
||||||
|
typedef struct sm_event_bonding {
|
||||||
|
uint8_t type; // see <btstack/hci_cmds.h> SM_...
|
||||||
|
uint8_t addr_type;
|
||||||
|
bd_addr_t address;
|
||||||
|
uint32_t passkey; // only used for SM_PASSKEY_DISPLAY_NUMBER
|
||||||
|
} sm_event_bonding_t;
|
||||||
|
|
||||||
|
typedef struct sm_event_identity_resolving {
|
||||||
|
uint8_t type; // see <btstack/hci_cmds.h> SM_IDENTITY_RESOLVING_
|
||||||
|
uint16_t central_device_db_index;
|
||||||
|
} sm_event_identity_resolving_t;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Security Manager Client API
|
// Security Manager Client API
|
||||||
//
|
//
|
||||||
|
@ -229,6 +229,8 @@ extern "C" {
|
|||||||
#define SM_PASSKEY_DISPLAY_CANCEL 0xb3
|
#define SM_PASSKEY_DISPLAY_CANCEL 0xb3
|
||||||
#define SM_PASSKEY_INPUT_NUMBER 0xb4
|
#define SM_PASSKEY_INPUT_NUMBER 0xb4
|
||||||
#define SM_PASSKEY_INPUT_CANCEL 0xb5
|
#define SM_PASSKEY_INPUT_CANCEL 0xb5
|
||||||
|
#define SM_IDENTITY_RESOLVING_FAILED 0xb6
|
||||||
|
#define SM_IDENTITY_RESOLVING_SUCCEEDED 0xb7
|
||||||
|
|
||||||
// last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors
|
// last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user