CH579 CH573 CH582 开关蓝牙/BLE/RF

蓝牙/BLE/RF开启以后,为了降低功耗或者其他原因要关闭此功能,分几种情况

如果是设备模式,未被连接状态

只要关闭广播功能,无线模块就被关闭

     uint8_t  initial_advertising_enable = FALSE;// Set the GAP Role ParametersGAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initial_advertising_enable);//关闭广播包

如果是设备模式,已经被连接

需要先断开连接,然后关闭广播

复制代码
/*** @brief       Terminates the existing connection.  断开当前连接** @return      SUCCESS or bleIncorrectMode*/
extern bStatus_t GAPRole_TerminateLink( uint16_t connHandle );  //connHandle 需要断开的连接的handle值 
复制代码

以peripheral为例,connHandle 如下:

 

断开连接后再关闭广播

     uint8_t  initial_advertising_enable = FALSE;// Set the GAP Role ParametersGAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initial_advertising_enable);//关闭广播包

 

如果是RF模式的话,直接广播RF即可,如下:

复制代码
/*** @brief   shut down,stop tx/rx mode.** @param   None.** @return  0 - success.*/
extern bStatus_t RF_Shut( void );
复制代码