Customising a bluetooth Zephyr sample

Hi,

I am currently developing with the nRF52 DK (nRF52832 SoC) and the nRF52833 DK (nRf52833 SoC). I have built and flashed the Bluetooth: Peripheral HT sample from Zephyr to both boards successfully. I have tested the application with an Android mobile phone and receive temperature measurements as expected. I would like to customise the source code of this sample application in 2 specific ways:

1. How do I change the TX power?

2. How do I change the PHY to use Coded PHY (S = 8)? I know that this can only be done for the nRF52833.

Thanks,

Adam

  • Hi Adam

    1. In this case, my colleague Hung has explained how to set the TX power in the nRF Connect SDK (NCS).

    2. In order to enable Coded PHY, enable the following Kconfigs in your project: 

    CONFIG_BT_CTLR_PHY_CODED=y
    CONFIG_BT_EXT_ADV=y

    You can also check out the Peripheral Heart Rate Monitor with Coded PHY project that already implements Coded PHY. The Coded PHY and extended advertising also needs to be set in the advertising initialization I believe.

    Best regards,

    Simon

  • Thanks for the help Simon,

    1. That is for the HCI power control application where the TX power is modulated according to the RSSI. How can I simply set the default power to 8dBm in the Bluetooth: Peripheral HT sample from Zephyr?

    2. Can you please be more specific as to what advertising initialization needs to change in the Bluetooth: Peripheral HT sample? Do I need to change the bt_ready function (code attached below)?

    Furthermore, under requirements for the Peripheral Heart Rate Monitor with Coded PHY sample, it does not support the nRF52833 DK which I am using. Surely this sample can be built for the nRF52833 as it supports Coded PHY?

    static void bt_ready(void)
    {
    int err;
    printk("Bluetooth initialized\n");
    hts_init();
    err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0);
    if (err) {
    printk("Advertising failed to start (err %d)\n", err);
    return;
    }
    printk("Advertising successfully started\n");
    }
  • Hi

    1. Okay, to just set the TX power statically to +8dBm you can add the CONFIG_BT_CTLR_TX_PWR_PLUS_8 to the Kconfig file of your project.

    2. You can set up a Coded PHY advertising with something like this snippet from the peripheral_hr_coded sample:

    static int create_advertising_coded(void)
    {
    	int err;
    	struct bt_le_adv_param param =
    		BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_CONNECTABLE |
    				     BT_LE_ADV_OPT_EXT_ADV |
    				     BT_LE_ADV_OPT_CODED,
    				     BT_GAP_ADV_FAST_INT_MIN_2,
    				     BT_GAP_ADV_FAST_INT_MAX_2,
    				     NULL);
    
    	err = bt_le_ext_adv_create(&param, NULL, &adv);
    	if (err) {
    		printk("Failed to create advertiser set (%d)\n", err);
    		return err;
    	}
    
    	printk("Created adv: %p\n", adv);
    
    	err = bt_le_ext_adv_set_data(adv, ad, ARRAY_SIZE(ad), NULL, 0);
    	if (err) {
    		printk("Failed to set advertising data (%d)\n", err);
    		return err;
    	}
    
    	return 0;
    }

    Yes, the Coded PHY sample should be possible to build for the nRF52833 as well, we've just not set it up and tested it on our end, so we can't add it to the sample page.

    Best regards,

    Simon

  • Thanks Simon,

    1. I did try that and it doesn't seem to change the TX power value when I tested it. I added the following line into the prj.conf file: CONFIG_BT_CTLR_TX_PWR_PLUS_8=y. I get the following message next to this line: In build_833: n.

    Furthermore, I get the following problem message in VS Code: CONFIG_BT_CTLR_TX_PWR_PLUS_8 was assigned the value y, but got the value n. Missing dependencies: HAS_HW_NRF_RADIO_TX_PWR_HIGH.

    2. Can I add this function into the source code in addition to the existing advertising functions in the Bluetooth: Peripheral HT sample

    Thanks very much,

    Adam

  • Hi Adam

    1. Indeed, you also need to include the dependencies for a config you set, so you also have to set CONFIG_HAS_HW_NRF_RADIO_TX_PWR_HIGH=Y in your config file as well.

    2. What is "this function"?

    Best regards,

    Simon

Related