ble_gap_connect

int
ble_gap_connect(
                             uint8_t  own_addr_type,
                    const ble_addr_t *peer_addr,
                             int32_t  duration_ms,
    const struct ble_gap_conn_params *conn_params,
                    ble_gap_event_fn *cb,
                                void *cb_arg
)

Description

Initiates a connect procedure.

Parameters

ParameterDescription
own_addr_typeThe type of address the stack should use for itself during connection establishment. BLE_OWN_ADDR_PUBLIC BLE_OWN_ADDR_RANDOM BLE_OWN_ADDR_RPA_PUBLIC_DEFAULT BLE_OWN_ADDR_RPA_RANDOM_DEFAULT
peer_addrThe address of the peer to connect to. If this parameter is NULL, the white list is used.
duration_msThe duration of the discovery procedure. On expiration, the procedure ends and a BLE_GAP_EVENT_DISC_COMPLETE event is reported. Units are milliseconds.
conn_paramsAdditional arguments specifying the particulars of the connect procedure. Specify null for default values.
cbThe callback to associate with this connect procedure. When the connect procedure completes, the result is reported through this callback. If the connect procedure succeeds, the connection inherits this callback as its event-reporting mechanism.
cb_argThe optional argument to pass to the callback function.

Returned values

ValueCondition
0Success.
BLE_HS_EALREADYA connection attempt is already in progress.
BLE_HS_EBUSYInitiating a connection is not possible because scanning is in progress.
BLE_HS_EDONEThe specified peer is already connected.
Core return codeUnexpected error.