小蚂蚁~CC2640_开启关闭广播

CC26xx 开启关闭广播

Description

在很多应用开发中都需要开启关闭广播来实现:动态更新广播名字(可以通过广播名字存在flash中,复位芯片来实现,亦可以通过复位广播这中更人性化的方式来实现);定时广播(在超低功耗应用中会有此需求,广播频率会极大的降低,可能一小时广播一次,甚至更长);

API介绍

Set the GAP Role Parameters

GAPRole_setParameter(GAPROLE_ADVERT_ENABLED,sizeof(uint8_t), &initialAdvertEnable);

这条语句是在GAPROLE初始化时的参数设置,使能广播;

开启广播

uint8_t turnOnAdv = TRUE;     

GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED,sizeof(uint8_t), &turnOnAdv);

关闭广播

uint8_t turnOnAdv = FALSE;     

GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED,sizeof(uint8_t), &turnOnAdv);

一般在使用的时候,通常都是先关闭广播,然后更新参数,最后再次开启广播;

TI_Sample(TI 广播状态切换参考)

toggleAdvertising

static voidBloodPressure_toggleAdvertising(void)

{

 uint8_t advStatus;

 

  //Find the current GAP advertisement status.

 GAPRole_GetParameter(GAPROLE_ADVERT_ENABLED, &advStatus);

 

  //Get the opposite state.

 advStatus = !advStatus;

 

  //Change the GAP advertisement status to opposite of current status.

 GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),

                       &advStatus); 

}

 

 

你可能感兴趣的:(CC25XX_BLE)