Using bt_le_adv_update_data()

This is a continuation of Case ID: 272157

That case resolved issues I had dynamically changing the device name (and having that new name show up in advertising).

It seemed to work OK when developing the code using the nRF52840-DK board.

i'm now using that code with nRF Connect SDK 2.0.0 and Visual Studio code (and Zephyr) on a custom board.   The target device is nrf52840 in a BL654PA module.

The code to "rename" the device is:

int newBleAdvName(char *newName) {
  int err;

  // Update the device name
  printk("Set new name: %s\n",newName);
  err = bt_set_name(newName);
  if(err) {
    printk("Error setting device name: %d\n", err);
  } else {
printk("Changed device name to: %s\n", newName);
    // Update the advertising and scan response data needed to update the advertised device name
    // Only need to modify the scan response data in this example as name is in scan response here.
    sd->data = newName;
    sd->data_len = strlen(newName);
    err = bt_le_adv_update_data(ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
    if(err) {
      printk("Error setting advertised name: %d\n", err);
    } else {
printk("Changed advertised name to: %s\n", newName);
    }
  }
  return err;
}

When invoked, function fails, returning error code -11    From errno.h        #define EAGAIN 11       /**< No more contexts */  

Here is a screen capture of the RTT console output during that time:

If I set a breakpoint to try to step through, I get an exception:

I suspect this is due to some real-time interaction with the BLE stack, so I think the error code message is what I need to resolve.

It's unclear to me what "No more contexts" means or how to correct this.

Do you have any suggestions?

Thanks!

Related