GNRC netif implementation for NimBLE, enabling the integration of NimBLE into GNRC. More...
GNRC netif implementation for NimBLE, enabling the integration of NimBLE into GNRC.
This NimBLE submodule provides a GNRC netif wrapper for integrating NimBLE with GNRC and other network stacks using netif (e.g. CCNlite).
According to the IPv6-over-BLE standards (RFC7668 and IPSP), this module exposes a (configurable) number of point-to-point BLE connections as a single network device to BLE. Unicast traffic is only send using the corresponding BLE connection. Multicast and Broadcast packets are duplicated and send via each open BLE connection.
The netif implementation is able to handle multiple connections simultaneously. The maximum number of concurrent connections is configured during compile time, using NimBLEs MYNEWT_VAL_BLE_MAX_CONNECTIONS option. Dependent on this value, the netif implementation takes care of allocation all the memory needed. The API of this submodule uses simply integer values to reference the used connection context (like file descriptors in linux).
Like any other GNRC network device, the NimBLE netif wrapper runs in its own thread. This thread is started and configured by the common netif code. All send and get/set operations are handled by this thread. For efficiency reasons, receiving of data is however handled completely in the NimBLE host thread, from where the received data is directly passed on to the corresponding GNRC thread.
Although the wrapper hooks into GNRC using the netif interface, it does need to implement parts of the netdev interface as well. This is done where needed.
This submodule is designed to work fully asynchronous, in the same way as the NimBLE interfaces are designed. All functions in this submodule will only trigger the intended action. Once this action is complete, the module will report the result asynchronously using the configured callback.
So before using this module, make sure to register a callback using the nimble_netif_eventcb() function.
After this, this module provides functions for managing BLE connections to other devices. Once these connections are established, this module takes care of mapping IP packets to the corresponding connections.
Modules | |
Connection State Management for netif | |
Helper module for managing the memory needed to store the BLE connection state for the netif wrapper. | |
Files | |
file | nimble_netif.h |
GNRC netif implementation for NimBLE. | |
Macros | |
#define | NIMBLE_NETIF_MAX_CONN (MYNEWT_VAL_BLE_MAX_CONNECTIONS) |
The maximum number of BLE connections that can be open concurrently. More... | |
#define | NIMBLE_NETIF_CID (BLE_L2CAP_CID_IPSP) |
Default L2CAP channel ID to use. | |
#define | NIMBLE_NETIF_MTU (1280U) |
Default MTU size supported by the NimBLE netif wrapper. | |
Typedefs | |
typedef void(* | nimble_netif_eventcb_t) (int handle, nimble_netif_event_t event, const uint8_t *addr) |
Event callback signature used for asynchronous event signaling. More... | |
Functions | |
void | nimble_netif_init (void) |
Initialize the netif implementation, spawns the netif thread. More... | |
void | nimble_netif_eventcb (nimble_netif_eventcb_t cb) |
Register a global event callback, servicing all NimBLE connections. More... | |
int | nimble_netif_connect (const ble_addr_t *addr, const struct ble_gap_conn_params *conn_params, uint32_t timeout) |
Open a BLE connection as BLE master. More... | |
int | nimble_netif_close (int handle) |
Close the connection with the given handle. More... | |
int | nimble_netif_accept (const uint8_t *ad, size_t ad_len, const struct ble_gap_adv_params *adv_params) |
Accept incoming connections by starting to advertise this node. More... | |
int | nimble_netif_accept_stop (void) |
Stop accepting incoming connections (stop advertising) *. More... | |
int | nimble_netif_update (int handle, const struct ble_gap_upd_params *conn_params) |
Update the connection parameters for the given connection. More... | |
#define NIMBLE_NETIF_MAX_CONN (MYNEWT_VAL_BLE_MAX_CONNECTIONS) |
The maximum number of BLE connections that can be open concurrently.
Definition at line 85 of file nimble_netif.h.
typedef void(* nimble_netif_eventcb_t) (int handle, nimble_netif_event_t event, const uint8_t *addr) |
Event callback signature used for asynchronous event signaling.
[in] | handle | handle to the connection that triggered the event |
[in] | event | type of the event |
[in] | addr | BLE address of the peer in the effected connection |
Definition at line 160 of file nimble_netif.h.
anonymous enum |
Return codes used by the NimBLE netif module.
Definition at line 108 of file nimble_netif.h.
anonymous enum |
Flags describing the state of a single connection context.
Definition at line 138 of file nimble_netif.h.
enum nimble_netif_event_t |
Event types triggered by the NimBLE netif module.
Definition at line 121 of file nimble_netif.h.
int nimble_netif_accept | ( | const uint8_t * | ad, |
size_t | ad_len, | ||
const struct ble_gap_adv_params * | adv_params | ||
) |
Accept incoming connections by starting to advertise this node.
[in] | ad | advertising data (in BLE AD format) |
[in] | ad_len | length of ad in bytes |
[in] | adv_params | advertising (timing) parameters to use |
int nimble_netif_accept_stop | ( | void | ) |
Stop accepting incoming connections (stop advertising) *.
int nimble_netif_close | ( | int | handle | ) |
Close the connection with the given handle.
[in] | handle | handle for the connection to be closed |
int nimble_netif_connect | ( | const ble_addr_t * | addr, |
const struct ble_gap_conn_params * | conn_params, | ||
uint32_t | timeout | ||
) |
Open a BLE connection as BLE master.
[in] | addr | address of the advertising BLE slave, in the NimBLE addr format (little endian) |
[in] | conn_params | connection (timing) parameters |
[in] | timeout | connect timeout [in ms] |
void nimble_netif_eventcb | ( | nimble_netif_eventcb_t | cb | ) |
Register a global event callback, servicing all NimBLE connections.
[in] | cb | event callback to register, may be NULL |
void nimble_netif_init | ( | void | ) |
Initialize the netif implementation, spawns the netif thread.
This function is meant to be called once during system initialization, i.e. auto-init.
int nimble_netif_update | ( | int | handle, |
const struct ble_gap_upd_params * | conn_params | ||
) |
Update the connection parameters for the given connection.
[in] | handle | connection handle |
[in] | conn_params | new connection parameters to apply |