nimble_netif.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2019 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 
71 #include "net/ble.h"
72 
73 #include "host/ble_hs.h"
74 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
84 #ifndef NIMBLE_NETIF_MAX_CONN
85 #define NIMBLE_NETIF_MAX_CONN (MYNEWT_VAL_BLE_MAX_CONNECTIONS)
86 #endif
87 
91 #ifndef NIMBLE_NETIF_CID
92 #define NIMBLE_NETIF_CID (BLE_L2CAP_CID_IPSP)
93 #endif
94 
98 /* NOTE: We do not use the @ref IPV6_MIN_MTU define here, as the iov6.h header
99  pulls in some other RIOT headers that clash with NimBLE header (e.g.
100  * byteorder.h vs. endian.h) */
101 #ifndef NIMBLE_NETIF_MTU
102 #define NIMBLE_NETIF_MTU (1280U)
103 #endif
104 
108 enum {
116 };
117 
121 typedef enum {
134 
138 enum {
145  NIMBLE_NETIF_ADV = 0x0100,
148  NIMBLE_NETIF_ANY = 0xffff,
149 };
150 
160 typedef void(*nimble_netif_eventcb_t)(int handle,
162  const uint8_t *addr);
163 
170 void nimble_netif_init(void);
171 
180 
194 int nimble_netif_connect(const ble_addr_t *addr,
195  const struct ble_gap_conn_params *conn_params,
196  uint32_t timeout);
197 
207 int nimble_netif_close(int handle);
208 
220 int nimble_netif_accept(const uint8_t *ad, size_t ad_len,
221  const struct ble_gap_adv_params *adv_params);
222 
229 int nimble_netif_accept_stop(void);
230 
241 int nimble_netif_update(int handle,
242  const struct ble_gap_upd_params *conn_params);
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 
248 #endif /* NIMBLE_NETIF_H */
249 
NIMBLE_NETIF_ACCEPTING
@ NIMBLE_NETIF_ACCEPTING
accepting incoming connections
Definition: nimble_netif.h:122
nimble_netif_eventcb
void nimble_netif_eventcb(nimble_netif_eventcb_t cb)
Register a global event callback, servicing all NimBLE connections.
nimble_netif_accept_stop
int nimble_netif_accept_stop(void)
Stop accepting incoming connections (stop advertising) *.
nimble_netif_close
int nimble_netif_close(int handle)
Close the connection with the given handle.
NIMBLE_NETIF_ABORT_SLAVE
@ NIMBLE_NETIF_ABORT_SLAVE
connection est.
Definition: nimble_netif.h:131
NIMBLE_NETIF_NOTFOUND
@ NIMBLE_NETIF_NOTFOUND
no fitting entry found
Definition: nimble_netif.h:115
NIMBLE_NETIF_NOTCONN
@ NIMBLE_NETIF_NOTCONN
not connected
Definition: nimble_netif.h:110
NIMBLE_NETIF_ABORT_MASTER
@ NIMBLE_NETIF_ABORT_MASTER
connection est.
Definition: nimble_netif.h:130
NIMBLE_NETIF_OK
@ NIMBLE_NETIF_OK
everything went fine
Definition: nimble_netif.h:109
NIMBLE_NETIF_CLOSED_SLAVE
@ NIMBLE_NETIF_CLOSED_SLAVE
connection closed (we were slave)
Definition: nimble_netif.h:129
event
event structure
Definition: event.h:142
nimble_netif_update
int nimble_netif_update(int handle, const struct ble_gap_upd_params *conn_params)
Update the connection parameters for the given connection.
NIMBLE_NETIF_ANY
@ NIMBLE_NETIF_ANY
match any state
Definition: nimble_netif.h:148
NIMBLE_NETIF_INIT_MASTER
@ NIMBLE_NETIF_INIT_MASTER
conn.
Definition: nimble_netif.h:124
nimble_netif_event_t
nimble_netif_event_t
Event types triggered by the NimBLE netif module.
Definition: nimble_netif.h:121
ble.h
General BLE values as defined by the BT standard.
NIMBLE_NETIF_ADV
@ NIMBLE_NETIF_ADV
currently advertising
Definition: nimble_netif.h:145
NIMBLE_NETIF_BUSY
@ NIMBLE_NETIF_BUSY
network device is busy
Definition: nimble_netif.h:112
NIMBLE_NETIF_L2CAP_SERVER
@ NIMBLE_NETIF_L2CAP_SERVER
L2CAP server.
Definition: nimble_netif.h:140
NIMBLE_NETIF_CONNECTED_MASTER
@ NIMBLE_NETIF_CONNECTED_MASTER
connection established as master
Definition: nimble_netif.h:126
NIMBLE_NETIF_ACCEPT_STOP
@ NIMBLE_NETIF_ACCEPT_STOP
stop accepting incoming connections
Definition: nimble_netif.h:123
NIMBLE_NETIF_UNUSED
@ NIMBLE_NETIF_UNUSED
context unused
Definition: nimble_netif.h:147
NIMBLE_NETIF_INIT_SLAVE
@ NIMBLE_NETIF_INIT_SLAVE
conn.
Definition: nimble_netif.h:125
nimble_netif_eventcb_t
void(* nimble_netif_eventcb_t)(int handle, nimble_netif_event_t event, const uint8_t *addr)
Event callback signature used for asynchronous event signaling.
Definition: nimble_netif.h:160
NIMBLE_NETIF_GAP_CONNECTED
@ NIMBLE_NETIF_GAP_CONNECTED
GAP is connected.
Definition: nimble_netif.h:144
NIMBLE_NETIF_NOTADV
@ NIMBLE_NETIF_NOTADV
not advertising
Definition: nimble_netif.h:114
NIMBLE_NETIF_L2CAP_CONNECTED
@ NIMBLE_NETIF_L2CAP_CONNECTED
L2CAP is connected.
Definition: nimble_netif.h:141
NIMBLE_NETIF_DEVERR
@ NIMBLE_NETIF_DEVERR
internal BLE stack error
Definition: nimble_netif.h:111
NIMBLE_NETIF_CLOSED_MASTER
@ NIMBLE_NETIF_CLOSED_MASTER
connection closed (we were master)
Definition: nimble_netif.h:128
NIMBLE_NETIF_GAP_SLAVE
@ NIMBLE_NETIF_GAP_SLAVE
GAP slave.
Definition: nimble_netif.h:143
NIMBLE_NETIF_CONNECTING
@ NIMBLE_NETIF_CONNECTING
connection in progress
Definition: nimble_netif.h:146
NIMBLE_NETIF_GAP_MASTER
@ NIMBLE_NETIF_GAP_MASTER
GAP master.
Definition: nimble_netif.h:142
nimble_netif_accept
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.
NIMBLE_NETIF_L2CAP_CLIENT
@ NIMBLE_NETIF_L2CAP_CLIENT
L2CAP client.
Definition: nimble_netif.h:139
NIMBLE_NETIF_CONN_UPDATED
@ NIMBLE_NETIF_CONN_UPDATED
connection parameter update done
Definition: nimble_netif.h:132
nimble_netif_connect
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.
NIMBLE_NETIF_NOMEM
@ NIMBLE_NETIF_NOMEM
insufficient memory
Definition: nimble_netif.h:113
NIMBLE_NETIF_CONNECTED_SLAVE
@ NIMBLE_NETIF_CONNECTED_SLAVE
connection established as slave
Definition: nimble_netif.h:127
nimble_netif_init
void nimble_netif_init(void)
Initialize the netif implementation, spawns the netif thread.