In my application,the end product is given to the user with a static passkey. We need to give the user the provision to change the passkey .currently i run the code of static passkey with default passkey set as "123456" but i want to change static passkey after bonding .
As per i have to change the value of default passkey set so i am able to receive six digit value from write value command and able to write the variable in SpiFlash memory and when i have to read the variable from Spi flash memory i have been read the variable in gap_params_init,but when i run the code the system get hangs only reset button is working other PushButton which are running on my code before get hangs.
Below is my small code function where i read the variable from spiflash memory and put the variable (passkey) in sd_ble_opt_set function.
In another trial method i have used sd_ble_opt_set function on my write value command function when i run my code it gives Fatal error .Can you guide how i can change the static key password after 1st bonding.
/
**@brief Function for the GAP initialization.
*
* @details This function sets up all the necessary GAP (Generic Access Profile) parameters of the
* device including the device name, appearance, and the preferred connection parameters.
*/
static void gap_params_init(void)
{
ret_code_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);
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);
//=======================================
W25qxx_ReadPage(passkey1,8144,0,4); //
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);
}