BLE client can't connect multi BLE server device

Hi Supporter
I use Ameba26 board, BLE setting as Central type and try to connect to other BLE Peripheral device, it’s only one connection success if setting (BLE.beginCentral(1)), I try to set BLE Cnetral argument(BLE.beginCentral(3)) is also fail, I saw the config for link number(#define BLE_CENTRAL_APP_MAX_LINKS 3) in BLEDevice.h file.If I want to connect more than one Peripheral device, which argument I need to config?Thanks.

for more info about BLE please refer to
https://www.amebaiot.com/en/rtl8722dm-arduino-online-api-documents/

Hi Sir
For this problem we can’t success to connect more than one bluetooth device, we use this web side API to try to connect, as below 8720DF datasheet it support 3+1 BLE link, for this case testing code as below, we only success for one BLE connection, what I miss for this multi connection flow?Thanks for your support.

/*

Example guide:
BLE – Battery Client – Realtek IoT/Wi-Fi MCU Solutions
*/

#include “BLEDevice.h”

#define BATT_SERVICE_UUID “180F”
#define BATT_LEVEL_UUID “2A19”
#define jj_MAXCONN 2

BLEAdvertData foundDevice;
BLEAdvertData targetDevice[jj_MAXCONN];
BLEClient* client_0;
BLEClient* client_1;
BLERemoteService* battService_0;
BLERemoteService* battService_1;
BLERemoteCharacteristic* battChar_0;
BLERemoteCharacteristic* battChar_1;

bool notifyState = false;
int8_t connID[jj_MAXCONN];
int8_t connOffset=0;
int8_t i;

void scanCB(T_LE_CB_DATA* p_data) {
foundDevice.parseScanInfo(p_data);
if (foundDevice.hasName()) {
if (foundDevice.getName() == String(“Nordic_HTS”)){ //AMEBA_BLE_DEV")) {
Serial.print("Found Nordic_HTS BLE Device at address ");
Serial.println(foundDevice.getAddr().str());
targetDevice[connOffset] = foundDevice;
if(++connOffset >=jj_MAXCONN){
connOffset=jj_MAXCONN-1; //fix connOffset to 2 (max of connOffset)
Serial.print(“connection number over MAXCONN_jj”);
}

    }
}
uint8_t serviceCount = foundDevice.getServiceCount();
    if (serviceCount > 0) {
    BLEUUID* serviceList = foundDevice.getServiceList();
        for (uint8_t i = 0; i < serviceCount; i++) {
            if (serviceList[i] == BLEUUID("180F")) {
            Serial.print("Found Battery Service at address ");
            Serial.println(foundDevice.getAddr().str());
            Serial.print("Connection number ");
            Serial.println(connOffset);
        }
    }
}

}

void notificationCB (BLERemoteCharacteristic* chr, uint8_t* data, uint16_t len) {
Serial.print("Notification received for chr UUID: “);
Serial.print(chr->getUUID().str());
if (len == 1) {
Serial.print(” Battery level: ");
Serial.println(data[0]);
}
}
void notificationCB_1 (BLERemoteCharacteristic* chr, uint8_t* data, uint16_t len) {
Serial.print("Notification received for chr UUID: “);
Serial.print(chr->getUUID().str());
Serial.print(chr->getUUID().str());
if (len == 1) {
Serial.print(” Battery level: ");
Serial.println(data[0]);
}
}

void setup() {
Serial.begin(115200);

BLE.init();
BLE.configScan()->setScanMode(GAP_SCAN_MODE_ACTIVE);
BLE.configScan()->setScanInterval(500);   // Start a scan every 500ms
BLE.configScan()->setScanWindow(250);     // Each scan lasts for 250ms
BLE.setScanCallback(scanCB);
BLE.beginCentral(3);

BLE.configScan()->startScan(20000);    // Scan for 20 seconds, then stop
for(i=0;i<=connOffset;i++){
  BLE.configConnection()->connect(targetDevice[i], 2000);
  delay(3000);
  connID[i] = BLE.configConnection()->getConnId(targetDevice[i]);
}

if (!BLE.connected(connID[0])&&!BLE.connected(connID[1])) {
    Serial.println("BLE not connected");
} else if (BLE.connected(connID[0])){
    BLE.configClient();
    client_0 = BLE.addClient(connID[0]);
    client_0->discoverServices();
    Serial.print("Discovering services of connected device");
    do {
        Serial.print(".");
        delay(1000);
    } while (!(client_0->discoveryDone()));
    Serial.println();

    battService_0 = client_0->getService(BATT_SERVICE_UUID);
    if (battService_0 != nullptr) {
        battChar_0 = battService_0->getCharacteristic(BATT_LEVEL_UUID);
        if (battChar_0 != nullptr) {
            Serial.println("Battery level characteristic found");
            battChar_0->setNotifyCallback(notificationCB);
        }
    }

}
else if (BLE.connected(connID[1])){
    client_1 = BLE.addClient(connID[1]);
    client_1->discoverServices();
    Serial.print("Discovering services of connected device");
    do {
        Serial.print(".");
        delay(1000);
    } while (!(client_1->discoveryDone()));
    Serial.println();

    battService_1 = client_1->getService(BATT_SERVICE_UUID);
    if (battService_1 != nullptr) {
        battChar_1 = battService_1->getCharacteristic(BATT_LEVEL_UUID);
        if (battChar_1 != nullptr) {
            Serial.println("Battery level characteristic found");
            battChar_1->setNotifyCallback(notificationCB_1);
        }
    }

}    

}

void loop() {
if (BLE.connected(connID[0])||BLE.connected(connID[1])) {
delay(5000);
Serial.print("Battery level read: ");
if (BLE.connected(connID[0])){
Serial.println(battChar_0->readData8());
}
if (BLE.connected(connID[1])){
Serial.println(battChar_1->readData8());
}
delay(5000);
notifyState = !notifyState;
if (notifyState) {
Serial.println(“Notifications Enabled”);
battChar_0->enableNotifyIndicate();
battChar_1->enableNotifyIndicate();
} else {
Serial.println(“Notifications Disabled”);
battChar_0->disableNotifyIndicate();
battChar_1->disableNotifyIndicate();
}
}
else {
Serial.println(“BLE not connected”);
delay(5000);
}
}