cancel
Showing results for 
Search instead for 
Did you mean: 

How to transmit data when reading characteristic?

ABern
Associate II

Hi,

I was wondering if it is possible to send data from client to sever when reading characteristic?

In order to save memory, I am trying to have only 1 profile with 3 characteristics (Read/Write/Notify).

The idea is, when the client wants to read data it will request a read and use 2 bytes data in the read request to indicate to the server which data has to be sent back.

I tried to find the datasheet about read characteristic but I couldn't find anything. If someone can help me out I would really appreciate.

Thanks,

A.

3 REPLIES 3
Winfred LU
ST Employee

Hi Anthony,

It will be simpler to just read that characteristic accordingly.

You may choose to read the characteristic value given its attribute handle,

0690X000009ZbUaQAK.png

or to read the characteristic value given its UUID (and the range of attribute handle).

0690X000009ZbUfQAK.png

Best Regards,

Winfred

ABern
Associate II

Hi @Winfred LU​ ,

Thanks for your response. Not sure I understood correctly.

Just to make it clear, I want to create one profile and let's say 1 characteristic (Read only, up to 20 bytes). What I was thinking is the content of the response might be different based on the read request.

Is it possible to follow the Figure 4.8:

Read Request(0x0002) -> Read Response ("Example Device")

And Read Request(0x0003) -> Read Response(0x55, "Example Device")

My idea is to use the 0x0002/0x0003 as a bit mask.

What is exactly 0x0002? a UUID?

The whole idea is to save memory on the device.

Hi Anthony,

The idea to save memory is good, but not practical.

Image that you have a 20-byte buffer storing the data you need.

How would you expect the buffer to provide you different data?

The only possible solutions would be

  • Make the buffer writable : Whenever the buffer is written with new data, you will get the new data by reading it.

or

  • Have more buffers : You need to read the buffer with its corresponding index. The buffers can be read only.

Best Regards,

Winfred