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中SimpleBLECenter的simpleBLEFindSvcUuid() UUUID的过滤的问题

Other Parts Discussed in Thread: CC2540

请问使用CC2540SimpleBLECenter,在static bool simpleBLEFindSvcUuid( uint16 uuid, uint8 *pData, uint8 dataLen )里面

 

这句是用来过滤UUIDFFF0的从机-->if ( pData[0] == LO_UINT16(uuid) && pData[1] == HI_UINT16(uuid) )

 

如果现在设定#define DEFAULT_DEV_DISC_BY_SVC_UUID  FALSE

要怎么改,它才会把智能手机的UUID也算进去?

  • 你想简单的把所有设备添加进来的话,把这个simpleBLEFindSvcUuid函数的使用注释掉。

    你想增加一个UUID的话,添加:

    else if(simpleBLEFindSvcUuid(……))//新的UUID

    {

    //增加设备

    }

  • 谢谢甜甜的大香瓜回应

     

    但我把simpleBLEFindSvcUuid函数使用注释掉的话,例如以下写法的确是把周围的BLE装置全都列出来了

     

        case GAP_DEVICE_INFO_EVENT:

          {

            // if filtering device discovery results based on service UUID

            if ( DEFAULT_DEV_DISC_BY_SVC_UUID == FALSE )

            {

     

                simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );

               

                SerialPrintString((uint8*) bdAddr2Str(pEvent->deviceInfo.addr));

                SerialPrintString("&");

                SerialPrintValue("rssi:-",  (uint8)(-(pEvent->deviceInfo.rssi)),10);

                SerialPrintString("\r\n");

             

            }

          }

          break;

     

    如下图

    只有SCAN到3个装置,但其中2个装置却重复印了出来

    如果我不另外增加UUID的话,有什么办法让它SCAN到所有的装置只印一次吗?

  • static void SimpleBLECentral_addDeviceInfo(uint8_t *pAddr, uint8_t addrType)
    {
    uint8_t i;

    // If result count not at max
    if (scanRes < DEFAULT_MAX_SCAN_RES)
    {
    // Check if device is already in scan results
    for (i = 0; i < scanRes; i++)
    {
    if (memcmp(pAddr, devList[i].addr , B_ADDR_LEN) == 0)
    {
    return;
    }
    }

    //

    //打印

    //


    // Add addr to scan result list
    memcpy(devList[scanRes].addr, pAddr, B_ADDR_LEN);
    devList[scanRes].addrType = addrType;

    // Increment scan result count
    scanRes++;
    }
    }

  • 谢谢甜甜的大香瓜回应,

    我做了2个实验,首先照着您的分享,的确可以打印出addr,如下

     

        case GAP_DEVICE_INFO_EVENT:

          {

            // if filtering device discovery results based on service UUID

            if ( DEFAULT_DEV_DISC_BY_SVC_UUID == FALSE )

            {

     

                SimpleBLECentral_addDeviceInfo ( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );

               

             

            }

          }

          break;

     

    static void SimpleBLECentral_addDeviceInfo(uint8_t *pAddr, uint8_t addrType)
    {
    uint8_t i;

    // If result count not at max
    if (scanRes < DEFAULT_MAX_SCAN_RES)
    {
    // Check if device is already in scan results
    for (i = 0; i < scanRes; i++)
    {
    if (memcmp(pAddr, devList[i].addr , B_ADDR_LEN) == 0)
    {
    return;
    }
    }

    //

        SerialPrintString((uint8*) bdAddr2Str(pAddr));

        SerialPrintString("\r\n");

    //


    // Add addr to scan result list
    memcpy(devList[scanRes].addr, pAddr, B_ADDR_LEN);
    devList[scanRes].addrType = addrType;

    // Increment scan result count
    scanRes++;
    }
    }

    结果如下图

     

    接着,我把RSSI印出

        case GAP_DEVICE_INFO_EVENT:

          {

            // if filtering device discovery results based on service UUID

            if ( DEFAULT_DEV_DISC_BY_SVC_UUID == FALSE )

            {

     

                SimpleBLECentral_addDeviceInfo ((uint8*)(- pEvent->deviceInfo.rssi), pEvent->deviceInfo.addrType );

               

             

            }

          }

          break;

     

    static void SimpleBLECentral_addDeviceInfo(uint8_t *pAddr, uint8_t addrType)
    {
    uint8_t i;

    // If result count not at max
    if (scanRes < DEFAULT_MAX_SCAN_RES)
    {
    // Check if device is already in scan results
    for (i = 0; i < scanRes; i++)
    {
    if (memcmp(pAddr, devList[i].addr , B_ADDR_LEN) == 0)
    {
    return;
    }
    }

    //

        SerialPrintString((uint8*) (pAddr));

        SerialPrintString("\r\n");

    //


    // Add addr to scan result list
    memcpy(devList[scanRes].addr, pAddr, B_ADDR_LEN);
    devList[scanRes].addrType = addrType;

    // Increment scan result count
    scanRes++;
    }
    }

     

    结果如下图

     

    请问我在印出RSSI出了什么问题呢?