Static hard-coded PIN for pairing SDK 5

3 posts / 0 new
Last post
Vadym
Offline
Last seen:1 year 2 months ago
Joined:2015-08-13 08:28
Static hard-coded PIN for pairing SDK 5

Hi.

I start to work with SDK 5.0.3.
I want to use pairing connection with static hard-coded PIN number.
For this purpose i changed the security setup to:

.iocap = GAP_IO_CAP_DISPLAY_ONLY,
.auth = GAP_AUTH_REQ_MITM_BOND,
.sec_req = GAP_SEC1_AUTH_PAIR_ENC,
.ikey_dist = GAP_KDIST_ENCKEY,
.rkey_dist = GAP_KDIST_ENCKEY,

I have the next problem:
1) I can't to change the PIN number. It still to be 000000.
2) The android phone connects with my target without bonding(key asking). iOS 9 works as expected. Is it happens because the TK== 000000?

Is anybody can answer to few question:
1) Where can i change the PIN code?
2) Can I use the "default_app_on_tk_exch_nomitm" function for TK code exchanging? Or do i need to write my "tk exch mitm"? Does any example exist for SDK5 with pairing?

Thanks in advance,
Vadym.

Device:
Vadym
Offline
Last seen:1 year 2 months ago
Joined:2015-08-13 08:28
Dear support.

Dear support.

For my opinion, there is a bug in SDK in function app_easy_security_set_tk():

The gapc_bond_cfm need to be sent?
Do the line need to be added?
ke_msg_send(cfm);

Thanks.

MT_dialog
Offline
Last seen:2 months 6 days ago
Staff
Joined:2015-06-08 11:34
Hi Vadym,

Hi Vadym,

You are right about the bug in the security, please try the below snippet, it should work.

void default_app_on_tk_exch_nomitm(uint8_t connection_idx, struct gapc_bond_req_ind const * param)
{
uint32_t pin_code = 334455;/ / / app_sec_gen_tk ();
struct gapc_bond_cfm * cfm = app_easy_security_tk_get_active(connection_idx);
memset(cfm->data.tk.key, 0, KEY_LEN);
memcpy(cfm->data.tk.key, (uint8_t*) &pin_code, 4 );
app_easy_security_tk_exch( connection_idx);
}

Thanks MT_dialog