硬件平台:CC2541
软件环境:IAR for 8051 v8.20.2
协议栈版本:1.4.0
最近一个项目中,用了CC2541的广播模式(单一模式,不带从机或主机)。我是按照SimpleBLEBroadcaster的示例工程做的。
对广播数据的操作如下:
/* 关闭广播 */
ini
tial_advertising_enable = FALSE;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
/* 更新广播数据 */
GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );
/* 打开广播 */
initial_advertising_enable = TRUE;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
虽然advertData[ ]的数据改变了,但是实际广播出来的数据没有任何变化,后来更改为更新数据之后,10ms再打开广播,还是不起作用。请帮我查看一下问题所在。
下面贴出初始化部分的代码:
/* Setup the GAP Broadcaster Role Profile */
[
/* Device starts advertising upon initialization */
uint8 initial_advertising_enable = TRUE;
/* By setting this to zero, the device will go into the waiting state after
being discoverable for 30.72 second, and will not being advertising again
until the enabler is set back to TRUE */
uint16 gapRole_AdvertOffTime = 0;
uint8 advType = GAP_ADTYPE_ADV_SCAN_IND; // use scannable unidirected advertisements
/* Set the GAP Role Parameters */
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );
GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof( scanRspData ), scanRspData );
GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );
GAPRole_SetParameter( GAPROLE_ADV_EVENT_TYPE, sizeof( uint8 ), &advType );
]
/* 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 );
]
/* Setup a delayed profile startup */
osal_set_event( smartTag_TaskID, ST_START_DEVICE_EVT );