# Identical BLE Receive String Function Crashing

**URL:** <https://community.thunkable.com/t/identical-ble-receive-string-function-crashing/2839717>\
**Category:** BLE / BlueTooth\
**Tags:** bluetooth, help\
**Created:** [February 18, 2024, 2:14am UTC](https://community.thunkable.com/t/identical-ble-receive-string-function-crashing/2839717 "2024-02-18T02:14:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.chaney3nptx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/michael.chaney3nptx/32/138314_2.png) [@michael.chaney3nptx](https://community.thunkable.com/u/michael.chaney3nptx)\
**Post date:** [February 18, 2024, 2:14am UTC](https://community.thunkable.com/t/identical-ble-receive-string-function-crashing/2839717/1 "2024-02-18T02:14:41Z")

</div>

I have the following blocks. GetSpeed works without issue. GetBrightness crashes the app. The first step in the callbacks on the ESP32 is to print the read type. For example, when I call getSpeed, the ESP32 immediately prints SPEED READ Initialized, then it prints one mroe line with the value sent. When I call getBrightness, the BRIGHTNESS READ Initialized message isn’t output and the app crashes. I rebuilt the function using a different name with the same result when it is called.

My phone is still connected, otherwise I would see the device disconnected message so it seems that the app is crashing before the call to BLE Receive String transmits.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/2/12c194b2a8d85cf10e06c6eaaf18796159c7e8dd.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/2/628ff113bd3ce4cfec9ce2174f228b64bf804d77.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/0/10c1b4b8adaba06e4b69d67e6d61cf440cd7a63d.png)

---

<div class="post-metadata">

**Author:** ![michael.chaney3nptx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/michael.chaney3nptx/32/138314_2.png) [@michael.chaney3nptx](https://community.thunkable.com/u/michael.chaney3nptx)\
**Post date:** [February 18, 2024, 10:27pm UTC](https://community.thunkable.com/t/identical-ble-receive-string-function-crashing/2839717/2 "2024-02-18T22:27:41Z")

</div>

I think I’m just going to try rebuilding the app from scratch 😡

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [February 19, 2024, 6:05pm UTC](https://community.thunkable.com/t/identical-ble-receive-string-function-crashing/2839717/3 "2024-02-19T18:05:50Z")

</div>

Hello @michael.chaney3nptx  
Before you make changes to the blocks, could you please ensure that you send the correct type of data?  
In your case, esp32 should send a string  
Are you sure that is the correct UUID?  
If this is correct you can try to add the “Receive string” block inside of a when button click and connect the data response into a label

---

<div class="post-metadata">

**Author:** ![michael.chaney3nptx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/michael.chaney3nptx/32/138314_2.png) [@michael.chaney3nptx](https://community.thunkable.com/u/michael.chaney3nptx)\
**Post date:** [February 19, 2024, 6:29pm UTC](https://community.thunkable.com/t/identical-ble-receive-string-function-crashing/2839717/4 "2024-02-19T18:29:47Z")

</div>

Thank you for the assistance!

I’ve made sure the data types are exactly the same from the ESP32. If you look at the last screenshot you can see the MODE and SPEED reads work but the BRIGHTNESS read isn’t even called. Printing that line is the first step in the callback on the ESP32.

I’m positive it’s the correct UUID. I swapped UUID’s for speed and brightness and speed still works. without issue.

I’m already calling Receive String and the brightness string is formatted exactly like the speed. XXX,XXX should be the value sent for either.

I have a when block for changing a label value. Speed or brightness can be a value between 0 and 100. The first value is for strip 1, the second for strip 2. The values XXX,XXX are split into a list when received. When the list variables are initialized or changed the label for each value is changed. There are seperate list variables for mode, speed and brightness.

Everything points to the app crashing when the Receive String call is made from the GetBrightness function, even though it’s identical to the GetSpeed function which works.

I added a notification box to the GetBrightness function before Receive String is called and it runs without issue, then the app immediately crashes on confirm when Receive string is called, but only in the GetBrightness function.

---

<div class="post-metadata">

**Author:** ![michael.chaney3nptx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/michael.chaney3nptx/32/138314_2.png) [@michael.chaney3nptx](https://community.thunkable.com/u/michael.chaney3nptx)\
**Post date:** [February 19, 2024, 7:23pm UTC](https://community.thunkable.com/t/identical-ble-receive-string-function-crashing/2839717/5 "2024-02-19T19:23:14Z")

</div>

It wasn’t an issue in the blocks. By default there’s a limit on the number of characteristics handled. I changed the following ESP32 code and am now receiving the Brightness value without issue.

From:  
BLEService \*pService = pServer-\>createService(SERVICE\_UUID);

To:  
BLEService \*pService = pServer-\>createService(BLEUUID(SERVICE\_UUID), 30, 0);

> <https://github.com/nkolban/esp32-snippets/issues/829>
>
> 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();                                                 
> \`
