Dynamically changing Advertisement name when using PHY ENCODED

I'm using the nRF52840 with NCS SDK 2.0.2 and need to be able to change the BLE advertisement name of the peripheral device dynamically.

I have this working when using "normal" BLE strength.    This is accomplished by calling "bt_le_adv_update_data()", but also needs a change in the file adv.c  (Commenting out lines 847-849).  See Case #272157

After getting "normal" BLE working, I am attempting to use "PHY ENCODED" to extend the BLE range using the example in NCS SDK 2.0.2   (See Case #294814).

I can get the initial device name to advertise using PHY ENCODED, but haven't figured out how to change the name dynamically.    I tried using "bt_le_adv_upate_data()" but this doesn't work.

I also tried calling bt_le_ext_adv_set_data() again (with the updated data), but the initial device name continues to be advertised.

What is the sequence needed to dynamically change the advertised name when using PHY ENCODED?   (Why is it different from "normal" BLE)?

Thanks!

Parents
  • Hello

    According to the description of bt_set_name(), it looks like it might be bt_le_ext_adv_set_data() you are looking for?

    Or have you tried using bt_set_name()?

    Best regards,

    Einar

  • Thanks...   But I don't think this is set.   Here is the code used to start advertising:

    static void btAdvertisingStart(void) {
      int err;
    printk("Start Avertisement\n");
    
      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), sd, ARRAY_SIZE(sd));
      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;
    	}
    
      err = bt_le_ext_adv_start(adv, NULL);
    	if (err) {
    		printk("Failed to start advertising set (%d)\n", err);
    		return;
    	} else {
        printk("Advertising successfully started\n");
      }
    
        // Change the name of the module
    #if 1
      printf("After bt ready: Setting name to %s\n",telemetry1Name.name.chars);
          err= newBleAdvName(telemetry1Name.name.chars);
          if(err < 0) {
      printk("Error setting device name at startup: %d\n",err);
          }
    #endif
    }

  • Hi

    Can you please share the contents of your ad array before and after you try to set the new name using coded phy?

Reply Children
  • OK...   Now I see what is happening...  

    When I changed from "normal" to "coded" BLE modes, I had to move the advertised name from the sd[] array to the ad[] array.    

    When changing the advertised name, I failed to change the "index" (using the index of the advertised name in sd[] when modifying the (now moved) advertised name in ad[]) when making the modification.

    The modified values made it into the ad[] array, but the old name was also still there and was used by BLE when advertising.    Using the proper index fixed things.

    Thanks

Related