admin管理员组

文章数量:1550690

从机给主机发送数据有两种方式:
第一种:通过GATT_Notification()这个函数来通知主机。
第二种:通过GATTServApp_ProcessCharCfg()这个函数通知主机。

简介这两种方式,
一、GATT_Notification():
在从机代码中使用,由从机主动通知,且不需要主机发出请求和回应。
例如,在需要从机给主机发送数据的地方,直接使用这个函数即可。
void GUA_SimpleGATTprofile_Char1_Notify(uint16 nGUA_ConnHandle, uint8 *pGUA_Value, uint8 nGUA_Len)    
{    
    attHandleValueNoti_t  stGUA_Noti; 
    
    //填充数据  
    stGUA_Noti.handle = simpleProfileAttrTbl[3].handle; //读取notification对应的handle
    stGUA_Noti.len = nGUA_Len;   //数据长度 
    osal_memcpy(stGUA_Noti.value, pGUA_Value, nGUA_Len);  //赋值
      
    //发送数据  
    GATT_Notification(nGUA_ConnHandle, &stGUA_Noti, FALSE);    
}
注意:在这里函数GATT_Notification()直接把通知发送给主机,不管是否通知是否使能。即无论notify开关是否打开,从机都能把数据发送给主机。

二、GATTServApp_

本文标签: Notification