您好,我按照下面连接这种方式添加了一个类似于特征1的特征0xFFE6,不含通知属性,为什么在手机上还是只有5个特征值,就是在蓝牙CH579\EVT1\EXAM\BLE\Peripheral这个例程的基础上修改的。但是在手机上还是只有0XFFE1-oxffe5,不知道是为什么。
// Profile Parameters
#define SIMPLEPROFILE_CHAR1 0 // RW uint8 - Profile Characteristic 1 value
#define SIMPLEPROFILE_CHAR2 1 // RW uint8 - Profile Characteristic 2 value
#define SIMPLEPROFILE_CHAR3 2 // RW uint8 - Profile Characteristic 3 value
#define SIMPLEPROFILE_CHAR4 3 // RW uint8 - Profile Characteristic 4 value
#define SIMPLEPROFILE_CHAR5 4 // RW uint8 - Profile Characteristic 5 value
#define SIMPLEPROFILE_CHAR6 5 // RW uint8 - Profile Characteristic 6 value //GUA
// Simple Profile Service UUID
#define SIMPLEPROFILE_SERV_UUID 0xFFE0
// Key Pressed UUID
#define SIMPLEPROFILE_CHAR1_UUID 0xFFE1
#define SIMPLEPROFILE_CHAR2_UUID 0xFFE2
#define SIMPLEPROFILE_CHAR3_UUID 0xFFE3
#define SIMPLEPROFILE_CHAR4_UUID 0xFFE4
#define SIMPLEPROFILE_CHAR5_UUID 0xFFE5
#define SIMPLEPROFILE_CHAR6_UUID 0xFFE6 //GUA
// Simple Keys Profile Services bit fields
#define SIMPLEPROFILE_SERVICE 0x00000001
// Length of Characteristic 5 in bytes
#define SIMPLEPROFILE_CHAR5_LEN 5
// Length of Characteristic 6 in bytes
#define SIMPLEPROFILE_CHAR6_LEN 20 //GUA
/************************************************************************/
// Characteristic 6 UUID: 0xFFF6
CONST uint8 simpleProfilechar6UUID[ATT_BT_UUID_SIZE] =
{
LO_UINT16(SIMPLEPROFILE_CHAR6_UUID), HI_UINT16(SIMPLEPROFILE_CHAR6_UUID)
};
/**********************************************************************/
// Simple Profile Characteristic 6 Properties
static uint8 simpleProfileChar6Props = GATT_PROP_READ | GATT_PROP_WRITE | GATT_PROP_NOTIFY;
// Characteristic 6 Value
static uint8 simpleProfileChar6[SIMPLEPROFILE_CHAR6_LEN] = {0};
// Simple Profile Characteristic 6 Configuration Each client has its own
// instantiation of the Client Characteristic Configuration. Reads of the
// Client Characteristic Configuration only shows the configuration for
// that client and writes only affect the configuration of that client.
static gattCharCfg_t simpleProfileChar6Config[GATT_MAX_NUM_CONN];
// Simple Profile Characteristic 6 User Description
static uint8 simpleProfileChar6UserDesp[17] = "Characteristic 6\0";
/*********************************************************************/
// Characteristic 6 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar6Props
},
// Characteristic Value 6
{
{ ATT_BT_UUID_SIZE, simpleProfilechar6UUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
simpleProfileChar6
},
// Characteristic 6 configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
(uint8 *)simpleProfileChar6Config
},
// Characteristic 6 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar6UserDesp
},
/*******************************************************************/
case SIMPLEPROFILE_CHAR6:
if ( len == SIMPLEPROFILE_CHAR6_LEN )
{
VOID osal_memcpy( simpleProfileChar6, value, SIMPLEPROFILE_CHAR6_LEN );
}
else
{
ret = bleInvalidRange;
}
break;
/***************************************************************/
case SIMPLEPROFILE_CHAR6:
VOID osal_memcpy( value, simpleProfileChar6, SIMPLEPROFILE_CHAR6_LEN );
break;
/***************************************************************/
case SIMPLEPROFILE_CHAR6_UUID:
*pLen = SIMPLEPROFILE_CHAR6_LEN;
VOID osal_memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR6_LEN );
break;
/******************************************************************/
case SIMPLEPROFILE_CHAR6_UUID:
//Validate the value
// Make sure it's not a blob oper
if ( offset == 0 )
{
if ( len != SIMPLEPROFILE_CHAR6_LEN )
{
status = ATT_ERR_INVALID_VALUE_SIZE;
}
}
else
{
status = ATT_ERR_ATTR_NOT_LONG;
}
//Write the value
if ( status == SUCCESS )
{
VOID osal_memcpy( pAttr->pValue, pValue, SIMPLEPROFILE_CHAR6_LEN );
notifyApp = SIMPLEPROFILE_CHAR6;
}
break;
/*********************************************************************/
// Setup the SimpleProfile Characteristic Values
{
uint8 charValue1 = 1;
uint8 charValue2 = 2;
uint8 charValue3 = 3;
uint8 charValue4 = 4;
uint8 charValue5[SIMPLEPROFILE_CHAR5_LEN] = { 1, 2, 3, 4, 5 };
uint8 charValue6[SIMPLEPROFILE_CHAR6_LEN] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR1, sizeof ( uint8 ), &charValue1 );
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR2, sizeof ( uint8 ), &charValue2 );
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR3, sizeof ( uint8 ), &charValue3 );
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof ( uint8 ), &charValue4 );
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR5, SIMPLEPROFILE_CHAR5_LEN, charValue5 );
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR6, SIMPLEPROFILE_CHAR6_LEN, charValue6 );
}
/*************************************************************************/
//******************************************************************************
//name: simpleProfileChangeCB
//introduce: simple服务的回调函数
//parameter: paramID: 特征值ID
//return: none
//author: 甜甜的大香瓜
//email: 897503845@qq.com
//QQ group 香瓜BLE之CC2541(127442605)
//changetime: 2016.12.08
//******************************************************************************
static void simpleProfileChangeCB( uint8 paramID )
{
uint16 nGUA_ConnHandle;
uint8 nbGUA_Char6[20] = {0};
switch( paramID )
{
//char1
case SIMPLEPROFILE_CHAR1:
{
break;
}
//char3
case SIMPLEPROFILE_CHAR3:
{
break;
}
//char6
case SIMPLEPROFILE_CHAR6:
{
//获取连接句柄
GAPRole_GetParameter(GAPROLE_CONNHANDLE, &nGUA_ConnHandle);
//读取char6的数值
SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR6, &nbGUA_Char6);
//发送数据
GUA_SimpleGATTprofile_Char6_Notify(nGUA_ConnHandle, nbGUA_Char6, 20);
break;
}
default:
{
break;
}
}
}
/****************************************************************************/
就是按照上面这个步骤,模仿着在在官网wch.cn下载的例程测试Peripheral例程中修改的,但是不知道为什么在手机端搜索不到。
|