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.

当外设与手机连接后,可以监测到每次“连接事件”是成功还是失败吗?

Other Parts Discussed in Thread: CC2640R2F

当外设与手机连接后,可以监测到每次“连接事件”是成功还是失败吗?

因为我不想等到发生“连接超时”(例如20s)后才知道断线了,我想在每次“连接事件”后,闪烁一次绿灯表示连接事件OK,若闪烁一次红灯表示连接事件失败。

如何实现?

  • 基本上就是在processGapStateChangeEvt 裡面的case GAPROLE_CONNECTED:/case GAPROLE_WAITING:裡面處理
  • status_t GapInit_connect ( GAP_Peer_Addr_Types_t peerAddrType,
    uint8_t * pPeerAddress,
    uint8_t phys,
    uint16_t timeout
    )
    Initiate connection with the specified peer device

    Parameters
    peerAddrType peer device's address type.
    pPeerAddress peer device's address
    phys PHY to try making connection on: shall be one from GapInit_InitPhy_t.
    timeout If there is no chance to initiate a connection within timeout ms, this connect request will be canceled automatically. if timeout is 0, the initiator will keep trying to get a chance to make a connection until GapInit_cancelConnect is called.
    Returns
    SUCCESS
    bleNotReady
    bleInvalidRange
    bleMemAllocError
    bleAlreadyInRequestedMode
    当你timeout 设置为0时会立刻返回在processGapStateChangeEvt
  • 请问
    1. 这个 GapInit_connect () 函数在哪个c文件里面?
    2. 若按你说的把timeout设为0后,是不是当手机连接CC2640R2F后,按照约定的“连接时间”,CC2640R2F能将“连接事件”成功或失败的结果,通过某个回调函数通知用户程序吗?
  • 请提供你的芯片型号以及SDK版本。