在从机中进行如下设置,就可向主机发送数据。
static attHandleValueNoti_t pReport;
pReport.len = numBytes;
pReport.handle = 0x0035;
osal_memcpy(pReport.value, buf, numBytes);
GATT_Notification( 0, &pReport, FALSE );
在主机中使用GATT_RegisterForInd( simpleBLETaskId );注册ATT Indications/Notifications,然后在使用以下程序主机就可处理从机发来的数据
else if ( ( pMsg->method == ATT_HANDLE_VALUE_NOTI ) ) //通知
{
if( pMsg->msg.handleValueNoti.handle == 0x0035) //CHAR6的通知 串口打印
{
NPI_WriteTransport(pMsg->msg.handleValueNoti.value, pMsg->msg.handleValueNoti.len );
}
}
以上过程和Characteristic 6有什么关系?或者说二者在哪里建立了关系呢?
许多资料里都在讲主、从机之间是利用Characteristic Value进行信息交流的。那么对于Characteristic 的具体操作是什么样的流程呢?