CC2541修改广播时间教程
时间:10-02
整理:3721RD
点击:
CC2541修改广播时间教程
转载,897503845@qq.com。主要介绍如何修改CC2541广播时间,举例实现广播60S后停止广播。
代码修改
1、修改成limit模式(SimpleBLEPeripheral.c中)
[cpp] view plain copy
#if defined ( CC2540_MINIDK )
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_LIMITED
#else
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_LIMITED//GAP_ADTYPE_FLAGS_GENERAL
#endif // defined ( CC2540_MINIDK )
2、修改广播时间(SimpleBLEPeripheral.c的SimpleBLEPeripheral_Init函数中添加)
[cpp] view plain copy
//修改limit模式下的广播时间
#define tgap_lim_adv_timeout 60 //60秒
GAP_SetParamValue(TGAP_LIM_ADV_TIMEOUT, tgap_lim_adv_timeout);
如果不做此修改,默认是3分钟。在如下处有说明:
[cpp] view plain copy
#define TGAP_LIM_ADV_TIMEOUT 1 //!< Maximum time to remain advertising, when in Limited Discoverable mode. In seconds (default