OVMS3-idf/components/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h
2019-06-30 16:39:00 +08:00

135 lines
3.5 KiB
C

/*
* Copyright (c) 2015-2016 Intel Corporation
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_HCI_H_
#define _BLE_MESH_HCI_H_
#include "mesh_kernel.h"
#include "mesh_bearer_adapt.h"
#include "mesh_atomic.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Porting form zephyr/subsys/bluetooth/host/hci_core.h */
#define BLE_MESH_LMP_FEAT_PAGES_COUNT 1
/* bt_mesh_dev flags: the flags defined here represent BT controller state */
enum {
BLE_MESH_DEV_ENABLE,
BLE_MESH_DEV_READY,
BLE_MESH_DEV_ID_STATIC_RANDOM,
BLE_MESH_DEV_HAS_PUB_KEY,
BLE_MESH_DEV_PUB_KEY_BUSY,
BLE_MESH_DEV_ADVERTISING,
BLE_MESH_DEV_KEEP_ADVERTISING,
BLE_MESH_DEV_SCANNING,
BLE_MESH_DEV_EXPLICIT_SCAN,
BLE_MESH_DEV_ACTIVE_SCAN,
BLE_MESH_DEV_SCAN_FILTER_DUP,
BLE_MESH_DEV_RPA_VALID,
BLE_MESH_DEV_ID_PENDING,
/* Total number of flags - must be at the end of the enum */
BLE_MESH_DEV_NUM_FLAGS,
};
struct bt_mesh_dev_le {
/* LE features */
u8_t features[8];
/* LE states */
u64_t states;
};
/* State tracking for the local Bluetooth controller */
struct bt_mesh_dev {
/* Flags indicate which functionality is enabled */
BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_DEV_NUM_FLAGS);
/* Controller version & manufacturer information */
u8_t hci_version;
u8_t lmp_version;
u16_t hci_revision;
u16_t lmp_subversion;
u16_t manufacturer;
/* LMP features (pages 0, 1, 2) */
u8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8];
/* LE controller specific features */
struct bt_mesh_dev_le le;
};
/*Porting from zephyr/subsys/bluetooth/host/hci_core.h */
/* HCI version from Assigned Numbers */
#define BLE_MESH_HCI_VERSION_1_0B 0
#define BLE_MESH_HCI_VERSION_1_1 1
#define BLE_MESH_HCI_VERSION_1_2 2
#define BLE_MESH_HCI_VERSION_2_0 3
#define BLE_MESH_HCI_VERSION_2_1 4
#define BLE_MESH_HCI_VERSION_3_0 5
#define BLE_MESH_HCI_VERSION_4_0 6
#define BLE_MESH_HCI_VERSION_4_1 7
#define BLE_MESH_HCI_VERSION_4_2 8
#define BLE_MESH_HCI_VERSION_5_0 9
/* OpCode Group Fields */
#define BLE_MESH_OGF_LINK_CTRL 0x01
#define BLE_MESH_OGF_BASEBAND 0x03
#define BLE_MESH_OGF_INFO 0x04
#define BLE_MESH_OGF_STATUS 0x05
#define BLE_MESH_OGF_LE 0x08
#define BLE_MESH_OGF_VS 0x3f
/* Construct OpCode from OGF and OCF */
#define BLE_MESH_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
/* Obtain OGF from OpCode */
#define BLE_MESH_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
/* Obtain OCF from OpCode */
#define BLE_MESH_OCF(opcode) ((opcode) & BIT_MASK(10))
#define BLE_MESH_HCI_OP_SET_ADV_PARAM BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0006)
struct bt_mesh_hci_cp_set_adv_param {
u16_t min_interval;
u16_t max_interval;
u8_t type;
u8_t own_addr_type;
bt_mesh_addr_t direct_addr;
u8_t channel_map;
u8_t filter_policy;
} __packed;
#define BLE_MESH_HCI_OP_SET_ADV_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0008)
struct bt_mesh_hci_cp_set_adv_data {
u8_t len;
u8_t data[31];
} __packed;
#define BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0009)
struct bt_mesh_hci_cp_set_scan_rsp_data {
u8_t len;
u8_t data[31];
} __packed;
/* Added by Espressif */
extern struct bt_mesh_dev bt_mesh_dev;
void bt_mesh_hci_init(void);
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_HCI_H_ */