Functions
Functions
BLE » Generic Access Profile (GAP) » Generic Access Profile (GAP) Connection Control

## Functions
uint16_t | ble_gap_disconnect (uint8_t conn_idx)
| Terminate an existing connection. More...
uint16_t | ble_gap_disconnect_with_reason (uint8_t conn_idx, ble_gap_disconn_reason_t reason)
| Terminate an existing connection with a specified reason. More...
uint16_t | ble_gap_conn_param_update (uint8_t conn_idx, const ble_gap_conn_update_param_t *p_conn_param)
| Change the Link Layer connection parameters of a connection. More...
uint16_t | ble_gap_update_conn_param_method_set (uint8_t conn_idx, bool use_l2cap_flag)
| Set the method for updating connection parameter. More...
uint16_t | ble_gap_latency_set (uint8_t conn_idx, uint16_t latency)
| Set connection's Latency. More...
uint16_t | ble_gap_latency_get (uint8_t conn_idx, uint16_t *latency)
| Get connection's Latency. More...
uint16_t | ble_gap_con_plan_consult (uint8_t *p_act_num, ble_gap_con_plan_tag_t **p_conn_plan_arr)
| Consult BLE connection activity plan situation function. More...
uint16_t | ble_gap_conn_param_update_reply (uint8_t conn_idx, bool accept)
| Connection param update reply to peer device. More...
uint16_t | ble_gap_data_length_update (uint8_t conn_idx, uint16_t tx_octects, uint16_t tx_time)
| The suggested maximum transmission packet size and maximum packet transmission time to be used for a given connection. More...
uint16_t | ble_gap_phy_update (uint8_t conn_idx, uint8_t tx_phys, uint8_t rx_phys, uint8_t phy_opt)
| Set the PHY preferences for the connection identified by the connection index. More...
uint16_t | ble_gap_conn_info_get (uint8_t conn_idx, ble_gap_get_conn_info_op_t opcode)
| Get the information of the connection. More...
uint16_t | ble_gap_peer_info_get (uint8_t conn_idx, ble_gap_get_peer_info_op_t opcode)
| Get the information of the peer device. More...
uint16_t | ble_gap_bond_dev_addr_get (uint8_t conn_idx, ble_gap_bdaddr_t *p_peer_addr)
| Get BD address of the bonded device. More...
uint16_t | ble_gap_conn_cte_trans_param_set (uint8_t conn_idx, ble_gap_set_conn_cte_trans_param_t *param)
| Set connection CTE transmit parameters. More...
uint16_t | ble_gap_conn_cte_recv_param_set (uint8_t conn_idx, ble_gap_set_conn_cte_rcv_param_t *param)
| Set connection CTE receive parameters. More...
uint16_t | ble_gap_conn_cte_req_enable_set (uint8_t conn_idx, bool enable_flag, ble_gap_set_conn_cte_req_enable_t *param)
| Set connection CTE request enable. More...
uint16_t | ble_gap_conn_cte_rsp_enable_set (uint8_t conn_idx, bool enable_flag)
| Set connection CTE response enable. More...
void | ble_gap_get_local_addr_by_conidx (uint8_t conidx, uint8_t *p_addr)
| Get BD address of the local device by the conidx. More...
uint16_t | ble_gap_le_event_noti_report_enable_set (uint8_t conn_idx, bool enable_flag)
| Enable or disable the reporting of LE event notification. More...
uint8_t | ble_gap_conn_link_num_get (void)
| Get connection link number. More...
uint16_t | ble_gap_ignore_latency_set (uint8_t conn_idx, bool ignore_flag, uint8_t ignore_num)
| Ignore latency with numbers indicated by ignore_num, after slave sending data. More...
uint16_t | ble_gap_get_adv_addr_by_conidx (uint8_t conn_idx, uint8_t *p_adv_addr)
| Get adv address by connection index, only used for slave role. More...

## Detailed Description

## Function Documentation

## ◆ ble_gap_bond_dev_addr_get()

uint16_t ble_gap_bond_dev_addr_get | ( | uint8_t | conn_idx,
|  | ble_gap_bdaddr_t * | p_peer_addr
| ) |  |

Get BD address of the bonded device.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | p_peer_addr | Pointer to the peer BD addrss

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.

## ◆ ble_gap_con_plan_consult()

uint16_t ble_gap_con_plan_consult | ( | uint8_t * | p_act_num,
|  | ble_gap_con_plan_tag_t ** | p_conn_plan_arr
| ) |  |

Consult BLE connection activity plan situation function.

Note
  This function should be called when connection established and no periodic advertising exists.

Parameters

  [out] | p_act_num | Pointer to the number of existing connection activities.
  [out] | p_conn_plan_arr | Pointer to the global array that stores planned connection activities.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.

## ◆ ble_gap_conn_cte_recv_param_set()

uint16_t ble_gap_conn_cte_recv_param_set | ( | uint8_t | conn_idx,
|  | ble_gap_set_conn_cte_rcv_param_t * | param
| ) |  |

Set connection CTE receive parameters.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | param | Set connection CTE receive parameters info, see ble_gap_set_conn_cte_rcv_param_t.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_PARAM | Invalid parameter supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.

## ◆ ble_gap_conn_cte_req_enable_set()

uint16_t ble_gap_conn_cte_req_enable_set | ( | uint8_t | conn_idx,
|  | bool | enable_flag,
|  | ble_gap_set_conn_cte_req_enable_t * | param
| ) |  |

Set connection CTE request enable.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | enable_flag | Wheter to request the cte for the connection. If enable_flag is set to false, the param shall be NULL.
  [in] | param | Set connection CTE request enable info, see ble_gap_set_conn_cte_req_enable_t.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_PARAM | Invalid parameter supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.

## ◆ ble_gap_conn_cte_rsp_enable_set()

uint16_t ble_gap_conn_cte_rsp_enable_set | ( | uint8_t | conn_idx,
|  | bool | enable_flag
| ) |  |

Set connection CTE response enable.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | enable_flag | Wheter to response the cte req for the connection.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.

## ◆ ble_gap_conn_cte_trans_param_set()

uint16_t ble_gap_conn_cte_trans_param_set | ( | uint8_t | conn_idx,
|  | ble_gap_set_conn_cte_trans_param_t * | param
| ) |  |

Set connection CTE transmit parameters.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | param | Set connection CTE transmit parameters info, see ble_gap_set_conn_cte_trans_param_t.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_PARAM | Invalid parameter supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.

## ◆ ble_gap_conn_info_get()

uint16_t ble_gap_conn_info_get | ( | uint8_t | conn_idx,
|  | ble_gap_get_conn_info_op_t | opcode
| ) |  |

Get the information of the connection.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | opcode | The operation code. See ble_gap_get_conn_info_op_t.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_PARAM | Invalid parameter supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gap_conn_link_num_get()

uint8_t ble_gap_conn_link_num_get | ( | void |  | ) |

Get connection link number.

Return values

  ::Return | the number of connection link.

## ◆ ble_gap_conn_param_update()

uint16_t ble_gap_conn_param_update | ( | uint8_t | conn_idx,
|  | const ble_gap_conn_update_param_t * | p_conn_param
| ) |  |

Change the Link Layer connection parameters of a connection.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | p_conn_param | The new connection param.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gap_conn_param_update_reply()

uint16_t ble_gap_conn_param_update_reply | ( | uint8_t | conn_idx,
|  | bool | accept
| ) |  |

Connection param update reply to peer device.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | accept | True to accept connection parameters, false to reject.

Return values

  SDK_SUCCESS | Operation is success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gap_data_length_update()

uint16_t ble_gap_data_length_update | ( | uint8_t | conn_idx,
|  | uint16_t | tx_octects,
|  | uint16_t | tx_time
| ) |  |

The suggested maximum transmission packet size and maximum packet transmission time to be used for a given connection.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | tx_octects | Preferred maximum number of payload octets that the local Controller should include in a single Link Layer packet on this connection. Range 0x001B-0x00FB (all other values reserved for future use).
  [in] | tx_time | Preferred maximum number of microseconds that the local Controller should use to transmit a single Link Layer packet on this connection. Range 0x0148-0x4290 (all other values reserved for future use).

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gap_disconnect()

uint16_t ble_gap_disconnect | ( | uint8_t | conn_idx | ) |

Terminate an existing connection.

Parameters

  [in] | conn_idx | The index of connection.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gap_disconnect_with_reason()

uint16_t ble_gap_disconnect_with_reason | ( | uint8_t | conn_idx,
|  | ble_gap_disconn_reason_t | reason
| ) |  |

Terminate an existing connection with a specified reason.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | reason | The specified reason.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gap_get_adv_addr_by_conidx()

uint16_t ble_gap_get_adv_addr_by_conidx | ( | uint8_t | conn_idx,
|  | uint8_t * | p_adv_addr
| ) |  |

Get adv address by connection index, only used for slave role.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | p_adv_addr | Pointer to the adv address.

Return values

  SDK_SUCCESS | Operation is success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.

## ◆ ble_gap_get_local_addr_by_conidx()

void ble_gap_get_local_addr_by_conidx | ( | uint8_t | conidx,
|  | uint8_t * | p_addr
| ) |  |

Get BD address of the local device by the conidx.

Parameters

  [in] | conidx | The index of conncetion.
  [in] | p_addr | Pointer to the local BD addrss

## ◆ ble_gap_ignore_latency_set()

uint16_t ble_gap_ignore_latency_set | ( | uint8_t | conn_idx,
|  | bool | ignore_flag,
|  | uint8_t | ignore_num
| ) |  |

Ignore latency with numbers indicated by ignore_num, after slave sending data.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | ignore_flag | Latency ignore flag.
  [in] | ignore_num | Number for ignore latency, only valid if ignore_flag is true.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.

## ◆ ble_gap_latency_get()

uint16_t ble_gap_latency_get | ( | uint8_t | conn_idx,
|  | uint16_t * | latency
| ) |  |

Get connection's Latency.

Note
  This function is used to get connection's Latency.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | latency | Pointer to the latency of connection.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.

## ◆ ble_gap_latency_set()

uint16_t ble_gap_latency_set | ( | uint8_t | conn_idx,
|  | uint16_t | latency
| ) |  |

Set connection's Latency.

Note
  The latency shall be set to X value by LLCP firstly, then uses this API to change the latency in [0, X].

Parameters

  [in] | conn_idx | The index of connection.
  [in] | latency | The latency of connection.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.

## ◆ ble_gap_le_event_noti_report_enable_set()

uint16_t ble_gap_le_event_noti_report_enable_set | ( | uint8_t | conn_idx,
|  | bool | enable_flag
| ) |  |

Enable or disable the reporting of LE event notification.

Note
  This API is asynchronous.
  After invoking this API, the event BLE_GAPC_EVT_LE_EVT_NOTI_REPORT will be called.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | enable_flag | The enable flag for reporting of LE event notification.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.

## ◆ ble_gap_peer_info_get()

uint16_t ble_gap_peer_info_get | ( | uint8_t | conn_idx,
|  | ble_gap_get_peer_info_op_t | opcode
| ) |  |

Get the information of the peer device.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | opcode | The operation code. See ble_gap_get_peer_info_op_t.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_PARAM | Invalid parameter supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gap_phy_update()

uint16_t ble_gap_phy_update | ( | uint8_t | conn_idx,
|  | uint8_t | tx_phys,
|  | uint8_t | rx_phys,
|  | uint8_t | phy_opt
| ) |  |

Set the PHY preferences for the connection identified by the connection index.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | tx_phys | A bit field that indicates the transmitter PHYs that the Host prefers the Controller to use (see ble_gap_phy_bit_t).
  [in] | rx_phys | A bit field that indicates the receiver PHYs that the Host prefers the Controller to use (see ble_gap_phy_bit_t).
  [in] | phy_opt | A bit field that allows the Host to specify options for PHYs (see ble_gap_phy_options_t), only valid for coded phy.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gap_update_conn_param_method_set()

uint16_t ble_gap_update_conn_param_method_set | ( | uint8_t | conn_idx,
|  | bool | use_l2cap_flag
| ) |  |

Set the method for updating connection parameter.

Parameters

  [in] | conn_idx | Connection index.
  [in] | use_l2cap_flag | Preferred to use l2cap to update connection parameter.

Return values

  SDK_SUCCESS | Operation is Success.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.