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, 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 gap_conn_update_param_t *p_conn_param)
| Change the Link Layer connection parameters of a connection. More...
uint16_t | ble_gap_latency_set (uint8_t conn_idx, uint16_t latency)
| Set connection's Latency. More...
uint16_t | ble_gap_con_plan_consult (uint8_t *p_act_num, 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, 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, gap_get_peer_info_op_t opcode)
| Get the information of the peer device. More...

## Detailed Description

## Function Documentation

## ◆ ble_gap_con_plan_consult()

uint16_t ble_gap_con_plan_consult | ( | uint8_t * | p_act_num,
|  | 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_info_get()

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

Get the information of the connection.

Note
  Once the connection information has been available, the callback function gap_cb_fun_t::app_gap_connection_info_get_cb will be called.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | opcode | The operation code. See 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_param_update()

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

Change the Link Layer connection parameters of a connection.

Note
  When APP wants to update connection param, it should call this function, and if the update connection param is finished, the callback function gap_cb_fun_t::app_gap_connection_update_cb will be called.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | p_conn_param | Pointer to 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.

Note
  If the Host receives the param update request from the peer device, it will call the callback function. gap_cb_fun_t::app_gap_connection_update_req_cb, and then the APP should call this function to confirm.

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.

Note
  Once this operation has been completed, the callback function gap_cb_fun_t::app_gap_le_pkt_size_info_cb will be called.

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.

Note
  When APP wants to disconnect a connection, it should call this function, and when the disconnection is finished, the callback function gap_cb_fun_t::app_gap_disconnect_cb will be called.

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,
|  | gap_disconn_reason_t | reason
| ) |  |

Terminate an existing connection with a specified reason.

Note
  When APP wants to disconnect a connection, it should call this function, and when the disconnection is finished, the callback function gap_cb_fun_t::app_gap_disconnect_cb will be called.

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_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_peer_info_get()

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

Get the information of the peer device.

Note
  Once the peer information has been available, the callback function gap_cb_fun_t::app_gap_peer_info_get_cb will be called.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | opcode | The operation code. See 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.

Note
  Once this operation has been completed, the callback function gap_cb_fun_t::app_gap_phy_update_cb will be called.

Parameters

  [in] | conn_idx | The index of connection.
  [in] | tx_phys | The transmitter PHYs that the Host prefers the Controller to use (see GAP PHYs (bitmask)).
  [in] | rx_phys | A bit field that indicates the receiver PHYs that the Host prefers the Controller to use (see GAP PHYs (bitmask)).
  [in] | phy_opt | A bit field that allows the Host to specify options for PHYs (see GAP PHY OPTIONS (bitmask)).

Return values

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