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

一、我们设计要求需要从设备(Peripheral)与主设备(Central)先连接,如果超出距离之后,断开连接后,从设备(Peripheral)需要处于一个可连接的状态,而此状态是其他CC2540主设备通过GAPCentralRole_StartDiscovery()无法找到该从设备,前次已连接过的主设备(Central)可通过按键直接启动连接函数(GAPCentralRole_EstablishLink())和已存储的从设备信息 连接到从设备!请问这种方式能否实现?

二、CC2540从设备(Peripheral)使用什么函数获取已他配对的CC2540主设备(Central)的信息(地址)?

  • hi zhenhao liao,

    一. 让其他主设备找不到, 这个没法做到. 但是你可以用connectable direct advertising 的方式进行广播, 这种模式的广播是带对方地址的, 只允许这个地址的设备来连接, 其他设备不允许连接. 具体请看 peripheral.c 中的

    void GAPRole_Init( uint8 task_id ) 里面的 gapRole_AdvEventType = GAP_ADTYPE_ADV_IND, 试一下改成 GAP_ADTYPE_ADV_DIRECT_IND, 然后请根据需要设置相应参数. 具体位置在: uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events ) 里面  if ( events & START_ADVERTISING_EVT ) 下面.

    二. 连上后可以用 GAPRole_GetParameter(GAPROLE_CONN_BD_ADDR, ...)来获取对方地址.