Hi,
I'm using BLE on ESP32.
The ESP32 board is my server.
I have a problem: the number of services is limited to 7, and also the number of characteristics is limited to 7.
If I try to use more services or characteristics the client (the smartphone or another ESP32 board) can't see them.
Is it possible to use more services and characteristics?
I have tried to see if there are some #define in the .h files that limit this number, but I don't have found anything.
Thank you
BLE: limited number of services and characteristics
Re: BLE: limited number of services and characteristics
There is parameter handles number
https://github.com/nkolban/ESP32_BLE_Ar ... Server.cpp
https://github.com/nkolban/ESP32_BLE_Ar ... Server.cpp
Re: BLE: limited number of services and characteristics
Thank you very much!
If other people are interested in this: the parameter numHandles of the function createService allows you to specify the number of characteristics.
Just out of curiosity: is it possible to change also the number of services?
If other people are interested in this: the parameter numHandles of the function createService allows you to specify the number of characteristics.
Just out of curiosity: is it possible to change also the number of services?
Re: BLE: limited number of services and characteristics
There is no services number limit. Only limit is handles number which is 0xFFFF.
Re: BLE: limited number of services and characteristics
I have the same issue with the number of services for the esp32.
The following code stops after starting the seventh service.
Is the number of possible BLE-services on an ESP32 limited or can I change something in the code to expand the number?
The following code stops after starting the seventh service.
Is the number of possible BLE-services on an ESP32 limited or can I change something in the code to expand the number?
- /*
- 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 SERVICE1_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE2_UUID "5fafc201-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE3_UUID "6fafc201-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE4_UUID "7fafc201-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE5_UUID "8fafc201-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE6_UUID "9fafc201-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE7_UUID "4fafc301-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE8_UUID "4fafc401-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE9_UUID "4fafc501-1fb5-459e-8fcc-c5c9c331914b"
- #define SERVICE10_UUID "4fafc601-1fb5-459e-8fcc-c5c9c331914b"
- void setup() {
- Serial.begin(115200);
- Serial.println("Starting BLE work!");
- BLEDevice::init("Long name works now");
- BLEServer *pServer = BLEDevice::createServer();
- Serial.println("Service1");
- BLEService *pService1 = pServer->createService(SERVICE1_UUID);
- BLECharacteristic *pCharacteristic1 = pService1->createCharacteristic(SERVICE1_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic1->setValue("Hello World says Neil");
- pService1->start();
- Serial.println("Service2");
- BLEService *pService2 = pServer->createService(SERVICE2_UUID);
- BLECharacteristic *pCharacteristic2 = pService2->createCharacteristic(SERVICE2_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic2->setValue("Hello World says Neil");
- pService2->start();
- Serial.println("Service3");
- BLEService *pService3 = pServer->createService(SERVICE3_UUID);
- BLECharacteristic *pCharacteristic3 = pService3->createCharacteristic(SERVICE3_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic3->setValue("Hello World says Neil");
- pService3->start();
- Serial.println("Service4");
- BLEService *pService4 = pServer->createService(SERVICE4_UUID);
- BLECharacteristic *pCharacteristic4 = pService4->createCharacteristic(SERVICE4_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic4->setValue("Hello World says Neil");
- pService4->start();
- Serial.println("Service5");
- BLEService *pService5 = pServer->createService(SERVICE5_UUID);
- BLECharacteristic *pCharacteristic5 = pService5->createCharacteristic(SERVICE5_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic5->setValue("Hello World says Neil");
- pService5->start();
- Serial.println("Service6");
- BLEService *pService6 = pServer->createService(SERVICE6_UUID);
- BLECharacteristic *pCharacteristic6 = pService6->createCharacteristic(SERVICE6_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic6->setValue("Hello World says Neil");
- pService6->start();
- Serial.println("Service7");
- BLEService *pService7 = pServer->createService(SERVICE7_UUID);
- BLECharacteristic *pCharacteristic7 = pService7->createCharacteristic(SERVICE7_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic7->setValue("Hello World says Neil");
- pService7->start();
- Serial.println("Service8");
- BLEService *pService8 = pServer->createService(SERVICE8_UUID);
- BLECharacteristic *pCharacteristic8 = pService8->createCharacteristic(SERVICE8_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic8->setValue("Hello World says Neil");
- pService8->start();
- Serial.println("Service9");
- BLEService *pService9 = pServer->createService(SERVICE9_UUID);
- BLECharacteristic *pCharacteristic9 = pService9->createCharacteristic(SERVICE9_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic9->setValue("Hello World says Neil");
- pService9->start();
- Serial.println("Service10");
- BLEService *pService10 = pServer->createService(SERVICE10_UUID);
- BLECharacteristic *pCharacteristic10 = pService10->createCharacteristic(SERVICE10_UUID, BLECharacteristic::PROPERTY_READ);
- pCharacteristic10->setValue("Hello World says Neil");
- pService10->start();
- 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);
- }
Re: BLE: limited number of services and characteristics
I tried this code with esp-idf in PIO and i found this, which is very strange:
You can try to use this function and decrease numHandles:
https://github.com/nkolban/esp32-snippe ... rver.h#L67
Each characteristic needs 2 handles and descriptor 1 handle.
Code: Select all
BT_GATT: GATTS_ReserveHandles: no free handle blocks
https://github.com/nkolban/esp32-snippe ... rver.h#L67
Each characteristic needs 2 handles and descriptor 1 handle.
-
- Posts: 8
- Joined: Thu Jul 30, 2020 11:23 am
Re: BLE: limited number of services and characteristics
Hello,
I am facing exactly same issue.
I am using Arduino IDE to code ESP-32 module. Currently I am using BLE functionality to communicate with our mobile app.
There seems to be limitation on number of BLE services which can be created. Even If I create more than 7 services, only 6 are visible.
I find some link which states solution in ESP-IDF but I couldn't find this variable GATT_MAX_SR_PROFILES or bt_target.h file:
https://github.com/espressif/esp-idf/issues/1644
https://github.com/espressif/esp-idf/issues/5495
Can someone help me?
I am facing exactly same issue.
I am using Arduino IDE to code ESP-32 module. Currently I am using BLE functionality to communicate with our mobile app.
There seems to be limitation on number of BLE services which can be created. Even If I create more than 7 services, only 6 are visible.
I find some link which states solution in ESP-IDF but I couldn't find this variable GATT_MAX_SR_PROFILES or bt_target.h file:
https://github.com/espressif/esp-idf/issues/1644
https://github.com/espressif/esp-idf/issues/5495
Can someone help me?
Who is online
Users browsing this forum: No registered users and 67 guests