5 Replies Latest reply on Feb 2, 2019 9:40 AM by JeCr_2235141

    Android - Using MTU size of 512 byte

      Hi,

         

      in my current project we're designing a custom board acting as a Peripheral. Another company is designing an App (iOS & Android) acting as Central to control actions on our board.

      According to the engineer designing the Android App, it isn't possible to use a MTU greater than 23 byte under Android. So I set the MTU in my design to that value. Now that we're using OTA upgrade functionality it takes around 11min to do a upgrade the firmware with these MTU settings. So there is the need to change the MTU to 512 byte which would reduce the update time drastically.

         

      I did following test:

         

      - Changing the MTU size to 512 byte.

         

      - Disabled Write Long Characteristic support.

         

      - Writing a characteristic with a size of  50 byte on iOS via CySmart App -> Write succeeded.

         

      - Doing the same on Android -> Write succeeded.

         

      That just confused me, because the engineer of the Android App said that this shouldn't work.

         

       

         

      I did another test:

         

      - Changing the MTU size to 23 byte.

         

      - Disabled Write Long Characteristic support.

         

      - Writing a characteristic with a size of  50 byte on iOS via CySmart App -> Write succeeded.

         

      - Doing the same on Android-> Write succeeded.

         

      That confused me way more. In my opinion that shouldn't be possible, because I disabled Write Long Support.
       

         

      All that leads me to some questions:

         

      - Is it possible to use a MTU size of 512 byte under Android?

         

      - How is it possible that the CySmart could write characteristics with a size exceeding the MTU? How is that handled in the App?
       

         

      Hope you can help me.

      Best

         

      Philipp

        • 2. Re: Android - Using MTU size of 512 byte
          himam_31

          Hi ,

             

          For Android phones, it is not possible to change the MTU size from default (23 bytes).

             

          Can you please let me know how you verified the write is success after disabling the write long? Did you read back the GATT DB written value? Is it was showing the data which > 20 bytes? Please check it, it would not have updated the GATT DB .

             

          Thanks,

             

          Hima

          • 3. Re: Android - Using MTU size of 512 byte

            I forgot to mention, that I disabled the Write Long Support in my BLE event callback function by not handling the corresponding events. And yes, I verified this by reading back the written values.

               

            Is the Write Long Support somewhere handled in the stack?

            • 4. Re: Android - Using MTU size of 512 byte
              JeCr_2235141

              Hello,

               

              I am also searching for information around this topic.  I question the statment you have made regarding android not being able to handle MTU > 23.  For example in Cypress' own CySmart Phone app, I can see clearly MTU sending data in larger chunks than 20 for sure (see attached).

               

              I have verified PSOC Creator code works with CySmart laptop application & USB dongle.  MTU =500, chunks of data;

              I have also verified on android CySmart App that  the MTU is negotiated and chunks of data are ~500 I believe.  Definitely > 20.

               

              In android App however, some difficulty.  When I set MTU value to any number < 20, it seems to function.  I change the value using the command mBluetoothGatt.requestMtu(mtu), where MTU is some integer.

               

              When I set the value > 20, 23 for example, I get an error.  The way I get the values from the characteristic, are I dynamically instantiate an array of length MTU, and I cycle through a for loop MTU times filling this array with

               

              characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT8,ii).toString()

               

              When I reach ii > 20, I get the error that it is null.

               

              Perhaps there is a better way to do this?  But I am also not sure why the characteristic is returning a null value after request.

               

              Thanks

              • 5. Re: Android - Using MTU size of 512 byte
                JeCr_2235141

                I guess my question is what does Cypress do in Android CySmart app to handle MTU request?