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(作为主机)如何实时获取从机广播过来的数据



 GAPCentralRole_StartDiscovery( DEFAULT_DISCOVERY_MODE,
                                       DEFAULT_DISCOVERY_ACTIVE_SCAN,
                                       DEFAULT_DISCOVERY_WHITE_LIST );   

也就是搜索的时候,只要广播里的数据有变都能收到。

  • 所有从从机发过来的GATT封包可以在simpleBLECentralProcessGATTMsg()里收到。

  • 你好,simpleBLECentralProcessGATTMsg()这里是不是,建立连接的。

             我现在

    static void simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent )
    {
      uint8 send_Len = 0;
      switch ( pEvent->gap.opcode )
      {
        case GAP_DEVICE_INFO_EVENT://在这里获取广播的数据,但这里是不会,像ANDROID那个,每20MS都可以更新,广播包数据
         break;
    }
    }
    请问在那里可以一直监听到,广播数据包。不是连接上的通信数据包。


  • case GAP_DEVICE_INFO_EVENT:
          {
            // if filtering device discovery results based on service UUID
            if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE )
            {
              if ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV_UUID,
                                         pEvent->deviceInfo.pEvtData,
                                         pEvent->deviceInfo.dataLen ) )
              {
                simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );
                //打印主机搜索到的广播数据
                NPI_WriteTransport ( pEvent->deviceInfo.pEvtData, osal_strlen((char *)(pEvent->deviceInfo.pEvtData))); 
              }
            }
          }


    这里获取广播数据,更新数据需要再次发送搜索命令

  • 你这个方法是对的,主要时实性,也不高。