ch579主机设置白名单

我在Central例程中调用LL_AddWhiteListDevice(PeerAddrDefType,PeerAddrDef);设置白名单,然后将DEFAULT_DISCOVERY_WHITE_LIST设置为TRUE。但是依旧可以扫描到其他Peripheral,还请大神指点。以下是相关代码:

void Central_Init( )

{

memset(&g_data_update_last, 0, sizeof(data_update_s));

memset(&g_data_update_new, 0, sizeof(data_update_s));

memset(&g_ble_protocol, 0, sizeof(ble_protocol_s));

memset(&g_one_line_data, 0, sizeof(g_one_line_data));

/** default 1 */

setIoDefault();

  centralTaskId = TMOS_ProcessEventRegister( Central_ProcessEvent );

  

  // Setup GAP

  GAP_SetParamValue( TGAP_DISC_SCAN, DEFAULT_SCAN_DURATION );

/// GAP_SetParamValue( TGAP_DISC_SCAN, 200 );

  GAP_SetParamValue( TGAP_CONN_EST_INT_MIN, DEFAULT_MIN_CONNECTION_INTERVAL );

  GAP_SetParamValue( TGAP_CONN_EST_INT_MAX, DEFAULT_MAX_CONNECTION_INTERVAL );

  GAP_SetParamValue( TGAP_CONN_EST_SUPERV_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT );

  

  // Setup the GAP Bond Manager

  {

    uint32 passkey = DEFAULT_PASSCODE;

    uint8 pairMode = DEFAULT_PAIRING_MODE;

    uint8 mitm = DEFAULT_MITM_MODE;

    uint8 ioCap = DEFAULT_IO_CAPABILITIES;

    uint8 bonding = DEFAULT_BONDING_MODE;

    

    GAPBondMgr_SetParameter( GAPBOND_CENT_DEFAULT_PASSCODE, sizeof( uint32 ), &passkey );

    GAPBondMgr_SetParameter( GAPBOND_CENT_PAIRING_MODE, sizeof( uint8 ), &pairMode );

    GAPBondMgr_SetParameter( GAPBOND_CENT_MITM_PROTECTION, sizeof( uint8 ), &mitm );

    GAPBondMgr_SetParameter( GAPBOND_CENT_IO_CAPABILITIES, sizeof( uint8 ), &ioCap );

    GAPBondMgr_SetParameter( GAPBOND_CENT_BONDING_ENABLED, sizeof( uint8 ), &bonding );

  }  

  // Initialize GATT Client

  GATT_InitClient();

  // Register to receive incoming ATT Indications/Notifications

  GATT_RegisterForInd( centralTaskId );

/** add whitelist */

    LL_ClearWhiteList();

    LL_AddWhiteListDevice(PeerAddrDefType,PeerAddrDef);


  // Setup a delayed profile startup

  tmos_set_event( centralTaskId, START_DEVICE_EVT );

}


你好,可以直接参考该博客的第三点,注意添加白名单后返回值的判断。

CH58x蓝牙白名单(BLE_WhiteList) - SweetTea_lllpc - 博客园 (cnblogs.com)


好的,多谢


只有登录才能回复,可以选择微信账号登录