Connecting BlueDash® to Arduino via BLE After Idle Period

Hello everyone,

I’m currently working with a project that involves using BlueDash® for Bluetooth® LE communication with an Arduino device. I’ve encountered a peculiar issue: after my Arduino (equipped with a BLE module) remains idle for about 5-10 minutes, I can no longer establish a connection through BlueDash®. This problem seems akin to the device entering a sleep or deep sleep mode and not being able to wake up.

I’ve tried several approaches to prevent the Arduino from going into sleep mode, including implementing idle hooks and locking the sleep manager, but these attempts haven’t yielded success. Here’s a snippet of the setup I’m using (error handling excluded for brevity):

cppCopy code


#include "ArduinoBLE.h"
#include "events/EventQueue.h"

// Setting up advertising data and event queue
static uint8_t advData[31] = { /* Advertising data bytes */ };
static events::EventQueue eq;

// Function to initiate advertising
void advertise() {
    // Code to configure and start advertising
}

// BLE event handling structure
struct EventHandler: public BLEEventHandler {
    void onDisconnectionComplete(const DisconnectionCompleteEvent &event) override {
        advertise();
    }
};

// Initialization and event scheduling functions
void onInitComplete(BLEInitializationCompleteCallbackContext *event) {
    // Handling after initialization is complete
}

void scheduleEvents(BLEOnEventsToProcessCallbackContext *event) {
    eq.call(&event->ble, &BLE::processEvents);
}

int main() {
    // Main function for BLE and event handling setup
}

When I continuously connect and disconnect every 2-3 minutes using BlueDash®, the Arduino remains discoverable. However, if I let it stay idle for longer, it becomes undetectable.

Hello,

that seems like interesting project, but how you many times mentioned it is Arduino and this is Mbed community forum. So how exactly can we help you? If it is a board what run on Mbed under hood, then Arduino is responsible anyway.

BR, Jan