NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_hs_priv.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_PRIV_
21#define H_BLE_HS_PRIV_
22
23#include <assert.h>
24#include <inttypes.h>
25#include "ble_att_cmd_priv.h"
26#include "ble_att_priv.h"
27#include "ble_gap_priv.h"
28#include "ble_gatt_priv.h"
29#include "ble_hs_hci_priv.h"
30#include "ble_hs_atomic_priv.h"
31#include "ble_hs_conn_priv.h"
32#include "ble_hs_mbuf_priv.h"
33#include "ble_hs_startup_priv.h"
34#include "ble_l2cap_priv.h"
35#include "ble_l2cap_sig_priv.h"
36#include "ble_l2cap_coc_priv.h"
37#include "ble_sm_priv.h"
38#include "ble_hs_adv_priv.h"
39#include "ble_hs_flow_priv.h"
40#include "ble_hs_pvcy_priv.h"
41#include "ble_hs_id_priv.h"
42#include "ble_hs_periodic_sync_priv.h"
43#include "ble_uuid_priv.h"
44#include "nimble/nimble/host/include/host/ble_hs.h"
45#include "nimble/nimble/include/nimble/nimble_opt.h"
46#include "nimble/porting/nimble/include/stats/stats.h"
47#if MYNEWT_VAL(BLE_GATT_CACHING)
48#include "ble_gattc_cache_priv.h"
49#endif
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54struct ble_hs_conn;
55struct ble_l2cap_chan;
56struct os_mbuf;
57struct os_mempool;
58struct os_event;
59
60#define BLE_HS_SYNC_STATE_BAD 0
61#define BLE_HS_SYNC_STATE_BRINGUP 1
62#define BLE_HS_SYNC_STATE_GOOD 2
63
64#define BLE_HS_ENABLED_STATE_OFF 0
65#define BLE_HS_ENABLED_STATE_STOPPING 1
66#define BLE_HS_ENABLED_STATE_ON 2
67
68#if NIMBLE_BLE_CONNECT
69#define BLE_HS_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
70#else
71#define BLE_HS_MAX_CONNECTIONS 0
72#endif
73
74#if !MYNEWT_VAL(BLE_ATT_SVR_QUEUED_WRITE)
75#define BLE_HS_ATT_SVR_QUEUED_WRITE_TMO 0
76#else
77#define BLE_HS_ATT_SVR_QUEUED_WRITE_TMO \
78 MYNEWT_VAL(BLE_ATT_SVR_QUEUED_WRITE_TMO)
79#endif
80
81STATS_SECT_START(ble_hs_stats)
82 STATS_SECT_ENTRY(conn_create)
83 STATS_SECT_ENTRY(conn_delete)
84 STATS_SECT_ENTRY(hci_cmd)
85 STATS_SECT_ENTRY(hci_event)
86 STATS_SECT_ENTRY(hci_invalid_ack)
87 STATS_SECT_ENTRY(hci_unknown_event)
88 STATS_SECT_ENTRY(hci_timeout)
89 STATS_SECT_ENTRY(reset)
90 STATS_SECT_ENTRY(sync)
91 STATS_SECT_ENTRY(pvcy_add_entry)
92 STATS_SECT_ENTRY(pvcy_add_entry_fail)
93STATS_SECT_END
94extern STATS_SECT_DECL(ble_hs_stats) ble_hs_stats;
95
96extern struct os_mbuf_pool ble_hs_mbuf_pool;
97extern uint8_t ble_hs_sync_state;
98extern uint8_t ble_hs_enabled_state;
99
100extern const uint8_t ble_hs_misc_null_addr[6];
101
102extern uint16_t ble_hs_max_attrs;
103extern uint16_t ble_hs_max_services;
104extern uint16_t ble_hs_max_client_configs;
105
106void ble_hs_process_rx_data_queue(void);
107int ble_hs_tx_data(struct os_mbuf *om);
108void ble_hs_wakeup_tx(void);
109void ble_hs_enqueue_hci_event(uint8_t *hci_evt);
110void ble_hs_event_enqueue(struct os_event *ev);
111
112int ble_hs_hci_rx_evt(uint8_t *hci_ev, void *arg);
113int ble_hs_hci_evt_acl_process(struct os_mbuf *om);
114
115int ble_hs_misc_conn_chan_find(uint16_t conn_handle, uint16_t cid,
116 struct ble_hs_conn **out_conn,
117 struct ble_l2cap_chan **out_chan);
118int ble_hs_misc_conn_chan_find_reqd(uint16_t conn_handle, uint16_t cid,
119 struct ble_hs_conn **out_conn,
120 struct ble_l2cap_chan **out_chan);
121uint8_t ble_hs_misc_own_addr_type_to_id(uint8_t addr_type);
122uint8_t ble_hs_misc_peer_addr_type_to_id(uint8_t addr_type);
123int ble_hs_misc_restore_irks(void);
124
125int ble_hs_locked_by_cur_task(void);
126int ble_hs_is_parent_task(void);
127void ble_hs_lock_nested(void);
128void ble_hs_unlock_nested(void);
129void ble_hs_lock(void);
130void ble_hs_unlock(void);
131void ble_hs_hw_error(uint8_t hw_code);
132void ble_hs_timer_resched(void);
133void ble_hs_notifications_sched(void);
134struct ble_npl_eventq *ble_hs_evq_get(void);
135void ble_hs_stop_init(void);
136void ble_hs_stop_deinit(void);
137
138struct ble_mqueue {
139 STAILQ_HEAD(, os_mbuf_pkthdr) head;
140 struct ble_npl_event ev;
141};
142
143int ble_mqueue_init(struct ble_mqueue *mq, ble_npl_event_fn *ev_fn, void *ev_arg);
144struct os_mbuf *ble_mqueue_get(struct ble_mqueue *mq);
145int ble_mqueue_put(struct ble_mqueue *mq, struct ble_npl_eventq *evq, struct os_mbuf *om);
146
147void ble_gap_npl_sync_lost(struct ble_npl_event *ev);
148
149#if MYNEWT_VAL(BLE_HS_DEBUG)
150 #define BLE_HS_DBG_ASSERT(x) assert(x)
151 #define BLE_HS_DBG_ASSERT_EVAL(x) assert(x)
152#else
153 #define BLE_HS_DBG_ASSERT(x)
154 #define BLE_HS_DBG_ASSERT_EVAL(x) ((void)(x))
155#endif
156
157#ifdef __cplusplus
158}
159#endif
160
161#endif
Definition os_mbuf.h:70
Definition os_mbuf.h:52
Definition os_mbuf.h:86
Definition os_mempool.h:57