When I enable notification on a characteristic on my client app, why does the app only see 20 bytes?

4 posts / 0 new
Last post
vikramtheone
Offline
Last seen:4 years 9 months ago
Joined:2015-06-12 08:42
When I enable notification on a characteristic on my client app, why does the app only see 20 bytes?

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.

  1. Is it a limitation of the BTLE. Are the notifications only able to send 20 bytes?
  2. Or Is it a limitation of the client app I'm using?
  3. 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_sizeparameter 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
...
...

Device:
MT_dialog
Offline
Last seen:3 weeks 11 hours ago
Staff
Joined:2015-06-08 11:34
Hi vikramtheone,

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

vikramtheone
Offline
Last seen:4 years 9 months ago
Joined:2015-06-12 08:42
WOW! That worked.

WOW! That worked.

I implemented, rather used, thegattc_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_REQrequest 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.

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
Joined:2014-12-30 05:01
That seems great. Thanks for

That seems great. Thanks for sharing.

Topic locked