1 /* 2 * SPDX-FileCopyrightText: 2015-2016 Intel Corporation 3 * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 #ifndef _BLE_MESH_HCI_H_ 8 #define _BLE_MESH_HCI_H_ 9 10 #include "mesh_atomic.h" 11 #include "mesh_bearer_adapt.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /* Porting form zephyr/subsys/bluetooth/host/hci_core.h */ 18 19 #define BLE_MESH_LMP_FEAT_PAGES_COUNT 1 20 21 /* bt_mesh_dev flags: the flags defined here represent BT controller state */ 22 enum { 23 BLE_MESH_DEV_ENABLE, 24 BLE_MESH_DEV_READY, 25 BLE_MESH_DEV_ID_STATIC_RANDOM, 26 BLE_MESH_DEV_HAS_PUB_KEY, 27 BLE_MESH_DEV_PUB_KEY_BUSY, 28 29 BLE_MESH_DEV_ADVERTISING, 30 BLE_MESH_DEV_KEEP_ADVERTISING, 31 BLE_MESH_DEV_SCANNING, 32 BLE_MESH_DEV_EXPLICIT_SCAN, 33 BLE_MESH_DEV_ACTIVE_SCAN, 34 BLE_MESH_DEV_SCAN_FILTER_DUP, 35 36 BLE_MESH_DEV_RPA_VALID, 37 38 BLE_MESH_DEV_ID_PENDING, 39 40 /* Total number of flags - must be at the end of the enum */ 41 BLE_MESH_DEV_NUM_FLAGS, 42 }; 43 44 struct bt_mesh_dev_le { 45 /* LE features */ 46 uint8_t features[8]; 47 48 /* LE states */ 49 uint64_t states; 50 }; 51 52 /* State tracking for the local Bluetooth controller */ 53 struct bt_mesh_dev { 54 /* Flags indicate which functionality is enabled */ 55 BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_DEV_NUM_FLAGS); 56 57 /* Controller version & manufacturer information */ 58 uint8_t hci_version; 59 uint8_t lmp_version; 60 uint16_t hci_revision; 61 uint16_t lmp_subversion; 62 uint16_t manufacturer; 63 64 /* LMP features (pages 0, 1, 2) */ 65 uint8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8]; 66 67 /* LE controller specific features */ 68 struct bt_mesh_dev_le le; 69 }; 70 71 /*Porting from zephyr/subsys/bluetooth/host/hci_core.h */ 72 /* HCI version from Assigned Numbers */ 73 #define BLE_MESH_HCI_VERSION_1_0B 0 74 #define BLE_MESH_HCI_VERSION_1_1 1 75 #define BLE_MESH_HCI_VERSION_1_2 2 76 #define BLE_MESH_HCI_VERSION_2_0 3 77 #define BLE_MESH_HCI_VERSION_2_1 4 78 #define BLE_MESH_HCI_VERSION_3_0 5 79 #define BLE_MESH_HCI_VERSION_4_0 6 80 #define BLE_MESH_HCI_VERSION_4_1 7 81 #define BLE_MESH_HCI_VERSION_4_2 8 82 #define BLE_MESH_HCI_VERSION_5_0 9 83 84 /* OpCode Group Fields */ 85 #define BLE_MESH_OGF_LINK_CTRL 0x01 86 #define BLE_MESH_OGF_BASEBAND 0x03 87 #define BLE_MESH_OGF_INFO 0x04 88 #define BLE_MESH_OGF_STATUS 0x05 89 #define BLE_MESH_OGF_LE 0x08 90 #define BLE_MESH_OGF_VS 0x3f 91 92 /* Construct OpCode from OGF and OCF */ 93 #define BLE_MESH_OP(ogf, ocf) ((ocf) | ((ogf) << 10)) 94 95 /* Obtain OGF from OpCode */ 96 #define BLE_MESH_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6)) 97 98 /* Obtain OCF from OpCode */ 99 #define BLE_MESH_OCF(opcode) ((opcode) & BIT_MASK(10)) 100 101 #define BLE_MESH_HCI_OP_SET_ADV_PARAM BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0006) 102 struct bt_mesh_hci_cp_set_adv_param { 103 uint16_t min_interval; 104 uint16_t max_interval; 105 uint8_t type; 106 uint8_t own_addr_type; 107 bt_mesh_addr_t direct_addr; 108 uint8_t channel_map; 109 uint8_t filter_policy; 110 } __packed; 111 112 #define BLE_MESH_HCI_OP_SET_ADV_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0008) 113 struct bt_mesh_hci_cp_set_adv_data { 114 uint8_t len; 115 uint8_t data[31]; 116 } __packed; 117 118 #define BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0009) 119 struct bt_mesh_hci_cp_set_scan_rsp_data { 120 uint8_t len; 121 uint8_t data[31]; 122 } __packed; 123 124 /* Added by Espressif */ 125 extern struct bt_mesh_dev bt_mesh_dev; 126 127 void bt_mesh_hci_init(void); 128 129 #ifdef __cplusplus 130 } 131 #endif 132 133 #endif /* _BLE_MESH_HCI_H_ */ 134