[Solved] BLE_GROUP: group->scan() (or BLE_GROUP connection?) impacts WiFi connection on DeviceOS 3.1

Hi,

I have applied the fixes and workarounds explained on this post: BLE_GROUP: can’t make it work on DeviceOS 3.1

I have now noticed that as soon as the group->scan() is executed (or maybe when the devices connect, I am not sure), both the peripheral and the central devices go blinking green and never reconnect to WiFi.

If I turn off one of them, the WiFi connection for the one that remains on is solid and stable.
But as soon as I power back on the other device (be it the central or the peripheral) the device that was breathing cyan, and happily connected to the Internet, it does the following:

  • its LED goes white of a short period of time
  • it starts blinking green

After this, the device that I just powered on keeps on blinking green. In fact, both keep blinking green (forever, perhaps?).

I fear there is a potential issue here in BLE_GROUP, at least in DeviceOs3.1.

Here’s code that reproduces this issue. You can see I commented out few lines to try to pinpoint the issue:

Central code:

#include "BLE_Group.h"
BLE_Group *group;

SYSTEM_THREAD(ENABLED);

SerialLogHandler logHandler(LOG_LEVEL_INFO);

unsigned long scan_time;

void callbackFunc(const char *event, const char *data)
{
  Log.info("Event: %s, Data: %s", event, data);
}

void setup()
{
#if SYSTEM_VERSION == SYSTEM_VERSION_v310
  // This is required with 3.1.0 only
  BLE.setScanPhy(BlePhy::BLE_PHYS_AUTO);
#endif

  group = new BLE_Group_Central(1); // The parameter is the groupID
  // group->subscribe("test", callbackFunc);
}

void loop()
{
  if (group->devices_connected() < BLE_GROUP_MAX_PERIPHERALS && (millis() - scan_time) > 3000)
  {
    Log.info("central is about to scan");
    group->scan();
    scan_time = millis();
  }

  // // group->publish("test-central", "Some data");
  Log.info("looping in central");
  delay(5000);
}

Peripheral code:

#include "BLE_Group.h"
BLE_Group *group;

SYSTEM_THREAD(ENABLED);

SerialLogHandler logHandler(LOG_LEVEL_INFO);

void callbackFunc(const char *event, const char *data)
{
  Log.info("Event: %s, Data: %s", event, data);
}

void setup()
{
#if SYSTEM_VERSION == SYSTEM_VERSION_v310
  // This is required with 3.1.0 only
  BLE.setScanPhy(BlePhy::BLE_PHYS_AUTO);
#endif

  group = new BLE_Group_Peripheral(1); // The parameter is the groupID
  // group->subscribe("test", callbackFunc);
}

void loop()
{
  // group->publish("test-periph", "Some Data");
  Log.info("looping in peripheral");
  delay(6000);
}

Now, I have two questions:

  1. Did I hit another BLE scan issue like the one mentioned in the previous BLE_GROUP post?
  2. How do I troubleshoot this?

Thank you!
Gustavo.
FYI @rickkas7 @mariano

1 Like

Oh, ouch! That’s a bug with a pointer being left uninitialized.

I just pushed a new version into the library system and Github that fixes the issue. Please try it and let me know if it’s fixed.

Sorry about the bug, but nice catch @gusgonnet !

1 Like

that fixed it, gracias Mariano!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.