Migrating ble_app_proximity example from SDK 17.1.0 to SDK 3.0.1

I have been using the SDK example ble_app_proximity to flash my demo boards nRF52840 to do some RF PHY testing on Bluetooth advertising.

It was very easy in this example to change the BLE advertising interval as well as the TX transmit power.

It was easy using the SEGGER IDE to re-build the example and flash the board.

Moving to the new SDK 2.x and 3.x, this example ble_app_proximity is no longer part of the nRF SDK.

Is there an equivalent simple example in the SDK 2.0, or SDK3.0 ?  

OS: Windows 10 and 11

HW: nRF52840DK, nRF5340DK

Regards

JM Gayet

Parents
  • Hi Edvin,

    Thank for answering my post.

    At the end I am looking for a basic Bluetooth LE example in the new SDK V3.0.2 from where I can set up the Advertising Interval and the transmit power. I don't need any other features. In the old SDK, I was using the ble_app_proximity example as it was very easy in the Segger IDE to change the Advertising Interval and the Transmit power.

    I am just using my Nordic dev kit nRF52840 and nRF5340 to do some RF PHY testing with my R&S CMW and CMP testers.

    At the end I am only using 2 Nordic app, the direct_test_mode and the ble_app_proximity. 

    The direct_test_mode app is still in the latest SDK 3.0.2 and work fine. 

    But for Advertising test, I need to find a simple app in the SDK 3.0.2.

    Let me know

    Best Regards

    JM Gayet 

  • Hello,

    My go to sample is the peripheral_uart, which is the equivalent to the ble_app_uart example in the old nRF5 SDK.

    Found in: NCS\nrf\samples\bluetooth\peripheral_uart

    The way that advertising interval and transmit power is set up is a bit different in the nRF Connect SDK (NCS). 

    Advertising:

    In this sample, the advertising is started in adv_work_handler() in main.c.

    int err = bt_le_adv_start(BT_LE_ADV_CONN_FAST_2, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));

    ad and sd are the arrays containing the advertising data and scan response data. 

    BT_LE_ADV_CONN_FAST_2 is a macro for advertising parameters. It is defined as connectable advertising, using an advertising interval between BT_GAP_ADV_FAST_INT_MIN_2 (100ms) and BT_GAP_ADV_FAST_INT_MAX_2 (150ms). 

    You can adjust these by changing adv_work_handler() from:

    static void adv_work_handler(struct k_work *work)
    {
    	int err = bt_le_adv_start(BT_LE_ADV_CONN_FAST_2, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
    
    	if (err) {
    		LOG_ERR("Advertising failed to start (err %d)", err);
    		return;
    	}
    
    	LOG_INF("Advertising successfully started");
    }

    to:

    static void adv_work_handler(struct k_work *work)
    {
    	struct bt_le_adv_param my_adv_params =
    		BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_CONN,
    				     BT_GAP_ADV_FAST_INT_MIN_2,
    				     BT_GAP_ADV_FAST_INT_MAX_2,
    				     NULL);
    	int err = bt_le_adv_start(&my_adv_params, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
    
    	if (err) {
    		LOG_ERR("Advertising failed to start (err %d)", err);
    		return;
    	}
    
    	LOG_INF("Advertising successfully started");
    }

    And there you can change the parameters individually. Although the declaration of bt_le_adv_param states that the minimum and maximum advertising interval should not be the same value, it does build and run if you do that. 

    Regarding the transmit power, this can be set build time using this Kconfig in your prj.conf file:

    CONFIG_BT_CTLR_TX_PWR_0=y

    You can see the supported values in the file NCS\zephyr\subsys\bluetooth\controller\kconfig. Values like CONFIG_BT_CTLR_TX_PWR_PLUS_4 and BT_CTLR_TX_PWR_MINUS_4 are examples of supported values. It needs to match one of the values from the TXPOWER register of the device you are using:

    https://docs.nordicsemi.com/bundle/ps_nrf52840/page/radio.html#ariaid-title70

    Best regards,

    Edvin

Reply
  • Hello,

    My go to sample is the peripheral_uart, which is the equivalent to the ble_app_uart example in the old nRF5 SDK.

    Found in: NCS\nrf\samples\bluetooth\peripheral_uart

    The way that advertising interval and transmit power is set up is a bit different in the nRF Connect SDK (NCS). 

    Advertising:

    In this sample, the advertising is started in adv_work_handler() in main.c.

    int err = bt_le_adv_start(BT_LE_ADV_CONN_FAST_2, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));

    ad and sd are the arrays containing the advertising data and scan response data. 

    BT_LE_ADV_CONN_FAST_2 is a macro for advertising parameters. It is defined as connectable advertising, using an advertising interval between BT_GAP_ADV_FAST_INT_MIN_2 (100ms) and BT_GAP_ADV_FAST_INT_MAX_2 (150ms). 

    You can adjust these by changing adv_work_handler() from:

    static void adv_work_handler(struct k_work *work)
    {
    	int err = bt_le_adv_start(BT_LE_ADV_CONN_FAST_2, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
    
    	if (err) {
    		LOG_ERR("Advertising failed to start (err %d)", err);
    		return;
    	}
    
    	LOG_INF("Advertising successfully started");
    }

    to:

    static void adv_work_handler(struct k_work *work)
    {
    	struct bt_le_adv_param my_adv_params =
    		BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_CONN,
    				     BT_GAP_ADV_FAST_INT_MIN_2,
    				     BT_GAP_ADV_FAST_INT_MAX_2,
    				     NULL);
    	int err = bt_le_adv_start(&my_adv_params, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
    
    	if (err) {
    		LOG_ERR("Advertising failed to start (err %d)", err);
    		return;
    	}
    
    	LOG_INF("Advertising successfully started");
    }

    And there you can change the parameters individually. Although the declaration of bt_le_adv_param states that the minimum and maximum advertising interval should not be the same value, it does build and run if you do that. 

    Regarding the transmit power, this can be set build time using this Kconfig in your prj.conf file:

    CONFIG_BT_CTLR_TX_PWR_0=y

    You can see the supported values in the file NCS\zephyr\subsys\bluetooth\controller\kconfig. Values like CONFIG_BT_CTLR_TX_PWR_PLUS_4 and BT_CTLR_TX_PWR_MINUS_4 are examples of supported values. It needs to match one of the values from the TXPOWER register of the device you are using:

    https://docs.nordicsemi.com/bundle/ps_nrf52840/page/radio.html#ariaid-title70

    Best regards,

    Edvin

Children
No Data
Related