蓝牙HCI剖析(三)

原创 专注于无线通信的蓬勃 2016-05-06 21:35

关键字:bluetooth 蓝牙协议  HCI剖析 HCI概述 HCI笔记 LMP L2CAP SDP RFCOMM 


作者:zhongjun

本着互相学习的目的,来分享此一系列的文章,欢迎转载,请注明作者,尊重版权,谢谢

文章有不当处请指正,共同学习


此系列目前这样打算:

LMP剖析 + 模拟源码:


HCI剖析 + 模拟源码:


L2CAP剖析 + 模拟源码(未完成)
SDP剖析 + 模拟源码(未完成)

rfcomm剖析 + 模拟源码(未完成)


------------------------------------------------------------------------------------------------------------------------------------

华丽分割线,进入正题

------------------------------------------------------------------------------------------------------------------------------------

HCI源码:

bt_hci.h

/*
* This file is part of the HCI protocal.
* Data  :20160506
* Author: zhongjun
*
*/

#ifndef BT_HCI_H_H
#define BT_HCI_H_H

#include "bt_cfg.h"

#ifdef DEBUG_BT_HCI
#define DEBUG(x) {printf x;}
#define BT_HCI_DEBUG(x) DEBUG(x)
#else
#define BT_HCI_DEBUG(x) 
#endif

#define TRANSPORT_UART
#define TRANSPORT_USBx
#define TRANSPORT_SDIOx

#define SCAN_DISABLED		0x00
#define SCAN_INQUIRY		0x01
#define SCAN_PAGE		0x02

/* ACL flags */
#define ACL_CONT		0x01
#define ACL_START		0x02
#define ACL_ACTIVE_BCAST	0x04
#define ACL_PICO_BCAST		0x08

/* CMD/EVT/ACL/SCO types */
#define HCI_COMMAND_PKT		0x01
#define HCI_ACLDATA_PKT		0x02
#define HCI_SCODATA_PKT		0x03
#define HCI_EVENT_PKT		0x04
#define HCI_VENDOR_PKT		0xff

/* HCI Packet types */
#define HCI_2DH1	0x0002
#define HCI_3DH1	0x0004
#define HCI_DM1		0x0008
#define HCI_DH1		0x0010
#define HCI_2DH3	0x0100
#define HCI_3DH3	0x0200
#define HCI_DM3		0x0400
#define HCI_DH3		0x0800
#define HCI_2DH5	0x1000
#define HCI_3DH5	0x2000
#define HCI_DM5		0x4000
#define HCI_DH5		0x8000

#define HCI_HV1		0x0020
#define HCI_HV2		0x0040
#define HCI_HV3		0x0080

#define HCI_EV3		0x0008
#define HCI_EV4		0x0010
#define HCI_EV5		0x0020
#define HCI_2EV3	0x0040
#define HCI_3EV3	0x0080
#define HCI_2EV5	0x0100
#define HCI_3EV5	0x0200

/* HCI Error codes */
#define HCI_UNKNOWN_COMMAND			0x01
#define HCI_NO_CONNECTION			0x02
#define HCI_HARDWARE_FAILURE			0x03
#define HCI_PAGE_TIMEOUT			0x04
#define HCI_AUTHENTICATION_FAILURE		0x05
#define HCI_PIN_OR_KEY_MISSING			0x06
#define HCI_MEMORY_FULL				0x07
#define HCI_CONNECTION_TIMEOUT			0x08
#define HCI_MAX_NUMBER_OF_CONNECTIONS		0x09
#define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS	0x0a
#define HCI_ACL_CONNECTION_EXISTS		0x0b
#define HCI_COMMAND_DISALLOWED			0x0c
#define HCI_REJECTED_LIMITED_RESOURCES		0x0d
#define HCI_REJECTED_SECURITY			0x0e
#define HCI_REJECTED_PERSONAL			0x0f
#define HCI_HOST_TIMEOUT			0x10
#define HCI_UNSUPPORTED_FEATURE			0x11
#define HCI_INVALID_PARAMETERS			0x12
#define HCI_OE_USER_ENDED_CONNECTION		0x13
#define HCI_OE_LOW_RESOURCES			0x14
#define HCI_OE_POWER_OFF			0x15
#define HCI_CONNECTION_TERMINATED		0x16
#define HCI_REPEATED_ATTEMPTS			0x17
#define HCI_PAIRING_NOT_ALLOWED			0x18
#define HCI_UNKNOWN_LMP_PDU			0x19
#define HCI_UNSUPPORTED_REMOTE_FEATURE		0x1a
#define HCI_SCO_OFFSET_REJECTED			0x1b
#define HCI_SCO_INTERVAL_REJECTED		0x1c
#define HCI_AIR_MODE_REJECTED			0x1d
#define HCI_INVALID_LMP_PARAMETERS		0x1e
#define HCI_UNSPECIFIED_ERROR			0x1f
#define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE	0x20
#define HCI_ROLE_CHANGE_NOT_ALLOWED		0x21
#define HCI_LMP_RESPONSE_TIMEOUT		0x22
#define HCI_LMP_ERROR_TRANSACTION_COLLISION	0x23
#define HCI_LMP_PDU_NOT_ALLOWED			0x24
#define HCI_ENCRYPTION_MODE_NOT_ACCEPTED	0x25
#define HCI_UNIT_LINK_KEY_USED			0x26
#define HCI_QOS_NOT_SUPPORTED			0x27
#define HCI_INSTANT_PASSED			0x28
#define HCI_PAIRING_NOT_SUPPORTED		0x29
#define HCI_TRANSACTION_COLLISION		0x2a
#define HCI_QOS_UNACCEPTABLE_PARAMETER		0x2c
#define HCI_QOS_REJECTED			0x2d
#define HCI_CLASSIFICATION_NOT_SUPPORTED	0x2e
#define HCI_INSUFFICIENT_SECURITY		0x2f
#define HCI_PARAMETER_OUT_OF_RANGE		0x30
#define HCI_ROLE_SWITCH_PENDING			0x32
#define HCI_SLOT_VIOLATION			0x34
#define HCI_ROLE_SWITCH_FAILED			0x35
#define HCI_EIR_TOO_LARGE			0x36
#define HCI_SIMPLE_PAIRING_NOT_SUPPORTED	0x37
#define HCI_HOST_BUSY_PAIRING			0x38

/* 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_get_handle(h)		(h & 0x0fff)
#define acl_get_flags(h)		(h >> 12)


/* -----  HCI Commands ----- */
/* Link Control */
#define OGF_LINK_CTL		0x01
#define OCF_INQUIRY			0x0001
#define OCF_INQUIRY_CANCEL		0x0002
#define OCF_PERIODIC_INQUIRY		0x0003
#define OCF_EXIT_PERIODIC_INQUIRY	0x0004
#define OCF_CREATE_CONN			0x0005
#define OCF_DISCONNECT			0x0006
#define OCF_ADD_SCO			0x0007
#define OCF_CREATE_CONN_CANCEL		0x0008
#define OCF_ACCEPT_CONN_REQ		0x0009
#define OCF_REJECT_CONN_REQ		0x000A
#define OCF_LINK_KEY_REPLY		0x000B
#define OCF_LINK_KEY_NEG_REPLY		0x000C
#define OCF_PIN_CODE_REPLY		0x000D
#define OCF_PIN_CODE_NEG_REPLY		0x000E
#define OCF_SET_CONN_PTYPE		0x000F
#define OCF_AUTH_REQUESTED		0x0011
#define OCF_SET_CONN_ENCRYPT		0x0013
#define OCF_CHANGE_CONN_LINK_KEY	0x0015
#define OCF_MASTER_LINK_KEY		0x0017
#define OCF_REMOTE_NAME_REQ		0x0019
#define OCF_REMOTE_NAME_REQ_CANCEL	0x001A
#define OCF_READ_REMOTE_FEATURES	0x001B
#define OCF_READ_REMOTE_EXT_FEATURES	0x001C
#define OCF_READ_REMOTE_VERSION		0x001D
#define OCF_READ_CLOCK_OFFSET		0x001F
#define OCF_READ_LMP_HANDLE		0x0020
#define OCF_SETUP_SYNC_CONN		0x0028
#define OCF_ACCEPT_SYNC_CONN_REQ	0x0029
#define OCF_REJECT_SYNC_CONN_REQ	0x002A
#define OCF_IO_CAPABILITY_REPLY		0x002B
#define OCF_USER_CONFIRM_REPLY		0x002C
#define OCF_USER_CONFIRM_NEG_REPLY	0x002D
#define OCF_USER_PASSKEY_REPLY		0x002E
#define OCF_USER_PASSKEY_NEG_REPLY	0x002F
#define OCF_REMOTE_OOB_DATA_REPLY	0x0030
#define OCF_REMOTE_OOB_DATA_NEG_REPLY	0x0033
#define OCF_IO_CAPABILITY_NEG_REPLY	0x0034

/* Link Policy */
#define OGF_LINK_POLICY		0x02
#define OCF_HOLD_MODE			0x0001
#define OCF_SNIFF_MODE			0x0003
#define OCF_EXIT_SNIFF_MODE		0x0004
#define OCF_PARK_MODE			0x0005
#define OCF_EXIT_PARK_MODE		0x0006
#define OCF_QOS_SETUP			0x0007
#define OCF_ROLE_DISCOVERY		0x0009
#define OCF_SWITCH_ROLE			0x000B
#define OCF_READ_LINK_POLICY		0x000C
#define OCF_WRITE_LINK_POLICY		0x000D
#define OCF_READ_DEFAULT_LINK_POLICY	0x000E
#define OCF_WRITE_DEFAULT_LINK_POLICY	0x000F
#define OCF_FLOW_SPECIFICATION		0x0010
#define OCF_SNIFF_SUBRATING		0x0011

/* Host Controller and Baseband */
#define OGF_HOST_CTL		0x03
#define OCF_SET_EVENT_MASK		0x0001
#define OCF_RESET			0x0003
#define OCF_SET_EVENT_FLT		0x0005
#define OCF_FLUSH			0x0008
#define OCF_READ_PIN_TYPE		0x0009
#define OCF_WRITE_PIN_TYPE		0x000A
#define OCF_CREATE_NEW_UNIT_KEY		0x000B
#define OCF_READ_STORED_LINK_KEY	0x000D
#define OCF_WRITE_STORED_LINK_KEY	0x0011
#define OCF_DELETE_STORED_LINK_KEY	0x0012
#define OCF_CHANGE_LOCAL_NAME		0x0013
#define OCF_READ_LOCAL_NAME		0x0014
#define OCF_READ_CONN_ACCEPT_TIMEOUT	0x0015
#define OCF_WRITE_CONN_ACCEPT_TIMEOUT	0x0016
#define OCF_READ_PAGE_TIMEOUT		0x0017
#define OCF_WRITE_PAGE_TIMEOUT		0x0018
#define OCF_READ_SCAN_ENABLE		0x0019
#define OCF_WRITE_SCAN_ENABLE		0x001A
#define OCF_READ_PAGE_ACTIVITY		0x001B
#define OCF_WRITE_PAGE_ACTIVITY		0x001C
#define OCF_READ_INQ_ACTIVITY		0x001D
#define OCF_WRITE_INQ_ACTIVITY		0x001E
#define OCF_READ_AUTH_ENABLE		0x001F
#define OCF_WRITE_AUTH_ENABLE		0x0020
#define OCF_READ_ENCRYPT_MODE		0x0021
#define OCF_WRITE_ENCRYPT_MODE		0x0022
#define OCF_READ_CLASS_OF_DEV		0x0023
#define OCF_WRITE_CLASS_OF_DEV		0x0024
#define OCF_READ_VOICE_SETTING		0x0025
#define OCF_WRITE_VOICE_SETTING		0x0026
#define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT	0x0027
#define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT	0x0028
#define OCF_READ_NUM_BROADCAST_RETRANS	0x0029
#define OCF_WRITE_NUM_BROADCAST_RETRANS	0x002A
#define OCF_READ_HOLD_MODE_ACTIVITY	0x002B
#define OCF_WRITE_HOLD_MODE_ACTIVITY	0x002C
#define OCF_READ_TRANSMIT_POWER_LEVEL	0x002D
#define OCF_READ_SYNC_FLOW_ENABLE	0x002E
#define OCF_WRITE_SYNC_FLOW_ENABLE	0x002F
#define OCF_SET_CONTROLLER_TO_HOST_FC	0x0031
#define OCF_HOST_BUFFER_SIZE		0x0033
#define OCF_HOST_NUM_COMP_PKTS		0x0035
#define OCF_READ_LINK_SUPERVISION_TIMEOUT	0x0036
#define OCF_WRITE_LINK_SUPERVISION_TIMEOUT	0x0037
#define OCF_READ_NUM_SUPPORTED_IAC	0x0038
#define OCF_READ_CURRENT_IAC_LAP	0x0039
#define OCF_WRITE_CURRENT_IAC_LAP	0x003A
#define OCF_READ_PAGE_SCAN_PERIOD_MODE	0x003B
#define OCF_WRITE_PAGE_SCAN_PERIOD_MODE	0x003C
#define OCF_READ_PAGE_SCAN_MODE		0x003D
#define OCF_WRITE_PAGE_SCAN_MODE	0x003E
#define OCF_SET_AFH_CLASSIFICATION	0x003F
#define OCF_READ_INQUIRY_SCAN_TYPE	0x0042
#define OCF_WRITE_INQUIRY_SCAN_TYPE	0x0043
#define OCF_READ_INQUIRY_MODE		0x0044
#define OCF_WRITE_INQUIRY_MODE		0x0045
#define OCF_READ_PAGE_SCAN_TYPE		0x0046
#define OCF_WRITE_PAGE_SCAN_TYPE	0x0047
#define OCF_READ_AFH_MODE		0x0048
#define OCF_WRITE_AFH_MODE		0x0049
#define OCF_READ_EXT_INQUIRY_RESPONSE	0x0051
#define OCF_WRITE_EXT_INQUIRY_RESPONSE	0x0052
#define OCF_REFRESH_ENCRYPTION_KEY	0x0053
#define OCF_READ_SIMPLE_PAIRING_MODE	0x0055
#define OCF_WRITE_SIMPLE_PAIRING_MODE	0x0056
#define OCF_READ_LOCAL_OOB_DATA		0x0057
#define OCF_READ_INQUIRY_TRANSMIT_POWER_LEVEL	0x0058
#define OCF_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL	0x0059
#define OCF_READ_DEFAULT_ERROR_DATA_REPORTING	0x005A
#define OCF_WRITE_DEFAULT_ERROR_DATA_REPORTING	0x005B
#define OCF_ENHANCED_FLUSH		0x005F
#define OCF_SEND_KEYPRESS_NOTIFY	0x0060

/* Informational Parameters */
#define OGF_INFO_PARAM		0x04
#define OCF_READ_LOCAL_VERSION		0x0001
#define OCF_READ_LOCAL_COMMANDS		0x0002
#define OCF_READ_LOCAL_FEATURES		0x0003
#define OCF_READ_LOCAL_EXT_FEATURES	0x0004
#define OCF_READ_BUFFER_SIZE		0x0005
#define OCF_READ_COUNTRY_CODE		0x0007
#define OCF_READ_BD_ADDR		0x0009

/* Status params */
#define OGF_STATUS_PARAM	0x05
#define OCF_READ_FAILED_CONTACT_COUNTER		0x0001
#define OCF_RESET_FAILED_CONTACT_COUNTER	0x0002
#define OCF_READ_LINK_QUALITY		0x0003
#define OCF_READ_RSSI			0x0005
#define OCF_READ_AFH_MAP		0x0006
#define OCF_READ_CLOCK			0x0007

/* Testing commands */
#define OGF_TESTING_CMD		0x06
#define OCF_READ_LOOPBACK_MODE			0x0001
#define OCF_WRITE_LOOPBACK_MODE			0x0002
#define OCF_ENABLE_DEVICE_UNDER_TEST_MODE	0x0003
#define OCF_WRITE_SIMPLE_PAIRING_DEBUG_MODE	0x0004

/* Vendor specific commands */
#define OGF_VENDOR_CMD		0x3f


/* ---- HCI Events ---- */

#define EVT_INQUIRY_COMPLETE		0x01
#define EVT_INQUIRY_RESULT		0x02
#define EVT_CONN_COMPLETE		0x03
#define EVT_CONN_REQUEST		0x04
#define EVT_DISCONN_COMPLETE		0x05
#define EVT_AUTH_COMPLETE		0x06
#define EVT_REMOTE_NAME_REQ_COMPLETE	0x07
#define EVT_ENCRYPT_CHANGE		0x08
#define EVT_CHANGE_CONN_LINK_KEY_COMPLETE	0x09
#define EVT_MASTER_LINK_KEY_COMPLETE		0x0A
#define EVT_READ_REMOTE_FEATURES_COMPLETE	0x0B
#define EVT_READ_REMOTE_VERSION_COMPLETE	0x0C
#define EVT_QOS_SETUP_COMPLETE		0x0D
#define EVT_CMD_COMPLETE 		0x0E
#define EVT_CMD_STATUS 			0x0F
#define EVT_HARDWARE_ERROR		0x10
#define EVT_FLUSH_OCCURRED		0x11
#define EVT_ROLE_CHANGE			0x12
#define EVT_NUM_COMP_PKTS		0x13
#define EVT_MODE_CHANGE			0x14
#define EVT_RETURN_LINK_KEYS		0x15
#define EVT_PIN_CODE_REQ		0x16
#define EVT_LINK_KEY_REQ		0x17
#define EVT_LINK_KEY_NOTIFY		0x18
#define EVT_LOOPBACK_COMMAND		0x19
#define EVT_DATA_BUFFER_OVERFLOW	0x1A
#define EVT_MAX_SLOTS_CHANGE		0x1B
#define EVT_READ_CLOCK_OFFSET_COMPLETE	0x1C
#define EVT_CONN_PTYPE_CHANGED		0x1D
#define EVT_QOS_VIOLATION		0x1E
#define EVT_PSCAN_REP_MODE_CHANGE	0x20
#define EVT_FLOW_SPEC_COMPLETE		0x21
#define EVT_INQUIRY_RESULT_WITH_RSSI	0x22
#define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE	0x23
#define EVT_SYNC_CONN_COMPLETE		0x2C
#define EVT_SYNC_CONN_CHANGED		0x2D
#define EVT_SNIFF_SUBRATING		0x2E
#define EVT_EXTENDED_INQUIRY_RESULT	0x2F
#define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE	0x30
#define EVT_IO_CAPABILITY_REQUEST	0x31
#define EVT_IO_CAPABILITY_RESPONSE	0x32
#define EVT_USER_CONFIRM_REQUEST	0x33
#define EVT_USER_PASSKEY_REQUEST	0x34
#define EVT_REMOTE_OOB_DATA_REQUEST	0x35
#define EVT_SIMPLE_PAIRING_COMPLETE	0x36
#define EVT_LINK_SUPERVISION_TIMEOUT_CHANGED	0x38
#define EVT_ENHANCED_FLUSH_COMPLETE	0x39
#define EVT_USER_PASSKEY_NOTIFY		0x3B
#define EVT_KEYPRESS_NOTIFY		0x3C
#define EVT_REMOTE_HOST_FEATURES_NOTIFY	0x3D

#define HCI_COMMAND_HDR_SIZE 3
#define HCI_EVENT_HDR_SIZE 3
#define HCI_ACL_HDR_SIZE 4
#define HCI_SCO_HDR_SIZE 3
#pragma pack(1)
/*PDU HDR*/
typedef struct
{
  uint16_t opcode;
  uint8_t para_total_len;
}HCI_Command_HDR_Format;

typedef struct
{
  uint8_t evecode;
  uint8_t para_total_len;
}HCI_Event_HDR_Format;

typedef struct {
  uint16_t handle;		/* Handle & Flags(PB, BC) */
  uint16_t dlen;
}HCI_ACL_HDR_Format;

typedef struct {
 uint16_t handle;
 uint8_t dlen;
}HCI_SCO_HDR_Format;

/*DEATIL COMMAND PDU FORMAT*/
/* Link Control */
typedef struct
{
  HCI_Command_HDR_Format HDR;
  uint8_t lap[3];
  uint8_t inquiry_time;
  uint8_t num_limit;
}COM_Inquiay_Format;

typedef struct
{
  HCI_Command_HDR_Format HDR;
  uint8_t BD_ADDR[6];
  uint16_t pkt_type;
  uint8_t pscan_rep_mode;
  uint8_t reserved;
  uint16_t clock_offset;
  uint8_t role_switch;
}COM_Create_Connect_Format;

typedef struct
{
  HCI_Command_HDR_Format HDR;
  uint16_t con_handle;
  uint8_t reason;
}COM_Disconnect_Format;
/* Link Policy */
/* Host Controller and Baseband */
typedef struct
{
  HCI_Command_HDR_Format HDR;
}COM_Reset_Format;

typedef struct 
{
  uint8_t status;
}Reset_rsp_Format;

typedef struct
{
  HCI_Command_HDR_Format HDR;
  uint8_t scan_enable;
}COM_Write_Scan_Enable_Format;

typedef struct 
{
  uint8_t status;
}Write_Scan_Enable_rsp_Format;
/* Informational Parameters */
typedef struct
{
  HCI_Command_HDR_Format HDR;
}COM_Read_Buffer_Size_Format;

typedef struct
{
  uint8_t status;
  uint16_t acl_mtu;
  uint8_t sco_mtu;
  uint16_t acl_max_pkt;
  uint16_t sco_max_pkt;
}Read_Buffer_Size_rsp_Format;

typedef struct
{
  HCI_Command_HDR_Format HDR;
}COM_Read_BD_ADDR_Format;

typedef struct
{
  uint8_t status;
  uint8_t BD_ADDR[6];
}Read_BD_ADDR_rsp_Format;
/* Status params */
/* Testing commands */
/* Vendor specific commands */
/* Vendor specific commands */

/*DEATIL EVENT PDU FORMAT*/
typedef struct {
  HCI_Event_HDR_Format HDR;
  uint8_t ncmd;
  uint16_t opcode;
}EVT_Com_Complete_HDR_Format;

typedef struct {
  HCI_Event_HDR_Format HDR;
  uint8_t status;
  uint8_t ncmd;
  uint16_t opcode;
}EVT_CMD_Status_Format;

typedef struct {
  HCI_Event_HDR_Format HDR;
  uint8_t ncmd;
  uint8_t bdaddr[6];
  uint8_t page_scan_mode;
  uint8_t reserved[2];
  uint8_t dev_class[3];
  uint16_t clock_offset;
}EVT_CMD_Inquiry_result_Format;

typedef struct {
  HCI_Event_HDR_Format HDR;
  uint8_t status;
  uint16_t con_handle;
  uint8_t bdaddr[6];
  uint8_t link_type;
  uint8_t encryption_enabled;
}EVT_CMD_Connect_complete_Format;

typedef struct {
  HCI_Event_HDR_Format HDR;
  uint8_t status;
  uint16_t con_handle;
  uint8_t reason;
}EVT_CMD_Disconnect_complete_Format;

typedef struct {
  HCI_Event_HDR_Format HDR;
  uint8_t status;
}EVT_CMD_Inquiry_complete_Format;


#pragma pack ()

/*HCI API*/
int hci_reset();
int hci_read_buffer_size();
int hci_write_scan_enable(uint8_t scan_enable);
int hci_read_bd_addr();
int hci_connect_req(uint8_t BD_ADDR[6],uint16_t pkt_type,uint8_t pscan_rep_mode,uint8_t allow_role_switch);
int hci_disconnect(uint16_t con_handle,uint8_t reason);
int hci_inquiry(uint8_t lap[3],uint8_t inquiry_time,uint8_t num_limit);
int hci_send_acl_data(uint16_t handle,uint8_t *acl_data,uint16_t acl_length);
int hci_send_cmd(uint8_t *PDU,uint32_t length);

int hci_receive_pdu(uint8_t *PDU,uint32_t length);
int hci_parse_cmd(uint8_t *PDU,uint32_t length);
int hci_parse_evt(uint8_t *PDU,uint32_t length);
int hci_parse_acl(uint8_t *PDU,uint32_t length);
int hci_parse_sco(uint8_t *PDU,uint32_t length);
int hci_parse_evt_complete(uint8_t *PDU,uint32_t length);
int hci_parse_evt_cmd_status(uint8_t *PDU,uint32_t length);
int hci_parse_evt_inquiry_result(uint8_t *PDU,uint32_t length);
int hci_parse_evt_inquiry_complete(uint8_t *PDU,uint32_t length);
int hci_parse_evt_connect_complete(uint8_t *PDU,uint32_t length);
int hci_parse_evt_disconnect_complete(uint8_t *PDU,uint32_t length);
int hci_parse_reset_rsp(uint8_t *PDU,uint32_t length);
int hci_parse_read_buffer_size_rsp(uint8_t *PDU,uint32_t length);
int hci_parse_write_scan_enable_rsp(uint8_t *PDU,uint32_t length);
int hci_parse_read_BD_ADDR_rsp(uint8_t *PDU,uint32_t length);
#endif

bt_hci.c

#include "bt_hci.h"

int hci_reset()
{
  COM_Reset_Format PDU;
  PDU.HDR.opcode = cmd_opcode_pack(OGF_HOST_CTL,OCF_RESET);
  PDU.HDR.para_total_len = sizeof(COM_Reset_Format) - HCI_COMMAND_HDR_SIZE;
  hci_send_cmd((uint8_t *)&PDU,sizeof(COM_Reset_Format));
}
int hci_read_buffer_size()
{
  COM_Read_Buffer_Size_Format PDU;
  PDU.HDR.opcode = cmd_opcode_pack(OGF_INFO_PARAM,OCF_READ_BUFFER_SIZE);
  PDU.HDR.para_total_len = sizeof(COM_Read_Buffer_Size_Format) - HCI_COMMAND_HDR_SIZE;
  hci_send_cmd((uint8_t *)&PDU,sizeof(COM_Read_Buffer_Size_Format));
}
int hci_write_scan_enable(uint8_t scan_enable)
{
  COM_Write_Scan_Enable_Format PDU;
  PDU.HDR.opcode = cmd_opcode_pack(OGF_HOST_CTL,OCF_WRITE_SCAN_ENABLE);
  PDU.HDR.para_total_len = sizeof(COM_Write_Scan_Enable_Format) - HCI_COMMAND_HDR_SIZE;
  PDU.scan_enable = scan_enable;
  hci_send_cmd((uint8_t *)&PDU,sizeof(COM_Write_Scan_Enable_Format));
}
int hci_read_bd_addr()
{
  COM_Read_BD_ADDR_Format PDU;
  PDU.HDR.opcode = cmd_opcode_pack(OGF_INFO_PARAM,OCF_READ_BD_ADDR);
  PDU.HDR.para_total_len = sizeof(COM_Read_BD_ADDR_Format) - HCI_COMMAND_HDR_SIZE;
  hci_send_cmd((uint8_t *)&PDU,sizeof(COM_Read_BD_ADDR_Format));
}
int hci_connect_req(uint8_t BD_ADDR[6],uint16_t pkt_type,uint8_t pscan_rep_mode,uint8_t allow_role_switch)
{
  COM_Create_Connect_Format PDU;
  PDU.HDR.opcode = cmd_opcode_pack(OGF_LINK_CTL,OCF_CREATE_CONN);
  PDU.HDR.para_total_len = sizeof(COM_Create_Connect_Format) - HCI_COMMAND_HDR_SIZE;
  memcpy(PDU.BD_ADDR,BD_ADDR,6);
  PDU.pkt_type = pkt_type;
  PDU.pscan_rep_mode = pscan_rep_mode;
  PDU.reserved = 0;
  PDU.clock_offset = 0;
  PDU.role_switch = allow_role_switch;
  hci_send_cmd((uint8_t *)&PDU,sizeof(COM_Create_Connect_Format)); 
}
int hci_disconnect(uint16_t con_handle,uint8_t reason)
{
  COM_Disconnect_Format PDU;
  PDU.HDR.opcode = cmd_opcode_pack(OGF_LINK_CTL,OCF_DISCONNECT);
  PDU.HDR.para_total_len = sizeof(COM_Disconnect_Format) - HCI_COMMAND_HDR_SIZE;
  PDU.con_handle = con_handle;
  PDU.reason = reason;
  hci_send_cmd((uint8_t *)&PDU,sizeof(COM_Disconnect_Format)); 
}
int hci_inquiry(uint8_t lap[3],uint8_t inquiry_time,uint8_t num_limit)
{
  COM_Inquiay_Format PDU;
  PDU.HDR.opcode = cmd_opcode_pack(OGF_LINK_CTL,OCF_INQUIRY);
  PDU.HDR.para_total_len = sizeof(COM_Inquiay_Format) - HCI_COMMAND_HDR_SIZE;
  memcpy(PDU.lap,lap,3);
  PDU.inquiry_time = inquiry_time;
  PDU.num_limit = num_limit;
  hci_send_cmd((uint8_t *)&PDU,sizeof(COM_Inquiay_Format));
}
int hci_send_acl_data(uint16_t handle,uint8_t *acl_data,uint16_t acl_length)
{
  
}
int hci_send_cmd(uint8_t *PDU,uint32_t length)
{
  int index = 0;
#if defined(TRANSPORT_UART)
  uint8_t HCI_PDU[length+1];
  HCI_PDU[0] = HCI_COMMAND_PKT;
  memcpy(HCI_PDU+1,PDU,length);
  
  BT_HCI_DEBUG((">> SEDN HCI COMMAND:"));
  for(index = 0;index < length+1;index++)
  {
    BT_HCI_DEBUG(("0x%x ",HCI_PDU[index]));
  }
  BT_HCI_DEBUG(("\n"));
  
  //NEED TO DO PASS THE DATA TO UART PORT
#elif defined(TRANSPORT_USB)
  //TODO
#elif defined(TRANSPORT_SDIO)
  //TODO
#endif
}

int hci_receive_pdu(uint8_t *PDU,uint32_t length)
{
#if defined(TRANSPORT_UART)
  uint8_t pck_type = *PDU;
  switch(pck_type)
  {
    case HCI_COMMAND_PKT:
    {
      BT_HCI_DEBUG(("<< COMMAND:"));
      hci_parse_cmd(PDU+1,length-1);
      break;
    }
    case HCI_ACLDATA_PKT:
    {
      BT_HCI_DEBUG(("<< ACL:"));
      hci_parse_acl(PDU+1,length-1);
      break;
    }
    case HCI_SCODATA_PKT:
    {
      BT_HCI_DEBUG(("<< SCO:"));
      hci_parse_sco(PDU+1,length-1);
      break;
    }
    case HCI_EVENT_PKT:
    {
      BT_HCI_DEBUG(("<< HCI_EVENT_PKT:"));
      hci_parse_evt(PDU+1,length-1);
      break;
    }
    default:
    {
      BT_HCI_DEBUG(("WARNING:UNKNOW PDU\n"));
      break;
    }
  }
#elif defined(TRANSPORT_USB)
    
  //TODO
#elif defined(TRANSPORT_SDIO)
  //TODO
#endif  
}

int hci_parse_cmd(uint8_t *PDU,uint32_t length)
{
  HCI_Command_HDR_Format *COM_PDU = (HCI_Command_HDR_Format *)PDU;
}
int hci_parse_evt(uint8_t *PDU,uint32_t length)
{
  HCI_Event_HDR_Format *EVT_PDU = (HCI_Event_HDR_Format *)PDU;
  switch(EVT_PDU->evecode)
  {
    case EVT_CMD_COMPLETE:
    {
      BT_HCI_DEBUG(("EVT_CMD_COMPLETE "));
      hci_parse_evt_complete(PDU,length);
      break;
    }
    case EVT_CMD_STATUS:
    {
      BT_HCI_DEBUG(("EVT_CMD_STATUS \n"));
      hci_parse_evt_cmd_status(PDU,length);
      break;
    }
    case EVT_INQUIRY_RESULT:
    {
      BT_HCI_DEBUG(("EVT_INQUIRY_RESULT"));
      hci_parse_evt_inquiry_result(PDU,length);
      break;
    }
    case EVT_INQUIRY_COMPLETE:
    {
      BT_HCI_DEBUG(("EVT_INQUIRY_COMPLETE"));
      hci_parse_evt_inquiry_complete(PDU,length);
      break;
    }
    case EVT_CONN_COMPLETE:
    {
      BT_HCI_DEBUG(("EVT_CONN_COMPLETE"));
      hci_parse_evt_connect_complete(PDU,length);
      break;
    }
    case EVT_DISCONN_COMPLETE:
    {
      BT_HCI_DEBUG(("EVT_DISCONN_COMPLETE"));
      hci_parse_evt_disconnect_complete(PDU,length);
      break;
    }
    default:
    {
      int index = 0;
      BT_HCI_DEBUG(("UNKNOW EVENT:"));
      for(index = 0;index < length;index++)
      {
	BT_HCI_DEBUG(("0x%02x ",PDU[index]));
      }
      BT_HCI_DEBUG(("\n"));
      break;
    }
  }
}
int hci_parse_acl(uint8_t *PDU,uint32_t length)
{
  HCI_ACL_HDR_Format *ACL_PDU = (HCI_ACL_HDR_Format *)PDU;
}
int hci_parse_sco(uint8_t *PDU,uint32_t length)
{
  HCI_SCO_HDR_Format *SCO_PDU = (HCI_SCO_HDR_Format *)PDU;
}
int hci_parse_evt_complete(uint8_t *PDU,uint32_t length)
{
  EVT_Com_Complete_HDR_Format *EVT_PDU = (EVT_Com_Complete_HDR_Format*)PDU;
  switch(cmd_opcode_ogf(EVT_PDU->opcode))
  {
    case OGF_LINK_CTL:
    {
      BT_HCI_DEBUG(("OGF_LINK_CTL\n"));
      break;
    }
    case OGF_LINK_POLICY:
    {
      BT_HCI_DEBUG(("OGF_LINK_POLICY\n"));
      break;
    }
    case OGF_HOST_CTL:
    {
      BT_HCI_DEBUG(("OGF_HOST_CTL\n"));
      switch(cmd_opcode_ocf(EVT_PDU->opcode))
      {
	case OCF_RESET:
	{
	  hci_parse_reset_rsp((uint8_t *)EVT_PDU+sizeof(EVT_Com_Complete_HDR_Format),length-sizeof(EVT_Com_Complete_HDR_Format));
	  break;
	}
	case OCF_WRITE_SCAN_ENABLE:
	{
	  hci_parse_write_scan_enable_rsp((uint8_t *)EVT_PDU+sizeof(EVT_Com_Complete_HDR_Format),length-sizeof(EVT_Com_Complete_HDR_Format));
	}
	default:
	{
	  break;
	}
      }
      break;
    }
    case OGF_INFO_PARAM:
    {
      BT_HCI_DEBUG(("OGF_INFO_PARAM\n"));
      switch(cmd_opcode_ocf(EVT_PDU->opcode))
      {
	case OCF_READ_BUFFER_SIZE:
	{
	  hci_parse_read_buffer_size_rsp((uint8_t *)EVT_PDU+sizeof(EVT_Com_Complete_HDR_Format),length-sizeof(EVT_Com_Complete_HDR_Format));
	  break;
	}
	case OCF_READ_BD_ADDR:
	{
	  hci_parse_read_BD_ADDR_rsp((uint8_t *)EVT_PDU+sizeof(EVT_Com_Complete_HDR_Format),length-sizeof(EVT_Com_Complete_HDR_Format));
	}
	default:
	{
	  break;
	}
      }
      break;
    }
    case OGF_STATUS_PARAM:
    {
      BT_HCI_DEBUG(("OGF_STATUS_PARAM\n"));
      break;
    }
    case OGF_TESTING_CMD:
    {
      BT_HCI_DEBUG(("OGF_TESTING_CMD\n"));
      break;
    }
    case OGF_VENDOR_CMD:
    {
      BT_HCI_DEBUG(("OGF_VENDOR_CMD\n"));
      break;
    }
    default:
    {
      break;
    }
  }
   
}
int hci_parse_evt_cmd_status(uint8_t *PDU,uint32_t length)
{
  EVT_CMD_Status_Format *EVT_PDU = (EVT_CMD_Status_Format*)PDU;
  
}
int hci_parse_evt_inquiry_result(uint8_t *PDU,uint32_t length)
{
  int index = 0;
  EVT_CMD_Inquiry_result_Format *EVT_PDU = (EVT_CMD_Inquiry_result_Format*)PDU;
  BT_HCI_DEBUG(("Inquiry rep num %d\n",EVT_PDU->ncmd));
  BT_HCI_DEBUG(("Inquiry ADDR:"));
  for(index = 0;index < 6;index++)
  {
    BT_HCI_DEBUG(("0x%02x ",EVT_PDU->bdaddr[index]));
  }
  BT_HCI_DEBUG(("\n"));
  BT_HCI_DEBUG(("Inquiry page_scan_mode %d\n",EVT_PDU->page_scan_mode));
  BT_HCI_DEBUG(("Inquiry COD:"));
  for(index = 0;index < 3;index++)
  {
    BT_HCI_DEBUG(("0x%02x ",EVT_PDU->dev_class[index]));
  }
  BT_HCI_DEBUG(("\n"));
  BT_HCI_DEBUG(("Inquiry clock_offset %d\n",EVT_PDU->clock_offset));
}
int hci_parse_evt_inquiry_complete(uint8_t *PDU,uint32_t length)
{
  EVT_CMD_Inquiry_complete_Format *EVT_PDU = (EVT_CMD_Inquiry_complete_Format *)PDU;
  BT_HCI_DEBUG(("status is %d\n",EVT_PDU->status));
}
int hci_parse_evt_connect_complete(uint8_t *PDU,uint32_t length)
{
  EVT_CMD_Connect_complete_Format *EVT_PDU = (EVT_CMD_Connect_complete_Format *)PDU;
  BT_HCI_DEBUG(("status is %d\n",EVT_PDU->status));
  BT_HCI_DEBUG(("con_handle is %d\n",EVT_PDU->con_handle));
  BT_HCI_DEBUG(("link_type is %d\n",EVT_PDU->link_type));
}
int hci_parse_evt_disconnect_complete(uint8_t *PDU,uint32_t length)
{
  EVT_CMD_Disconnect_complete_Format *EVT_PDU = (EVT_CMD_Disconnect_complete_Format *)PDU;
  BT_HCI_DEBUG(("status is %d\n",EVT_PDU->status));
  BT_HCI_DEBUG(("con_handle is %d\n",EVT_PDU->con_handle));
  BT_HCI_DEBUG(("reason is %d\n",EVT_PDU->reason));
}
int hci_parse_reset_rsp(uint8_t *PDU,uint32_t length)
{
  Reset_rsp_Format *RSP = (Reset_rsp_Format *)PDU;
  BT_HCI_DEBUG(("status is %d\n",RSP->status));
}
int hci_parse_read_buffer_size_rsp(uint8_t *PDU,uint32_t length)
{
  Read_Buffer_Size_rsp_Format *RSP = (Read_Buffer_Size_rsp_Format *)PDU;
  BT_HCI_DEBUG(("status is %d\n",RSP->status));
  BT_HCI_DEBUG(("acl_mtu is %d\n",RSP->acl_mtu));
  BT_HCI_DEBUG(("sco_mtu is %d\n",RSP->sco_mtu));
  BT_HCI_DEBUG(("acl_max_pkt is %d\n",RSP->acl_max_pkt));
  BT_HCI_DEBUG(("sco_max_pkt is %d\n",RSP->sco_max_pkt));
}
int hci_parse_write_scan_enable_rsp(uint8_t *PDU,uint32_t length)
{
  Write_Scan_Enable_rsp_Format *RSP = (Write_Scan_Enable_rsp_Format *)PDU;
  BT_HCI_DEBUG(("status is %d\n",RSP->status));
}
int hci_parse_read_BD_ADDR_rsp(uint8_t *PDU,uint32_t length)
{
  int index = 0;
  Read_BD_ADDR_rsp_Format *RSP = (Read_BD_ADDR_rsp_Format *)PDU;
  BT_HCI_DEBUG(("status is %d\n",RSP->status));
  BT_HCI_DEBUG(("ADDR:"));
  for(index = 0;index<6;index++)
  {
    BT_HCI_DEBUG(("0x%02x ",(RSP->BD_ADDR)[index]));
  }
  BT_HCI_DEBUG(("\n"));
}

bt_cfg.h

#ifndef BT_HCI_CFG_H
#define BT_HCI_CFG_H

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define DEBUG_BT_HCI

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;


//typedef  char int8_t;
typedef  short int16_t;
typedef  int int32_t;
typedef long long int64_t;

#undef NULL 
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif

#endif

main.c

#include <stdio.h>
#include "bt_hci.h"
#include "memory_pool.h"

void HDR_PAR_UNPAR_Test()
{
  uint16_t Reset_opcode_2 = 0x0c03; 
  uint16_t Read_Buffer_Size = 0x1005;
  uint16_t acl_header = 0x204d;
  uint16_t handle = 0x004d;
  uint8_t flag = ACL_START;
  
  printf("COMMAND HDR SIZE is %d\n",sizeof(HCI_Command_HDR_Format));
  printf("EVENT HDR SIZE is %d\n",sizeof(HCI_Event_HDR_Format));
  printf("ACL HDR SIZE is %d\n",sizeof(HCI_ACL_HDR_Format));
  printf("SCO HDR SIZE is %d\n",sizeof(HCI_SCO_HDR_Format));
  
  printf("OGF is %d\n",cmd_opcode_ogf(Read_Buffer_Size));
  printf("OCF is %d\n",cmd_opcode_ocf(Read_Buffer_Size));
  printf("Rset opcode is 0x%04x\n",cmd_opcode_pack(3,3));
  
  printf("HANDLE is 0x%04x\n",acl_get_handle(acl_header));
  printf("FLAG is %d\n",acl_get_flags(acl_header));
  printf("ACL HDR is 0x%04x\n",acl_handle_pack(handle,flag));
}
int main()
{
  BT_HCI_DEBUG(("HCI START\n"));
  uint8_t BD_ADDR[6] = {0x1,0x1,0x1,0x1,0x1,0x1};
  uint8_t inquiry_access[3] = {0x9e,0x8b,0x33};
  uint8_t receive_reset_complete_evt[7] = {0x4,0xe,0x4,0x1,0x3,0xc,0x0};
  uint8_t receive_read_buffer_size_complete_evt[14] = {0x4,0xe,0xb,0x1,0x5,0x10,0x0,0x80,0x01,0x40,0x04,0x00,0x08,0x00};
  uint8_t receive_write_scan_enable_complete_evt[7] = {0x4,0xe,0x4,0x1,0x1a,0xc,0x0};
  uint8_t receive_read_BD_ADDR_complete_evt[13] = {0x04,0x0e,0x0a,0x1,0x9,0x10,0x00,0x4e,0xa8,0x00,0x4e,0x49,0x4a};
  uint8_t receive_cmd_status_evt_inquiry[7] = {0x4,0xf,0x4,0x0,0x1,0x1,0x4};
  uint8_t receive_inquiry_result_evt[18] = {0x4,0x2,0xf,0x1,0x1,0x01,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x52,0x2e,0x0,0x0};
  uint8_t receive_inquiry_complete_evt[4] = {0x4,0x1,0x1,0x0};
  uint8_t receive_cmd_status_evt_connect[7] = {0x4,0xf,0x4,0x0,0x1,0x5,0x4};
  uint8_t receive_create_connect_complete_evt[14] = {0x4,0x3,0xb,0x0,0x29,0x0,0x5f,0x21,0xa3,0x60,0x10,0x0,0x1,0x0};
  uint8_t receive_cmd_status_evt_disconnect[7] = {0x4,0xf,0x4,0x0,0x1,0x6,0x4};
  uint8_t receive_cmd_disconnect_complete_evt[7] = {0x4,0x5,0x4,0x0,0x29,0x0,0x16};
  HDR_PAR_UNPAR_Test();
  
  /*HCI TEST*/
  hci_reset();
  hci_receive_pdu(receive_reset_complete_evt,sizeof(receive_reset_complete_evt));
  
  hci_read_buffer_size();
  hci_receive_pdu(receive_read_buffer_size_complete_evt,sizeof(receive_read_buffer_size_complete_evt));
  
  hci_write_scan_enable(SCAN_INQUIRY|SCAN_PAGE);
  hci_receive_pdu(receive_write_scan_enable_complete_evt,sizeof(receive_write_scan_enable_complete_evt));
  
  hci_read_bd_addr();
  hci_receive_pdu(receive_read_BD_ADDR_complete_evt,sizeof(receive_read_BD_ADDR_complete_evt));
  
  hci_inquiry(inquiry_access,6,1);
  hci_receive_pdu(receive_cmd_status_evt_inquiry,sizeof(receive_cmd_status_evt_inquiry));
  hci_receive_pdu(receive_inquiry_result_evt,sizeof(receive_inquiry_result_evt));
  hci_receive_pdu(receive_inquiry_complete_evt,sizeof(receive_inquiry_complete_evt));
  
  hci_connect_req(BD_ADDR,HCI_DM5|HCI_DH5|HCI_DM3|HCI_DH3|HCI_DH1|HCI_DM1,0,0);
  hci_receive_pdu(receive_cmd_status_evt_connect,sizeof(receive_cmd_status_evt_connect));
  hci_receive_pdu(receive_create_connect_complete_evt,sizeof(receive_create_connect_complete_evt));
  
  hci_disconnect(0x0029,0x13);
  hci_receive_pdu(receive_cmd_status_evt_disconnect,sizeof(receive_cmd_status_evt_disconnect));
  hci_receive_pdu(receive_cmd_disconnect_complete_evt,sizeof(receive_cmd_disconnect_complete_evt));
}

makefile

objects = bt_hci.o main.o memory_pool.o
LMP : $(objects)
	cc $(objects) -o HCI
main.o : main.c 
bt_lmp.o : bt_hci.c bt_cfg.h bt_hci.h
memory_pool.o : memory_pool.h memory_pool.c 
clean :
	rm HCI $(objects)


专注于无线通信的蓬勃 朝气蓬勃——不积跬步 无以至千里, 不积小流 无以成江海
评论
  • 每日可见的315MHz和433MHz遥控模块,你能分清楚吗?众所周知,一套遥控设备主要由发射部分和接收部分组成,发射器可以将控制者的控制按键经过编码,调制到射频信号上面,然后经天线发射出无线信号。而接收器是将天线接收到的无线信号进行解码,从而得到与控制按键相对应的信号,然后再去控制相应的设备工作。当前,常见的遥控设备主要分为红外遥控与无线电遥控两大类,其主要区别为所采用的载波频率及其应用场景不一致。红外遥控设备所采用的射频信号频率一般为38kHz,通常应用在电视、投影仪等设备中;而无线电遥控设备
    华普微HOPERF 2025-01-06 15:29 127浏览
  • 彼得·德鲁克被誉为“现代管理学之父”,他的管理思想影响了无数企业和管理者。然而,关于他的书籍分类,一种流行的说法令人感到困惑:德鲁克一生写了39本书,其中15本是关于管理的,而其中“专门写工商企业或为企业管理者写的”只有两本——《为成果而管理》和《创新与企业家精神》。这样的表述广为流传,但深入探讨后却发现并不完全准确。让我们一起重新审视这一说法,解析其中的矛盾与根源,进而重新认识德鲁克的管理思想及其著作的真正价值。从《创新与企业家精神》看德鲁克的视角《创新与企业家精神》通常被认为是一本专为企业管
    优思学院 2025-01-06 12:03 119浏览
  • 随着市场需求不断的变化,各行各业对CPU的要求越来越高,特别是近几年流行的 AIOT,为了有更好的用户体验,CPU的算力就要求更高了。今天为大家推荐由米尔基于瑞芯微RK3576处理器推出的MYC-LR3576核心板及开发板。关于RK3576处理器国产CPU,是这些年的骄傲,华为手机全国产化,国人一片呼声,再也不用卡脖子了。RK3576处理器,就是一款由国产是厂商瑞芯微,今年第二季推出的全新通用型的高性能SOC芯片,这款CPU到底有多么的高性能,下面看看它的几个特性:8核心6 TOPS超强算力双千
    米尔电子嵌入式 2025-01-03 17:04 55浏览
  • 大模型的赋能是指利用大型机器学习模型(如深度学习模型)来增强或改进各种应用和服务。这种技术在许多领域都显示出了巨大的潜力,包括但不限于以下几个方面: 1. 企业服务:大模型可以用于构建智能客服系统、知识库问答系统等,提升企业的服务质量和运营效率。 2. 教育服务:在教育领域,大模型被应用于个性化学习、智能辅导、作业批改等,帮助教师减轻工作负担,提高教学质量。 3. 工业智能化:大模型有助于解决工业领域的复杂性和不确定性问题,尽管在认知能力方面尚未完全具备专家级的复杂决策能力。 4. 消费
    丙丁先生 2025-01-07 09:25 80浏览
  • 村田是目前全球量产硅电容的领先企业,其在2016年收购了法国IPDiA头部硅电容器公司,并于2023年6月宣布投资约100亿日元将硅电容产能提升两倍。以下内容主要来自村田官网信息整理,村田高密度硅电容器采用半导体MOS工艺开发,并使用3D结构来大幅增加电极表面,因此在给定的占位面积内增加了静电容量。村田的硅技术以嵌入非结晶基板的单片结构为基础(单层MIM和多层MIM—MIM是指金属 / 绝缘体/ 金属) 村田硅电容采用先进3D拓扑结构在100um内,使开发的有效静电容量面积相当于80个
    知白 2025-01-07 15:02 75浏览
  • 根据环洋市场咨询(Global Info Research)项目团队最新调研,预计2030年全球无人机锂电池产值达到2457百万美元,2024-2030年期间年复合增长率CAGR为9.6%。 无人机锂电池是无人机动力系统中存储并释放能量的部分。无人机使用的动力电池,大多数是锂聚合物电池,相较其他电池,锂聚合物电池具有较高的能量密度,较长寿命,同时也具有良好的放电特性和安全性。 全球无人机锂电池核心厂商有宁德新能源科技、欣旺达、鹏辉能源、深圳格瑞普和EaglePicher等,前五大厂商占有全球
    GIRtina 2025-01-07 11:02 71浏览
  •     为控制片内设备并且查询其工作状态,MCU内部总是有一组特殊功能寄存器(SFR,Special Function Register)。    使用Eclipse环境调试MCU程序时,可以利用 Peripheral Registers Viewer来查看SFR。这个小工具是怎样知道某个型号的MCU有怎样的寄存器定义呢?它使用一种描述性的文本文件——SVD文件。这个文件存储在下面红色字体的路径下。    例:南京沁恒  &n
    电子知识打边炉 2025-01-04 20:04 100浏览
  • 根据Global Info Research项目团队最新调研,预计2030年全球封闭式电机产值达到1425百万美元,2024-2030年期间年复合增长率CAGR为3.4%。 封闭式电机是一种电动机,其外壳设计为密闭结构,通常用于要求较高的防护等级的应用场合。封闭式电机可以有效防止外部灰尘、水分和其他污染物进入内部,从而保护电机的内部组件,延长其使用寿命。 环洋市场咨询机构出版的调研分析报告【全球封闭式电机行业总体规模、主要厂商及IPO上市调研报告,2025-2031】研究全球封闭式电机总体规
    GIRtina 2025-01-06 11:10 104浏览
  • PLC组态方式主要有三种,每种都有其独特的特点和适用场景。下面来简单说说: 1. 硬件组态   定义:硬件组态指的是选择适合的PLC型号、I/O模块、通信模块等硬件组件,并按照实际需求进行连接和配置。    灵活性:这种方式允许用户根据项目需求自由搭配硬件组件,具有较高的灵活性。    成本:可能需要额外的硬件购买成本,适用于对系统性能和扩展性有较高要求的场合。 2. 软件组态   定义:软件组态主要是通过PLC
    丙丁先生 2025-01-06 09:23 85浏览
  • 在智能家居领域中,Wi-Fi、蓝牙、Zigbee、Thread与Z-Wave等无线通信协议是构建短距物联局域网的关键手段,它们常在实际应用中交叉运用,以满足智能家居生态系统多样化的功能需求。然而,这些协议之间并未遵循统一的互通标准,缺乏直接的互操作性,在进行组网时需要引入额外的网关作为“翻译桥梁”,极大地增加了系统的复杂性。 同时,Apple HomeKit、SamSung SmartThings、Amazon Alexa、Google Home等主流智能家居平台为了提升市占率与消费者
    华普微HOPERF 2025-01-06 17:23 145浏览
  • 本文介绍Linux系统更换开机logo方法教程,通用RK3566、RK3568、RK3588、RK3576等开发板,触觉智能RK3562开发板演示,搭载4核A53处理器,主频高达2.0GHz;内置独立1Tops算力NPU,可应用于物联网网关、平板电脑、智能家居、教育电子、工业显示与控制等行业。制作图片开机logo图片制作注意事项(1)图片必须为bmp格式;(2)图片大小不能大于4MB;(3)BMP位深最大是32,建议设置为8;(4)图片名称为logo.bmp和logo_kernel.bmp;开机
    Industio_触觉智能 2025-01-06 10:43 87浏览
  • 这篇内容主要讨论三个基本问题,硅电容是什么,为什么要使用硅电容,如何正确使用硅电容?1.  硅电容是什么首先我们需要了解电容是什么?物理学上电容的概念指的是给定电位差下自由电荷的储藏量,记为C,单位是F,指的是容纳电荷的能力,C=εS/d=ε0εrS/4πkd(真空)=Q/U。百度百科上电容器的概念指的是两个相互靠近的导体,中间夹一层不导电的绝缘介质。通过观察电容本身的定义公式中可以看到,在各个变量中比较能够改变的就是εr,S和d,也就是介质的介电常数,金属板有效相对面积以及距离。当前
    知白 2025-01-06 12:04 173浏览
  • By Toradex 秦海1). 简介嵌入式平台设备基于Yocto Linux 在开发后期量产前期,为了安全以及提高启动速度等考虑,希望将 ARM 处理器平台的 Debug Console 输出关闭,本文就基于 NXP i.MX8MP ARM 处理器平台来演示相关流程。 本文所示例的平台来自于 Toradex Verdin i.MX8MP 嵌入式平台。  2. 准备a). Verdin i.MX8MP ARM核心版配合Dahlia载板并
    hai.qin_651820742 2025-01-07 14:52 45浏览
我要评论
0
点击右上角,分享到朋友圈 我知道啦
请使用浏览器分享功能 我知道啦