2016-11-24 17:58:26 +00:00
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-11-05 12:40:07 +00:00
|
|
|
#ifndef __ESP_BT_DEFS_H__
|
2016-11-24 18:10:15 +00:00
|
|
|
#define __ESP_BT_DEFS_H__
|
2016-10-26 12:19:48 +00:00
|
|
|
|
2016-11-15 12:56:15 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2016-12-08 06:26:19 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-08-08 09:28:19 +00:00
|
|
|
#define ESP_BLUEDROID_STATUS_CHECK(status) \
|
|
|
|
if (esp_bluedroid_get_status() != (status)) { \
|
|
|
|
return ESP_ERR_INVALID_STATE; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-25 07:39:01 +00:00
|
|
|
/* relate to BT_STATUS_xxx in bt_def.h */
|
2016-12-01 10:58:54 +00:00
|
|
|
/// Status Return Value
|
2016-11-15 12:56:15 +00:00
|
|
|
typedef enum {
|
2017-05-27 02:47:56 +00:00
|
|
|
ESP_BT_STATUS_SUCCESS = 0, /* relate to BT_STATUS_SUCCESS in bt_def.h */
|
2017-05-25 07:39:01 +00:00
|
|
|
ESP_BT_STATUS_FAIL, /* relate to BT_STATUS_FAIL in bt_def.h */
|
|
|
|
ESP_BT_STATUS_NOT_READY, /* relate to BT_STATUS_NOT_READY in bt_def.h */
|
|
|
|
ESP_BT_STATUS_NOMEM, /* relate to BT_STATUS_NOMEM in bt_def.h */
|
|
|
|
ESP_BT_STATUS_BUSY, /* relate to BT_STATUS_BUSY in bt_def.h */
|
2017-05-27 02:47:56 +00:00
|
|
|
ESP_BT_STATUS_DONE = 5, /* relate to BT_STATUS_DONE in bt_def.h */
|
2017-05-25 07:39:01 +00:00
|
|
|
ESP_BT_STATUS_UNSUPPORTED, /* relate to BT_STATUS_UNSUPPORTED in bt_def.h */
|
|
|
|
ESP_BT_STATUS_PARM_INVALID, /* relate to BT_STATUS_PARM_INVALID in bt_def.h */
|
|
|
|
ESP_BT_STATUS_UNHANDLED, /* relate to BT_STATUS_UNHANDLED in bt_def.h */
|
|
|
|
ESP_BT_STATUS_AUTH_FAILURE, /* relate to BT_STATUS_AUTH_FAILURE in bt_def.h */
|
2017-05-27 02:47:56 +00:00
|
|
|
ESP_BT_STATUS_RMT_DEV_DOWN = 10, /* relate to BT_STATUS_RMT_DEV_DOWN in bt_def.h */
|
2017-05-25 07:39:01 +00:00
|
|
|
ESP_BT_STATUS_AUTH_REJECTED, /* relate to BT_STATUS_AUTH_REJECTED in bt_def.h */
|
2017-05-31 09:20:29 +00:00
|
|
|
ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR, /* relate to BT_STATUS_INVALID_STATIC_RAND_ADDR in bt_def.h */
|
2017-06-02 05:09:23 +00:00
|
|
|
ESP_BT_STATUS_PENDING, /* relate to BT_STATUS_PENDING in bt_def.h */
|
|
|
|
ESP_BT_STATUS_UNACCEPT_CONN_INTERVAL, /* relate to BT_UNACCEPT_CONN_INTERVAL in bt_def.h */
|
|
|
|
ESP_BT_STATUS_PARAM_OUT_OF_RANGE, /* relate to BT_PARAM_OUT_OF_RANGE in bt_def.h */
|
2017-06-14 13:19:48 +00:00
|
|
|
ESP_BT_STATUS_TIMEOUT, /* relate to BT_STATUS_TIMEOUT in bt_def.h */
|
|
|
|
ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED, /* relate to BTM_PEER_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
|
|
|
|
ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* relate to BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
|
2017-08-24 12:46:03 +00:00
|
|
|
ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in hcidefs.h */
|
2016-11-15 12:56:15 +00:00
|
|
|
} esp_bt_status_t;
|
2016-09-26 13:37:39 +00:00
|
|
|
|
2017-04-13 14:14:28 +00:00
|
|
|
|
|
|
|
/*Define the bt octet 16 bit size*/
|
|
|
|
#define ESP_BT_OCTET16_LEN 16
|
|
|
|
typedef uint8_t esp_bt_octet16_t[ESP_BT_OCTET16_LEN]; /* octet array: size 16 */
|
|
|
|
|
|
|
|
#define ESP_BT_OCTET8_LEN 8
|
|
|
|
typedef uint8_t esp_bt_octet8_t[ESP_BT_OCTET8_LEN]; /* octet array: size 8 */
|
|
|
|
|
|
|
|
typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */
|
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// Default GATT interface id
|
2016-11-24 18:10:15 +00:00
|
|
|
#define ESP_DEFAULT_GATT_IF 0xff
|
2016-11-16 11:50:44 +00:00
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// Default BLE connection param, if the value doesn't be overwritten
|
2016-10-31 10:55:54 +00:00
|
|
|
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
2016-10-21 06:16:01 +00:00
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// Check the param is valid or not
|
2016-11-15 12:56:15 +00:00
|
|
|
#define ESP_BLE_IS_VALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// UUID type
|
2016-11-15 12:56:15 +00:00
|
|
|
typedef struct {
|
2016-11-24 18:10:15 +00:00
|
|
|
#define ESP_UUID_LEN_16 2
|
|
|
|
#define ESP_UUID_LEN_32 4
|
|
|
|
#define ESP_UUID_LEN_128 16
|
2016-11-28 13:59:04 +00:00
|
|
|
uint16_t len; /*!< UUID length, 16bit, 32bit or 128bit */
|
2016-11-24 18:10:15 +00:00
|
|
|
union {
|
|
|
|
uint16_t uuid16;
|
|
|
|
uint32_t uuid32;
|
|
|
|
uint8_t uuid128[ESP_UUID_LEN_128];
|
2016-11-28 13:59:04 +00:00
|
|
|
} uuid; /*!< UUID */
|
|
|
|
} __attribute__((packed)) esp_bt_uuid_t;
|
2016-11-15 12:56:15 +00:00
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// Bluetooth device type
|
2016-11-15 12:56:15 +00:00
|
|
|
typedef enum {
|
2016-11-24 18:10:15 +00:00
|
|
|
ESP_BT_DEVICE_TYPE_BREDR = 0x01,
|
|
|
|
ESP_BT_DEVICE_TYPE_BLE = 0x02,
|
|
|
|
ESP_BT_DEVICE_TYPE_DUMO = 0x03,
|
2016-11-15 12:56:15 +00:00
|
|
|
} esp_bt_dev_type_t;
|
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// Bluetooth address length
|
2016-11-24 18:10:15 +00:00
|
|
|
#define ESP_BD_ADDR_LEN 6
|
2016-12-01 10:58:54 +00:00
|
|
|
|
|
|
|
/// Bluetooth device address
|
|
|
|
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN];
|
2016-10-21 06:16:01 +00:00
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// BLE device address type
|
2016-11-15 12:56:15 +00:00
|
|
|
typedef enum {
|
2016-11-24 18:10:15 +00:00
|
|
|
BLE_ADDR_TYPE_PUBLIC = 0x00,
|
|
|
|
BLE_ADDR_TYPE_RANDOM = 0x01,
|
|
|
|
BLE_ADDR_TYPE_RPA_PUBLIC = 0x02,
|
|
|
|
BLE_ADDR_TYPE_RPA_RANDOM = 0x03,
|
2016-11-15 12:56:15 +00:00
|
|
|
} esp_ble_addr_type_t;
|
2016-09-26 13:37:39 +00:00
|
|
|
|
2017-04-13 14:14:28 +00:00
|
|
|
/// Used to exchange the encrytyption key in the init key & response key
|
2017-05-25 07:39:01 +00:00
|
|
|
#define ESP_BLE_ENC_KEY_MASK (1 << 0) /* relate to BTM_BLE_ENC_KEY_MASK in btm_api.h */
|
2017-04-13 14:14:28 +00:00
|
|
|
/// Used to exchange the IRK key in the init key & response key
|
2017-05-25 07:39:01 +00:00
|
|
|
#define ESP_BLE_ID_KEY_MASK (1 << 1) /* relate to BTM_BLE_ID_KEY_MASK in btm_api.h */
|
2017-04-13 14:14:28 +00:00
|
|
|
/// Used to exchange the CSRK key in the init key & response key
|
2017-05-25 07:39:01 +00:00
|
|
|
#define ESP_BLE_CSR_KEY_MASK (1 << 2) /* relate to BTM_BLE_CSR_KEY_MASK in btm_api.h */
|
2017-04-13 14:14:28 +00:00
|
|
|
/// Used to exchange the link key(this key just used in the BLE & BR/EDR coexist mode) in the init key & response key
|
2017-05-25 07:39:01 +00:00
|
|
|
#define ESP_BLE_LINK_KEY_MASK (1 << 3) /* relate to BTM_BLE_LINK_KEY_MASK in btm_api.h */
|
2017-08-09 08:46:49 +00:00
|
|
|
typedef uint8_t esp_ble_key_mask_t; /* the key mask type */
|
2017-04-13 14:14:28 +00:00
|
|
|
|
2016-12-01 10:58:54 +00:00
|
|
|
/// Minimum of the application id
|
2016-11-29 06:38:58 +00:00
|
|
|
#define ESP_APP_ID_MIN 0x0000
|
2016-12-01 10:58:54 +00:00
|
|
|
/// Maximum of the application id
|
2016-11-29 06:38:58 +00:00
|
|
|
#define ESP_APP_ID_MAX 0x7fff
|
2016-09-26 13:37:39 +00:00
|
|
|
|
2017-01-06 13:19:58 +00:00
|
|
|
#define ESP_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
|
|
|
|
#define ESP_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
|
|
|
|
|
2016-12-08 06:26:19 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __ESP_BT_DEFS_H__ */
|