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

Evaluation of BLE5 extended advertisement with nRF52832

Hi All,

I want explore BLE5 extended advertisement with nRF52832.

Using "ble_peripheral\ble_app_blinky" code from SDK16.0.0, facing "NRF_ERROR_INVALID_PARAM(7)" error in response to sd_ble_gap_adv_set_configure. Following is a source code of advertisement initialization.

Please draw my attention where I am making mistake.

#define ADV_MFG_DATA_SIZE 10
uint8_t gu8ar_mfg_adv_data[ADV_MFG_DATA_SIZE] = {0};

static void advertising_init(void)
{
    ret_code_t    err_code;
    ble_advdata_t advdata;
    ble_advdata_t srdata;	
	
    ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}};

    // Build and set advertising data.
    memset(&advdata, 0, sizeof(advdata));
    advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance = true;
    advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

	//-----------------------------------------------------------------------------
	ble_advdata_manuf_data_t manuf_data;
	for(uint8_t i=0;i<ADV_MFG_DATA_SIZE;i++) gu8ar_mfg_adv_data[i]=i+1;
    manuf_data.company_identifier = 0x0437;		
    manuf_data.data.size = sizeof(gu8ar_mfg_adv_data);	
    manuf_data.data.p_data = gu8ar_mfg_adv_data;
	advdata.p_manuf_specific_data = &manuf_data;

	//-----------------------------------------------------------------------------
	
    memset(&srdata, 0, sizeof(srdata));
    srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
    srdata.uuids_complete.p_uuids  = adv_uuids;
	
    err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
    APP_ERROR_CHECK(err_code);

    err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
    APP_ERROR_CHECK(err_code);

    ble_gap_adv_params_t adv_params;

    // Set advertising parameters.
    memset(&adv_params, 0, sizeof(adv_params));

    adv_params.primary_phy     = BLE_GAP_PHY_AUTO;
	adv_params.secondary_phy   = BLE_GAP_PHY_AUTO;
    adv_params.duration        = APP_ADV_DURATION;
    adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED;
    adv_params.p_peer_addr     = NULL;
    adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
	adv_params.set_id          = 4;
    adv_params.interval        = APP_ADV_INTERVAL;

    err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
    APP_ERROR_CHECK(err_code);
}

Parents
  • Hello,

    It is a bit tricky to set it up the way that you are doing it here, it seems. I suggest that you use the advertising module.

    If you look in the example ble_app_rscs from DK16.0.0 this is an example that will use extended advertising by default. If you look in advertising_init(), it says:

    init.config.ble_adv_extended_enabled = true;

    and then

    err_code = ble_advertising_init(&m_advertising, &init);

    This is not possible when using sd_ble_gap_adv_set_configure() directly. This setting is stored in the ble_advertising_init_t init.

    Search for "ble_adv_extended_enabled" in this project, and you can see where it is set. The structs are a bit different, using the ble_advertising_init_t type, so I haven't looked into the details, but it includes ble_advertising_init_t and ble_advertising_t, where the scan response is located in ble_advertising_t->adv_data.scan_rsp_data, which is different from ble_advdata_t.

    Take a look at that example, and see if you can get it up and running from there.

    Best regards,

    Edvin

  • Thanks Edvin.

    I have used example ble_app_rscs and able to evaluate extended advertisement. My next plan is to perform following. 

    1) Want to use chained advertisement to broadcast up to 1650 bytes. How can I do it with existing example?

    2) To evaluate high speed data transfer at 2 Mbps. Can I do it with existing example? If yes then how?

    Thanks in advance.

    Regards,

    Bipin Patel

  • Hello,

    If you use extended advertising you can hold up to 255 bytes of payload data per packet. However, transferring data via advertising packets is not a very reliable way of doing so. You have no way of knowing whether an advertisement packet is received correctly, or received at all from the peripheral. If you want to transfer data, I suggest that you enter a connection.

  • Hi Edvin,

    I just want to evaluate feature of extended advertisement for data >255 bytes using chained advertisement if possible with SDK and SD. In my actual application I will not use it.

    Can you also suggest evaluate high speed data transfer at 2 Mbps. Can I do it with existing example? If yes then how?

    Regards,

    Bipin Patel

Reply Children
  • Hello,

    Currently this is not possible with the softdevice. Please see this ticket. The maximum supported length is 255 bytes.

    Best regards,

    Edvin

  • Thanks Edvin for clarification on chained advertisement.

    Can you suggest me how can I evaluate high speed data transfer at 2 Mbps. Can I do it with existing example? If yes then how?

    Regards,

    Bipin

  • Hello,

    Yes, you can do that. 

    It can be done with pretty much any example, but if you want to send payload data, I would suggest you look into the ble_app_uart example. 

    Pretty much everything is already set up, but it doesn't by default use 2MBPS. 

    You can add something the following to the BLE_GAP_EVT_CONNECTED event:

    ble_gap_phys_t const my_new_phys = 
                {
                    .tx_phys = BLE_GAP_PHY_2MBPS,
                    .rx_phys = BLE_GAP_PHY_2MBPS
                };
                err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &my_new_phys);
                APP_ERROR_CHECK(err_code);

    And then look after the BLE_GAP_EVT_PHY_UPDATE event. When this event occurs, you can check the new phy:

            case BLE_GAP_EVT_PHY_UPDATE:
                NRF_LOG_INFO("Phy Updated. TX: %d, RX: %d", p_ble_evt->evt.gap_evt.params.phy_update.tx_phy, p_ble_evt->evt.gap_evt.params.phy_update.rx_phy);
                break;

    If it is updated to 2MBPS, then you should see:

    "Phy Updated. TX: 2, RX: 2"

    If it is printing other numbers than two, check which one they refer to in ble_gap.h -> BLE_GAP_PHYS

    Best regards,

    Edvin

  • Hi Edvin,

    Thanks for help. I am able to set successfully following with ble_app_uart example.

    .tx_phys = BLE_GAP_PHY_2MBPS,
    .rx_phys = BLE_GAP_PHY_2MBPS

    I have one some confusion with nordic sdk examples if you can clear it.

    1) How can I clearly differentiate that whatever example support BLE4 or BLE5? 

    2) Is any dedicated example is available which fully support BLE5 only?

    Regards,

    Bipin

  • Hello Bipin,

    1)

    It is a bit confusing. It is actually the softdevices that are BLE5 compatible, and not the examples. BLE5 is a superset of BLE4, meaning that BLE5 = BLE4++. All the features that are added to BLE5 are optional, so in theory, you can say that a BLE device that is working perfectly fine in BLE4 is BLE5 compatible, but doesn't support any of the new features. 

    Also, the features in BLE5 are backwards compatible in a way, meaning that if a connected device doesn't support that feature, they will stick to the BLE4 version of the feature. One example is the 2MBPS. If you request 2MBPS in a connection, but the connected device doesn't support it, then they will stay on 1MBPS. The same goes for Long Range, which is not supported by the nRF52832.

    2)

    So it is not really defined what BLE5 only is, because of what I described in 1). You can of course say that extended advertising is BLE5 only, because BLE4 only devices will not be able to read the advertising extensions, but other than that, all features are optional, and BLE5 is backwards compatible.

    Best regards,

    Edvin

Related