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:
`
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();
`
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!!!
Most helpful comment
here's the line of code that worked for me:
BLEService *pService = pServer->createService(BLEUUID(SERVICE_UUID), 30, 0);
Cheers