sj15712795029 / bluetooth_stack Goto Github PK
View Code? Open in Web Editor NEW这是一个开源的双模蓝牙协议栈(bluetooth.stack)(btstack),可以运行在STM32,Linux.,包含HCI,L2CAP,SDP,RFCOMM,HFP,SPP,A2DP,AVRCP,AVDTP,AVCTP,OBEX,PBAP等协议,后续会继续维护,以达到商用的目的
这是一个开源的双模蓝牙协议栈(bluetooth.stack)(btstack),可以运行在STM32,Linux.,包含HCI,L2CAP,SDP,RFCOMM,HFP,SPP,A2DP,AVRCP,AVDTP,AVCTP,OBEX,PBAP等协议,后续会继续维护,以达到商用的目的
操作步骤:
默认BLE GAP Service中只有一个device name特性,于是我按照Battery Service添加了一个appearance。但是添加之后手机连接蓝牙显示GAP Service为空,也就是出错了。添加代码如下:
//------------------------bt_gatt.c--------------------------------------------------------
uint8_t gatt_gap_uuid[] = {BT_LE_U16_TO_ARRAY(BT_UUID_SERVCLASS_GAP_SERVER)};
uint8_t gatt_gap_characteristic[] = {GATT_CHAR_PROP_BIT_READ,BT_LE_U16_TO_ARRAY(GATT_GAP_NAME_HANDLE),BT_LE_U16_TO_ARRAY(GATT_UUID_GAP_DEVICE_NAME)};
uint8_t gatt_gap_icon_characteristic[] = {GATT_CHAR_PROP_BIT_READ,BT_LE_U16_TO_ARRAY(GATT_GAP_ICON_HANDLE),BT_LE_U16_TO_ARRAY(GATT_UUID_GAP_ICON)};
uint8_t gatt_gap_appearance[] = {0,0};
gatt_server_service_t gap_service[] =
{
{ GATT_GAP_SERVICE_HANDLE,GATT_UUID_PRI_SERVICE,
gatt_gap_uuid,sizeof(gatt_gap_uuid),GATT_PERM_READ,NULL},
{ GATT_GAP_CHARACTERISTIC_HANDLE,GATT_UUID_CHAR_DECLARE,
gatt_gap_characteristic,sizeof(gatt_gap_characteristic),GATT_PERM_READ,NULL},
{ GATT_GAP_NAME_HANDLE,GATT_UUID_GAP_DEVICE_NAME,
(uint8_t*)GATT_GAP_NAME,sizeof(GATT_GAP_NAME),GATT_PERM_READ,NULL},
{ GATT_GAP_ICON_CHARACTERISTIC_HANDLE,GATT_UUID_CHAR_DECLARE,
gatt_gap_icon_characteristic,sizeof(gatt_gap_icon_characteristic),GATT_PERM_READ,NULL},
{ GATT_GAP_ICON_HANDLE,GATT_UUID_GAP_ICON,
gatt_server_change,sizeof(gatt_server_change),GATT_PERM_READ,NULL},
};
err_t gatt_server_init(void)
{
gatt_server_add_pri_service(gap_service,GATT_GAP_SERVICE_HANDLE,GATT_GAP_ICON_HANDLE,sizeof(gap_service)/sizeof(gatt_server_service_t),BT_UUID_SERVCLASS_GAP_SERVER);
gatt_server_add_pri_service(gatt_service,GATT_SERVICE_HANLE,GATT_SRV_CHGD_CLIENT_CHARA_CONF_HANDLE,sizeof(gatt_service)/sizeof(gatt_server_service_t),BT_UUID_SERVCLASS_GATT_SERVER);
return BT_ERR_OK;
}
//--------------------------bt_config.h------------------------------------------------------
#define GATT_PRI_SERVICE_MAX_COUNT 15
#define GATT_BLE_MTU_SIZE 23
#define GATT_GAP_SERVICE_HANDLE 0x0001
#define GATT_GAP_CHARACTERISTIC_HANDLE 0x0002
#define GATT_GAP_NAME_HANDLE 0x0003
#define GATT_GAP_ICON_CHARACTERISTIC_HANDLE 0x0004
#define GATT_GAP_ICON_HANDLE 0x0005
#define GATT_SERVICE_HANLE 0x0006
#define GATT_SRV_CHGD_CHAR_HANDLE 0x0007
#define GATT_SERVICE_CHGD_HANLE 0x0008
#define GATT_SRV_CHGD_CLIENT_CHARA_CONF_HANDLE 0x0009
#define GATT_GAP_NAME BT_LOCAL_NAME
#define GATT_BAS_SERVICE_HANDLE 0x000A
#define GATT_BAS_CHARACTERISTIC_HANDLE 0x000B
#define GATT_BAS_LEVEL_HANDLE 0x000C
#define GATT_BAS_CLIENT_CHARA_CONF_HANDLE 0x000D
举例:
架设上层要发送超过HCI read buffer size event获取到的acl size
pcb->maxsize = *((uint16_t *)(((uint8_t *)p->payload)+1));
如何实现连接手机后,请求获取手机上的通话记录,联系人列表
void uart_bt_send(uint8_t buf, uint16_t len)
{
uint8_t index;
for (index = 0; index < len ; index++) {
/ Wait until the last send is complete, then send the data */
while (USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET);
USART_SendData(USART2, buf[index]);
}
while (USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET);
}
if len > 255, there will be a dead loop because index is uint8.
FrontLine / Ellisys 这两个软件的安装包谁可以发一下,谢谢。
Hello! 你好.
我最近在学习蓝牙协议栈SDP部分内容, 在和手机/耳机交互时, 发现A2DP下有一个AttributeID是0x0311, 我从官方文档中找不到对这个AttributeID的定义, 以及它在SDP发现服务中的具体作用?
您可以解答一下我这个疑惑吗?
btrfcomm.c 文件
rfcomm_input函数
1328行与1342行 对rfcommhdr.ctrl分支判断相同问题。
if(rfcommhdr.ctrl == RFCOMM_UIH)
{
if(pcb->cn == 0)
{
if(fcs != pcb->uih0_in_fcs) /* Check against the precalculated fcs /
{
//if(fcs8_crc_check(p, RFCOMM_UIHCRC_CHECK_LEN, fcs) != 0) {
/ Packet discarded due to failing frame check sequence /
BT_RFCOMM_TRACE_DEBUG("rfcomm_input: UIH packet discarded due to failing frame check sequence\n");
bt_pbuf_free(p);
return BT_ERR_OK;
}
}
}
else if(rfcommhdr.ctrl == RFCOMM_UIH)
{
if(fcs != pcb->uih_in_fcs) / Check against the precalculated fcs /
{
//if(fcs8_crc_check(p, RFCOMM_UIHCRC_CHECK_LEN, fcs) != 0) {
/ Packet discarded due to failing frame check sequence */
BT_RFCOMM_TRACE_DEBUG("rfcomm_input: UIH packet discarded due to failing frame check sequence\n");
bt_pbuf_free(p);
return BT_ERR_OK;
}
}
1.HCI host -> controller flow control
2.HCI controller -> host flow control
3.RFCOMM C/R bit的理清
4. BT_STOP内存回收
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.