/*********************************************************************
* @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. 6、springboot之根目录设置

    访问的时候用

  2. 深入浅出ConcurrentHashMap1.8

    转载:https://www.jianshu.com/p/c0642afe03e0 好文 关于文章中的疑问:为什么要构造一个反序链表,放在nextTable的i+n的位置上呢,在<深入分析Con ...

  3. php字符集转换

    PHP通过iconv将字符串从GBK转换为UTF8字符集. 1. iconv()介绍 iconv函数可以将一种已知的字符集文件转换成另一种已知的字符集文件.例如:从GB2312转换为UTF-8. ic ...

  4. Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Unable to load the mojo 'resources' (or one of its required components)

    1.异常提示: Description Resource Path Location Type Execution default-resources of goal org.apache.maven ...

  5. vue-cli脚手架之其他文件解释

    好了,脚手架目录中重要的文件基本都介绍了,但还有一个不太注意到的文件没有解释,这里也说明一下. config文件夹下的index.js,作用是不同开发环境下的参数配置(可选项很多,生产环境.开发环境. ...

  6. ASICS各跑鞋分类及选购方法

    从跑吧转来的,老帖子后面的鞋子可能不能与时俱进 不过前面的方法不错. 1简介: ASICS鞋子鞋底如果有AHAR或AHAR+的为超耐磨标志,而且超耐度一般都是黑色,用指甲刮鞋底时如刮车轮底胶.ASIC ...

  7. Sass初入门

    什么是CSS预处理器? CSS预处理器定义了一种新的语言,其基本思想是,用一种专门的编程语言,为CSS增加了一些编程的特性,将CSS作为目标生成文件,然后开发者就只要使用这种语言进行编码工作.   什 ...

  8. webpack从零开始第1课:安装webpack和webpack-dev-server

    原文地址:https://segmentfault.com/a/1190000012536871 webpack目录 第1课: 安装webpack和webpack-dev-server 第2课: 配置 ...

  9. June 23rd 2017 Week 25th Friday

    Life doesn't get easier, you just get stronger. 生活从未变得轻松,是你在一点一点变得坚强. So in the same way we can get ...

  10. make menuconfig 出错解决

    问题: hank@hank-virtual-machine:/opt/Emb/linux-2.6.30.4$ sudo make menuconfig *** Unable to find the n ...