Skip to content

BLE reconnection bug (ESP32-S3 / Arduino BLE) #2963

Description

@Jollar24

Problem:

After the first successful pairing, reconnecting a bonded device failed. The Companion connected only after removing the bond ("Forget device") and pairing again. New pairing always worked; subsequent reconnects did not.

Cause:

SerialBLEInterface::checkRecvFrame() reset deviceConnected from pServer->getConnectedCount(). On some Android devices, onAuthenticationComplete() occurred before m_connectedCount was updated, so deviceConnected was immediately cleared and never restored. As a result, writeFrame() refused to send any responses.

Fix:

File: src/helpers/esp32/SerialBLEInterface.cpp

  • Removed:
    if (pServer->getConnectedCount() == 0) deviceConnected = false;
    from SerialBLEInterface::checkRecvFrame().

  • Added:
    deviceConnected = false;
    to SerialBLEInterface::onDisconnect().

This makes connection state event-driven instead of polling getConnectedCount(), fixing bonded-device reconnection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions