simpleBLEPeripheral例程,请问simpleProfile_ReadAttrCB函数会被自动调用么?
我的理解是只要SimpleProfile_SetParameter被调用到,simpleProfile_ReadAttrCB会自动执行一次,所以simpleBLEPeripheral例程中每5秒应该进一次SimpleProfile_SetParameter和simpleProfile_ReadAttrCB。
现在我测试是SimpleProfile_SetParameter可以进去,但simpleProfile_ReadAttrCB从来没进去过。请问TI大神,我应该改哪里呢?每个特征值的属性我没变过。急!
请帮忙说一下,万分感谢!
谁能帮帮忙?simpleProfile_ReadAttrCB进不去,芯片就不能向上位机发数据,卡在这里进行不下去了。
我使用的代码如下:
static void SimpleBLEPeripheral_performPeriodicTask(void)
{
#ifndef FEATURE_OAD
uint8_t valueToCopy;
// Call to retrieve the value of the third characteristic in the profile
if (SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &valueToCopy) == SUCCESS)
{
// Call to set that value of the fourth characteristic in the profile.
// Note that if notifications of the fourth characteristic have been
// enabled by a GATT client device, then a notification will be sent
// every time this function is called.
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
&valueToCopy);
}
SimpleProfile_SetParameter中的CHAR4:
case SIMPLEPROFILE_CHAR4:
if ( len == sizeof ( uint8 ) )
{
simpleProfileChar4 = *((uint8*)value);
// See if Notification has been enabled
GATTServApp_ProcessCharCfg( simpleProfileChar4Config, &simpleProfileChar4, FALSE,
simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),
INVALID_TASK_ID, simpleProfile_ReadAttrCB );
}
else
{
ret = bleInvalidRange;
}
break;
simpleProfile_ReadAttrCB我就不说怎么写的了。因为根本进不去。求教啊,我哪里写错了。还应该改哪里?
没有响应是因为需要和主机进行连接吧?
你好,
simpleProfile_ReadAttrCB和simpleProfile_WriteAttrCB都是被定义到simpleProfileCBs 函数里面,
/*********************************************************************
* PROFILE CALLBACKS
*/
// Simple Profile Service Callbacks
CONST gattServiceCBs_t simpleProfileCBs =
{
simpleProfile_ReadAttrCB, // Read callback function pointer
simpleProfile_WriteAttrCB, // Write callback function pointer
NULL // Authorization callback function pointer
};
在bStatus_t SimpleProfile_AddService( uint32 services )函数中有注册simpleProfileCBs 函数!
这个是在蓝牙初始化时调用过得函数。
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 );
}