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. | |
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_MS (75U) |
Connection interval used when opening a new connection [in ms]. | |
#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]. | |
Enumerations | |
enum | { NIMBLE_STATCONN_OK = 0, NIMBLE_STATCONN_NOSLOT = -1, NIMBLE_STATCONN_NOTCONN = -2, NIMBLE_STATCONN_INUSE = -3 } |
Return codes used by the statconn module. More... | |
Functions | |
void | nimble_statconn_init (void) |
Initialize the statconn module. More... | |
void | nimble_statconn_eventcb (nimble_netif_eventcb_t cb) |
Register a callback that is called on netif events. More... | |
int | nimble_statconn_add_master (const uint8_t *addr) |
Connect to peer (master) with a given address as slave. More... | |
int | nimble_statconn_add_slave (const uint8_t *addr) |
Connect to a peer (slave) with a given address as master. More... | |
int | nimble_statconn_rm (const uint8_t *addr) |
Remove the connection to the given peer. More... | |
anonymous enum |
Return codes used by the statconn module.
Definition at line 106 of file nimble_statconn.h.
int nimble_statconn_add_master | ( | const uint8_t * | addr | ) |
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 |
int nimble_statconn_add_slave | ( | const uint8_t * | addr | ) |
Connect to a peer (slave) with a given address as master.
[in] | addr | BLE address of the peer |
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 |