Skip to content

ESP32 BLE client connect to multiple servers #6926

@UmangSuthar101

Description

@UmangSuthar101

Board

ESP32 DevKitc V4

Device Description

  • Development Kit: ESP32 DevKitc V4(attached picture)
    ESP32-DEV-KIT-DevKitC-v4-pinout-mischianti

  • Module or chip used: ESP32-WROOM-32

  • Compiler version: Extensa-esp32-elf-GCC

Hardware Configuration

GPIO(34) connected to the resistor n/w for getting analog value of the battery!!

Version

v1.0.6

IDE Name

Arduino IDE

Operating System

Windows 10

Flash frequency

80 MHz

PSRAM enabled

no

Upload speed

921600

Description

I upload the code for the BLE multi-client in this module.

After some time such logs appear in the console:
....
lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 2)
....
lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)

BLE disconnects happen too often and show me these types of logs.
Capture

Expected Behavior

  • Stable BLE connection
  • Can connect multiple BLE servers on this module and get the data
    simultaneously

Sketch

bool connectToServer() {

  BLEClient*  pClient  = BLEDevice::createClient();
  pClient->setClientCallbacks(new MyClientCallback());
  pClient->connect(myDevice);
  Serial.println(" - Connected to Spo2");

  BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
  if (pRemoteService == nullptr) {
    pClient->disconnect();
    return false;
  }
  pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
  if (pRemoteCharacteristic == nullptr) {
    pClient->disconnect();
    return false;
  }
  if (pRemoteCharacteristic->canNotify())
    pRemoteCharacteristic->registerForNotify(notifyCallback);
  return true;
}

//This upper code will write multiple times as per servers //numbers

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
      // We have found a device, let us now see if it contains the service we are looking for.
      if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)) {
        BLEDevice::getScan()->stop();
        myDevice = new BLEAdvertisedDevice(advertisedDevice);
        doConnect = true;
        doScan = true;
      }
    }
};


void setup() {
  Serial.begin(115200);
  ble();
  ble1();
  ble2();
  ble3();
}

void ble() {
  BLEDevice::init("abc");

  BLEScan* pBLEScan = BLEDevice::getScan();
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setInterval(1349);
  pBLEScan->setWindow(449);
  pBLEScan->setActiveScan(true);
  pBLEScan->start(1);
}

// multiple ble's loop functions

Debug Message

....
lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 2)
....
lld_pdu_get_tx_flush_nb HCI packet count mismatch (0, 1)

Note: I already attached serial output for the perticular error.

Other Steps to Reproduce

I go thruogh the espriff forum and also check github for HCI error but nothing get any solution.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions