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

Static pass key implementation

Hi,

I am using softdevice-7 and SDK 6.1 for our application. I want to implement static key pairing for serial port over ble application "ble_app_uart".

I have implemented following changes for static key implementation.

1)changed I/o capabilities to " BLE_GAP_IO_CAPS_DISPLAY_ONLY"

2)in gap_params_init () , added static pin info

// Add static pin:
		uint8_t passkey[] = STATIC_PASSKEY;
		m_static_pin_option.gap.passkey.p_passkey = passkey;
		err_code =  sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &m_static_pin_option);
		APP_ERROR_CHECK(err_code);
  1. in on_ble_evt(), commented /deleted following case statements

BLE_GAP_EVT_SEC_PARAMS_REQUEST:

BLE_GATTS_EVT_SYS_ATTR_MISSING

BLE_GAP_EVT_SEC_INFO_REQUEST

and added new case statement

case BLE_GAP_EVT_PASSKEY_DISPLAY:
#ifdef DEBUG_PRINT

	    	simple_uart_putstring("  in  on_ble_evt()##BLE_GAP_EVT_PASSKEY_DISPLAY##\n");

#endif
            // Don't send delayed Security Request if security procedure is already in progress.
            err_code = app_timer_stop(m_sec_req_timer_id);

            APP_ERROR_CHECK(err_code);
      			p_passkey = (char *)p_ble_evt->evt.gap_evt.params.passkey_display.passkey;

      	// Using static pin, display is not necessary.
            /*if (m_is_display_available)
                  {
                      p_passkey = (char *)p_ble_evt->evt.gap_evt.params.passkey_display.passkey;

                      success = nrf6350_lcd_on();
                      APP_ERROR_CHECK_BOOL(success);

                      success = nrf6350_lcd_write_string(PASSKEY_TXT,
                                                         PASSKEY_TXT_LENGTH,
                                                         LCD_UPPER_LINE,
                                                         0);
                      APP_ERROR_CHECK_BOOL(success);

                      success = nrf6350_lcd_write_string(p_passkey, PASSKEY_LENGTH,LCD_LOWER_LINE, 0);
                      APP_ERROR_CHECK_BOOL(success);
                  } */
                  break;
  1. ble_evt_dispatch() added dm_ble_evt_handler() function

  2. added device_manager_init() , device_manager_evt_handler() functions and registered.

6)sec_req_timeout_handler() is added.

even after implementing these following changes also, I am able to connect /bond without authentication. for reference here I am attaching complete source file which can be build in GCC environment.

I will be very much thankful ,if some one share information procedure to implement the static key.

Thanking you very much, Regards, Raju

edit: format edit2: format

Parents
  • Hi Raju,

    It looks like the attachment is missing.

    But I understand you are trying to make the device manager module handle security. But have you registered with device manager with the right security parameters (using dm_register)? For your case, you will need to turn on mitm when you register with dm_register. But I dont see you doing this in step 5.

    If you do not want to use device manager, then undo what you did in step 3 (keep the case you added for BLE_GAP_EVT_PASSKEY_DISPLAY), step 4, step 5, and step 6. It should work as per your expectation.

    Cheers, Balaji

Reply
  • Hi Raju,

    It looks like the attachment is missing.

    But I understand you are trying to make the device manager module handle security. But have you registered with device manager with the right security parameters (using dm_register)? For your case, you will need to turn on mitm when you register with dm_register. But I dont see you doing this in step 5.

    If you do not want to use device manager, then undo what you did in step 3 (keep the case you added for BLE_GAP_EVT_PASSKEY_DISPLAY), step 4, step 5, and step 6. It should work as per your expectation.

    Cheers, Balaji

Children
No Data
Related