Static connection manager for NimBLE netif that keeps opens connections on demand and takes care of keeping them open. More...
Static connection manager for NimBLE netif that keeps opens connections on demand and takes care of keeping them open.
This module is highly experimental! Expect bugs, instabilities and sudden API changes :-)
Statconn is the implementation of a static connection manager for the NimBLE netif module. It initiates new connections when told and additionally takes care of reopening connections in case of connection loss.
A node can either be a master, the one initiating the connection, or a slave, the one advertising its presence, w.r.t. to BLE connections. To open a connection between two nodes, call nimble_statconn_add_slave() with the BLE address of the slave node on the designated master node and call nimble_statconn_add_master() with the address of the master node on the designated slave node. From that point on, statconn will take care of opening and maintaining the connection between these two nodes.
This module is configured completely statically. All relevant configuration options are set at compile time using a couple of macros.
Files | |
file | nimble_statconn.h |
Simple static connection manager for NimBLE netif. | |
Data Structures | |
struct | nimble_statconn_cfg_t |
Statconn connection parameters. More... | |
Macros | |
#define | NIMBLE_STATCONN_ADV_ITVL_MS (90U) |
Advertising interval used when in advertising mode [in ms]. | |
#define | NIMBLE_STATCONN_CONN_WIN_MS (100U) |
Scan window used when opening new connections [in ms]. | |
#define | NIMBLE_STATCONN_CONN_TIMEOUT_MS (600U) |
Opening a new connection is aborted after this time [in ms]. | |
#define | NIMBLE_STATCONN_CONN_ITVL_MIN_MS (75U) |
Minimum connection interval used when opening a new connection. | |
#define | NIMBLE_STATCONN_CONN_ITVL_MAX_MS (75U) |
Maximum connection interval to use. | |
#define | NIMBLE_STATCONN_CONN_LATENCY (0) |
Slave latency used for new connections [# of connection events]. | |
#define | NIMBLE_STATCONN_CONN_SUPERTO_MS (2500U) |
Supervision timeout used for new connections [in ms]. | |
#define | NIMBLE_STATCONN_PHY_MODE NIMBLE_PHY_1M |
BLE PHY mode used by statconn. | |
Functions | |
void | nimble_statconn_init (void) |
Initialize the statconn module. | |
void | nimble_statconn_eventcb (nimble_netif_eventcb_t cb) |
Register a callback that is called on netif events. | |
int | nimble_statconn_add_master (const uint8_t *addr, const nimble_statconn_cfg_t *cfg) |
Connect to peer (master) with a given address as slave. | |
int | nimble_statconn_add_slave (const uint8_t *addr, const nimble_statconn_cfg_t *cfg) |
Connect to a peer (slave) with a given address as master. | |
int | nimble_statconn_rm (const uint8_t *addr) |
Remove the connection to the given peer. | |
#define NIMBLE_STATCONN_ADV_ITVL_MS (90U) |
Advertising interval used when in advertising mode [in ms].
Definition at line 66 of file nimble_statconn.h.
#define NIMBLE_STATCONN_CONN_ITVL_MAX_MS (75U) |
Maximum connection interval to use.
See NIMBLE_STATCONN_CONN_ITVL_MIN_MS for more information. [in ms]
Definition at line 99 of file nimble_statconn.h.
#define NIMBLE_STATCONN_CONN_ITVL_MIN_MS (75U) |
Minimum connection interval used when opening a new connection.
The actual used connection interval will be a random value ranging from NIMBLE_STATCONN_CONN_ITVL_MIN_MS to NIMBLE_STATCONN_CONN_ITVL_MAX_MS. Set both variables to the same value to use a fixed connection interval. [in ms]
Definition at line 91 of file nimble_statconn.h.
#define NIMBLE_STATCONN_CONN_LATENCY (0) |
Slave latency used for new connections [# of connection events].
Definition at line 106 of file nimble_statconn.h.
#define NIMBLE_STATCONN_CONN_SUPERTO_MS (2500U) |
Supervision timeout used for new connections [in ms].
Definition at line 113 of file nimble_statconn.h.
#define NIMBLE_STATCONN_CONN_TIMEOUT_MS (600U) |
Opening a new connection is aborted after this time [in ms].
Definition at line 80 of file nimble_statconn.h.
#define NIMBLE_STATCONN_CONN_WIN_MS (100U) |
Scan window used when opening new connections [in ms].
Definition at line 73 of file nimble_statconn.h.
#define NIMBLE_STATCONN_PHY_MODE NIMBLE_PHY_1M |
BLE PHY mode used by statconn.
This value is only used if statconn is used in its extended mode (module nimble_statconn_ext
)
Definition at line 121 of file nimble_statconn.h.
int nimble_statconn_add_master | ( | const uint8_t * | addr, |
const nimble_statconn_cfg_t * | cfg | ||
) |
Connect to peer (master) with a given address as slave.
Adding a master will make this node advertise itself to wait for an incoming connection by that master.
[in] | addr | BLE address of the peer |
[in] | cfg | additional connection parameters, set to NULL to apply default values |
int nimble_statconn_add_slave | ( | const uint8_t * | addr, |
const nimble_statconn_cfg_t * | cfg | ||
) |
Connect to a peer (slave) with a given address as master.
[in] | addr | BLE address of the peer |
[in] | cfg | additional connection parameters, set to NULL to apply default values |
void nimble_statconn_eventcb | ( | nimble_netif_eventcb_t | cb | ) |
Register a callback that is called on netif events.
The registered callback function is a simple pass-through of nimble_netif events. The callback is executed in the context of NimBLE's host thread.
[in] | cb | event callback to register, may be NULL |
void nimble_statconn_init | ( | void | ) |
Initialize the statconn module.
int nimble_statconn_rm | ( | const uint8_t * | addr | ) |
Remove the connection to the given peer.
[in] | addr | BLE address of the peer |