DIY - ESP32:ESP32 藍牙(Bluetooth)GAP API 函數結構件及其它(八十一):
除了 SP32 藍牙(Bluetooth)的 GAP(Generic Access Profile)的 API 函數模塊外,還提供了結構件(Structures)、巨集(Marco)、 泛型型別定義(Type Definitions)和枚舉(Enumerations)。
1. Structure:
1.1. struct esp_bt_cod_t:
Class of device.
Public Members
|
Description
|
uint32_t reserved_2
|
undefined
|
uint32_t minor
|
minor class
|
uint32_t major
|
major class
|
uint32_t service
|
service class
|
uint32_t reserved_8
|
undefined
|
1.2. struct esp_bt_gap_dev_prop_t:
Bluetooth Device Property
Descriptor.
Public Members
|
Description
|
esp_bt_gap_dev_prop_type_t type
|
device property type
|
int len
|
device property value length
|
void ﹡val
|
device property value
|
2. Macros:
Macros
|
Description
|
ESP_BT_GAP_RSSI_HIGH_THRLD
|
RSSI threshold.
High RSSI threshold
|
ESP_BT_GAP_RSSI_LOW_THRLD
|
Low RSSI threshold
|
ESP_BT_GAP_MAX_BDNAME_LEN
|
Maximum bytes of Bluetooth device name.
|
ESP_BT_GAP_EIR_DATA_LEN
|
Maximum size of EIR Significant part.
|
ESP_BT_PIN_CODE_LEN
|
Max pin code length
|
ESP_BT_IO_CAP_OUT
|
|
ESP_BT_IO_CAP_IO
|
|
ESP_BT_IO_CAP_IN
|
|
ESP_BT_IO_CAP_NONE
|
|
ESP_BT_COD_SRVC_BIT_MASK
|
Bits of major service class field.
Major service bit mask
|
ESP_BT_COD_SRVC_BIT_OFFSET
|
Major service bit offset
|
ESP_BT_COD_MAJOR_DEV_BIT_MASK
|
Bits of major device class field.
Major device bit mask
|
ESP_BT_COD_MAJOR_DEV_BIT_OFFSET
|
Major device bit offset
|
ESP_BT_COD_MINOR_DEV_BIT_MASK
|
Bits of minor device class field.
Minor device bit mask
|
ESP_BT_COD_MINOR_DEV_BIT_OFFSET
|
Minor device bit offset
|
ESP_BT_COD_FORMAT_TYPE_BIT_MASK
|
Bits of format type.
Format type bit mask
|
ESP_BT_COD_FORMAT_TYPE_BIT_OFFSET
|
Format type bit offset
|
ESP_BT_COD_FORMAT_TYPE_1
|
Class of device format type 1
|
ESP_BT_GAP_MIN_INQ_LEN
|
Minimum and Maximum inquiry length Minimum inquiry
duration, unit is 1.28s
|
ESP_BT_GAP_MAX_INQ_LEN
|
Maximum inquiry duration, unit is 1.28s
|
3. Type Definitions:
Type Definitions
|
Description
|
typedef uint8_t esp_bt_pin_code_t[ESP_BT_PIN_CODE_LEN]
|
Pin Code (upto 128 bits) MSB is 0
|
typedef uint8_t esp_bt_io_cap_t
|
combination of the io capability
|
typedef void (﹡esp_bt_gap_cb_t)(esp_bt_gap_cb_event_t
event, esp_bt_gap_cb_param_t ﹡param)
|
bluetooth GAP callback function type
Parameters
event: : Event type
param: : Pointer to callback parameter
|
4. Enumerations:
4.1. enum esp_bt_cod_mode_t:
Bluetooth A2DP connection states.
Enumeration
|
Description
|
ESP_BT_SET_COD_MAJOR_MINOR
= 0x01
|
overwrite major, minor class
|
ESP_BT_SET_COD_SERVICE_CLASS
= 0x02
|
set the bits in the input, the current bit will remain
|
ESP_BT_CLR_COD_SERVICE_CLASS
= 0x04
|
clear the bits in the input, others will remain
|
ESP_BT_SET_COD_ALL
= 0x08
|
overwrite major, minor, set the bits in service class
|
ESP_BT_INIT_COD
= 0x0a
|
overwrite major, minor, and service class
|
4.2. enum esp_bt_scan_mode_t:
Bluetooth A2DP disconnection reason.
Enumeration
|
Description
|
ESP_BT_SCAN_MODE_NONE = 0
|
Neither discoverable nor connectable
|
ESP_BT_SCAN_MODE_CONNECTABLE
|
Connectable but not discoverable
|
ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
|
both discoverable and connectable
|
4.3. enum
esp_bt_gap_dev_prop_type_t:
Bluetooth Device Property type.
Enumeration
|
Description
|
ESP_BT_GAP_DEV_PROP_BDNAME = 1
|
Bluetooth device name, value type is int8_t []
|
ESP_BT_GAP_DEV_PROP_COD
|
Class of Device, value type is uint32_t
|
ESP_BT_GAP_DEV_PROP_RSSI
|
Received Signal strength Indication, value type is int8_t,
ranging from -128 to 127
|
ESP_BT_GAP_DEV_PROP_EIR
|
Extended Inquiry Response, value type is uint8_t []
|
4.4. enum esp_bt_eir_type_t:
Extended Inquiry Response data
type.
Enumeration
|
Description
|
ESP_BT_EIR_TYPE_FLAGS = 0x01
|
Flag with information such as BR/EDR and LE support
|
ESP_BT_EIR_TYPE_INCMPL_16BITS_UUID = 0x02
|
Incomplete list of 16-bit service UUIDs
|
ESP_BT_EIR_TYPE_CMPL_16BITS_UUID = 0x03
|
Complete list of 16-bit service UUIDs
|
ESP_BT_EIR_TYPE_INCMPL_32BITS_UUID = 0x04
|
Incomplete list of 32-bit service UUIDs
|
ESP_BT_EIR_TYPE_CMPL_32BITS_UUID = 0x05
|
Complete list of 32-bit service UUIDs
|
ESP_BT_EIR_TYPE_INCMPL_128BITS_UUID = 0x06
|
Incomplete list of 128-bit service UUIDs
|
ESP_BT_EIR_TYPE_CMPL_128BITS_UUID = 0x07
|
Complete list of 128-bit service UUIDs
|
ESP_BT_EIR_TYPE_SHORT_LOCAL_NAME = 0x08
|
Shortened Local Name
|
ESP_BT_EIR_TYPE_CMPL_LOCAL_NAME = 0x09
|
Complete Local Name
|
ESP_BT_EIR_TYPE_TX_POWER_LEVEL = 0x0a
|
Tx power level, value is 1 octet ranging from -127 to 127, unit is dBm
|
ESP_BT_EIR_TYPE_MANU_SPECIFIC = 0xff
|
Manufacturer specific data
|
4.5. enum esp_bt_cod_srvc_t:
Major service class field of Class
of Device, mutiple bits can be set.
Enumeration
|
Description
|
ESP_BT_COD_SRVC_NONE = 0
|
None indicates an invalid value
|
ESP_BT_COD_SRVC_LMTD_DISCOVER = 0x1
|
Limited Discoverable Mode
|
ESP_BT_COD_SRVC_POSITIONING = 0x8
|
Positioning (Location identification)
|
ESP_BT_COD_SRVC_NETWORKING = 0x10
|
Networking, e.g. LAN, Ad hoc
|
ESP_BT_COD_SRVC_RENDERING = 0x20
|
Rendering, e.g. Printing, Speakers
|
ESP_BT_COD_SRVC_CAPTURING = 0x40
|
Capturing, e.g. Scanner, Microphone
|
ESP_BT_COD_SRVC_OBJ_TRANSFER = 0x80
|
Object Transfer, e.g. v-Inbox, v-Folder
|
ESP_BT_COD_SRVC_AUDIO = 0x100
|
Audio, e.g. Speaker, Microphone, Headset service
|
ESP_BT_COD_SRVC_TELEPHONY = 0x200
|
Telephony, e.g. Cordless telephony, Modem, Headset service
|
ESP_BT_COD_SRVC_INFORMATION = 0x400
|
Information, e.g., WEB-server, WAP-server
|
4.6. enum esp_bt_pin_type_t:
Enumeration
|
Description
|
ESP_BT_PIN_TYPE_VARIABLE = 0
|
Refer to BTM_PIN_TYPE_VARIABLE
|
ESP_BT_PIN_TYPE_FIXED = 1
|
Refer to BTM_PIN_TYPE_FIXED
|
4.7. enum esp_bt_sp_param_t:
Enumeration
|
Description
|
ESP_BT_SP_IOCAP_MODE = 0
|
Set IO mode
|
4.8. enum esp_bt_cod_major_dev_t:
Major device class field of Class
of Device.
Enumeration
|
Description
|
ESP_BT_COD_MAJOR_DEV_MISC = 0
|
Miscellaneous
|
ESP_BT_COD_MAJOR_DEV_COMPUTER = 1
|
Computer
|
ESP_BT_COD_MAJOR_DEV_PHONE = 2
|
Phone(cellular, cordless, pay phone, modem
|
ESP_BT_COD_MAJOR_DEV_LAN_NAP = 3
|
LAN, Network Access Point
|
ESP_BT_COD_MAJOR_DEV_AV = 4
|
Audio/Video(headset, speaker, stereo, video display, VCR
|
ESP_BT_COD_MAJOR_DEV_PERIPHERAL = 5
|
Peripheral(mouse, joystick, keyboard)
|
ESP_BT_COD_MAJOR_DEV_IMAGING = 6
|
Imaging(printer, scanner, camera, display
|
ESP_BT_COD_MAJOR_DEV_WEARABLE = 7
|
Wearable
|
ESP_BT_COD_MAJOR_DEV_TOY = 8
|
Toy
|
ESP_BT_COD_MAJOR_DEV_HEALTH = 9
|
Health
|
ESP_BT_COD_MAJOR_DEV_UNCATEGORIZED = 31
|
Uncategorized: device not specified
|
4.9. enum
esp_bt_gap_discovery_state_t:
Bluetooth Device Discovery state
Enumeration
|
Description
|
ESP_BT_GAP_DISCOVERY_STOPPED
|
device discovery stopped
|
ESP_BT_GAP_DISCOVERY_STARTED
|
device discovery started
|
4.10. enum esp_bt_gap_cb_event_t:
BT GAP callback events.
Enumeration
|
Description
|
ESP_BT_GAP_DISC_RES_EVT = 0
|
device discovery result event
|
ESP_BT_GAP_DISC_STATE_CHANGED_EVT
|
discovery state changed event
|
ESP_BT_GAP_RMT_SRVCS_EVT
|
get remote services event
|
ESP_BT_GAP_RMT_SRVC_REC_EVT
|
get remote service record event
|
ESP_BT_GAP_AUTH_CMPL_EVT
|
AUTH complete event
|
ESP_BT_GAP_PIN_REQ_EVT
|
Legacy Pairing Pin code request
|
ESP_BT_GAP_CFM_REQ_EVT
|
Simple Pairing User Confirmation request.
|
ESP_BT_GAP_KEY_NOTIF_EVT
|
Simple Pairing Passkey Notification
|
ESP_BT_GAP_KEY_REQ_EVT
|
Simple Pairing Passkey request
|
ESP_BT_GAP_READ_RSSI_DELTA_EVT
|
read rssi event
|
ESP_BT_GAP_EVT_MAX
|
|
4.11. enum esp_bt_inq_mode_t:
Inquiry Mode
Enumeration
|
Description
|
ESP_BT_INQ_MODE_GENERAL_INQUIRY
|
General inquiry mode
|
ESP_BT_INQ_MODE_LIMITED_INQUIRY
|
Limited inquiry mode
|
5. Unions:
union esp_bt_gap_cb_param_t.
#include
A2DP state callback parameters.
Unions
|
Description
|
struct
esp_bt_gap_cb_param_t::disc_res_param disc_res
|
discovery result parameter struct
|
struct
esp_bt_gap_cb_param_t::disc_state_changed_param disc_st_chgt
|
discovery state changed parameter struct
|
struct
esp_bt_gap_cb_param_t::rmt_srvcs_param rmt_srvcs
|
services of remote device parameter struct
|
struct
esp_bt_gap_cb_param_t::rmt_srvc_rec_param rmt_srvc_rec
|
specific service record from remote device parameter
struct
|
struct
esp_bt_gap_cb_param_t::read_rssi_delta_param read_rssi_delta
|
read rssi parameter struct
|
struct
esp_bt_gap_cb_param_t::auth_cmpl_param auth_cmpl
|
authentication complete parameter struct
|
struct
esp_bt_gap_cb_param_t::pin_req_param pin_req
|
pin request parameter struct
|
struct
esp_bt_gap_cb_param_t::cfm_req_param cfm_req
|
confirm request parameter struct
|
struct
esp_bt_gap_cb_param_t::key_notif_param key_notif
|
passkey notif parameter struct
|
struct
esp_bt_gap_cb_param_t::key_req_param key_req
|
passkey request parameter struct
|
struct
auth_cmpl_param
|
#include
ESP_BT_GAP_AUTH_CMPL_EVT.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
esp_bt_status_t stat - authentication complete status
uint8_t device_name[ESP_BT_GAP_MAX_BDNAME_LEN+1]
- device name
|
struct
cfm_req_param
|
#include
ESP_BT_GAP_CFM_REQ_EVT.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
uint32_t num_val - the numeric value for comparison.
|
struct
disc_res_param
|
#include
ESP_BT_GAP_DISC_RES_EVT.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
int num_prop - number of properties got
esp_bt_gap_dev_prop_t ﹡prop - properties discovered from
the new device
|
struct
disc_state_changed_param
|
#include
ESP_BT_GAP_DISC_STATE_CHANGED_EVT.
Public Members
esp_bt_gap_discovery_state_t state - discovery state
|
struct
key_notif_param
|
#include
ESP_BT_GAP_KEY_NOTIF_EVT.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
uint32_t passkey - the numeric value for passkey entry.
|
struct
key_req_param
|
#include
ESP_BT_GAP_KEY_REQ_EVT.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
|
struct
pin_req_param
|
#include
ESP_BT_GAP_PIN_REQ_EVT.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
bool min_16_digit - TRUE if the pin returned must be at
least 16 digits
|
struct read_rssi_delta_param
|
#include
ESP_BT_GAP_READ_RSSI_DELTA_EVT ﹡.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
esp_bt_status_t stat - read rssi status
int8_t rssi_delta - rssi delta value range -128 ~127, The
value zero indicates that the RSSI is inside the Golden Receive Power Range,
the Golden Receive Power Range is from ESP_BT_GAP_RSSI_LOW_THRLD to
ESP_BT_GAP_RSSI_HIGH_THRLD
|
struct
rmt_srvc_rec_param
|
#include
ESP_BT_GAP_RMT_SRVC_REC_EVT.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
esp_bt_status_t stat - service search status
|
struct
rmt_srvcs_param
|
#include
ESP_BT_GAP_RMT_SRVCS_EVT.
Public Members
esp_bd_addr_t bda - remote bluetooth device address
esp_bt_status_t stat - service search status
int num_uuids - number of UUID in uuid_list
esp_bt_uuid_t ﹡uuid_list - list of service UUIDs of remote
device
|
Header File:bt/bluedroid/api/include/api/esp_gap_bt_api.h
參考網址:https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/esp_gap_bt.html
2019年 1月 26日 天氣報告
氣溫:16.9度 @ 22:00
相對濕度:百分之 69%
天氣:天色大致良好