NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_ll_hci.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_LL_HCI_
21#define H_BLE_LL_HCI_
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include "nimble/nimble/include/nimble/hci_common.h"
28#include "nimble/nimble/transport/include/nimble/transport.h"
29
30/* For supported commands */
31#define BLE_LL_SUPP_CMD_LEN (47)
32extern const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN];
33
34/* The largest event the controller will send. */
35#define BLE_LL_MAX_EVT_LEN MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
36
37/*
38 * This determines the number of outstanding commands allowed from the
39 * host to the controller. NOTE: you cannot change this without modifying
40 * other portions of the code as we currently use a global os event for
41 * the command; you would need to allocate a pool of these.
42 */
43#define BLE_LL_CFG_NUM_HCI_CMD_PKTS (1)
44
45typedef void (*ble_ll_hci_post_cmd_complete_cb)(void);
46
47#if MYNEWT_VAL(BLE_LL_HCI_VS)
48typedef int (* ble_ll_hci_vs_cb_t)(uint16_t ocf,
49 const uint8_t *cmdbuf, uint8_t cmdlen,
50 uint8_t *rspbuf, uint8_t *rsplen);
51
52#define BLE_LL_HCI_VS_CMD(_ocf, _cb) { .ocf = (_ocf), .cb = (_cb) }
53
54struct ble_ll_hci_vs_cmd {
55 uint16_t ocf;
56 ble_ll_hci_vs_cb_t cb;
57 SLIST_ENTRY(ble_ll_hci_vs_cmd) link;
58};
59#endif
60
61/* Initialize LL HCI */
62void ble_ll_hci_init(void);
63
64/* Used to determine if the LE event is enabled/disabled */
65bool ble_ll_hci_is_le_event_enabled(unsigned int subev);
66
67/* Used to determine if event is enabled/disabled */
68bool ble_ll_hci_is_event_enabled(unsigned int evcode);
69
70/* Send event from controller to host */
71int ble_ll_hci_event_send(struct ble_hci_ev *hci_ev);
72
73/* Sends a command complete with a no-op opcode to host */
74void ble_ll_hci_send_noop(void);
75
76/* Checks the preferref phy masks from set default phy and set phy commands */
77int ble_ll_hci_chk_phy_masks(uint8_t all_phys, uint8_t tx_phys, uint8_t rx_phys,
78 uint8_t *txphy, uint8_t *rxphy);
79
80/* Returns true if Extended Advertising HCI commands are in use */
81bool ble_ll_hci_adv_mode_ext(void);
82
83/* Get TX power compensation rounded to integer dB */
84int8_t ble_ll_get_tx_pwr_compensation(void);
85
86#if MYNEWT_VAL(BLE_LL_HCI_VS)
87void ble_ll_hci_vs_register(struct ble_ll_hci_vs_cmd *cmds, uint32_t num_cmds);
88#endif
89
90#ifdef __cplusplus
91}
92#endif
93
94#endif /* H_BLE_LL_HCI_ */