Edge BLE Connect Issue

Hi,

I have been attempting to establish a BLE connection between my Particle Monitor and another NRF52840 device. However, the following logs have occurred multiple times (sometimes after hours) before the connection could be successfully made:

[app] INFO: Into Scan Result
[app] INFO: MAC: 12:34:56:78:90:12 , deviceName: Test-1
[app] INFO: Connect State
[wiring.ble] TRACE: New peripheral is connected.
[wiring.ble] TRACE: Start discovering services.
[app] INFO: Client disconnected
[wiring.ble] TRACE: Disconnected

How can I enable debug mode on the edge device so I can access more detailed logs regarding the error? I attempted to edit ble_hal.cpp as follows, but it did not yield any success:

#define DEBUG_BUILD
#undef LOG_COMPILE_TIME_LEVEL

Thank you!

The HAL functions are part of Device OS, so enabling debugging is difficult, because by default it will not be flashed to the device when you build your firmware, and pre-built binaries (without your change) will be used by default.

The easiest way to force a modified version to be used is to follow the instructions to use a custom device OS build. Use Particle: Configure Project for Device and select deviceOS@source. Then Particle: flash application for debug (local) to flash your firmware and the modified version of Device OS.

Hi, what deviceOS are you using? There was this issue on BLE on 5.7.0 that was resolved on 5.8.0.

Thanks. I'm on 5.7.0.... Let's me try the new 5.8.0 firmware.

When I use my phone to clone the nrf52840 device, my phone has the same characteristics, and the particle device connects fine. However, the issue only occurs when the nrf advertises itself, so I'm curious why that happens

The issue still happen on 5.8.0 firmware for the Edge

I tried the flash application for debug(local) but the log isn't giving me much info regarding why it dropped ble connection when trying to discover characteristic.

Was there a version of device OS where this worked fine? A problem that came up with recent device OS versions?

I began with version 5.7.0 and have not experimented with any versions older than 5.7.0. However, I recently tried version 5.8.0 but same issue happen.

   case NodeState::Scan:
    {

        //Log.info("SCan For device");
        BLE.scan(scanResultCallback);
        break;
    }
    case NodeState::Connect:
    {
        Log.info("Connect State");
        stateConnect();
        break;
    } 

void scanResultCallback(const BleScanResult *scanResult, void *context)
{

    Log.info("Into Scan Result");
    if (strstr(scanResult->advertisingData().deviceName().c_str(), "Test") != nullptr)
    {
        Log.info("MAC: %02X:%02X:%02X:%02X:%02X:%02X , deviceName: %s",
                 scanResult->address()[0], scanResult->address()[1],
                 scanResult->address()[2], scanResult->address()[3],
                 scanResult->address()[4], scanResult->address()[5],
                 scanResult->advertisingData().deviceName().c_str());
        BLE.stopScanning();

        Target_Address = scanResult->address();
        _nodeState = NodeState::Connect;
    }
}
void stateConnect(void)
{
    // peer = BLE.connect(Target_Address);
    peer = BLE.connect(Target_Address);
    Log.info("Connecting To %02X:%02X:%02X:%02X:%02X:%02X!", Target_Address[0], Target_Address[1], Target_Address[2], Target_Address[3], Target_Address[4], Target_Address[5]);
    if (!peer.connected())
    {
        Log.error("failed to connect, retrying");

        return;
    }

    else
    {
        Log.info("successfully connected  to %02X:%02X:%02X:%02X:%02X:%02X!",
                 Target_Address[0], Target_Address[1], Target_Address[2], Target_Address[3], Target_Address[4], Target_Address[5]);
        {
            _nodeState = NodeState::Characteristic_Subscribe;
        }
    }
}