1 /*********************************************************************
2 * @fn performPeriodicTask 执行 周期 任务
3 *
4 * @brief Perform a periodic application task. This function gets
5 * called every five seconds as a result of the SBP_PERIODIC_EVT
6 * OSAL event. In this example, the value of the third
7 * characteristic in the SimpleGATTProfile service is retrieved
8 * from the profile, and then copied into the value of the
9 * the fourth characteristic.
10 *
11 * 执行周期性的应用任务,这个函数被调用(每隔五秒)作为 SBP_PERIODIC_EVT 的
12 * OSAL 事件。在这个案例中,第三个 特征值(characteristic)在SimpleGATTProfile
13 * 服务里被获取从 Profile里,并且这个值被复制到第四个特征值里!
14 *
15 * profile:描述了某个应用场景中设备有什么功能(执行什么工作)。在一个profile里会定义好角色。
16 * 角色会包含一个服务service或者多个service或者没有。profile一般定义两个角色,例如防丢器中定义了一个报告者和监视者。
17 *
18 * 2016年12月15日08:59:13,GXP
19 *
20 * @param none
21 *
22 * @return none
23 */
24 static void performPeriodicTask( void )
25 {
26 uint8 valueToCopy;
27 uint8 stat;
28
29 // Call to retrieve the value of the third characteristic in the profile
30 // 调用 获取第三个特征值在 profile里
31
32 /*
33 * GXP,NOTE,2016年12月15日10:36:28
34 *
35 * 这个函数第二个形参是一个空指针类型,通过取valueToCopy这个 局部变量的地址
36 * 这样就能在SimpleProfile_GetParameter这个函数里把 valueToCopy这个 局部变量
37 * 进行赋值。这个函数调用还返回了一个status,通过这个状态可以知道是否调用成功,
38 * 以及如果失败可以知道失败的原因。
39 */
40 stat = SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &valueToCopy);
41
42 if( stat == SUCCESS )
43 {
44 /*
45 * Call to set that value of the fourth characteristic in the profile. Note
46 * that if notifications of the fourth characteristic have been enabled by
47 * a GATT client device, then a notification will be sent every time this
48 * function is called.
49 */
50
51 /*
52 * 调用 设置 第四个特征值 在profile 里。
53 * 注意:第四个特征值已经被一个GATT客户端设备使能!
54 * 这种情况下,这个通知值(第四个特征值)将要被设置,每当这个函数被调用时!
55 */
56 SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint8), &valueToCopy);
57 }
58 }