GATT client characteristic configuration ->value 设置
如下图所示,为BTool 读取到的关于 client characteristic configuration 的值。 从我自己做的cc2650 demo 值切始终为0 。但其他的模块取得该值为[01:00]
问题:请问此值可以设定? 表示的意义? 如何去设置?
有懂的朋友解答一下,谢谢!
自顶
可以参考我个性签名档的博客地址,《CC2541之notify》、《CC2541之indicate》。
里面解释了你想知道的CCC(client characteristic configuration )。
你好,
因为你压根没设置notification的值
notification里面的值需要你自己去定义的:
软件设置如下所示:
第一在SimpleProfile_AddService函数里面高亮部分:
bStatus_t SimpleProfile_AddService( uint32 services )
{
uint8 status;
// Allocate Client Characteristic Configuration table
simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) *
linkDBNumConns );
if ( simpleProfileChar4Config == NULL )
{
return ( bleMemAllocError );
}
// Initialize Client Characteristic Configuration attributes
GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar4Config );
if ( services & SIMPLEPROFILE_SERVICE )
{
// Register GATT attribute list and CBs with GATT Server App
status = GATTServApp_RegisterService( simpleProfileAttrTbl,
GATT_NUM_ATTRS( simpleProfileAttrTbl ),
GATT_MAX_ENCRYPT_KEY_SIZE,
&simpleProfileCBs );
}
2在
bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )函数里面:
case SIMPLEPROFILE_CHAR4:
if ( len == sizeof ( uint8 ) )
{
simpleProfileChar4 = *((uint8*)value);
//One choice
// See if Notification has been enabled
GATTServApp_ProcessCharCfg( simpleProfileChar4Config, &simpleProfileChar4, FALSE,
simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),
// INVALID_TASK_ID, simpleProfile_ReadAttrCB );
// the other choice
dValue = GATTServApp_ReadCharCfg( notify_Handle, simpleProfileChar4Config );//读出CCC的值
static attHandleValueNoti_t pReport;
if ( dValue & GATT_CLIENT_CFG_NOTIFY ) //判断是否打开通知开关,打开了则发送数据
{
pReport.handle = simpleProfileAttrTbl[11].handle;
pReport.len = 1;
//osal_memcpy( pReport.pValue, &simpleProfileChar4, len); //数据
pReport.pValue[0] = simpleProfileChar4;
GATT_Notification( notify_Handle, &pReport, FALSE );
}
}
else
{
ret = bleInvalidRange;
}
break;