This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

RANDOM PASSKEY

Hi I want to connect the system with random passkey, i modified the code like below the central is giving the passkey and  i entering the passkey at device but not able to connecting please help.

#define SEC_PARAM_BOND 1 /**< Perform bonding. */
#define SEC_PARAM_MITM 1 /**< Man In The Middle protection not required. */
#define SEC_PARAM_LESC 1 /**< LE Secure Connections not enabled. */
#define SEC_PARAM_KEYPRESS 0 /**< Keypress notifications not enabled. */
#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_KEYBOARD_ONLY

#define SEC_PARAM_OOB 0 /**< Out Of Band data not available. */
#define SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */
#define SEC_PARAM_MAX_KEY_SIZE 16

static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;

// BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&sec_mode); 

err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *) DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);

memset(&gap_conn_params, 0, sizeof(gap_conn_params));

gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;

err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);

ble_gap_opt_t gap_opt;

gap_opt.passkey.p_passkey = (uint8_t *)NULL; 

err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY,(const ble_opt_t *)&gap_opt); 
APP_ERROR_CHECK(err_code); 
}

Related