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个档位.我们的目的是直接用最高 ...
随机推荐
- 定时器实现方式之TimerTask、Timer
在未来某个指定的时间点或者经过一段时间延迟后执行某个事件,这时候就需要用到定时器了.定时器的实现方式有很多种,今天总结最简单的实现方式.java 1.3引入了定时器框架,用于在定时器上下文中控制线程的 ...
- ul li各属性设置
1. ul li删除前面的黑点:style=“list-style:none;” <ul style=“list-style:none;”> <li></li> & ...
- 排序算法Nb三人组-快速排序
核心思想: 将列表中第一个元素拿出来,放到一边,左右两个循环,左面的大于拿出来的数,就把他挪到右面, 右面的小于拿出来的数就把他放在左面,这是列表被第一个元素''分''为两个列表,在对两个列表进行同样 ...
- new Date(年-月)时间是8点
new Date('2018-02')获取的小时是8时解决new Date('2018-2')获取的小时是0时
- 【阿里云产品公测】OpenSearch初体验
OpenSearch是一个非常有意义的功能,对于很多数据量较大的站点, SF2< 如果搜索功能自己做的话,或者用数据库里的查询语句,首先效率低下,而且占用资源. ); <Le6 另 ...
- HTTP协议(持续更新)
http请求由三部分组成,分别是:请求行.消息报头.请求正文 HTTP(超文本传输协议)是一个基于请求与响应模式的.无状态的.应用层的协议,常基于TCP的连接方式,HTTP1.1版本中给出一种持续连接 ...
- C# GDI+ 利用 Rectangle GraphicsPath 判断 矩形或多边形 图形关系
最近在做一些简单的图像对比工作,总结了一些GDI+对象的使用方式,记录下来共享给大家使用. 判断Rectangl与多边形的关系 /// <summary> /// 是否包含输入范围 /// ...
- Data Flow ->> Source ->> Error Output ->> Error & Truncation: Ignore Failure, Redirect Now, Fail Component
Ignore Failure: 当该字段遇到错误时,字段值被设为NULL Redirect Now: 把该行输出到SSIS的Source组件的红色输出线,这时红色输出线应该连接一个可以接受结果集的组件 ...
- SQL计算上下两行某列的差
SELECT * FROM #TempHuDong SELECT * FROM #TempHuDong SELECT TOP 1 ABS(a.num -b.num) '差' FROM (select ...
- 【Leetcode】【Medium】Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...