Helper module for managing the memory needed to store the BLE connection state for the netif wrapper. More...
Helper module for managing the memory needed to store the BLE connection state for the netif wrapper.
Files | |
file | nimble_netif_conn.h |
Connection allocation and maintenance for NimBLE netif. | |
Data Structures | |
struct | nimble_netif_conn_t |
Memory layout for holding the relevant connection information. More... | |
Macros | |
#define | NIMBLE_NETIF_CONN_INVALID (-1) |
Value for marking a handle invalid. | |
Typedefs | |
typedef int(* | nimble_netif_conn_iter_t) (nimble_netif_conn_t *conn, int handle, void *arg) |
Iterator function signature used by nimble_netif_conn_foreach() | |
Functions | |
void | nimble_netif_conn_init (void) |
Initialize the connection state manager. | |
nimble_netif_conn_t * | nimble_netif_conn_get (int handle) |
Get the connection context corresponding to the given handle. | |
int | nimble_netif_conn_get_adv (void) |
Get the handle to the context that is currently advertising. | |
int | nimble_netif_conn_get_connecting (void) |
Get the handle to the context that is busy connecting. | |
int | nimble_netif_conn_get_by_addr (const uint8_t *addr) |
Find the connection to the peer with the given BLE address. | |
int | nimble_netif_conn_get_by_gaphandle (uint16_t gaphandle) |
Find the connection using the given NimBLE GAP handle. | |
void | nimble_netif_conn_foreach (uint16_t filter, nimble_netif_conn_iter_t cb, void *arg) |
Iterate over all connection contexts that match the filter condition. | |
int | nimble_netif_conn_get_next (int handle, uint16_t filter) |
Find the next context that matches the filter condition. | |
unsigned | nimble_netif_conn_count (uint16_t filter) |
Count the number of connections contexts for which the given filter applies. | |
int | nimble_netif_conn_start_connection (const uint8_t *addr) |
Allocate an unused context for starting a connection. | |
int | nimble_netif_conn_start_adv (void) |
Reserve a unused context for the purpose of accepting a new connection. | |
void | nimble_netif_conn_free (int handle, uint8_t *addr) |
Free the connection context with the given handle. | |
uint16_t | nimble_netif_conn_get_itvl_ms (int handle) |
Get the used connection interval for the given connection handle. | |
bool | nimble_netif_conn_itvl_used (uint16_t itvl, int skip_handle) |
Check if the given connection interval is used, taking the minimal spacing as defined by NIMBLE_NETIF_CONN_ITVL_SPACING into account. | |
uint16_t | nimble_netif_conn_gen_itvl (uint16_t min, uint16_t max) |
Generate a pseudorandom connection interval from the given range. | |
static nimble_netif_conn_t * | nimble_netif_conn_from_gaphandle (uint16_t gh) |
Find the connection context with a given GAP handle and return a pointer to it. | |
static int | nimble_netif_conn_connecting (void) |
Convenience function to check if any context is currently in the connecting state (NIMBLE_NETIF_CONNECTING) | |
static int | nimble_netif_conn_connected (const uint8_t *addr) |
Convenience function to check if we are currently connected to a peer with the given address. | |
static int | nimble_netif_conn_is_open (const nimble_netif_conn_t *conn) |
Test if the given connection is (still) open. | |
static int | nimble_netif_conn_is_adv (void) |
Convenience function to check if any context is currently in the advertising state (NIMBLE_NETIF_ADV) | |
#define NIMBLE_NETIF_CONN_INVALID (-1) |
Value for marking a handle invalid.
Definition at line 37 of file nimble_netif_conn.h.
typedef int(* nimble_netif_conn_iter_t) (nimble_netif_conn_t *conn, int handle, void *arg) |
Iterator function signature used by nimble_netif_conn_foreach()
[in] | conn | connection context of the current entry |
[in] | handle | handle of the current entry |
[in] | arg | user supplied argument |
Definition at line 61 of file nimble_netif_conn.h.
|
inlinestatic |
Convenience function to check if we are currently connected to a peer with the given address.
[in] | addr | BLE address, in network byte order |
Definition at line 256 of file nimble_netif_conn.h.
|
inlinestatic |
Convenience function to check if any context is currently in the connecting state (NIMBLE_NETIF_CONNECTING)
Definition at line 242 of file nimble_netif_conn.h.
unsigned nimble_netif_conn_count | ( | uint16_t | filter | ) |
Count the number of connections contexts for which the given filter applies.
[in] | filter | filter mask |
void nimble_netif_conn_foreach | ( | uint16_t | filter, |
nimble_netif_conn_iter_t | cb, | ||
void * | arg | ||
) |
Iterate over all connection contexts that match the filter condition.
[in] | filter | filter mask |
[in] | cb | callback called on each filtered entry |
[in] | arg | user argument |
|
inlinestatic |
Find the connection context with a given GAP handle and return a pointer to it.
[in] | gh | GAP handle used by NimBLE |
Definition at line 230 of file nimble_netif_conn.h.
uint16_t nimble_netif_conn_gen_itvl | ( | uint16_t | min, |
uint16_t | max | ||
) |
Generate a pseudorandom connection interval from the given range.
If the NIMBLE_NETIF_CONN_ITVL_SPACING option is enabled, this function ensures that the generated connection interval is spaced at least NIMBLE_NETIF_CONN_ITVL_SPACING from the connection interval of each open BLE connection.
[in] | min | minimum connection interval |
[in] | max | maximum connection interval |
nimble_netif_conn_t * nimble_netif_conn_get | ( | int | handle | ) |
Get the connection context corresponding to the given handle.
[in] | handle | handle to a connection context |
int nimble_netif_conn_get_adv | ( | void | ) |
Get the handle to the context that is currently advertising.
int nimble_netif_conn_get_by_addr | ( | const uint8_t * | addr | ) |
Find the connection to the peer with the given BLE address.
[in] | addr | BLE address, in network byte order |
int nimble_netif_conn_get_by_gaphandle | ( | uint16_t | gaphandle | ) |
Find the connection using the given NimBLE GAP handle.
[in] | gaphandle | GAP handle as exposed by NimBLE |
int nimble_netif_conn_get_connecting | ( | void | ) |
Get the handle to the context that is busy connecting.
uint16_t nimble_netif_conn_get_itvl_ms | ( | int | handle | ) |
Get the used connection interval for the given connection handle.
[in] | handle | connection handle |
int nimble_netif_conn_get_next | ( | int | handle, |
uint16_t | filter | ||
) |
Find the next context that matches the filter condition.
This function allows for iterating connection contexts in a non-blocking way.
[in] | handle | last used handle, set to NIMBLE_NETIF_CONN_INVALID to get the first matching entry |
[in] | filter | filter mask |
void nimble_netif_conn_init | ( | void | ) |
Initialize the connection state manager.
This functions is typically called by nimble_netif_init().
|
inlinestatic |
Convenience function to check if any context is currently in the advertising state (NIMBLE_NETIF_ADV)
Definition at line 281 of file nimble_netif_conn.h.
|
inlinestatic |
Test if the given connection is (still) open.
[in] | conn | Connection to test |
Definition at line 269 of file nimble_netif_conn.h.
bool nimble_netif_conn_itvl_used | ( | uint16_t | itvl, |
int | skip_handle | ||
) |
Check if the given connection interval is used, taking the minimal spacing as defined by NIMBLE_NETIF_CONN_ITVL_SPACING into account.
[in] | itvl | connection interval to check, multiples of 1.25ms |
[in] | skip_handle | do not compare against connection interval for this handle, set to NIMBLE_NETIF_CONN_INVALID to check all |
int nimble_netif_conn_start_adv | ( | void | ) |
Reserve a unused context for the purpose of accepting a new connection.
int nimble_netif_conn_start_connection | ( | const uint8_t * | addr | ) |
Allocate an unused context for starting a connection.
[in] | addr | the BLE address of the peer node, in network byte order |