bond, unboun等功能:
static void app_menu_handler_gap_dev_select(void)
{
if (app_env.input[0] - '0' < BLE_CONNECTION_MAX)
{
app_env.select_idx = app_env.input[0] - '0';
switch (app_env.menu_id)
{
#if (QN_SECURITY_ON)
case menu_gap_bond:
{
struct bd_addr addr;
uint8_t auth;
if (app_get_bd_addr_by_idx(app_env.select_idx, &addr))
{
/// Authentication Requirements
switch (app_env.sec_lvl_set)
{
case GAP_SEC1_AUTH_PAIR_ENC:
auth = SMP_AUTH_REQ_MITM_BOND;
break;
case GAP_SEC1_NOAUTH_PAIR_ENC:
auth = SMP_AUTH_REQ_NO_MITM_BOND;
break;
case GAP_NO_SEC:
default:
auth = SMP_AUTH_REQ_NO_MITM_BOND;
break;
}
app_gap_bond_req(&addr, SMP_OOB_AUTH_DATA_NOT_PRESENT, auth, app_env.iocap_set);
}
else
QPRINTF("The selected device is not in connected status.\r\n");
}
break;
case menu_gap_unpair:
{
struct bd_addr addr;
if (app_get_bd_addr_by_idx(app_env.select_idx, &addr))
{
app_gap_unpair_req(&addr, app_get_bond_nb());
// TODO: Deleted paired information form NVDS
QPRINTF("Updated link bonded info success.\r\n");
}
else
QPRINTF("The selected device is not in bonded status.\r\n");
}
break;
#endif
case menu_gap_create_connection:
if (app_get_link_nb() != BLE_CONNECTION_MAX)
{
app_gap_le_create_conn_req(&app_env.inq_addr[app_env.select_idx], app_env.addr_type[app_env.select_idx], QN_ADDR_TYPE,
GAP_INIT_CONN_MIN_INTV, GAP_INIT_CONN_MAX_INTV, GAP_CONN_SUPERV_TIMEOUT);
}
else
{
QPRINTF("Connection Limit Exceeded\r\n");
}
break;
case menu_gap_disconnection:
if (app_env.input[0] == 'a')
{
for (uint8_t idx = 0; idx < BLE_CONNECTION_MAX; idx++)
{
uint16_t conhdl = app_get_conhdl_by_idx(idx);
if (conhdl != 0xFFFF)
{
app_gap_discon_req(conhdl);
}
}
}
else
{
uint16_t conhdl = app_get_conhdl_by_idx(app_env.select_idx);
if (conhdl != 0xFFFF)
app_gap_discon_req(conhdl);
else
QPRINTF("The selected device is not in connected status.\r\n");
}
break;
case menu_gatt_disc_all_svc:
{
uint16_t conhdl = app_get_conhdl_by_idx(app_env.select_idx);
if (conhdl != 0xFFFF)
{
#if QN_SVC_DISC_USED
app_env.dev_rec[app_env.select_idx].nb_svc = 0;
app_gatt_disc_svc_req(GATT_DISC_ALL_SVC, conhdl);
#endif
}
else
QPRINTF("The selected device is not in connected status.\r\n");
}
break;