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

Toggle 1Mbit PHY and CodedPHY

Hi.

I want to advertise switching 1Mbit PHY and CodedPHY every 5 seconds.

I designed it like this based on nrf52 ble app uart long range example.

advertising_start(coded)-->5s-->BLE_GAP_TIMEOUT_SRC_ADVERTISING{advertising_start(1MbpsPHY)}-->5s
-->BLE_GAP_TIMEOUT_SRC_ADVERTISING{advertising_start(coded)}-->....

 

The code is as follows.

#define APP_ADV_TIMEOUT_IN_SECONDS  5


void advertising_start(void)
{
    static ble_gap_adv_params_t adv_params = {0};

    adv_params.properties.connectable = 1;
    // Setting up the scan response packet is currently not supported when using CODED phy
    adv_params.properties.scannable = 0;
    adv_params.properties.legacy_pdu = 0;
    adv_params.p_peer_addr   = NULL;
    adv_params.fp            = BLE_GAP_ADV_FP_ANY;
    adv_params.interval      = APP_ADV_INTERVAL;
    adv_params.duration      = APP_ADV_TIMEOUT_IN_SECONDS * 100;
    if(adv_coded){
        adv_params.primary_phy   = BLE_GAP_PHY_1MBPS;
        adv_params.secondary_phy = BLE_GAP_PHY_1MBPS;
        adv_coded = false;
    }
    else{
        adv_params.primary_phy   = BLE_GAP_PHY_CODED;
        adv_params.secondary_phy = BLE_GAP_PHY_CODED;
        adv_coded = true;
    }

    sd_ble_gap_adv_start(BLE_GAP_ADV_SET_HANDLE_DEFAULT, &adv_params, APP_BLE_CONN_CFG_TAG);
}

However, in my Xperia it was not displayed at 1Mbps PHY.
Is there anything else I need to change?

thanks

Parents Reply Children
  • Coded receiver is Nordic Device. (nRF52840 PDK)

    My using App are nRF Connect and iBeaconDetector.
    I always use them to confirm BLE.

    Of course, it support.
    It is displayed if it is an ordinary uart sample.

    Thanks

  • Are you sure your phone supports extended advertising? There are not many phones on the market that already support advertising extensions. I suspect this is the problem for your Xperia.

    Also, if you are using the ble uart long range example from github that could mean you are using an alpha of the SoftDevice. If so, it could be wise to update to a production version.

  • Sorry, I'm letting you misunderstand...

    I want to recieve 1Mbps advertising at my phone.
    I do not want to receive Coded advertising at it.

  • Extended advertising can be used for coded, 1mbps and 2mbps.

    Coded advertising must use advertising extensions, but advertising extensions can aslo be used for 1mbps and 2mbps.

    When using advertising extensions, the advertising data is not in the original advertising packet, instead we use the advertising (on an advertising channel) to "point" to the advertising data (now on a data channel instead). Older phones do not support this feature, and many new phones are still waiting for support. Coded advertising uses extended advertising because the packets are to long for the "normal"/legacy advertising.

    I suspect that the Xperia phone can only see the "legacy" advertising, and not extended advertising

     

       adv_params.p_peer_addr = NULL;
        adv_params.fp         = BLE_GAP_ADV_FP_ANY;
        adv_params.interval   = APP_ADV_INTERVAL;
        adv_params.duration   = APP_ADV_TIMEOUT_IN_SECONDS * 100;
        if (adv_coded)
        {
            adv_params.properties.legacy_pdu = 1;
            adv_params.primary_phy           = BLE_GAP_PHY_1MBPS;
            adv_params.secondary_phy         = BLE_GAP_PHY_1MBPS;
            adv_coded = false;
        }
        else
        {
            adv_params.properties.legacy_pdu = 0;
            adv_params.primary_phy           = BLE_GAP_PHY_CODED;
            adv_params.secondary_phy         = BLE_GAP_PHY_CODED;
            adv_coded = true;
        }

     

  • I was misunderstanding. . .
    I added the item of legacy_pdu!!

    However, it did not appear on my phone too.
    And after advertise of Coded, advertise came to stop.

    If I add legacy_pdu = 1 to Coded, no longer advertise too...

    Is there anything else I should change?

Related