This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sending data

Hi all,

I have a small question. If a GATT server needs to send data to a GATT client(about 65 bytes), does it have to create a service first and then adds characteristic, or it can use directly sd_gap_gatts_hvx function()?

Regards,

mohBOSS.

Parents
  • Hi there,

    You will need to add a service and a characteristic to send arbitrary data. Once you have the handle to the characteristic you can use sd_ble_gatts_hvx() to send data. Alternatively, if it's easier for you, you can add the service and characteristic on the peer device and use sd_ble_gattc_write() to send data, acting as a GATT client.

    Carles

  • Hi there,

    1. When you add a service and then a characteristic, you are just populating your own attribute table, and adding a placeholder to then be able to store data (inside the characteristic) that can then be filled in by your application, read by the peer client and updated (via hvx()) by you.
    2. I think you are confusing terms here. The client can read your characteristic value at any time and it will get the current value that is in memory. You can change that value locally by calling sd_ble_gatts_value_set(). Independently of that you can notify (i.e. push an update) the client whenever you want by calling sd_ble_gatts_hvx().

    Carles

Reply
  • Hi there,

    1. When you add a service and then a characteristic, you are just populating your own attribute table, and adding a placeholder to then be able to store data (inside the characteristic) that can then be filled in by your application, read by the peer client and updated (via hvx()) by you.
    2. I think you are confusing terms here. The client can read your characteristic value at any time and it will get the current value that is in memory. You can change that value locally by calling sd_ble_gatts_value_set(). Independently of that you can notify (i.e. push an update) the client whenever you want by calling sd_ble_gatts_hvx().

    Carles

Children
No Data
Related