SimpleProfile_GetParameter && SimpleProfile_SetParameter

 1 /*********************************************************************
 2  * @fn      SimpleProfile_GetParameter       简单 profile 得到参数
 3  *
 4  * @brief   Get a Simple Profile parameter.  得到一个简单的profile参数。
 5  *
 6  * @param   param - Profile parameter ID     形参param:profile的参数ID
 7  *
 8  * @param   value - pointer to data to put.  This is dependent on
 9  *          the parameter ID and WILL be cast to the appropriate
10  *          data type (example: data type of uint16 will be cast to
11  *          uint16 pointer).
12  *
13  *
14  *  形参value:是一个空指针参数,指向输出数据的指针,这个依赖于参数的ID
15  *  并且 将被转换成适当的参数类似,例如:数据类型uint16将被转换成uint16指针。
16  *
17  *  profile:描述了某个应用场景中设备有什么功能(执行什么工作)。在一个profile里会定义好角色。
18  *  角色会包含一个服务service或者多个service或者没有。profile一般定义两个角色,例如防丢器中定义了一个报告者和监视者。
19  *
20  *  2016年12月15日09:09:14,GXP
21  *
22  * @return  bStatus_t  BLE_STATUS_VALUES
23  */
24 bStatus_t SimpleProfile_GetParameter( uint8 param, void *value )
25 {
26   bStatus_t ret = SUCCESS;
27   switch ( param )
28   {
29     case SIMPLEPROFILE_CHAR1:
30       *((uint8*)value) = simpleProfileChar1;
31       break;
32
33     case SIMPLEPROFILE_CHAR2:
34       *((uint8*)value) = simpleProfileChar2;
35       break;
36
37     case SIMPLEPROFILE_CHAR3:
38       *((uint8*)value) = simpleProfileChar3;
39       break;
40
41     case SIMPLEPROFILE_CHAR4:
42       *((uint8*)value) = simpleProfileChar4;
43       break;
44
45     case SIMPLEPROFILE_CHAR5:
46       VOID memcpy( value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN );
47       break;
48
49     default:
50       ret = INVALIDPARAMETER;//无效的ID
51       break;
52   }
53
54   return ( ret ); //返回函数调用的状态 是成功了 ,还是因为ID无效失败了
55 }
bStatus_t 的值在宏定义处被解释为BLE_STATUS_VALUES,下面是BLE_STATUS_VALUES的值的含义:


 1 /** @defgroup BLE_STATUS_VALUES BLE Default BLE Status Values
 2  * returned as bStatus_t
 3  * @{
 4  */
 5 #define bleInvalidTaskID                INVALID_TASK  //!< Task ID isn‘t setup properly
 6 #define bleNotReady                     0x10  //!< Not ready to perform task
 7 #define bleAlreadyInRequestedMode       0x11  //!< Already performing that task
 8 #define bleIncorrectMode                0x12  //!< Not setup properly to perform that task
 9 #define bleMemAllocError                0x13  //!< Memory allocation error occurred
10 #define bleNotConnected                 0x14  //!< Can‘t perform function when not in a connection
11 #define bleNoResources                  0x15  //!< There are no resource available
12 #define blePending                      0x16  //!< Waiting
13 #define bleTimeout                      0x17  //!< Timed out performing function
14 #define bleInvalidRange                 0x18  //!< A parameter is out of range
15 #define bleLinkEncrypted                0x19  //!< The link is already encrypted
16 #define bleProcedureComplete            0x1A  //!< The Procedure is completed
17 #define bleInvalidMtuSize               0x1B  //!< MTU size is out of range

 SimpleProfile_SetParameter 和上面这个函数类似!

时间: 2024-08-24 23:31:53

SimpleProfile_GetParameter && SimpleProfile_SetParameter的相关文章

蓝牙(BLE)应用框架接口设计和应用开发——以TI CC2541为例

本文从功能需求的角度分析一般蓝牙BLE单芯片的应用框架(SDK Framework)的接口设计过程,并以TI CC2541为例说明BLE的应用开发方法. 一.应用框架(Framework) 我们熟知的Framework包括Android Framework.Linux QT.Windows MFC.应用框架抽象并封装实现了一般应用场景的需求,完成应用开发的80%,剩下的20%则以回调(callback)和接口的方式供应用开发人员调用以完成具体的需求. 一般Framework完成的工作包括:任务分

simpleBLEPeripheral.c 文件分析

这个配置或者说任务, 让这个蓝牙设备成为了一个简单的BLE外设. 这里定义了外设的广播数据, 以及最重要, char被改变之后的回调, 引出后来的coreHandler里面的, ack 以及写e2prom. /************************************************************************************************** **********************************************

【BLE】CC2541之indicate

本篇博文最后修改时间:2016年09月12日,03:34. 一.简介 本篇以SimpleBLEPeripheral为例,讲述如何在工程中使用indicate指示. 二.实验平台 协议栈版本:BLE-CC254x-1.4.0 编译软件:IAR 8.20.2 硬件平台:Smart RF开发板 三.版权声明 博主:甜甜的大香瓜 声明:喝水不忘挖井人,转载请注明出处. 原文地址:http://blog.csdn.net/feilusia 联系方式:[email protected] 香瓜BLE之CC25

用蓝牙芯片CC2541/CC2540实现一个智能恒温箱

最近突然想自己做一个智能小冰箱玩一玩,于是决定动手试一试. 成品效果图 原材料 半导体制冷片一只 散热风扇 12V电源一台 智能恒温箱电路板 控制板的PCB图 原理图 供电部分原理图 制冷片控制部分原理图 蜂鸣器原理图 温度传感器原理图 GITHUB地址 完整代码以及电路图我放在了GITHUB上,欢迎下载哦. https://github.com/dingbig/bluttooth_ice_box 控制部分源代码 1 /**************************************

选择从节点,数据通信部分代码

1 选择从节点,建立连接 1 if ( !simpleBLEScanning && simpleBLEScanRes > 0) 2 { 3 simpleBLEScanIdx++; 4 if ( simpleBLEScanIdx >= simpleBLEScanRes ) 5 { 6 simpleBLEScanIdx = 0; 7 } 8 uint8 addrType; 9 uint8 *peerAddr: 10 11 if ( simpleBLEScanRes > 0 )

BLE4.0之自定义服务(CC2541)

1.什么是服务 蓝牙通信中,我们就是需要对各个服务中的特征值进行交流,现在尝试自定义一个服务. 2.创建TEMProfile.c.TEMProfile.h 这是服务的主体文件. 其里面大致无非是定义特征值,创建读写值的函数,注册函数,增添服务函数,以及包装一些回调函数. 具体如下. (1)所有定义的变量其实都是和特征值相关的,具体详见上篇文章:http://www.cnblogs.com/asam/p/6535374.html (2)创建函数 需要创建的函数如下: 全局函数: extern bS

BLE4.0之新增特征值(CC2541)

注:(本文基于我自己定义的一个服务TEMProfile,但适用其他服务) 1.特征值是什么 一个蓝牙协议栈中,包含了多个服务,一个服务里又包含了多个特征值,每个特征值都有其相关的一些信息. 我们与蓝牙进行通信的时候,就是通过读写这些特征值,来获得数据. 2.特征值的属性 一个特征值里面基本需要的变量是-- 1.UUID码   2.权限属性 :基本就是 可读.可写.可通知这些了.(通知是表示允许数据主动发送) 3.内容 4.描述:这个特征值的名称 3.属性表 一个服务里,所有的特征值中的每个变量都

蓝牙BLE以太网网关在智能家居中的应用(基于W5500)

 已刊登至<无线电>六月刊 早在1994年爱立信公司就创立了蓝牙技术,并制定了基本的技术规范,原意是创造一种设备间通讯的标准化协议,以解决设备间通讯不兼容的情况,规范公布后得到大量移动设备制造商的支持,并于1999年成立蓝牙技术联盟(Bluetooth Special Interest Group),该联盟制定并维护蓝牙无线规范,并对设备制造厂商提供Bluetooth认证与授权. 当前影响最广的版本应该是蓝牙4.0,本标准中增加了Bluetooth Smart和Bluetooth Smar