peripheralStateNotificationCB
/*********************************************************************
* @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的更多相关文章
- simpleBLEPeripheral.c 文件分析
这个配置或者说任务, 让这个蓝牙设备成为了一个简单的BLE外设. 这里定义了外设的广播数据, 以及最重要, char被改变之后的回调, 引出后来的coreHandler里面的, ack 以及写e2pr ...
- 蓝牙(BLE)应用框架接口设计和应用开发——以TI CC2541为例
本文从功能需求的角度分析一般蓝牙BLE单芯片的应用框架(SDK Framework)的接口设计过程,并以TI CC2541为例说明BLE的应用开发方法. 一.应用框架(Framework) 我们熟知的 ...
- 用蓝牙芯片CC2541/CC2540实现一个智能恒温箱
最近突然想自己做一个智能小冰箱玩一玩,于是决定动手试一试. 成品效果图 原材料 半导体制冷片一只 散热风扇 12V电源一台 智能恒温箱电路板 控制板的PCB图 原理图 供电部分原理图 制冷片控制部分原 ...
- 6、CC2541修改按键调节广播发送功率例程为持续发送4DB的蓝牙基站
一.目的 在 OSAL操作系统-实验31 从机广播功率修改-(20141029更新).zip 基础上进行修改,该工程是通过5向按键的上下按键来控制广播功率的加减,总共有4个档位.我们的目的是直接用最高 ...
随机推荐
- Sqoop迁移Hadoop与RDBMS间的数据
Sqoop是用来实现结构型数据(如:关系型数据库RDBMS)和Hadoop之间进行数据迁移的工具.它充分利用了MapReduce的并行特点以批处理的方式加快数据的传输,同时也借助MapReduce实现 ...
- Linux From Scratch(从零开始构建Linux系统,简称LFS)(三)
九. 系统配置 1. 安装 LFS-Bootscripts-20150222 软件包包含一套在 LFS 系统启动和关闭时的启动和停止脚本. cd /sources tar -jxf lfs-boots ...
- window.onload和3的小游戏
window.onload出现的原因? 我们都知道页面的代码顺序是从上往下进行加载,很多时候我们要对页面中的某一个模块进行操作,这时候我们常常使用javascript代码来进行操作.为了能够保证操作 ...
- JavaEE之HttpServletRequest
HttpServletRequest //要下载的这个文件的类型--客户端会通过文件的MIME类型去区分类型 response.setContentType( getServletContext(). ...
- 00HTML
一.概述 超文本标记语言(Hyper Text Markup Language),HTML是一门描述性的语言.基本语法: <标签> 内容 </标签>** 在一个网页中,HTML ...
- mybatis支持的jdbc类型
参考mybatis的枚举JdbcType源码: 关于这些类型mybatis是如何处理可以看一下TypeHandler类的源码.
- 如何一次性下载某个类库依赖的所有jar包"
** 经常碰到这种事情: ** 在一些非maven工程中(由于某种原因这种工程还是手工添加依赖的),需要用到某个新的类库(假设这个类库发布在maven库中),而这个类库又间接依赖很多其他类库,如果依赖 ...
- 关于ios 10 的新的部分
编译器Xcode 8.2.1 SDK 10.2 1. 关于麦克风,相机,相册等部分的权限,需要在info.plist内进行设置,否则会出现crash.
- 如何避免在EF自动生成的model中的DataAnnotation被覆盖掉
摘自ASP.NET MVC 5 网站开发之美 6.4 Metadata与数据验证 如果使用Database-First方式生成*.edms,那么所生成的类文件会在*.tt文件的层级之下,扩展名tt是一 ...
- MYSQL连接相关参数和状态值详解
针对mysql的连接参数和状态值,本文做些介绍和对比 一.MYSQL连接参数变量 1.常用连接数限制参数 show variables like '%connect%'; | max_connect_ ...