GATT_Notification vs. GATTServApp_ProcessCharCfg

A:Notification连接后,从机向主机发送的数据包,不需要主机确认收到,适合大量数据快速发送。
从机 Notification发送方式有两种,用户根据自身要求选择:
(1)调用GATT_Notification( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 authenticated );直接发送
(2)调用GATTServApp_ProcessCharCfg函数,这个函数内部最终会导致master那边调用一个read请求,回调到simpleProfile_ReadAttrCB()。用这个函数,只有master向Peripheral的Notification允许位写1,才能使能从机,从而调用GATT_Notification向主机发送Notification。

//声明attHandleValueNoti_t这个结构体
static attHandleValueNoti_t pReport ;
//存放handle
uint16 noti_cHandle; 
//读取notification对应的handle
pReport.handle = simpleProfileAttrTbl[11].handle;
//获取Connection Handle
GAPRole_GetParameter( GAPROLE_CONNHANDLE, &noti_cHandle);
pReport.len = 1;            //数据长度
pReport.value[0] = 0x03;    //赋值
GATT_Notification(noti_cHandle,&pReport,FALSE);
//!< Connection Handle. Read Only. Size is uint16.
#define GAPROLE_CONNHANDLE          0x30E 
//eg: 
GAPRole_GetParameter( GAPROLE_CONNHANDLE, &gapConnHandle );

simpleBLECentral
1、添加notification的接收
simpleBLECentralProcessGATTMsg()
类似
if ( ( pMsg->method == ATT_READ_RSP ) || ........)
添加
else if ( ( pMsg->method == ATT_HANDLE_VALUE_NOTI ) ||......)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值