关于 CC2540 Mini DK BLE 广播时间设置的问题
您好!
最近在熟悉 CC2540 BLE 的开发平台,手里的硬件是 CC2540 Mini DK 的板子,在学习 BLE KeyFob 例程代码的过程遇到如下问题。
例程的 peripheral.c 文件中,BLE 广播结束的时间设定为 30 秒, 文件定义为:#define DEFAULT_ADVERT_OFF_TIME 30000 // 30 seconds
但本人测试了一下, BLE 广播结束的时间实际为 3 分钟,试着改变该参数的数值,但是 BLE 广播结束的时间一直不变。
不知是本人哪里理解错了还是遗漏了什么,请各位帮忙回答一下这个问题。
也请各位指点一下,广播时间间隔设定在代码的那个位置?根据这个 http://www.deyisupport.com/question_answer/analog/wireless_connectivity/f/45/t/22810.aspx
的方法设定后, CC2540 Mini DK 板子上电 1 秒指示灯亮是 OK 的,但按下广播按键后,发现连广播指示灯不闪烁了,用 SmartRF Packet Sniffer 监听无广播包。
不知是否还要设定其它的地方?
非常感谢!
In keyfob code, the gapRole_AdvertOffTime is set to 0 in KeyFobApp_Init();
GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );
While Keyfob is set in limited discoverable mode
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_LIMITED
which will stop advertising after 180s by the following parameter
#define TGAP_LIM_ADV_TIMEOUT 1 //!< Maximum time to remain advertising, when in Limited Discoverable mode. In seconds (default 180 seconds)
you can change by :
GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, xxxxx );
In KeyFobApp_Init(); you will find code for setting the advertising interval
// Set advertising interval
{
uint16 advInt = DEFAULT_ADVERTISING_INTERVAL;
GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, advInt );
GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, advInt );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, advInt );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, advInt );
}
LED will turn off during sleep. the chip will go to sleep between advertising.
please find func HalLedEnterSleep( ) and HalLedExitSleep()and in file hal_led.c
Hi,jerry.
在cc2540的keyfobdemo.c代码里面,我可以看到的对我的DEFAULT_DISCOVERABLE_MODE的操作只有如下
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL
static uint8 advertData[] =
{
0x02, // length of first data structure (2 bytes excluding length byte)
GAP_ADTYPE_FLAGS, // AD Type = Flags
DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
// service UUID, to notify central devices what services are included
// in this peripheral
0x07, // length of second data structure (7 bytes excluding length byte)
GAP_ADTYPE_16BIT_MORE, // list of 16-bit UUID's available, but not complete list
LO_UINT16( LINK_LOSS_SERVICE_UUID ), // Link Loss Service (Proximity Profile)
HI_UINT16( LINK_LOSS_SERVICE_UUID ),
LO_UINT16( IMMEDIATE_ALERT_SERVICE_UUID ), // Immediate Alert Service (Proximity / Find Me Profile)
HI_UINT16( IMMEDIATE_ALERT_SERVICE_UUID ),
LO_UINT16( TX_PWR_LEVEL_SERVICE_UUID ), // Tx Power Level Service (Proximity Profile)
HI_UINT16( TX_PWR_LEVEL_SERVICE_UUID )
};
那么实际上cc2540是在哪里设定了是GAP_ADTYPE_FLAGS_GENERAL还是GAP_ADTYPE_FLAGS_LIMITED
我始终没有在程序中找到相关的语句
比如可以改变interval的语句
if( period_advertising_flag == 1 )
{
uint16 advInt=160;//DEFAULT_ADVERTISING_INTERVAL; //160 equals 100ms interval
GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MIN,advInt);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN,advInt);
GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MAX,advInt);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX,advInt);
}
希望得到解答