⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hci.h

📁 蓝牙的各种编程接口和各种按理介绍,还有一些例子和说明
💻 H
📖 第 1 页 / 共 2 页
字号:
	uint8_t 	link_key[16];} __attribute__ ((packed)) link_key_reply_cp;#define LINK_KEY_REPLY_CP_SIZE 22#define OCF_PIN_CODE_REPLY	0x000D#define OCF_PIN_CODE_NEG_REPLY	0x000Etypedef struct {	bdaddr_t	bdaddr;	uint8_t 	pin_len;	uint8_t 	pin_code[16];} __attribute__ ((packed)) pin_code_reply_cp;#define PIN_CODE_REPLY_CP_SIZE 23#define OCF_SET_CONN_PTYPE	0x000Ftypedef struct {	uint16_t	 handle;	uint16_t	 pkt_type;} __attribute__ ((packed)) set_conn_ptype_cp;#define SET_CONN_PTYPE_CP_SIZE 4#define OCF_AUTH_REQUESTED	0x0011typedef struct {	uint16_t	 handle;} __attribute__ ((packed)) auth_requested_cp;#define AUTH_REQUESTED_CP_SIZE 2#define OCF_SET_CONN_ENCRYPT	0x0013typedef struct {	uint16_t	handle;	uint8_t 	encrypt;} __attribute__ ((packed)) set_conn_encrypt_cp;#define SET_CONN_ENCRYPT_CP_SIZE 3#define OCF_REMOTE_NAME_REQ	0x0019typedef struct {	bdaddr_t	bdaddr;	uint8_t 	pscan_rep_mode;	uint8_t 	pscan_mode;	uint16_t	clock_offset;} __attribute__ ((packed)) remote_name_req_cp;#define REMOTE_NAME_REQ_CP_SIZE 10#define OCF_READ_REMOTE_FEATURES 0x001Btypedef struct {	uint16_t	handle;} __attribute__ ((packed)) read_remote_features_cp;#define READ_REMOTE_FEATURES_CP_SIZE 2#define OCF_READ_REMOTE_VERSION 0x001Dtypedef struct {	uint16_t	handle;} __attribute__ ((packed)) read_remote_version_cp;#define READ_REMOTE_VERSION_CP_SIZE 2/* Link Policy */#define OGF_LINK_POLICY	0x02   typedef struct {	uint8_t 	service_type;		/* 1 = best effort */	uint32_t	token_rate;		/* Byte per seconds */	uint32_t	peak_bandwidth;		/* Byte per seconds */	uint32_t	latency;		/* Microseconds */	uint32_t	delay_variation;	/* Microseconds */} __attribute__ ((packed)) hci_qos;#define HCI_QOS_CP_SIZE 17#define OCF_QOS_SETUP	0x0007typedef struct {	uint16_t 	handle;	uint8_t 	flags;			/* Reserved */	hci_qos 	qos;} __attribute__ ((packed)) qos_setup_cp;#define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)#define OCF_ROLE_DISCOVERY	0x0009typedef struct {	uint16_t	handle;} __attribute__ ((packed)) role_discovery_cp;#define ROLE_DISCOVERY_CP_SIZE 2typedef struct {	uint8_t 	status;	uint16_t	handle;	uint8_t 	role;} __attribute__ ((packed)) role_discovery_rp;#define ROLE_DISCOVERY_RP_SIZE 4#define OCF_READ_LINK_POLICY	0x000Ctypedef struct {	uint16_t	handle;} __attribute__ ((packed)) read_link_policy_cp;#define READ_LINK_POLICY_CP_SIZE 2typedef struct {	uint8_t 	status;	uint16_t	handle;	uint16_t	policy;} __attribute__ ((packed)) read_link_policy_rp;#define READ_LINK_POLICY_RP_SIZE 5#define OCF_SWITCH_ROLE	0x000Btypedef struct {	bdaddr_t	bdaddr;	uint8_t 	role;} __attribute__ ((packed)) switch_role_cp;#define SWITCH_ROLE_CP_SIZE 7#define OCF_WRITE_LINK_POLICY	0x000Dtypedef struct {	uint16_t	handle;	uint16_t	policy;} __attribute__ ((packed)) write_link_policy_cp;#define WRITE_LINK_POLICY_CP_SIZE 4typedef struct {	uint8_t 	status;	uint16_t	handle;} __attribute__ ((packed)) write_link_policy_rp;#define WRITE_LINK_POLICY_RP_SIZE 3/* Status params */#define OGF_STATUS_PARAM 	0x05#define OCF_READ_FAILED_CONTACT_COUNTER   0x0001typedef struct {	uint8_t 	status;	uint16_t	handle;	uint8_t 	counter;} __attribute__ ((packed)) read_failed_contact_counter_rp; #define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4 #define OCF_RESET_FAILED_CONTACT_COUNTER  0x0002typedef struct {	uint8_t 	status;	uint16_t	handle;} __attribute__ ((packed)) reset_failed_contact_counter_rp; #define OCF_RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4 #define OCF_GET_LINK_QUALITY   0x0003typedef struct {	uint8_t 	status;	uint16_t	handle;	uint8_t 	link_quality;} __attribute__ ((packed)) get_link_quality_rp; #define GET_LINK_QUALITY_RP_SIZE 4 #define OCF_READ_RSSI  0x0005typedef struct {	uint8_t 	status;	uint16_t	handle;	int8_t  	rssi;} __attribute__ ((packed)) read_rssi_rp; #define READ_RSSI_RP_SIZE 4 /* Testing commands */#define OGF_TESTING_CMD	0x3e/* Vendor specific commands */#define OGF_VENDOR_CMD	0x3f/* ---- HCI Events ---- */#define EVT_INQUIRY_COMPLETE 	0x01#define EVT_INQUIRY_RESULT 	0x02typedef struct {	bdaddr_t	bdaddr;	uint8_t 	pscan_rep_mode;	uint8_t 	pscan_period_mode;	uint8_t 	pscan_mode;	uint8_t 	dev_class[3];	uint16_t	clock_offset;} __attribute__ ((packed)) inquiry_info;#define INQUIRY_INFO_SIZE 14#define EVT_CONN_COMPLETE 	0x03typedef struct {	uint8_t 	status;	uint16_t	handle;	bdaddr_t	bdaddr;	uint8_t 	link_type;	uint8_t 	encr_mode;} __attribute__ ((packed)) evt_conn_complete;#define EVT_CONN_COMPLETE_SIZE 13#define EVT_CONN_REQUEST	0x04typedef struct {	bdaddr_t	bdaddr;	uint8_t 	dev_class[3];	uint8_t		link_type;} __attribute__ ((packed)) evt_conn_request;#define EVT_CONN_REQUEST_SIZE 10#define EVT_DISCONN_COMPLETE	0x05typedef struct {	uint8_t 	status;	uint16_t	handle;	uint8_t 	reason;} __attribute__ ((packed)) evt_disconn_complete;#define EVT_DISCONN_COMPLETE_SIZE 4#define EVT_AUTH_COMPLETE	0x06typedef struct {	uint8_t 	status;	uint16_t	handle;} __attribute__ ((packed)) evt_auth_complete;#define EVT_AUTH_COMPLETE_SIZE 3#define EVT_REMOTE_NAME_REQ_COMPLETE	0x07typedef struct {	uint8_t 	status;	bdaddr_t	bdaddr;	uint8_t 	name[248];} __attribute__ ((packed)) evt_remote_name_req_complete;#define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255#define EVT_ENCRYPT_CHANGE	0x08typedef struct {	uint8_t 	status;	uint16_t	handle;	uint8_t 	encrypt;} __attribute__ ((packed)) evt_encrypt_change;#define EVT_ENCRYPT_CHANGE_SIZE 5#define EVT_QOS_SETUP_COMPLETE 0x0Dtypedef struct {	uint8_t 	status;	uint16_t	handle;	uint8_t 	flags;			/* Reserved */	hci_qos 	qos;} __attribute__ ((packed)) evt_qos_setup_complete;#define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)#define EVT_QOS_VIOLATION	0x1Etypedef struct {	uint16_t	handle;} __attribute__ ((packed)) evt_qos_violation;#define EVT_QOS_VIOLATION_SIZE 2#define EVT_CMD_COMPLETE 	0x0etypedef struct {	uint8_t 	ncmd;	uint16_t 	opcode;} __attribute__ ((packed)) evt_cmd_complete;#define EVT_CMD_COMPLETE_SIZE 3#define EVT_CMD_STATUS 		0x0ftypedef struct {	uint8_t 	status;	uint8_t 	ncmd;	uint16_t	opcode;} __attribute__ ((packed)) evt_cmd_status;#define EVT_CMD_STATUS_SIZE 4#define EVT_NUM_COMP_PKTS	0x13typedef struct {	uint8_t		num_hndl;	/* variable length part */} __attribute__ ((packed)) evt_num_comp_pkts;#define EVT_NUM_COMP_PKTS_SIZE 1#define EVT_ROLE_CHANGE		0x12typedef struct {	uint8_t 	status;	bdaddr_t	bdaddr;	uint8_t 	role;} __attribute__ ((packed)) evt_role_change;#define EVT_ROLE_CHANGE_SIZE 8#define EVT_PIN_CODE_REQ        0x16typedef struct {	bdaddr_t	bdaddr;} __attribute__ ((packed)) evt_pin_code_req;#define EVT_PIN_CODE_REQ_SIZE 6#define EVT_LINK_KEY_REQ        0x17typedef struct {	bdaddr_t	bdaddr;} __attribute__ ((packed)) evt_link_key_req;#define EVT_LINK_KEY_REQ_SIZE 6#define EVT_LINK_KEY_NOTIFY	0x18typedef struct {	bdaddr_t	bdaddr;	uint8_t 	link_key[16];	uint8_t 	key_type;} __attribute__ ((packed)) evt_link_key_notify;#define EVT_LINK_KEY_NOTIFY_SIZE 23#define EVT_CONN_PTYPE_CHANGED	0x1Dtypedef struct {	uint8_t 	status;	uint16_t 	handle;	uint16_t 	ptype;} __attribute__ ((packed)) evt_conn_ptype_changed;#define EVT_CONN_PTYPE_CHANGED_SIZE 5#define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0Btypedef struct {	uint8_t 	status;	uint16_t	handle;	uint8_t 	features[8];} __attribute__ ((packed)) evt_read_remote_features_complete;#define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11#define EVT_READ_REMOTE_VERSION_COMPLETE 0x0Ctypedef struct {	uint8_t 	status;	uint16_t	handle;	uint8_t 	lmp_ver;	uint16_t	manufacturer;	uint16_t	lmp_subver;} __attribute__ ((packed)) evt_read_remote_version_complete;#define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8/* Internal events generated by BlueZ stack */#define EVT_STACK_INTERNAL	0xfdtypedef struct {	uint16_t	type;	uint8_t 	data[0];} __attribute__ ((packed)) evt_stack_internal;#define EVT_STACK_INTERNAL_SIZE 2#define EVT_SI_DEVICE  	0x01typedef struct {	uint16_t	event;	uint16_t	dev_id;} __attribute__ ((packed)) evt_si_device;#define EVT_SI_DEVICE_SIZE 4#define EVT_SI_SECURITY	0x02typedef struct {	uint16_t	event;	uint16_t	proto;	uint16_t	subproto;	uint8_t 	incoming;} __attribute__ ((packed)) evt_si_security;#define EVT_TESTING	0xfe#define EVT_VENDOR	0xff/* --------  HCI Packet structures  -------- */#define HCI_TYPE_LEN	1typedef struct {	uint16_t	opcode;		/* OCF & OGF */	uint8_t 	plen;} __attribute__ ((packed))	hci_command_hdr;#define HCI_COMMAND_HDR_SIZE 	3typedef struct {	uint8_t 	evt;	uint8_t 	plen;} __attribute__ ((packed))	hci_event_hdr;#define HCI_EVENT_HDR_SIZE 	2typedef struct {	uint16_t	handle;		/* Handle & Flags(PB, BC) */	uint16_t	dlen;} __attribute__ ((packed))	hci_acl_hdr;#define HCI_ACL_HDR_SIZE 	4typedef struct {	uint16_t	handle;	uint8_t 	dlen;} __attribute__ ((packed))	hci_sco_hdr;#define HCI_SCO_HDR_SIZE 	3/* Command opcode pack/unpack */#define cmd_opcode_pack(ogf, ocf)	(uint16_t)((ocf & 0x03ff)|(ogf << 10))#define cmd_opcode_ogf(op)		(op >> 10)#define cmd_opcode_ocf(op)		(op & 0x03ff)/* ACL handle and flags pack/unpack */#define acl_handle_pack(h, f)	(uint16_t)((h & 0x0fff)|(f << 12))#define acl_handle(h)		(h & 0x0fff)#define acl_flags(h)		(h >> 12)#endif /* _NO_HCI_DEFS *//* HCI Socket options */#define HCI_DATA_DIR	1#define HCI_FILTER	2#define HCI_TIME_STAMP	3/* HCI CMSG flags */#define HCI_CMSG_DIR	0x0001#define HCI_CMSG_TSTAMP	0x0002struct sockaddr_hci {	sa_family_t    hci_family;	unsigned short hci_dev;};#define HCI_DEV_NONE	0xffffstruct hci_filter {	uint32_t type_mask;	uint32_t event_mask[2];	uint16_t opcode;};#define HCI_FLT_TYPE_BITS	31#define HCI_FLT_EVENT_BITS	63#define HCI_FLT_OGF_BITS	63#define HCI_FLT_OCF_BITS	127/* Ioctl requests structures */struct hci_dev_stats {	uint32_t err_rx;	uint32_t err_tx;	uint32_t cmd_tx;	uint32_t evt_rx;	uint32_t acl_tx;	uint32_t acl_rx;	uint32_t sco_tx;	uint32_t sco_rx;	uint32_t byte_rx;	uint32_t byte_tx;};struct hci_dev_info {	uint16_t dev_id;	char     name[8];	bdaddr_t bdaddr;	uint32_t flags;	uint8_t  type;	uint8_t  features[8];	uint32_t pkt_type;	uint32_t link_policy;	uint32_t link_mode;	uint16_t acl_mtu;	uint16_t acl_pkts;	uint16_t sco_mtu;	uint16_t sco_pkts;	struct   hci_dev_stats stat;};struct hci_conn_info {	uint16_t handle;	bdaddr_t bdaddr;	uint8_t  type;	uint8_t	 out;	uint16_t state;	uint32_t link_mode;};struct hci_dev_req {	uint16_t dev_id;	uint32_t dev_opt;};struct hci_dev_list_req {	uint16_t dev_num;	struct hci_dev_req dev_req[0];	/* hci_dev_req structures */};struct hci_conn_list_req {	uint16_t dev_id;	uint16_t conn_num;	struct hci_conn_info conn_info[0];};struct hci_conn_info_req {	bdaddr_t bdaddr;	uint8_t  type;	struct hci_conn_info conn_info[0];};struct hci_inquiry_req {	uint16_t dev_id;	uint16_t flags;	uint8_t  lap[3];	uint8_t  length;	uint8_t  num_rsp;};#define IREQ_CACHE_FLUSH 0x0001struct hci_remotename_req {	uint16_t dev_id;	uint16_t flags;	bdaddr_t bdaddr;	uint8_t  name[248];};#ifdef __cplusplus}#endif#endif /* __HCI_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -