3 Replies Latest reply on Apr 14, 2019 10:35 PM by GyanC_36

    UART to BLE - increasing mtu


      I have created a PCB that uses a CYBLE-224116-01 module and have code running on it that communicates via the UART.  I added BLE peripheral functionality based off the 100 Projects in 100 Days Day 20 code downloaded from GitHub but my aim is to replace the UART with BLE so that the communication that went over the UART instead go over the BLE link.  I also reprogrammed a PRoC dongle in the Central role following this example https://iotexpert.com/2017/05/11/psoc4-ble-central-using-cysmart-dongle/


      I made this setup work (although there were some reliability issues as yet unresolved) but I need to increase the size of the packets I send over.  My peripheral device code creates data to send over the link which it sets up in a null-terminated string called strMsg1 defined as char strMsg1[64];  The problem is that the peripheral BLE code throws away anything more than 20 characters at the beginning of the string and I was advised to make the following changes the the peripheral BLE component settings:


      1) Set the Link Layer Max Tx Payload Size and Link Layer Max Rx Payload Size to 251

      2) Increase the size of the Tx data and Rx data characteristics to something larger than 20.  Maybe 250. 

      3) Up the Attribute MTU size to 512

      4) Set the L2CAP MTU and MPS sizes to 512


      I made these changes and it still worked with my dongle Central but any strings sent over the link were still limited to the first 20 characters.  I wonder if I needed to change the settings in the dongle end but when I tried to increase MTU to 512, it would not compile with an error of 'ram overflowed with stack', I tried a few changes in the System tab for the Stack and Heap sizes but was unable to find numbers that would compile without errors.



      1.     Were the setting suggested for the peripheral side OK? (I may try lower numbers as my max string length is going to be 64)

      2.     Do I even need to change the settings on the Central side?

      3.     If the answer to 2 is yes, can anyone help on the setting changes?


      Thanks in advance for any assistance.

        • 1. Re: UART to BLE - increasing mtu

          Hi Ted,


               Your peripheral side settings are perfect. I assume that you are sending a packet which has a length equal to "mtuSize-3" and if the MTU size in your central project (Dongle) is selected as 23 , then you will get a 20 bytes packet because on MTU negotiation process the MTU size will be the minimum of Central and Peripheral project.



                      uartTxDataNtf.value.val  = uartTxData;

                      uartTxDataNtf.value.len  = uartTxDataLength;  //GYAN -> Check what is the value of this ?

                      uartTxDataNtf.attrHandle = CYBLE_SERVER_UART_SERVER_UART_TX_DATA_CHAR_HANDLE;         

                      bleApiResult = CyBle_GattsNotification(cyBle_connHandle, &uartTxDataNtf);




          So, just check what is the MTU size selected in your central device and what is the length of packet you are giving for the notification packet you are sending.


          If it doesn't help , please share your project.



          1 of 1 people found this helpful
          • 2. Re: UART to BLE - increasing mtu

            Hi Gyan,


            Thanks for the prompt response.  It seems that the next logical step for me is to increase the MTU size at the Central end but I am having issues with this.


            As linked in my original post, I used the Central program from the 100 projects in 100 days UART to BLE (Day 20) example . Following Alan Hawse's example of loading that onto a Cypress CY5670 Dongle (with PRoC & 128K of Flash) after tweaking the code by changing the device to the CYBL10162-56LQXI and changing the Conn_LED pin to P3.3.  That's what I have had working but limited to 20 bytes (which you now clearly confirm is as expected because of the MTU setting in that project).


            However, when I try to increase the 'Attribute MTU size' setting in the Gap Settings tab of the BLE component configuration box, I then get an error which seems to be related to stack and heap sizes.  The values I saw in System Tab for the Heap/Stack were 0x80/0x0800 respectively and I've tried increasing these but keep getting the error...


            Build error: region RAM overflowed with stack


            1.     Do I need to adjust something other than the Attribute MTU size' setting?

            2.     What are your recommended Heap/Stack sizes?


            Note that, if there's a space problem in the CYBL10162-56LQXI device, I can decrease the MTU allocation at both ends because the maximum packet size I expect to send is 64 bytes.


            Thanks for your help.




            [EDIT] I got it to compile by setting the Attribute MTU Size to 128 and then it compiled OK with the original Heap/Stack settings.  I also found that the range is poor so it connects reliably if the antennae are < 12 inches apart.  Now I have issues with teh handling of transmitted data, Appcallback etc.  I would like to share the project with you, is there some way I can do that privately?

            • 3. Re: UART to BLE - increasing mtu

              Hi Ted,


                You have to properly set the stack/heap size based on the size of your application. Yes, if you are sending a packet of 64 bytes ,you can set the MTU size to (64+3) = 67 at both central and peripheral.


              If you want to share the project , you can contact to your local Cypress FAE and share it with him.



              1 of 1 people found this helpful