Loading...
Searching...
No Matches
nimble_netif.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018-2021 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
64
65#include <stdint.h>
66#include <errno.h>
67
68#include "net/ble.h"
69#include "nimble_riot.h"
70
71#include "host/ble_hs.h"
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
82#ifndef NIMBLE_NETIF_MAX_CONN
83#define NIMBLE_NETIF_MAX_CONN (MYNEWT_VAL_BLE_MAX_CONNECTIONS)
84#endif
85
89#ifndef NIMBLE_NETIF_CID
90#define NIMBLE_NETIF_CID (BLE_L2CAP_CID_IPSP)
91#endif
92
96/* NOTE: We do not use the @ref IPV6_MIN_MTU define here, as the iov6.h header
97 pulls in some other RIOT headers that clash with NimBLE header (e.g.
98 * byteorder.h vs. endian.h) */
99#ifndef NIMBLE_NETIF_MTU
100#define NIMBLE_NETIF_MTU (1280U)
101#endif
102
107enum {
111};
112
126
142
165#ifndef NIMBLE_NETIF_CONN_ITVL_SPACING
166#define NIMBLE_NETIF_CONN_ITVL_SPACING 0
167#endif
168
185
189enum {
200};
201
211typedef void(*nimble_netif_eventcb_t)(int handle,
213 const uint8_t *addr);
214
222
231
247int nimble_netif_connect(const ble_addr_t *addr,
248 const nimble_netif_connect_cfg_t *cfg);
249
260int nimble_netif_close(int handle);
261
275int nimble_netif_accept(const uint8_t *ad, size_t ad_len,
276 const nimble_netif_accept_cfg_t *cfg);
277
291int nimble_netif_accept_direct(const ble_addr_t *addr,
292 const nimble_netif_accept_cfg_t *cfg);
293
302
313int nimble_netif_update(int handle,
314 const struct ble_gap_upd_params *conn_params);
315
329int nimble_netif_used_chanmap(int handle, uint8_t map[5]);
330
331#ifdef __cplusplus
332}
333#endif
334
nimble_phy_t
BLE PHY modes.
Definition nimble_riot.h:70
int nimble_netif_accept_direct(const ble_addr_t *addr, const nimble_netif_accept_cfg_t *cfg)
Wait for an incoming connection from a specific peer, sending directed advertisements.
int nimble_netif_update(int handle, const struct ble_gap_upd_params *conn_params)
Update the connection parameters for the given connection.
void nimble_netif_init(void)
Initialize the netif implementation, spawns the netif thread.
int nimble_netif_accept(const uint8_t *ad, size_t ad_len, const nimble_netif_accept_cfg_t *cfg)
Accept incoming connections by starting to advertise this node.
void nimble_netif_eventcb(nimble_netif_eventcb_t cb)
Register a global event callback, servicing all NimBLE connections.
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.
int nimble_netif_used_chanmap(int handle, uint8_t map[5])
Get the currently used channel map for the given connection as bitmap.
void(* nimble_netif_eventcb_t)(int handle, nimble_netif_event_t event, const uint8_t *addr)
Event callback signature used for asynchronous event signaling.
int nimble_netif_connect(const ble_addr_t *addr, const nimble_netif_connect_cfg_t *cfg)
Open a BLE connection as BLE master.
nimble_netif_event_t
Event types triggered by the NimBLE netif module.
@ NIMBLE_NETIF_FLAG_HD_MODE
use high duty cycle mode, only valid for direct advertising
@ NIMBLE_NETIF_FLAG_LEGACY
use legacy advertising mode
@ NIMBLE_NETIF_ADV
currently advertising
@ NIMBLE_NETIF_L2CAP_CLIENT
L2CAP client.
@ NIMBLE_NETIF_ANY
match any state
@ NIMBLE_NETIF_L2CAP_CONNECTED
L2CAP is connected.
@ NIMBLE_NETIF_GAP_SLAVE
GAP slave.
@ NIMBLE_NETIF_GAP_MASTER
GAP master.
@ NIMBLE_NETIF_CONNECTING
connection in progress
@ NIMBLE_NETIF_UNUSED
context unused
@ NIMBLE_NETIF_GAP_CONNECTED
GAP is connected.
@ NIMBLE_NETIF_L2CAP_SERVER
L2CAP server.
@ NIMBLE_NETIF_CONNECTED_MASTER
connection established as master
@ NIMBLE_NETIF_ACCEPT_STOP
stop accepting incoming connections
@ NIMBLE_NETIF_INIT_MASTER
conn.
@ NIMBLE_NETIF_CONN_UPDATED
connection parameter update done
@ NIMBLE_NETIF_CONNECTED_SLAVE
connection established as slave
@ NIMBLE_NETIF_ABORT_MASTER
connection est.
@ NIMBLE_NETIF_ACCEPTING
accepting incoming connections
@ NIMBLE_NETIF_CLOSED_MASTER
connection closed (we were master)
@ NIMBLE_NETIF_INIT_SLAVE
conn.
@ NIMBLE_NETIF_CLOSED_SLAVE
connection closed (we were slave)
@ NIMBLE_NETIF_ABORT_SLAVE
connection est.
RIOT specific glue functions for integrating NimBLE.
event structure
Definition event.h:142
Parameter set used to configure accepting connections (advertising)
uint32_t adv_itvl_ms
advertising interval [ms]
uint32_t timeout_ms
stop accepting after this time [ms]
nimble_phy_t primary_phy
primary PHY mode
uint8_t channel_map
specify custom channel map
int8_t tx_power
specify TX power to be used
nimble_phy_t secondary_phy
secondary PHY mode
uint8_t own_addr_type
specify our own address type to use
Parameter set used to configure connection initiation.
uint16_t conn_slave_latency
slave latency
uint16_t scan_window_ms
scan window [ms]
uint8_t own_addr_type
specify our own address type to use
uint16_t conn_itvl_min_ms
connection interval, lower bound [ms]
uint16_t conn_itvl_max_ms
connection interval, upper bound [ms]
uint8_t phy_mode
PHY mode used for the connection.
uint32_t timeout_ms
abort connection initiation after this time [ms]
uint16_t conn_supervision_timeout_ms
supervision timeout [ms]
uint16_t scan_itvl_ms
scan interval [ms]
General BLE values as defined by the BT standard.