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

bond with iOS center and Master Control Panel

hi, i add bond function on my project , now the Master Control Panel can work correctly(show the Confirm Box ) but the iOS app(on LightBlue),not show any Confirm Box for pairing.

In my opinion,the bond function is on the GAP. The BLE service and Characteristics no relation with bond.

can you give some suggestion ?

follow my code:

to redefine macro


#define SEC_PARAM_BOND                  1                                           /**< Perform bonding. */
#define SEC_PARAM_MITM                  1                                           /**< Man In The Middle protection required (applicable when display module is detected). */
#define SEC_PARAM_IO_CAPABILITIES       BLE_GAP_IO_CAPS_DISPLAY_ONLY

add the new macro for bond data


#define FLASH_PAGE_SYS_ATTR             (BLE_FLASH_PAGE_END - 3)                    /**< Flash page used for bond manager system attribute information. */
#define FLASH_PAGE_BOND                 (BLE_FLASH_PAGE_END - 1) 

and the ble event handle function


static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    switch (p_ble_evt->header.evt_id)
    {
    ........
     case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
            err_code = sd_ble_gap_sec_params_reply(m_conn_handle, 
                                                   BLE_GAP_SEC_STATUS_SUCCESS, 
                                                   &m_sec_params);
            break;
        case BLE_GAP_EVT_TIMEOUT:
            if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT)
            {
                nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);

                // Go to system-off mode (this function will not return; wakeup will cause a reset).
                GPIO_WAKEUP_BUTTON_CONFIG(KEY_PRESS_BUTTON_PIN_NO);
                GPIO_WAKEUP_BUTTON_CONFIG(BONDMNGR_DELETE_BUTTON_PIN_NO);
                err_code = sd_power_system_off();    
            }
            break;
        case BLE_GAP_EVT_PASSKEY_DISPLAY:
                p_passkey = (char *)p_ble_evt->evt.gap_evt.params.passkey_display.passkey;
                success = nrf6350_lcd_write_string(PASSKEY_TXT, 
                                                   PASSKEY_TXT_LENGTH, 
                                                   LCD_UPPER_LINE, 
                                                   0);
                APP_ERROR_CHECK_BOOL(success);                
            break;
        case BLE_GAP_EVT_AUTH_STATUS:
        case BLE_GAP_EVT_CONN_SEC_UPDATE:
            break;
}

add the ble_bondmngr_on_ble_evt


static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
{
    ble_bondmngr_on_ble_evt(p_ble_evt);
    ble_gls_on_ble_evt(&m_gls, p_ble_evt);
    ble_bas_on_ble_evt(&m_bas, p_ble_evt);
    ble_conn_params_on_ble_evt(p_ble_evt);
    on_ble_evt(p_ble_evt);
}

Related