Bluetooth: GATT: Refactor read API

Add read parameters to read callabck

Merge bt_gatt_read_multiple functionality into bt_gatt_read.
This makes it easier for application to handle all types of reads
as same sematics is kept for them.

Instead of destroy callback, call read_func with NULL data to
indicated that read has completed. This makes it clear when
read is completed and parameters used for it are no longer needed.
Thanks to this application doesn't need to abuse user data destroy
callback for detecting if read has completed. Since destroy callback
is no longer needed it is removed.

Also note that bt_gatt_read doesn't take any user data parameter
and that destroy callback was acctually called with read parameters.

If application would require to pass user data along with parameters
it may use CONTAINER_OF macro along with bt_gatt_read_params.

Change-Id: I8d6ea136b1e61c1dae73cca868b53c48c45a5492
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2016-01-21 10:47:12 +01:00 committed by Anas Nashif
commit 843268d78d
5 changed files with 143 additions and 200 deletions

View file

@ -407,12 +407,6 @@ void bt_gatt_cancel(struct bt_conn *conn)
{
}
int bt_gatt_read_multiple(struct bt_conn *conn, const uint16_t *handles,
size_t count, bt_gatt_read_func_t func)
{
return -ENOSYS;
}
void on_ble_gattc_write_rsp(const struct ble_gattc_write_rsp *ev,
void *priv)
{