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.

GAP_DEVICE_INFO_EVENT 处理

Expert 1254 points

按向上按键,central开始扫描,然后GAP_DEVICE_INFO_EVENT 产生,但是传进来的 pEvent->deviceInfo 中怎么没有 scanRspData 的数据?

  • Hi wei,

    应该会有.

    对应的结构体也可以处理scan 的数据. 但是代码中并没有实现, 只是比较了UUID, 符合了之后就不做什么事情了.

    你可以自己在GAP_DEVICE_INFO_EVENT之后加些代码实现.

  • 接收到ad数据时, 也会导致此事件发生, 此时的数据就是advertData[]中的内容了.

    再等接收到SCAN_RSP后导致此事件发生时, 这时的数据就是scanRspData了.

  • Hi Roger3

    你可以尝试在事件 GAP_DEVICE_INFO_EVEN中  通过判断消息的附加内容来处理scanRspData,如

    if(pEvent->deviceInfo.eventType == GAP_ADRPT_SCAN_RSP)//ScanRsp扫描相应包
    {

    //todo
    NPI_WriteTransport(pEvent->deviceInfo.pEvtData,pEvent->deviceInfo.dataLen);//打印...

    }

    else if(pEvent->deviceInfo.eventType == GAP_ADRPT_ADV_IND)//广播包

    {

    //todo

    }

  • 嗨,你的这个eventType 取值不是你红色标注的那些吧,,,怎么没有呢

  • 嗨 Yan好久不见!

    我增加这样的对Rspdata处理可不可以呢?有没有什么逻辑上的错误,我的目的是想看到他能区分广播包和从机发送的扫描响应数据。

     if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE )
            {
              if ( ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV_UUID,//接受的是广播包
                                         pEvent->deviceInfo.pEvtData,
                                         pEvent->deviceInfo.dataLen ) ) && 
                  ( pEvent->deviceInfo.eventType == GAP_ADTYPE_ADV_IND )  )
              {
                simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );
              }
              else if( pEvent->deviceInfo.eventType == GAP_ADTYPE_SCAN_RSP_IND )//接受的是扫描包
              {
                NPI_WriteTransport( pEvent->deviceInfo.pEvtData,pEvent->deviceInfo.dataLen);
              }
            }
  • 收不到这个事件pEvent->deviceInfo.eventType == GAP_ADRPT_SCAN_RSP
  • 这个帖子很老了,请重新发布你的问题,并提供尽可能详细的描述,比如,芯片,协议栈版本,所用例程,想要实现什么等