Is there a limit when creating BLE Characteristics?

Buccaneer6
Posts: 2
Joined: Mon Apr 10, 2023 3:48 pm

Is there a limit when creating BLE Characteristics?

Postby Buccaneer6 » Mon Apr 10, 2023 4:02 pm

Pretty sure the limit is around 512 but using the examples code BLE_server I can create new Characteristics and everything goes good for the first 6 and then nothing new showing in nRF. I get the same in my projects but this is the smallest code showing the problem and it gets worse if I try and create Descriptors for these i.e. less Characteristics created. Any ideas or directions to look in would be appreciated.

CHAR1_UUID and up and BLECharacteristic *pCharacteristic_1 and up are my additions.

Code: Select all

/*
    Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleServer.cpp
    Ported to Arduino ESP32 by Evandro Copercini
    updates by chegewara
*/

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/

#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
#define CHAR1_UUID "d0759e0f-1ffb-435c-a5a6-6a7350c160be"
#define CHAR2_UUID "e3223119-9445-4e96-a4a1-85358c4046a2"
#define CHAR3_UUID "c009e3a2-5fbb-42ba-9717-1a65cee3206b"
#define CHAR4_UUID "04e16d1a-c427-4347-964e-aaa9f3767d88"
#define CHAR5_UUID "b987d703-4cdd-461b-a8a9-079e95ee3334"
#define CHAR6_UUID "44f5847f-6335-4656-be5a-cbb41e49159f"
#define CHAR7_UUID "b4647d13-4eb9-4da7-ac06-e6e6f0f8d093"
#define CHAR8_UUID "1aa09320-08ec-4f52-a960-45a755d1ed8e"

void setup() {
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  BLEDevice::init("ESP32-C3");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
    CHARACTERISTIC_UUID,
    BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE);

  pCharacteristic->setValue("Hello World says Neil");

  BLECharacteristic *pCharacteristic_1 = pService->createCharacteristic(
    CHAR1_UUID,
    BLECharacteristic::PROPERTY_NOTIFY);
  //pCharacteristic_1->setValue("Num 1");

  BLECharacteristic *pCharacteristic_2 = pService->createCharacteristic(
    CHAR2_UUID,
    BLECharacteristic::PROPERTY_NOTIFY);

  BLECharacteristic *pCharacteristic_3 = pService->createCharacteristic(
    CHAR3_UUID,
    BLECharacteristic::PROPERTY_NOTIFY);

  BLECharacteristic *pCharacteristic_4 = pService->createCharacteristic(
    CHAR4_UUID,
    BLECharacteristic::PROPERTY_NOTIFY);

  BLECharacteristic *pCharacteristic_5 = pService->createCharacteristic(
    CHAR5_UUID,
    BLECharacteristic::PROPERTY_NOTIFY);

  BLECharacteristic *pCharacteristic_6 = pService->createCharacteristic(
    CHAR6_UUID,
    BLECharacteristic::PROPERTY_NOTIFY);

  BLECharacteristic *pCharacteristic_7 = pService->createCharacteristic(
    CHAR7_UUID,
    BLECharacteristic::PROPERTY_NOTIFY);

  BLECharacteristic *pCharacteristic_8 = pService->createCharacteristic(
    CHAR8_UUID,
    BLECharacteristic::PROPERTY_NOTIFY);

  pService->start();
  // BLEAdvertising *pAdvertising = pServer->getAdvertising();  // this still is working for backward compatibility
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  pAdvertising->setMinPreferred(0x06);  // 0x06 functions that help with iPhone connections issue
  pAdvertising->setMinPreferred(0x12);
  BLEDevice::startAdvertising();
  Serial.println("Characteristic defined! Now you can read it in your phone!");
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
}

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 117 guests