This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540的主机只能在极短的时间内搜索到从机

Other Parts Discussed in Thread: CC2540

CC2540从机程序下载好后,主机只能在从机程序运行后的几秒中内搜索到从机,之后就再也搜索不到从机,这是怎么回事?

  • 下载的哪个例子? 没有广播就搜索不到。如下enable advertising.

     uint8 initial_advertising_enable = TRUE;

    // Set the GAP Role Parameters
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );

  • 抓包看下,是不是从机不在广播了

  • BLE实战:BLE温度计-基于温湿度传感器DHT11开发,就下载的这个例子,不过我把DHT11换成了DS18B20,并且修改了采集温度部分的代码。

  • 不知道这是什么例子。控制广播的就是我上面说的接口,你enable了就能搜索到,disable了就搜不到。

    向这种带传感器的例子,应该是刻意关闭了广播以省电。需要什么事件激活,你在代码里搜索上面的那个函数看看

  • // 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_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enable_update_request );
    GAPRole_SetParameter( GAPROLE_MIN_CONN_INTERVAL, sizeof( uint16 ), &desired_min_interval );
    GAPRole_SetParameter( GAPROLE_MAX_CONN_INTERVAL, sizeof( uint16 ), &desired_max_interval );
    GAPRole_SetParameter( GAPROLE_SLAVE_LATENCY, sizeof( uint16 ), &desired_slave_latency );
    GAPRole_SetParameter( GAPROLE_TIMEOUT_MULTIPLIER, sizeof( uint16 ), &desired_conn_timeout );