nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs

Issue Changing ble_app_uart to Coded PHY

Hello,

I am using the ble_advertising module in sdk 17.0.2 on an nRF52840 with softdevice 140.  I have the application working but want to convert to using coded PHY.  After reading over this post (https://devzone.nordicsemi.com/f/nordic-q-a/40476/unable-to-convert-to-long-range-after-looking-at-umpteen-examples--) it seemed that the only changes I would have to make would be in my advertising_init function.  Originally it was:

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;
    init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

    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  = APP_ADV_DURATION;
    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}

And I added these lines at the end to change to coded PHY so that the function is now: 

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;
    init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

    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  = APP_ADV_DURATION;
    init.evt_handler = on_adv_evt;
    
     //added to set phy to coded
    init.config.ble_adv_primary_phy       = BLE_GAP_PHY_CODED;  // use Coded PHY
    init.config.ble_adv_secondary_phy     = BLE_GAP_PHY_CODED;
    init.config.ble_adv_extended_enabled  = true;               // Coded PHY needs extended adv (bigger adv packet size)


    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}

I don't get any errors compiling but I can't detect any advertising devices on the nRF Toolbox app on my phone so I'm not sure what's going wrong.  Are there other changes I need to make to implement the coded PHY, or have I implemented these changes incorrectly?

Also are there any changes to the config file that I need to make?

Thanks for the help,

Jake

  • I am not sure if the nRF Toolbox app can detect coded phy advertising packets. If your phone is supporting all BLE 5.0 features then installing nRF Connect app on your phone should allow you to change the settings of the scanner to scan on all PHYs. You should then be able to see the advertising extension packets. Please check this post for reference. 

    I have been using Ellisys sniffer for sniffer coded phy packets.

  • You're right, my phone does not support coded PHY scanning.  Are you aware of any more consumer grade sniffers for coded PHY?  The Ellisys ones are prohibitively expensive and I don't see any other options.  I tried modifying the central_hr_coded sample to connect to the NUS UUID but it isn't able to find anything, so something still seems to be wrong with the advertising.

    The advertising changes I made are just: 

    init.config.ble_adv_primary_phy       = BLE_GAP_PHY_CODED;  // use Coded PHY
        init.config.ble_adv_secondary_phy     = BLE_GAP_PHY_CODED;
        init.config.ble_adv_extended_enabled  = true;               // Coded PHY needs extended adv (bigger adv packet size)

    I saw people mention that the NRF_BLE_SCAN_BUFFER must be set to 255 or greater.  It wasn't in my config file so I added the line:

    #define NRF_BLE_SCAN_BUFFER 255

    Is this the correct way to go about this change, or am I possibly missing something?

  • Have you tried to look at the demo that is made in a little older version of the SDK here?
    Pay attention to the advertising_data_set. The API might be little different but gives you more details on the changes needed for both adv and scan to be compared at the same place in a nice manner.

    Unfortunately, we do not have any example to show a working example on the sdkv17

Related