Esp32-snippets: max # of characteristics supported?

Created on 8 Mar 2019  路  7Comments  路  Source: nkolban/esp32-snippets

I have set up a BLE service and added 6 characteristics.
Any BLE client I used only finds 5 of the characteristics. The last one is always not found.
I changed the sequence of characteristics added and still, the last one added is not found.

Is there a limit on max # of characteristics supported per service on a esp32?

Here is my server code snippet:

`

define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"

define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a0"

define CHARACTERISTIC1_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a1"

define CHARACTERISTIC2_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a2"

define CHARACTERISTIC3_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a3"

define CHARACTERISTIC4_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a4"

define CHARACTERISTIC5_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a5"

BLECharacteristic *pCharacteristic;
BLECharacteristic *pCharacteristic1;
BLECharacteristic *pCharacteristic2;
BLECharacteristic *pCharacteristic3;
BLECharacteristic *pCharacteristic4;
BLECharacteristic *pCharacteristic5;

BLEDevice::init("Sensor Testserver");
BLEServer *pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());

BLEService *pService = pServer->createService(SERVICE_UUID);
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY
);
pCharacteristic1 = pService->createCharacteristic(
CHARACTERISTIC1_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY
);
pCharacteristic2 = pService->createCharacteristic(
CHARACTERISTIC2_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY
);

pCharacteristic3 = pService->createCharacteristic(
CHARACTERISTIC3_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY
);

pCharacteristic4 = pService->createCharacteristic(
CHARACTERISTIC4_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY
);

pCharacteristic5 = pService->createCharacteristic(
CHARACTERISTIC5_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY
);

pCharacteristic->setValue("Pitch");
pCharacteristic->addDescriptor(new BLE2902());
pCharacteristic1->setValue("Roll");
pCharacteristic1->addDescriptor(new BLE2902());
pCharacteristic2->setValue("Heading");
pCharacteristic2->addDescriptor(new BLE2902());
pCharacteristic3->setValue("Pitch");
pCharacteristic3->addDescriptor(new BLE2902());
pCharacteristic4->setValue("Roll");
pCharacteristic4->addDescriptor(new BLE2902());
pCharacteristic5->setValue("Heading");
pCharacteristic5->addDescriptor(new BLE2902());

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); // functions that help with iPhone connections issue
pAdvertising->setMinPreferred(0x12);
BLEDevice::startAdvertising();
`

Most helpful comment

here's the line of code that worked for me:
BLEService *pService = pServer->createService(BLEUUID(SERVICE_UUID), 30, 0);

Cheers

All 7 comments

in addition, I have another strange observation:
for characteristics 0-3 I do get notifications, with characteristic 4 however, notifications do not work. It is possible to read the values, but changes do not get pushed. So this seems a strange behavior.
Could this be due to performance constraints on the ESP32?

that works!
@chegewara thank you very much!

@hellowtisch

Could you possibly share the line of code you implemented to fix this issue? I have the exact same issue and am struggling to implement numHandles to resolve it without syntax errors.

@hellowtisch
Could you possibly share the line of code you implemented to fix this issue? I have the exact same issue and am struggling to implement numHandles to resolve it without syntax errors.

No worries, seems to have resolved by changing the value from 15 to 20. Uploading for future people looking at this thread:

BLEService *pService = pServer->createService(BLEUUID((uint32_t)SERVICE_UUID), ((uint32_t)20));

here's the line of code that worked for me:
BLEService *pService = pServer->createService(BLEUUID(SERVICE_UUID), 30, 0);

Cheers

here's the line of code that worked for me:
BLEService *pService = pServer->createService(BLEUUID(SERVICE_UUID), 30, 0);

Cheers

I was facing the same issue, this resolved it, thanks a lot!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HarrisonOfTheNorth picture HarrisonOfTheNorth  路  8Comments

monteslu picture monteslu  路  4Comments

mkol5222 picture mkol5222  路  5Comments

wegunterjr picture wegunterjr  路  7Comments

JasXSL picture JasXSL  路  3Comments