NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_hs.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_BLE_HS_
21#define H_BLE_HS_
22
29#include <inttypes.h>
30#include "nimble/nimble/include/nimble/hci_common.h"
31#include "ble_att.h"
32#include "ble_eddystone.h"
33#include "ble_gap.h"
34#include "ble_gatt.h"
35#include "ble_hs_adv.h"
36#include "ble_hs_id.h"
37#include "ble_hs_hci.h"
38#include "ble_hs_log.h"
39#include "ble_hs_mbuf.h"
40#include "ble_hs_stop.h"
41#include "ble_ibeacon.h"
42#include "ble_l2cap.h"
43#include "ble_sm.h"
44#include "ble_store.h"
45#include "ble_uuid.h"
46#include "nimble/nimble/include/nimble/nimble_npl.h"
47#include "ble_esp_hs.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53#define BLE_HS_FOREVER INT32_MAX
54
56#define BLE_HS_CONN_HANDLE_NONE 0xffff
57
58#define BLE_HS_CTRL_DATA_HDR_SZ 0x4
59
70#define BLE_HS_EAGAIN 1
71#define BLE_HS_EALREADY 2
72#define BLE_HS_EINVAL 3
73#define BLE_HS_EMSGSIZE 4
74#define BLE_HS_ENOENT 5
75#define BLE_HS_ENOMEM 6
76#define BLE_HS_ENOTCONN 7
77#define BLE_HS_ENOTSUP 8
78#define BLE_HS_EAPP 9
79#define BLE_HS_EBADDATA 10
80#define BLE_HS_EOS 11
81#define BLE_HS_ECONTROLLER 12
82#define BLE_HS_ETIMEOUT 13
83#define BLE_HS_EDONE 14
84#define BLE_HS_EBUSY 15
85#define BLE_HS_EREJECT 16
86#define BLE_HS_EUNKNOWN 17
87#define BLE_HS_EROLE 18
88#define BLE_HS_ETIMEOUT_HCI 19
89#define BLE_HS_ENOMEM_EVT 20
90#define BLE_HS_ENOADDR 21
91#define BLE_HS_ENOTSYNCED 22
92#define BLE_HS_EAUTHEN 23
93#define BLE_HS_EAUTHOR 24
94#define BLE_HS_EENCRYPT 25
95#define BLE_HS_EENCRYPT_KEY_SZ 26
96#define BLE_HS_ESTORE_CAP 27
97#define BLE_HS_ESTORE_FAIL 28
98#define BLE_HS_EPREEMPTED 29
99#define BLE_HS_EDISABLED 30
100#define BLE_HS_ESTALLED 31
101
103#define BLE_HS_ERR_ATT_BASE 0x100
104
106#define BLE_HS_ATT_ERR(x) ((x) ? BLE_HS_ERR_ATT_BASE + (x) : 0)
107
109#define BLE_HS_ERR_HCI_BASE 0x200
110
112#define BLE_HS_HCI_ERR(x) ((x) ? BLE_HS_ERR_HCI_BASE + (x) : 0)
113
115#define BLE_HS_ERR_L2C_BASE 0x300
116
118#define BLE_HS_L2C_ERR(x) ((x) ? BLE_HS_ERR_L2C_BASE + (x) : 0)
119
121#define BLE_HS_ERR_SM_US_BASE 0x400
122
124#define BLE_HS_SM_US_ERR(x) ((x) ? BLE_HS_ERR_SM_US_BASE + (x) : 0)
125
127#define BLE_HS_ERR_SM_PEER_BASE 0x500
128
130#define BLE_HS_SM_PEER_ERR(x) ((x) ? BLE_HS_ERR_SM_PEER_BASE + (x) : 0)
131
133#define BLE_HS_ERR_HW_BASE 0x600
134
136#define BLE_HS_HW_ERR(x) (BLE_HS_ERR_HW_BASE + (x))
137
157#define BLE_HS_IO_DISPLAY_ONLY 0x00
158
160#define BLE_HS_IO_DISPLAY_YESNO 0x01
161
163#define BLE_HS_IO_KEYBOARD_ONLY 0x02
164
166#define BLE_HS_IO_NO_INPUT_OUTPUT 0x03
167
169#define BLE_HS_IO_KEYBOARD_DISPLAY 0x04
170
179typedef void ble_hs_reset_fn(int reason);
180
181
183typedef void ble_hs_sync_fn(void);
184
198 ble_gatt_register_fn *gatts_register_cb;
199
205
207 uint8_t sm_io_cap;
208
214
220 unsigned sm_bonding:1;
221
227 unsigned sm_mitm:1;
228
235 unsigned sm_sc:1;
236
241 unsigned sm_keypress:1;
242
245
248
255
262
263 /* XXX: These need to go away. Instead, the nimble host package should
264 * require the host-store API (not yet implemented)..
265 */
267 ble_store_read_fn *store_read_cb;
268
270 ble_store_write_fn *store_write_cb;
271
273 ble_store_delete_fn *store_delete_cb;
274
283 ble_store_status_fn *store_status_cb;
284
287};
288
289extern struct ble_hs_cfg ble_hs_cfg;
290
302int ble_hs_is_enabled(void);
303
311int ble_hs_synced(void);
312
328int ble_hs_start(void);
329
342void ble_hs_sched_start(void);
343
350void ble_hs_sched_reset(int reason);
351
359void ble_hs_evq_set(struct ble_npl_eventq *evq);
360
368void ble_hs_init(void);
369
379int ble_hs_shutdown(int reason);
380
381#ifdef __cplusplus
382}
383#endif
384
389#endif
void ble_hs_sync_fn(void)
Stack sync callback.
Definition ble_hs.h:183
void ble_hs_reset_fn(int reason)
Stack reset callback.
Definition ble_hs.h:179
void ble_hs_sched_start(void)
Definition ble_hs.c:508
int ble_hs_start(void)
Definition ble_hs.c:639
void ble_hs_sched_reset(int reason)
Definition ble_hs.c:624
void ble_hs_init(void)
Definition ble_hs.c:735
int ble_hs_synced(void)
Definition ble_hs.c:339
int ble_hs_shutdown(int reason)
Called when the system is shutting down. Stops the BLE host.
void ble_hs_evq_set(struct ble_npl_eventq *evq)
Definition ble_hs.c:127
int ble_hs_is_enabled(void)
Indicates whether the host is enabled. The host is enabled if it is starting or fully started....
Definition ble_hs.c:333
Bluetooth Host main configuration structure.
Definition ble_hs.h:193
ble_store_delete_fn * store_delete_cb
Definition ble_hs.h:273
unsigned sm_oob_data_flag
Security Manager OOB flag.
Definition ble_hs.h:213
void * gatts_register_arg
Definition ble_hs.h:204
uint8_t sm_their_key_dist
Security Manager Remote Key Distribution Mask.
Definition ble_hs.h:247
ble_gatt_register_fn * gatts_register_cb
Definition ble_hs.h:198
ble_store_write_fn * store_write_cb
Definition ble_hs.h:270
unsigned sm_mitm
Security Manager MITM flag.
Definition ble_hs.h:227
unsigned sm_keypress
Security Manager Key Press Notification flag.
Definition ble_hs.h:241
uint8_t sm_io_cap
Definition ble_hs.h:207
unsigned sm_sc
Security Manager Secure Connections flag.
Definition ble_hs.h:235
uint8_t sm_our_key_dist
Security Manager Local Key Distribution Mask.
Definition ble_hs.h:244
ble_hs_reset_fn * reset_cb
Stack reset callback.
Definition ble_hs.h:254
ble_store_status_fn * store_status_cb
Storage Status callback.
Definition ble_hs.h:283
unsigned sm_bonding
Security Manager Bond flag.
Definition ble_hs.h:220
ble_hs_sync_fn * sync_cb
Stack sync callback.
Definition ble_hs.h:261
void * store_status_arg
Definition ble_hs.h:286
ble_store_read_fn * store_read_cb
Definition ble_hs.h:267