BLE怎么添加一个带通知的特征值,初始化它是需要做哪些操作

2019-07-18 15:04发布

BLE怎么添加一个带通知的特征值,初始化它是需要做哪些操作

在SimpleBLEPeripheral的simpleGATTprofile中Characteristic4虽然没有读取权限但是在其被修改时会发送通知,使得Central设备能接收到Characteristic4的值。
于是自己仿写,扩展了这个simpleGATTprofile,扩增特征值表的长度,添加了一个新的特征值Characteristic6,UUID为0xfff6,其内容格式模仿Characteristic4,权限全部都是可写+可读。Characteristic4与其他特征值不同之处在于多了一个字段就是Characteristic 4 configuration,所以我的Characteristic6也自己添加了这个字段。其余函数读写函数进行相应的修改,Characteristic6的读写也都没有问题。但是唯独这通知的功能没有实现,即Characteristic6值改变了却不会通知Central,而预置的Characteristic4却没有问题。
我想应该是我的Characteristic 6 configuration的配置有问题请大家看一下问题出在什么地方
static gattCharCfg_t simpleProfileChar6Config[GATT_MAX_NUM_CONN];
// Characteristic 6 configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
(uint8 *)simpleProfileChar6Config
},
请问为什么我在SimpleProfile_SetParameter()设置Char6的case:后添加调用
GATTServApp_ProcessCharCfg( simpleProfileChar6Config, &simpleProfileChar6, FALSE,
simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),
INVALID_TASK_ID );
而Central端设备却没有收到通知呢?

我个人是认为是自己定义Characteristic 6 configuration的初始化有问题请问这个应该怎么初始化呢?我是不是漏了什么步骤?
我的初始化simpleProfileChar6Config就是在初始化simpleProfileChar4Config的同样位置后添加相同的内容,
在SimpleProfile_AddService()里的改变
// Initialize Client Characteristic Configuration attributes
GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar4Config );
GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar6Config );

在simpleProfile_HandleConnStatusCB()里的改变
GATTServApp_InitCharCfg( connHandle, simpleProfileChar4Config );
GATTServApp_InitCharCfg( connHandle, simpleProfileChar6Config );

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答
广电总局
1楼-- · 2019-07-18 15:23
characteristic 4 的 property 被设置成GATT_PROP_NOTIFY, 你的characteristic 6有相应的设置吗?

// Simple Profile Characteristic 4 Properties
static uint8 simpleProfileChar4Props = GATT_PROP_NOTIFY;

另外,notify是要被central 打开之后,pripheral才会发送数据过去,你有在central把characteristic 6的notify 给 enable起来吗?说具体点就是central通过write过程把simpleProfileChar6Config  写成0x0001.

一周热门 更多>