| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
BLE connection state functions
Connection state

## Functions
void | ble_conn_state_init (void)
| Function for initializing or resetting the module. More...
void | ble_conn_state_on_ble_evt (ble_evt_t *p_ble_evt)
| Function for providing BLE SoftDevice events to the connection state module. More...
bool | ble_conn_state_valid (uint16_t conn_handle)
| Function for querying whether a connection handle represents a valid connection. More...
uint8_t | ble_conn_state_role (uint16_t conn_handle)
| Function for querying the role of the local device in a connection. More...
ble_conn_state_status_t | ble_conn_state_status (uint16_t conn_handle)
| Function for querying the status of a connection. More...
bool | ble_conn_state_encrypted (uint16_t conn_handle)
| Function for querying whether a connection is encrypted. More...
bool | ble_conn_state_mitm_protected (uint16_t conn_handle)
| Function for querying whether a connection encryption is protected from Man in the Middle attacks. More...
uint32_t | ble_conn_state_n_connections (void)
| Function for querying the total number of connections. More...
uint32_t | ble_conn_state_n_centrals (void)
| Function for querying the total number of connections in which the role of the local device is BLE_GAP_ROLE_CENTRAL. More...
uint32_t | ble_conn_state_n_peripherals (void)
| Function for querying the total number of connections in which the role of the local device is BLE_GAP_ROLE_PERIPH. More...
sdk_mapped_flags_key_list_t | ble_conn_state_conn_handles (void)
| Function for obtaining a list of all connection handles for which the module has a record. More...
sdk_mapped_flags_key_list_t | ble_conn_state_central_handles (void)
| Function for obtaining a list of connection handles in which the role of the local device is BLE_GAP_ROLE_CENTRAL. More...
sdk_mapped_flags_key_list_t | ble_conn_state_periph_handles (void)
| Function for obtaining the handle for the connection in which the role of the local device is BLE_GAP_ROLE_PERIPH. More...
ble_conn_state_user_flag_id_t | ble_conn_state_user_flag_acquire (void)
| Function for obtaining exclusive access to one of the user flag collections. More...
bool | ble_conn_state_user_flag_get (uint16_t conn_handle, ble_conn_state_user_flag_id_t flag_id)
| Function for reading the value of a user flag. More...
void | ble_conn_state_user_flag_set (uint16_t conn_handle, ble_conn_state_user_flag_id_t flag_id, bool value)
| Function for setting the value of a user flag. More...
sdk_mapped_flags_t | ble_conn_state_user_flag_collection (ble_conn_state_user_flag_id_t flag_id)
| Function for getting the state of a user flag for all connection handles. More...

## Detailed Description

## Function Documentation

sdk_mapped_flags_key_list_t ble_conn_state_central_handles | ( | void |  | ) |

Function for obtaining a list of connection handles in which the role of the local device is BLE_GAP_ROLE_CENTRAL.

This function takes into account connections whose state is BLE_CONN_STATUS_DISCONNECTED.

Returns
  A list of all valid connection handles for which the module has a record and in which the role of local device is BLE_GAP_ROLE_CENTRAL.

sdk_mapped_flags_key_list_t ble_conn_state_conn_handles | ( | void |  | ) |

Function for obtaining a list of all connection handles for which the module has a record.

This function takes into account connections whose state is BLE_CONN_STATUS_DISCONNECTED.

Returns
  A list of all valid connection handles for which the module has a record.

bool ble_conn_state_encrypted | ( | uint16_t | conn_handle | ) |

Function for querying whether a connection is encrypted.

Parameters

  [in] | conn_handle | Handle of connection to get the encryption state for.

Return values

  true | If the connection is encrypted.
  false | If the connection is not encrypted or conn_handle is invalid.

void ble_conn_state_init | ( | void |  | ) |

Function for initializing or resetting the module.

This function sets all states to their default, removing all records of connection handles.

bool ble_conn_state_mitm_protected | ( | uint16_t | conn_handle | ) |

Function for querying whether a connection encryption is protected from Man in the Middle attacks.

Parameters

  [in] | conn_handle | Handle of connection to get the MITM state for.

Return values

  true | If the connection is encrypted with MITM protection.
  false | If the connection is not encrypted, or encryption is not MITM protected, or conn_handle is invalid.

uint32_t ble_conn_state_n_centrals | ( | void |  | ) |

Function for querying the total number of connections in which the role of the local device is BLE_GAP_ROLE_CENTRAL.

Returns
  The number of connections in which the role of the local device is BLE_GAP_ROLE_CENTRAL.

uint32_t ble_conn_state_n_connections | ( | void |  | ) |

Function for querying the total number of connections.

Returns
  The total number of valid connections for which the module has a record.

uint32_t ble_conn_state_n_peripherals | ( | void |  | ) |

Function for querying the total number of connections in which the role of the local device is BLE_GAP_ROLE_PERIPH.

Returns
  The number of connections in which the role of the local device is BLE_GAP_ROLE_PERIPH.

void ble_conn_state_on_ble_evt | ( | ble_evt_t * | p_ble_evt | ) |

Function for providing BLE SoftDevice events to the connection state module.

Parameters

  [in] | p_ble_evt | The SoftDevice event.

sdk_mapped_flags_key_list_t ble_conn_state_periph_handles | ( | void |  | ) |

Function for obtaining the handle for the connection in which the role of the local device is BLE_GAP_ROLE_PERIPH.

This function takes into account connections whose state is BLE_CONN_STATUS_DISCONNECTED.

Returns
  A list of all valid connection handles for which the module has a record and in which the role of local device is BLE_GAP_ROLE_PERIPH.

uint8_t ble_conn_state_role | ( | uint16_t | conn_handle | ) |

Function for querying the role of the local device in a connection.

Parameters

  [in] | conn_handle | Handle of the connection to get the role for.

Returns
  The role of the local device in the connection (see GAP Roles). If conn_handle is not valid, the function returns BLE_GAP_ROLE_INVALID.

ble_conn_state_status_t ble_conn_state_status | ( | uint16_t | conn_handle | ) |

Function for querying the status of a connection.

Parameters

  [in] | conn_handle | Handle of the connection.

Returns
  The status of the connection. If conn_handle is not valid, the function returns BLE_CONN_STATE_INVALID.

ble_conn_state_user_flag_id_t ble_conn_state_user_flag_acquire | ( | void |  | ) |

Function for obtaining exclusive access to one of the user flag collections.

The acquired collection contains one flag for each connection. These flags can be set and read individually for each connection.

The state of user flags will not be modified by the connection state module, except to set it to 0 for a connection when that connection is invalidated.

Returns
  The ID of the acquired flag, or BLE_CONN_STATE_USER_FLAG_INVALID if none are available.

sdk_mapped_flags_t ble_conn_state_user_flag_collection | ( | ble_conn_state_user_flag_id_t | flag_id | ) |

Function for getting the state of a user flag for all connection handles.

The returned collection can be used with the Mapped flags API. The returned collection is a copy, so modifying it has no effect on the conn_state module.

Parameters

  [in] | flag_id | Which flag to get states for.

Returns
  The collection of flag states. The collection is always all zeros when the flag_id is unregistered.

bool ble_conn_state_user_flag_get | ( | uint16_t | conn_handle,
|  | ble_conn_state_user_flag_id_t | flag_id
| ) |  |

Function for reading the value of a user flag.

Parameters

  [in] | conn_handle | Handle of connection to get the flag state for.
  [in] | flag_id | Which flag to get the state for.

Returns
  The state of the flag. If conn_handle is invalid, the function returns false.

void ble_conn_state_user_flag_set | ( | uint16_t | conn_handle,
|  | ble_conn_state_user_flag_id_t | flag_id,
|  | bool | value
| ) |  |

Function for setting the value of a user flag.

Parameters

  [in] | conn_handle | Handle of connection to set the flag state for.
  [in] | flag_id | Which flag to set the state for.
  [in] | value | Value to set the flag state to.

bool ble_conn_state_valid | ( | uint16_t | conn_handle | ) |

Function for querying whether a connection handle represents a valid connection.

A connection might be valid and have a BLE_CONN_STATUS_DISCONNECTED status. Those connections are invalidated after a new connection occurs.

Parameters

  [in] | conn_handle | Handle of the connection.

Return values

  true | If conn_handle represents a valid connection, thus a connection for which we have a record.
  false | If conn_handle is BLE_GAP_ROLE_INVALID, or if it has never been recorded.