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

When i enable the notify at app site with the six digit key,the connection disconnected.

HI ,ALL ,

i have change the project for the purpose of enter a six digit key at cellphone side to enable the notification with the board(52382).

But when i input the six digit passkey at cellphone side ,the connection disconnected.

Now,i will describe my configure steps.(There four steps in my changed project)

Premise

1.The project in use is

nRF5_SDK_11.0.0-2.alpha_bc3f6a0\examples\ble_peripheral\ble_app_uart

2.The Board in use is NRF52382,

3.The cellPhone in use is IPhone6plus and Iphone5s

4.The app in use is LightBlue

#The First Step:

i defined some macro which will use in my project

#define IO_CAPS BLE_GAP_IO_CAPS_DISPLAY_ONLY
#define BOND 0
#define OOB 0
#define MITM 1

#The Second Step

i added the function to enable the security purpose.

void resp_pair_request()
{
  ble_gap_sec_params_t sec_params;
  uint32_t err_code;
  memset(&sec_params,0,sizeof(ble_gap_sec_params_t));

  sec_params.bond = BOND;
  sec_params.io_caps = IO_CAPS;
  sec_params.max_key_size = 16;
  sec_params.min_key_size = 7;
  sec_params.oob = BOND;
  sec_params.mitm = MITM;
  err_code=sd_ble_gap_sec_params_reply(m_conn_handle,BLE_GAP_SEC_STATUS_SUCCESS,&sec_params,NULL);
  APP_ERROR_CHECK(err_code);
}

#The Third Step

i changed the Event in the function 'on_ble_evt'

case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
  printf("receive pair request\n");
  resp_pair_request();
  break;

case BLE_GAP_EVT_PASSKEY_DISPLAY:
  printf("show passkey: ")
  for ( int i = 0; i < 6; i++)
  { 
      printf("%c",p_ble_evt->evt.gap_evt.params.passkey_display.passkey[i]);
  }
  break;

#The Last Step

I change the security level in the rx_char_add function.

BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&cccd_md.write_perm);

// BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
Related