There is possible to set your CC254X be scanable when it is in connection. But, based on my test,the connecting would be sluggish if you modify the code as below steps:



  0. Check your BLE stack being 1.3.2 , if that is not, I apologize. if it is,  Backup the file :  TiBLEStackInstallationFolder\BLE-CC254x-1.3.2\Projects\ble\Profiles\Roles\peripheralBroadcaster.c.



 1. Substitute the file peripheral.c as  peripheralBroadcaster.c in your IAR project. That is, enable PLUS_BROADCASTER macro in preprocessor define, exclude peripheral.c, and include peripheralBroadcaster.c in your project.





Open the peripheralBroadcaster.c, it should be modified.



2. for line 45 : add the line :



    #include "hci_tl.h"

:
#include "hci.h"
#include "hci_tl.h"
#include "l2cap.h"
 

it is for passing compilation.



3. For line 641, change the line :

// Initialize the Profile Advertising and Connection Parameters
gapRole_profileRole = GAP_PROFILE_PERIPHERAL;

As :

#if(1)  //GAIGER
gapRole_profileRole = GAP_PROFILE_PERIPHERAL;
#else
gapRole_profileRole = (GAP_PROFILE_PERIPHERAL | GAP_PROFILE_BROADCASTER);
#endif

The peripheral could advertise now.





3. At the line 927 :

// Since gapRole_AdvertOffTime is set to 0, the device should not
// automatically become discoverable again after a period of time.
// Set enabler to FALSE; device will become discoverable again when
// this value gets set to TRUE
gapRole_AdvEnabled = FALSE;

Modify it as :

              // Since gapRole_AdvertOffTime is set to 0, the device should not
// automatically become discoverable again after a period of time.
// Set enabler to FALSE; device will become discoverable again when
// this value gets set to TRUE
#if(0) //GAIGER
gapRole_AdvEnabled = FALSE;
#else
osal_start_timerEx( gapRole_TaskID, START_ADVERTISING_EVT, 1000);
#endif

The device would keep advertising which it is connected.



4. For the line 937 :

  // Check whether update parameter request is enabled, and check the connection parameters
if ( ( gapRole_ParamUpdateEnable == TRUE ) &&
( (pPkt->connInterval < gapRole_MinConnInterval) ||
(pPkt->connInterval > gapRole_MaxConnInterval) ||
(pPkt->connLatency != gapRole_SlaveLatency) ||
(pPkt->connTimeout != gapRole_TimeoutMultiplier) ))
{
gapRole_SendUpdateParam( pPkt->connInterval, pPkt->connLatency );
} // Notify the Bond Manager to the connection
VOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr, pPkt->connectionHandle, GAP_PROFILE_PERIPHERAL );

There should be insert a line for resuming advertise after disconnection event occuring:

  // Check whether update parameter request is enabled, and check the connection parameters
if ( ( gapRole_ParamUpdateEnable == TRUE ) &&
( (pPkt->connInterval < gapRole_MinConnInterval) ||
(pPkt->connInterval > gapRole_MaxConnInterval) ||
(pPkt->connLatency != gapRole_SlaveLatency) ||
(pPkt->connTimeout != gapRole_TimeoutMultiplier) ))
{
gapRole_SendUpdateParam( pPkt->connInterval, pPkt->connLatency );
} #if(1) //GAIGER
VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );
#endif
// Notify the Bond Manager to the connection
VOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr, pPkt->connectionHandle, GAP_PROFILE_PERIPHERAL );

It is all, now the goal has been reached. Your cc 254x could keep advertising while it is on connection.



  I noet agagin, that would lead your peripheral be slow on connecting: it costs 5~8 seconds to discover services by using BLE scaner on my Sony Xperia Z3 compact, but for pure peripheral, it costs 1 second only at worst case.



  This method is refered from Texas  forum threads:



 https://e2e.ti.com/support/wireless_connectivity/f/538/t/197769



keyMatch=gaiger&tisearch=Search-CN-Everything">http://www.deyisupport.com/question_answer/wireless_connectivity/bluetooth/f/103/t/88540.aspx?

keyMatch=gaiger&tisearch=Search-CN-Everything

CC2540/CC2541 : Set the Peripheral Being Advertising while It is Being Connected的更多相关文章

  1. CC254x(cc2540/cc2541)的微信AirSync调试笔记

    一.前言 本尊自诩为IOT小能手,一直没涉足蓝牙实在说不过去.刚好上个月底的时候计划做个BLE设备,这阵子利用业余时间自学了BLE协议栈,了解了GATT,磕磕绊绊完成CC254x(cc2540/cc2 ...

  2. 蓝牙4.0BLE cc2540 cc2541 ios OAD课程(空中固件升级)[原版的,多图]

           蓝牙4.0BLE cc2540 cc2541 ios OAD课程(件) 为阿莫单片机论坛  www.AmoMcu.com 原创.仅仅公布于csdn博客, 如需转载,请注明出处,谢谢!   ...

  3. 蓝牙4.0BLE 手机控制 cc2540 CC2541 的串口透传功能已实现

           蓝牙4.0BLE 手机控制 cc2540 CC2541 的串口透传功能已实现        尽管蓝牙4.0 BLE芯片CC2540 是单芯片(即用户能够对它进行芯片级代码编写), 是80 ...

  4. cc2540 cc2541 开发板资料更新日志

    经过多次PCB打样和全面调试.已经完毕了cc2540 cc2541的开发板的批量贴片.硬件告一段落, 接下来是全面完好软件方面的工作.眼下已经针对没有开发经验的用户编写完毕0基础基础实验代码和教程.接 ...

  5. CC2540 / CC2541 竟然支持 Bluetooth BLE 5.0?

    CC2540 / CC2541 竟然支持 Bluetooth BLE 5.0? 无意中发现 CC2541 的 BLE 协议栈更新了. BLE-STACK is Bluetooth 5.0 qualif ...

  6. cc2540 cc2541 低功耗实測和总结-与注意事项 - 低功耗小于10uA

    CC2541 CC2540 实现超低功耗是很重要的: 我们来总结一下实现方法: 1,有定时器在跑时会一直跑在  PM2  电流在  300uA左右.    没有定时器跑后会到 PM3 , 电流会少于1 ...

  7. 2、利用蓝牙定位及姿态识别实现一个智能篮球场套件(二)——CC2540/CC2541基于广播的RSSI获得

    CC2541一拖多例程中RSSI获得是通过一个事件回调函数实现的,前提是需要连接上蓝牙设备. 这个对于多点定位来说是不可行的,由于主机搜索蓝牙设备过程中也能获得当前蓝牙设备的RSSI等信息,因此可基于 ...

  8. CC254x/CC2540/CC2541库函数速查(转)

    hci.h 转自:http://blog.csdn.net/xiaoleiacmer/article/details/44036607#t1 //分配内存,应用程序不应该调用这个函数. void *H ...

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

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

随机推荐

  1. Android Touch事件分发过程

    虽然网络上已经有非常多关于这个话题的优秀文章了,但还是写了这篇文章,主要还是为了加强自己的记忆吧,自己过一遍总比看别人的分析要深刻得多.那就走起吧. 简单演示样例 先看一个演示样例 : 布局文件 : ...

  2. java基础——transient

    今天在看struts1源代码的时候,发如今ActionForm中首先声明了两个transient类型的protected变量. 之前没有接触过该transient类型,所以就查了查. transien ...

  3. Log4J日志配置具体解释

    一.Log4j简单介绍 Log4j有三个基本的组件:Loggers(记录器),Appenders (输出源)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和日志以何种形式输出.综 ...

  4. 2016.03.04,英语,《Vocabulary Builder》Unit 04

    vor: 来自拉丁动词vorare,指to eat,-ivorous指吃某种食物的eater.carn肉,肉欲+vore吃→吃肉的:carnival狂欢节,谢肉节voracious a 狼吞虎咽的(v ...

  5. 0x11 栈

    这个不难吧,算是常识了..毕竟也是刷过USACO的人 对顶栈这东西前几天才遇到过,好像和在线求中位数那东西放一起了吧 单调栈倒是没什么...贴个代码算了.一开始有点蠢的每个位置算,后来发现出栈再算就行 ...

  6. centos6配置固定ip地址(选择桥接模式)

    1.配置ifcfg-eth0 vim /etc/sysconfig/network-scripts/ifcfg-eth0 首先把BOOTPROTO="dhcp"改成BOOTPROT ...

  7. 【刷题笔记】LeetCode 606. Construct String from Binary Tree

    题意 给一棵二叉树,把它转化为字符串返回.转化字符串的要求如下: 1.  null 直接转化为  () ;(这个要求其实有点误导人~) 2. 子节点用 () 包裹起来:(这是我自己根据例子添加的要求) ...

  8. linux服务器卸载本机默认安装的jdk

    1.      查看系统安装的版本情况: rpm -qa | grep jdk rpm -qa | grep gcj 2.      查看并删除 [root@iZ2zeedm3x12d8xb4g15a ...

  9. Re:从0开始的微服务架构--(二)快速快速体验微服务架构?--转

    原文地址:https://mp.weixin.qq.com/s/QO1QDQWnjHZp8EvGDrxZvw 这是专题的第二篇文章,看看如何搭建一个简单模式的微服务架构. 记得好久之前看到一个大牛说过 ...

  10. VS自动注释——GhostDoc

    直接上图片,使用步骤是按顺序来的: 安装就不多说了,直接下一步,下一步.直接讲讲如何自定义注释规则 软件下载链接:http://pan.baidu.com/s/1dF5TSel 密码:peuz 链接: ...