CC2640例程2
2015-11-14 23:14
375 查看
修改simpleBLEPeripheral,主要修改特性。例如需要一个特性可读可写做控制,另一个特性支持通知notification用来传输ADC值。基本上修改的部分就是如果自己添加服务特性需要添加的内容。
1、在哪修改? simpleGATTProfile.c文件实现了characteristic部分。
1.1 默认是有5个特性。开始变量申明部分有5个特性的UUID,可以注释掉235。
1.2、属性变量。每个特性都有句柄,权限,值和描述。下面显示了特性1的相关信息,同样注释掉235。
1.3 接下来是属性列表(attrtbl或者database)用来打包服务包含的所有特性。同样注释掉235部分。
1.4 设置参数和获取参数,在应用层用于设置或获取特性中的value。
1.5 在把235全部注释完后编译运行,会发现还是有几个多余的UUID。属性表的数量宏定义需要由17修改到最终的数量即可。app显示只有两个特性了。
1、在哪修改? simpleGATTProfile.c文件实现了characteristic部分。
1.1 默认是有5个特性。开始变量申明部分有5个特性的UUID,可以注释掉235。
/********************************************************************* * GLOBAL VARIABLES */ // Simple GATT Profile Service UUID: 0xFFF0 CONST uint8 simpleProfileServUUID[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID) }; // Characteristic 1 UUID: 0xFFF1 CONST uint8 simpleProfilechar1UUID[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_CHAR1_UUID), HI_UINT16(SIMPLEPROFILE_CHAR1_UUID) }; //// Characteristic 2 UUID: 0xFFF2 //CONST uint8 simpleProfilechar2UUID[ATT_BT_UUID_SIZE] = //{ // LO_UINT16(SIMPLEPROFILE_CHAR2_UUID), HI_UINT16(SIMPLEPROFILE_CHAR2_UUID) //}; // //// Characteristic 3 UUID: 0xFFF3 //CONST uint8 simpleProfilechar3UUID[ATT_BT_UUID_SIZE] = //{ // LO_UINT16(SIMPLEPROFILE_CHAR3_UUID), HI_UINT16(SIMPLEPROFILE_CHAR3_UUID) //}; // Characteristic 4 UUID: 0xFFF4 CONST uint8 simpleProfilechar4UUID[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_CHAR4_UUID), HI_UINT16(SIMPLEPROFILE_CHAR4_UUID) }; //// Characteristic 5 UUID: 0xFFF5 //CONST uint8 simpleProfilechar5UUID[ATT_BT_UUID_SIZE] = //{ // LO_UINT16(SIMPLEPROFILE_CHAR5_UUID), HI_UINT16(SIMPLEPROFILE_CHAR5_UUID) //};
1.2、属性变量。每个特性都有句柄,权限,值和描述。下面显示了特性1的相关信息,同样注释掉235。
/********************************************************************* * Profile Attributes - variables */ // Simple Profile Service attribute static CONST gattAttrType_t simpleProfileService = { ATT_BT_UUID_SIZE, simpleProfileServUUID }; // Simple Profile Characteristic 1 Properties static uint8 simpleProfileChar1Props = GATT_PROP_READ | GATT_PROP_WRITE; // Characteristic 1 Value static uint8 simpleProfileChar1 = 0; // Simple Profile Characteristic 1 User Description static uint8 simpleProfileChar1UserDesp[10] = "Control 1";
1.3 接下来是属性列表(attrtbl或者database)用来打包服务包含的所有特性。同样注释掉235部分。
static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] = { // Simple Profile Service { { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */ GATT_PERMIT_READ, /* permissions */ 0, /* handle */ (uint8 *)&simpleProfileService /* pValue */ }, // Characteristic 1 Declaration { { ATT_BT_UUID_SIZE, characterUUID }, GATT_PERMIT_READ, 0, &simpleProfileChar1Props },
1.4 设置参数和获取参数,在应用层用于设置或获取特性中的value。
bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value ) { bStatus_t ret = SUCCESS; switch ( param ) { case SIMPLEPROFILE_CHAR1: if ( len == sizeof ( uint8 ) ) { simpleProfileChar1 = *((uint8*)value); } else { ret = bleInvalidRange; } break;
1.5 在把235全部注释完后编译运行,会发现还是有几个多余的UUID。属性表的数量宏定义需要由17修改到最终的数量即可。app显示只有两个特性了。
gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED]
相关文章推荐
- phpize报cannot find autoconf
- 初学Android项目:开发电子市场<第一天>
- SIFT特征提取分析
- 面向对象S.O.L.I.D原则
- BC 62 (div.2) B
- range()和xrange()方法
- Swift语言的扩展与协议(接口)
- [Flux] Component / Views
- Xcode开发技巧之code snippets(代码片段)
- Spring MVC笔记
- Arduino与Android蓝牙通信笔记
- muduo的reactor模式基本实现
- nginx的rewrite伪静态配置机理笔记 , nginx 的一些内置变量
- U盘安装Kali 2.0 cd-rom无法挂载解决方法
- easyui datagrid 编辑状态时,为列添加文本改变事件
- java学习碰到死胡同了
- 银行实时支付系统是怎么躲过双十一这一坎的呢?
- SQL Server 大文件异地备份
- Button设置单框不显示
- APP中使用UI交互设计动效的三个好处