I developed a project that using static passkey to pair and bond with nRF SDK17.
It be fulfilled by the follow way:
//write static passkey
m_static_pin_option.gap_opt.passkey.p_passkey = passkey;
err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &m_static_pin_option);
APP_ERROR_CHECK(err_code);
//pair with MITM and check the passkey from phone
#define SEC_PARAM_BOND 1
#define SEC_PARAM_MITM 1
#define SEC_PARAM_LESC 0
#define SEC_PARAM_KEYPRESS 0
#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_DISPLAY_ONLY
#define SEC_PARAM_OOB 0
#define SEC_PARAM_MIN_KEY_SIZE 7
#define SEC_PARAM_MAX_KEY_SIZE 16
m_sec_param.bond = SEC_PARAM_BOND;
m_sec_param.mitm = SEC_PARAM_MITM;
m_sec_param.lesc = SEC_PARAM_LESC;
m_sec_param.keypress = SEC_PARAM_KEYPRESS;
m_sec_param.io_caps = BLE_GAP_IO_CAPS_DISPLAY_ONLY;
m_sec_param.oob = SEC_PARAM_OOB;
m_sec_param.min_key_size = SEC_PARAM_MIN_KEY_SIZE;
m_sec_param.max_key_size = SEC_PARAM_MAX_KEY_SIZE;
m_sec_param.kdist_own.enc = 1;
m_sec_param.kdist_own.id = 1;
m_sec_param.kdist_peer.enc = 1;
m_sec_param.kdist_peer.id = 1;
err_code = pm_sec_params_set(&m_sec_param);
APP_ERROR_CHECK(err_code);
However,when I turn to NCS,I don't know how to fulfill it.
I used the hid_mouse sample but it just push the button to confirm the bond.
How can I use the passkey to do the MITM protect?