Loading...
Searching...
No Matches
nimble_netif.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2021 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
66#ifndef NIMBLE_NETIF_H
67#define NIMBLE_NETIF_H
68
69#include <stdint.h>
70#include <errno.h>
71
72#include "net/ble.h"
73#include "nimble_riot.h"
74
75#include "host/ble_hs.h"
76
77#ifdef __cplusplus
78extern "C" {
79#endif
80
86#ifndef NIMBLE_NETIF_MAX_CONN
87#define NIMBLE_NETIF_MAX_CONN (MYNEWT_VAL_BLE_MAX_CONNECTIONS)
88#endif
89
93#ifndef NIMBLE_NETIF_CID
94#define NIMBLE_NETIF_CID (BLE_L2CAP_CID_IPSP)
95#endif
96
100/* NOTE: We do not use the @ref IPV6_MIN_MTU define here, as the iov6.h header
101 pulls in some other RIOT headers that clash with NimBLE header (e.g.
102 * byteorder.h vs. endian.h) */
103#ifndef NIMBLE_NETIF_MTU
104#define NIMBLE_NETIF_MTU (1280U)
105#endif
106
111enum {
115};
116
130
146
169#ifndef NIMBLE_NETIF_CONN_ITVL_SPACING
170#define NIMBLE_NETIF_CONN_ITVL_SPACING 0
171#endif
172
189
193enum {
204};
205
215typedef void(*nimble_netif_eventcb_t)(int handle,
217 const uint8_t *addr);
218
226
235
251int nimble_netif_connect(const ble_addr_t *addr,
252 const nimble_netif_connect_cfg_t *cfg);
253
264int nimble_netif_close(int handle);
265
279int nimble_netif_accept(const uint8_t *ad, size_t ad_len,
280 const nimble_netif_accept_cfg_t *cfg);
281
295int nimble_netif_accept_direct(const ble_addr_t *addr,
296 const nimble_netif_accept_cfg_t *cfg);
297
306
317int nimble_netif_update(int handle,
318 const struct ble_gap_upd_params *conn_params);
319
333int nimble_netif_used_chanmap(int handle, uint8_t map[5]);
334
335#ifdef __cplusplus
336}
337#endif
338
339#endif /* NIMBLE_NETIF_H */
nimble_phy_t
BLE PHY modes.
Definition nimble_riot.h:75
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:148
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.