This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why long range advertising cannot be filtered by uuid?

If you are broadcasting in normal mode, this code will not report an error. But if you are broadcasting in long range mode, this code will cause a  FATAL ERR. If you are broadcasting in long range mode, you will not be able to filter devices by UUID.

  • Hi

    In long-range advertising, extended advertisements are used, where the advertisements Primary Advertisements on the Primary advertisement channels (37, 38, and 39) point to Secondary Channel Advertisements that hold the advertising information. More information on Coded PHY advertising and scanning can be found in this blog post.

    Can you show me how you initialize advertising in your long-range device, as there are some things you need to make sure of when doing advertising using the Coded PHY for advertising. FIrst, make sure that adv_data.flags is set to BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; This is required in order to advertise in Coded PHY. Also, please note that you can not have scan response data in your Coded_PHY advertisements, and you need to set the scan response data to 0 like this.

    .scan_rsp_data =
    {
    .p_data = NULL,
    .len = 0

    }

    So if you have the UUID you're trying to filter in the scan response, that would explain why you're not able to use it to filter devices by UUID.

    Best regards,

    Simon

  • yes,So in the very beginning of the question I commented the relevant code, but I don't understand why it should be set this way.

    static void advertising_init(void)
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance = false;
    #if 0    
        
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    #else    
        
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    #endif
        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = 0;//APP_ADV_DURATION;
        init.evt_handler = NULL;
        
        if(m_advertising_mode == NORMAL_ADVERTISING_MODE)
        {
           
            init.config.ble_adv_primary_phy   = BLE_GAP_PHY_1MBPS;
            init.config.ble_adv_secondary_phy = BLE_GAP_PHY_1MBPS;
        }
        else if(m_advertising_mode == LONGRANGE_ADVERTISING_MODE)
        {
        
            init.config.ble_adv_primary_phy   = BLE_GAP_PHY_CODED;
            init.config.ble_adv_secondary_phy = BLE_GAP_PHY_CODED;
            init.config.ble_adv_extended_enabled = true;
        }
        else
        {
            init.config.ble_adv_primary_phy   = BLE_GAP_PHY_1MBPS;
            init.config.ble_adv_secondary_phy = BLE_GAP_PHY_1MBPS;
        }
    
        err_code = ble_advertising_init(&m_advertising, &init);
    
        MYAPP_ASSERT(err_code,MODULE_NAME);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

    Now we  want devices to be able to filter by UUID, so is there any way to do that?

  • Hi

    The following if-loop confuses me:

    #if 0    
        
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    #else    
        
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    Can you please explain your thoughts behind this?

    As the UUIDs are part of the scan response data in your advertisement, you won't be able to use these when doing long-range advertising, as Coded PHY does not support scan response data.

    Best regards,

    Simon

  • Hi

    The if-loop is just a test code to change the duration of the broadcast in different modes.

    Well, if there's no way to  filter by UUID in long-range mode, i will have to use other methods.

    Thank you very much for your careful answer.

Related