Git Product home page Git Product logo

sj15712795029 / bluetooth_stack Goto Github PK

View Code? Open in Web Editor NEW
319.0 19.0 145.0 44.54 MB

这是一个开源的双模蓝牙协议栈(bluetooth.stack)(btstack),可以运行在STM32,Linux.,包含HCI,L2CAP,SDP,RFCOMM,HFP,SPP,A2DP,AVRCP,AVDTP,AVCTP,OBEX,PBAP等协议,后续会继续维护,以达到商用的目的

C 98.82% HTML 0.74% Assembly 0.28% Batchfile 0.01% Makefile 0.01% C# 0.14% CSS 0.01% Python 0.01%
pbap avrcp l2cap hfp a2dp spp obex hci sdp rfcomm

bluetooth_stack's Issues

BLE GAP Service 添加多个特性出错

默认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层

  1. init code优化
  2. Command/event宏优化
  3. hci event input优化,把每个event拉出函数,防止函数过长,不易查看
  4. hci acl优化
  5. 函数static优化

high risk of dead loop in function "void uart_bt_send(uint8_t *buf, uint16_t len)"

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

FrontLine / Ellisys 这两个软件的安装包谁可以发一下,谢谢。

关于SDP AttributeID的问题

Hello! 你好.

我最近在学习蓝牙协议栈SDP部分内容, 在和手机/耳机交互时, 发现A2DP下有一个AttributeID是0x0311, 我从官方文档中找不到对这个AttributeID的定义, 以及它在SDP发现服务中的具体作用?

您可以解答一下我这个疑惑吗?

btrfcomm.c文件 ctrl字段解析分支问题

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;
}
}

TODO:

1.HCI host -> controller flow control
2.HCI controller -> host flow control
3.RFCOMM C/R bit的理清
4. BT_STOP内存回收

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.