/*********************************************************************
* @fn peripheralStateNotificationCB 外围设备 状态 通知 回调函数
*
* @brief Notification from the profile of a state change. 通知来自于profile的状态改变!
*
* @param@param newState - new state 形参:新状态,类型是一个枚举变量
*
* @return@return none
*/
static void peripheralStateNotificationCB( gaprole_States_t newState )
{
#ifdef PLUS_BROADCASTER //暂时不知 不作任何处理,2016年12月16日15:14:51
static uint8 first_conn_flag = ;
#endif // PLUS_BROADCASTER switch ( newState )
{
case GAPROLE_STARTED: //GAP 任务 开始,但 并不广播 的状态
{
uint8 ownAddress[B_ADDR_LEN]; //定义一个 存放 设备 地址的 buffer
uint8 systemId[DEVINFO_SYSTEM_ID_LEN];//定义一个存放 设备ID buffer //GAP 任务获取 设备 地址放到 ownAddress 临时 buffer中 GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress); // use 6 bytes of device address for 8 bytes of system ID value
systemId[] = ownAddress[];
systemId[] = ownAddress[];
systemId[] = ownAddress[]; // set middle bytes to zero
systemId[] = 0x00;
systemId[] = 0x00; // shift three bytes up
systemId[] = ownAddress[];
systemId[] = ownAddress[];
systemId[] = ownAddress[]; //设备信息设置参数 系统ID 为 设备 地址的 前三个字节+00+后三个字节 DevInfo_SetParameter(DEVINFO_SYSTEM_ID, DEVINFO_SYSTEM_ID_LEN, systemId); #if (defined HAL_LCD) && (HAL_LCD == TRUE)
// Display device address
HalLcdWriteString( bdAddr2Str( ownAddress ), HAL_LCD_LINE_2 );
HalLcdWriteString( "Initialized", HAL_LCD_LINE_3 );
#endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
}
break; case GAPROLE_ADVERTISING://GAP 任务 开始广播 的状态
{
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
HalLcdWriteString( "Advertising", HAL_LCD_LINE_3 );
#endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
}
break; #ifdef PLUS_BROADCASTER //暂时不知 不作任何处理,2016年12月16日15:14:51
/* After a connection is dropped a device in PLUS_BROADCASTER will continue
* sending non-connectable advertisements and shall sending this change of
* state to the application. These are then disabled here so that sending
* connectable advertisements can resume.
*/
case GAPROLE_ADVERTISING_NONCONN:
{
uint8 advertEnabled = FALSE; // Disable non-connectable advertising.
GAPRole_SetParameter(GAPROLE_ADV_NONCONN_ENABLED, sizeof(uint8),
&advertEnabled); // Reset flag for next connection.
first_conn_flag = ;
}
break;
#endif //PLUS_BROADCASTER case GAPROLE_CONNECTED://GAP 任务 已经连接的状态
{
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
HalLcdWriteString( "Connected", HAL_LCD_LINE_3 );
#endif // (defined HAL_LCD) && (HAL_LCD == TRUE) #ifdef PLUS_BROADCASTER
// Only turn advertising on for this state when we first connect
// otherwise, when we go from connected_advertising back to this state
// we will be turning advertising back on.
if ( first_conn_flag == )
{
uint8 advertEnabled = FALSE; // Turn on Advertising // Disable connectable advertising.
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8),
&advertEnabled); // Set to true for non-connectabel advertising.
advertEnabled = TRUE; // Enable non-connectable advertising.
GAPRole_SetParameter(GAPROLE_ADV_NONCONN_ENABLED, sizeof(uint8),
&advertEnabled); first_conn_flag = ;
}
#endif // PLUS_BROADCASTER
}
break; case GAPROLE_CONNECTED_ADV://GAP 任务连接状态下 进行广播 的状态
{
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
HalLcdWriteString( "Connected Advertising", HAL_LCD_LINE_3 );
#endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
}
break;
case GAPROLE_WAITING://GAP 任务 等待进行 周期性广播的 状态
{
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
HalLcdWriteString( "Disconnected", HAL_LCD_LINE_3 );
#endif // (defined HAL_LCD) && (HAL_LCD == TRUE) #ifdef PLUS_BROADCASTER
uint8 advertEnabled = TRUE; // Enabled connectable advertising.
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8),
&advertEnabled);
#endif //PLUS_BROADCASTER
}
break; case GAPROLE_WAITING_AFTER_TIMEOUT://GAP 任务 处于连接超时状态, 等待 执行 进行 周期性广播的 状态
{
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
HalLcdWriteString( "Timed Out", HAL_LCD_LINE_3 );
#endif // (defined HAL_LCD) && (HAL_LCD == TRUE) #ifdef PLUS_BROADCASTER
// Reset flag for next connection.
first_conn_flag = ;
#endif //#ifdef (PLUS_BROADCASTER)
}
break; case GAPROLE_ERROR://GAP 任务处于 无效的状态,暂时不太理解,2016年12月16日15:18:39
{
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
HalLcdWriteString( "Error", HAL_LCD_LINE_3 );
#endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
}
break; default://传入的GAP 状态参数有错
{
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
HalLcdWriteString( "", HAL_LCD_LINE_3 );
#endif // (defined HAL_LCD) && (HAL_LCD == TRUE)
}
break; } gapProfileState = newState; #if !defined( CC2540_MINIDK )
VOID gapProfileState; // added to prevent compiler warning with 添加编译器 警告 事件
// "CC2540 Slave" configurations
#endif }

截图 比较好看一点:

peripheralStateNotificationCB的更多相关文章

  1. simpleBLEPeripheral.c 文件分析

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

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

    本文从功能需求的角度分析一般蓝牙BLE单芯片的应用框架(SDK Framework)的接口设计过程,并以TI CC2541为例说明BLE的应用开发方法. 一.应用框架(Framework) 我们熟知的 ...

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

    最近突然想自己做一个智能小冰箱玩一玩,于是决定动手试一试. 成品效果图 原材料 半导体制冷片一只 散热风扇 12V电源一台 智能恒温箱电路板 控制板的PCB图 原理图 供电部分原理图 制冷片控制部分原 ...

  4. 6、CC2541修改按键调节广播发送功率例程为持续发送4DB的蓝牙基站

    一.目的 在 OSAL操作系统-实验31 从机广播功率修改-(20141029更新).zip 基础上进行修改,该工程是通过5向按键的上下按键来控制广播功率的加减,总共有4个档位.我们的目的是直接用最高 ...

随机推荐

  1. Java String、string[]、List初始化方法

    String初始化: 1.String str = new String("string1"); 2.String str = "string1"; Strin ...

  2. 键盘录入(Java)

    键盘录入(Java): 1.导包 格式 import java.util.Scanner; 位置 在class上面 2.创建键盘录入对象 格式 Scanner sc = new Scanner(Sys ...

  3. IntelliJ IDEA 16创建Web项目

    首先要理解一个概念:在IntelliJ IDEA中“new Project”相当于eclipse中的工作空间(Workspace),而“new Module”相当于eclipse中的工程(Projec ...

  4. Android JazzyViewPager

    JazzyViewPager: package com.itau.jingdong.widgets.jazzviewpager; import java.util.HashMap; import ja ...

  5. Git学习-Git配置(一)

    零.前言 Git是一个工具,就没必要把时间浪费在那些"高级"但几乎永远不会用到的命令上.一旦你真的非用不可了,到时候再自行Google或者请教专家也未迟. 如果你是一个开发人员,想 ...

  6. HTML 5篇(持续更新)

    1.sessionStorage .localStorage 和 cookie 之间的区别 (一)共同点:都是保存在浏览器端,且同源的. (二)区别:cookie数据始终在同源的http请求中携带(即 ...

  7. canvas.addEventListener()

    对 canvas 元素的事件监听用addEventListener()实现, 但是有一点缺陷是:canvas 不支持键盘事件,为了解决这个问题,可以采用以下两种方案: 方案一: key event - ...

  8. javascript面向对象的写法02

    面向对象特性的初步实现 1.封装 利用作用域封装变量 作用域的概念是一样的,for语句,if语句等这些作用域内定义的变量只能作用域内访问,函数内定义的变量只能函数内访问. function Class ...

  9. DevExpress中 TreeList控件的常规配置

    //以下为TreeList控件样式相关设置 this.treelist_SystemCfg.BackColor = Color.Transparent; this.treelist_SystemCfg ...

  10. sql server——子查询

    简述: 在查询语句中包含着有另外一条查询语句,被包含的查询语句称为子查询,包含着子查询的查询就称为父查询. 总之,子查询就是在查询语句里嵌套一条或者多条查询语句. 常用子查询分类: 一.独立子查询 特 ...