Ble advertising 52840 random pauses

Hi, 

I'm trying to setup a simple BLE Advertising beacon the broadcasts once per 3 seconds, th problem Im having is it will do this for about 10 broadcasts then stop and rest for 7ish seconds before starting again?

any suggestion for what I'm doing wrong?

I am prototyping using bluefruit library that uses softdevice S140 7.3.0

below is my code.

void startAdv(void)
{
  // Advertising packet
  Bluefruit.setName("DROID");
  Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
  Bluefruit.Advertising.addTxPower();
  Bluefruit.Advertising.addName();
  Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED);  // for XIAO BLE

  Bluefruit.Advertising.restartOnDisconnect(true);
  Bluefruit.autoConnLed(false);

  Bluefruit.Advertising.setInterval(500, 3000); // in unit of 0.625 ms
  Bluefruit.Advertising.setFastTimeout(1);     // number of seconds in fast mode
  Bluefruit.Advertising.start(0);             // 0 = Don't stop advertising after n seconds
}

void disconnectPin(uint32_t ulPin)
{
  if (ulPin >= PINS_COUNT)
  {
    return;
  }

  ulPin = g_ADigitalPinMap[ulPin];

  NRF_GPIO_Type *port = nrf_gpio_pin_port_decode(&ulPin);

  port->PIN_CNF[ulPin] =
      ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t)GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) | ((uint32_t)GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) | ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
}

void setup()
{

  flash.begin();
  Bluefruit.begin();
  Bluefruit.setTxPower(+8); // Check bluefruit.h for supported values
  flashTransport.begin();
  if (flashTransport.runCommand(0xB9)== false)
  {
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, LOW);
    while (1)
    {
      yield();
    }
  }

  flashTransport.end();

  flash.end();

  for (int i = 0; i < 25; i++)
  {
    disconnectPin(i);
  }
  sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
  sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
    startAdv();
    suspendLoop();
  __WFE();
  __WFI();
  sd_app_evt_wait();
}
Parents Reply Children
  • Hello,

    That said, looking over the provided code I think the parameters you are using are not correct in this case.
    If you wish to only advertise 3 times each second you will need to use an advertising interval of around 330 ms, which I assume is set with  Bluefruit.Advertising.setInterval or the equivalent for fast advertising.

    If you wish for this to go on only for 10 seconds you should set a timeout for your advertisement presumably using the Bluefruit.Advertising.setFastTimeout call, and then lastly if you wish for it to re-start advertising after 7 seconds you will need to create a timer or similar to restart the advertising again.

    Please keep in mind that I have no experience working with the arduino libraries, and so my assumptions about the functions and their input might be incorrect, but this is what I assume you will need to do to achieve the behavior you describe in this case. 

    Best regards,
    Karl

  • EDIT,

    Problem solved, it was my scanning window wasn't right and causing the issues.

    thanks, 

    Hi Karl

    thanks for your input, so your right about the above, I can get it advertising no worries and change the interval etc, but it sends 10 or so adverts then pauses for around 20seconds before sending another 10 adverts or so, just wondering if this is normal for BLE advertising or should i be able to advertise with a set interval indefinitely with no pauses? as far as im aware there have been no timeouts set.

    Thanks, 
    Ben

  • Hello Ben,

    Thank you for the update,
    I am happy to read that the issue now is resolved! :) 

    Please do not hesitate to open another ticket if you should encounter any other issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl

Related