I have noticed on some other threads that Android phones cannot have MTU > 23. I have adjusted my android code and PSOC project and now it works fine. At least instaed of a 100Hz Bandwidth, I am up to 2Khz seems.
But is there any way around this ? It seems quite limiting for some applications and I am not sure why Iphone would be able to go up to 500MTU while Android sits at 23? I would appreciate anyone's time with this specific question.
1 of 1 people found this helpful
Client will send the MTU request to the peripheral. CYBLE_EVT_GATTS_XCNHG_MTU_REQ event will be generated at the Peripheral device. The client and server exchange the maximum size of a packet that can be received using the Exchange MTU Request and Response PDUs. Both devices then use the minimum of these exchanged values for all further communication. Please refer the Day024_Throughput example project for more information on sending higher Throughput data.
Can you please let me know the Bluetooth version of the Android mobiles which you are using. Some of the mobiles( with having Bluetooth version 4.0) will not send the MTU request to the peripheral devices. So these devices accepts the default MTU size of length 23 bytes and these devices will not accept more than 23bytes MTU size.
Can you please resend the project. In the PSoC Creator, go to File ->Create Workspace Bundle -> Select minimal. Please attach the generated file.
Attached is the workspace bundle. You will find I am working from cypress capsenseled making modifications as necessary.
I had taken a look at the throughput tutorial, but as I am working with an Android App receiving the data, I perhaps did not look as closely. I will review.
capsenseled.cywrk.Archive01.zip 867.0 K
Please find the attached project in which I'm able to send 509 bytes of data continuously when notification was enabled at client side.
The API CyBle_GattcExchangeMtuReq() is used by the GATT Client to send Maximum Transmitted Unit (GATT MTU) supported by the GATT Client. Default GATT MTU size as per Bluetooth 4.1 core specification is 23 bytes. If the GATT Client supports a size greater than the default, it has to invoke this function with the desired GATT MTU size. This function should only be initiated once during a connection.
Please note that for Some of the mobiles( with having Bluetooth version 4.0 or lower) will not send the MTU request to the peripheral devices. So
capsenseled.cywrk.Archive01.zip 867.3 K
This works. Thanks for the assistance. I was able to confirm with both CYSMART app as well as android device, although, the android app is having some implementation issues I am working on.
In the CySmart app, it appears that reading this characteristic yield a ~500 length array. However, I do not see explicit negotiation of MTU in either PSOC Code or in CYSMART app.
In Android App, after discovering services, I am using mBluetoothGatt.requestMtu(mtu) to request changing the MTU. When I do so, the app has been crashing, thought I cannot find root cause yet. Any feedback would be appreciated.
Some additional Info.
In Android App, after discovering services, I am using mBluetoothGatt.requestMtu(mtu) to request changing the MTU.
When I change values to 10 or numbers less than 20, it is OK, and broadcast reciever is recieving data.
When I change values above 23, no data is recieved.
When I change MTU back to say 20, the app no longer works either.
When I disconnect power from the PSOC4, or push reset, and make connection again, the app is again working.
Please share the error seen in the logcat window when the app crashes in Android Studio. It will provide more information and help us debug further.
Sorry for delay. I would really appreciate some help closing this ticket, and I think we are almost there.
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
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.
I guess my question is what does Cypress do differently in CySmart app to handle MTU request?