Skip to content

NimBLEAdvertisedDevice::isConnectable() seems malfunctioning! #998

@Berg0162

Description

@Berg0162
/*
 * @brief Get the advertisement type.
 * @return The advertising type the device is reporting:
 * * BLE_HCI_ADV_TYPE_ADV_IND            (0) - indirect advertising
 * * BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD  (1) - direct advertising - high duty cycle
 * * BLE_HCI_ADV_TYPE_ADV_SCAN_IND       (2) - indirect scan response
 * * BLE_HCI_ADV_TYPE_ADV_NONCONN_IND    (3) - indirect advertising - not connectable
 * * BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD  (4) - direct advertising - low duty cycle
 */
Advertising Type Connectable Scannable Typical Use Case
ADV_IND ✅ Yes ✅ Yes Generic smart devices (e.g., Tacx, HRMs)
ADV_DIRECT_IND_HD ✅ Yes ❌ No Fast reconnects to bonded centrals
ADV_SCAN_IND ❌ No ✅ Yes Scannable beacons or status advertisers
ADV_NONCONN_IND ❌ No ❌ No Passive beacons (e.g., iBeacon)
ADV_DIRECT_IND_LD ✅ Yes ❌ No Power-efficient reconnect to known centrals

I have noticed that with devices that have advertisement type is BLE_HCI_ADV_TYPE_ADV_IND, always: isConnectable() returns false.
However these devices are very capable to connect without problems is my experience...

Explanation is in the source code NimBLEAdvertisedDevice.cpp where:

#define BLE_HCI_ADV_CONN_MASK               (0x0001)
#define BLE_HCI_ADV_SCAN_MASK               (0x0002)
#define BLE_HCI_ADV_DIRECT_MASK             (0x0004)
#define BLE_HCI_ADV_SCAN_RSP_MASK           (0x0008)

/**
 * @brief Check if this device is advertising as connectable.
 * @return True if the device is connectable.
 */
bool NimBLEAdvertisedDevice::isConnectable() const {
# if CONFIG_BT_NIMBLE_EXT_ADV
    if (m_isLegacyAdv) {
        return m_advType == BLE_HCI_ADV_RPT_EVTYPE_ADV_IND || m_advType == BLE_HCI_ADV_RPT_EVTYPE_DIR_IND;
    }
# endif
    return (m_advType & BLE_HCI_ADV_CONN_MASK) || (m_advType & BLE_HCI_ADV_DIRECT_MASK);
} // isConnectable

advertisement type is BLE_HCI_ADV_TYPE_ADV_IND (0x0000) will always return false. This seems incorrect, please have a close look!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions