BLE disconnects when Android phone turns off

Hello All!
I’ve only started playing with Arduino and Blynk a few weeks ago, so I’m still to figure it out and am apt to go around in circles trying to get things to work.

Here’s my situation, I’m using Bluetooth LE for a sketch and Blynk is disconnecting everytime the Android phone goes to sleep. It seems like this wasn’t happening about a week ago.

Did something change with the BLE widget when the Bluetooth widget was added about a week ago? Or am I just remembering it wrong? It doesn’t seem like you should have to reconnect the BLE widget everytime the phone wakes up.

Here’s my hardware:

Nexus 6 with Android 7.0
Sparkfun RedBoard (Uno Clone)
AdaFruit BlueFruit LE Shield

And a sketch to demonstrate what I’m doing:

/////////////////////////////////////
//
// Simple example of Blynk, debug, and BLE
//
// V0 Button Widget
// V1 LED Widget

// BLERG! The debug lines need to be at the top of the sketch!
#define BLYNK_PRINT Serial // Defines the object that is used for printing
// #define BLYNK_DEBUG        // Optional, this enables more detailed prints

// #define BLYNK_USE_DIRECT_CONNECT // This doesn't seem to work at the moment

// Adafruit Bluefruit LE Shield which uses SPI
#include <SPI.h>
#include <SoftwareSerial.h>
#include <BlynkSimpleSerialBLE.h>
#include <Adafruit_BLE.h>
#include <Adafruit_BluefruitLE_SPI.h>

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";

#define BLUEFRUIT_SPI_CS 8
#define BLUEFRUIT_SPI_IRQ 7
#define BLUEFRUIT_SPI_RST 4
#define BLUEFRUIT_VERBOSE_MODE true

Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

WidgetLED led1(V1);

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ble);
  ble.begin(BLUEFRUIT_VERBOSE_MODE);
  ble.factoryReset(); // Optional
  ble.setMode(BLUEFRUIT_MODE_DATA);
  led1.off();
}

void loop()
{
  Blynk.run(); // All the Blynk Magic happens here...
}

BLYNK_WRITE(V0)
{
  int p = param.asInt();
  int l = led1.getValue();
  BLYNK_LOG("Button is %i and %i", p, l);

  if (p == 1)
  {
    led1.on();
  }
  else if (p == 0)
  {
    led1.off();
  }
}

Any ideas or thoughts?

Thanks for any help,

digger

Hello. Let us check.

It’s ok behavior now, as we stops all communication in case of app being backgrounded, soon we’ll change this for BLE, but after implementation of some other app’s features.

Okay, @BlynkAndroidDev thanks for the information

(should I mark this as solved? Or leave it open till it’s resolved?)

Leave it, when we’ll return to this issue - i’ll notify you.

@BlynkAndroidDev,

Hi did this ever get updated for BLE to run in the background?

Thanks

It would not be changed in the nearest time. In any case app reconnects to the ble device on the re-open, so I don’t see any problem in this issue.