Hi,
in my application I have defined aCustom Profile, which has aCustom Serviceand this service has twoCustom Characteristics (1, 2). The second characteristic is used to send an array of bytes to the clientwith notification. I've followed the sample128 example (BTW such a good document) to write my application. I have configured my timer for5 secondsand every time it expires in the timer interrupt handler I'm calling theke_msg_send()to send an array of 20 bytes. Meanwhile, on my client app (BLE Scanner mobile app) when I enable the notifications for Characteristic 2, I'm able to see20 bytesconstantly arriving at 5 seconds interval.
Next, instead of 20 bytes, I'm sending64 bytes每次计时到期。但我注意到my client application (BLE Scanner mobile app) that, when I enable the notification for Characteristic 2, I see that only 20 bytes are displayed on the app. However, if I explicitly do a read of Characteristic 2 I see all the 64 bytes.
- Is it a limitation of the BTLE. Are the notifications only able to send 20 bytes?
- Or Is it a limitation of the client app I'm using?
- The changes I've made to my application are as below, but I don't know what else needs to be done.
What I've tried so far to achieve this are as follows:
Step 1: Increase the ATT_MTU size to 67
In the app_template_proj.c file, inside theapp_configuration_func(...)
function, I've increased the:
...
...
// Maximum transmit unit size
cmd->max_mtu = 67; // 23
...
...
Step 2: Increase thetotal_size
parameter ofattmdb_add_service()
function.
In the template_task.c, insidetemplate_create_db_req_handler()
function.
...
...
nb_att_16 = 4; // 4 UUID16 Attribute declaration types
nb_att_32 = 0; // 0 UUID32 Attribute declaration types
nb_att_128 = 2; // 2 UUID128 Attribute declaration types
status = attmdb_add_service( &(REDS_env.REDS_shdl),
TASK_XXXX,
nb_att_16,
nb_att_32,
nb_att_128,
121 // See calculation below);
// Total Data portion of GATT database = 58 data bytes:
// 16 Primary service declaration
// + 19 Declaration of characteristic 1
// + 1 Value declaration of characteristic 1
// + 19 Declaration of characteristic 2
// + 64 Value declaration of characteristic 2
// + 2 Client configuration declaration of characteristic 2
// = 121 Data bytes total
...
...
Hi vikramtheone,
I suppose that this post complements the previous one......the thing is that you can read the database with 64 bytes from your phone, but you cant enable the notifications and receive all 64 bytes. The notifications and the indications support only the current MTU of your peripheral, even if you change the MTU in your advertising procedure your client has to accept it in order to transfer all the payload in a notification packet. After setting up the MTU in app_configuration_func() you have to invoke a GATT_EXC_MTU_CMD in order to tell to the cenral to follow your set MTU. And it is up to the central if it will comply with the peripherals suggestion. You can find how to issue a gattc_exc_mtu_cmd in the DSPS application in app_sps_device_project.c file.
Thanks MT_dialog
WOW! That worked.
I implemented, rather used, the
gattc_exc_mtu_cmd()
function from GSPS application (also read more about it in the Section 4.3: Configuration, in RW-BLE-GATT-IS.pdf) and called that function from theapp_connection_func()
function after callingapp_template_enable()
just like how it is given in the GSPS application. And the android phone app (BLE Scanner) has accepted theGATT_EXC_MTU_REQ
request sent by the device and as soon as I enabled the notifications for Characteristic 2 I started to see 64 bytes.Conclusion: It is possible to send and receive notifications greater than 20 bytes.
Thank you for the help.
That seems great. Thanks for sharing.