BLE connection extreme slow

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi guys!

   

At the moment i am working on a project that should enable a Android Device (APP programmed with Java in Android Studio ) to send a picture to the CY8CKIT-142. I used a MTU size of 23 bytes because of another Problem which i want do discuss in another post. Because of the resolution of the Eink-display i have to send 284 - 23 byte packages. It takes about 28!!! seconds to transmit the picture. Is there any way to speed up the transmission?

   
        
  •  MTU size is 23byte;
  •     
  • Profile role: GATT Server
  •     
  • GAP role: Peripheral
  •     
  • BLE low power mode
  •     
  • Custom Service 16 bit and Custom Characteristic with 16 bit ->
  •     
  • variable named DATA Type: uint8[]; Length = 20 byte
  •     
  • Properties of Custom Characteristic: Read is true and write is true
  •     
  • GAP Settings -> General -> Attribute MTU size = 23bytes
  •     
  • GAP Settings -> Peripheral preferred connection -> Connection interval Minimum = Maximum = 7.5ms
  •    
   

a few lines of my Code (only write request in StackHandler of BLE)

   

case CYBLE_EVT_GATTS_WRITE_REQ:
        wrReqParam=(CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventParam; /       
        if(wrReqParam->handleValPair.attrHandle==CYBLE_DISPLAYAKT_DISPLAY_CHAR_HANDLE)
        {
            if(CYBLE_GATT_ERR_NONE==CyBle_GattsWriteAttributeValue(&wrReqParam->handleValPair,0,&cyBle_connHandle,CYBLE_GATT_DB_PEER_INITIATED))  
            {   
               for(i=0;i<MTU_SIZE-3-1;i++)
                {
                    picture[i+(MTU_SIZE-3)*packagenr]=wrReqParam->handleValPair.value.val;
                    //receive++;
                }                
                CyBle_GattsWriteRsp(cyBle_connHandle);

   

................... usw....

0 Likes
1 Solution
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Best way to do this is to create a characteristic attribute with the size you need, and then let the BLE stack figure oput how to transfer that best. I did this before, and 1kb can be transmitted in several milliseconds that way. (I think its called 'long read')

View solution in original post

0 Likes
5 Replies
Anonymous
Not applicable

Hi,

   

You have mentioned it takes "28!!!". Did you mean 28 mS or 28 seconds or anything else?

   

The best way is to icrease the MTU size. What issue do have in that? Did you make sure that the increased MTU Size is negotiated to the central using the MTU Update APIs?

   

Regards,

   

- Madhu Sudhan

0 Likes
Anonymous
Not applicable

Thank you for your fast reply I really appreciate your help!

   

 Unfortunately it takes 28 seconds for 5808 byte with a MTU size of 23 byte. Is this normal for BLE i don't think so... I manually changed the MTU size in the BLE block to 512 byte and the length of the characteristic DATA to uint8[] 509 byte. I tried to send 509 byte with the cypress CySmart App for android, but it seems the controller is shutting down...

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Best way to do this is to create a characteristic attribute with the size you need, and then let the BLE stack figure oput how to transfer that best. I did this before, and 1kb can be transmitted in several milliseconds that way. (I think its called 'long read')

0 Likes
Anonymous
Not applicable

That sounds like the answer I was searching for. Would you be so kind to share an example code with me? 

   

Did you mean this function:

   

 CyBle_GattcReadLongCharacteristicValues 

   

So if i understood erverything i have to define a characteristic on my APP and then have to read it with 'long read' instead of defining a characteristic on my PSoC and write to it with my APP?

   

On Android it is possible to make a long write just by trying to send a value of a characteristic greater than 20 byte. How do i prepare my PSoC or how do i respond on such a "long write" request? Is there a long write request i haven't found anything...

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

My project was the other way round - my PSoC4BLE provided an array of data, and the Android app was reading it. AFAIR (this was about a year ago...) it worked without any special setup.

   

_ReadLong looks like the right candidate, yes. When you switch GATT client and server, it even should work without anything else to do - just try with e.g the CySmart client and a small test application.

0 Likes