Bluetooth: OTS - rename client data receive callbacks

Rename the data and metadata callbacks to _read(), for consistency
with the corresponding function calls.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is contained in:
Asbjørn Sæbø 2022-02-15 13:03:16 +01:00 committed by Carles Cufí
commit 68144f58e9
3 changed files with 30 additions and 23 deletions

View file

@ -830,9 +830,11 @@ struct bt_ots_client_cb {
struct bt_conn *conn, int err); struct bt_conn *conn, int err);
/** @brief Callback function for content of the selected object. /** @brief Callback function for the data of the selected
* object.
* *
* Called when the object content is received. * Called when the data of the selected object are read using
* bt_ots_client_read_object_data().
* *
* @param ots_inst Pointer to the OTC instance. * @param ots_inst Pointer to the OTC instance.
* @param conn The connection to the peer device. * @param conn The connection to the peer device.
@ -844,14 +846,15 @@ struct bt_ots_client_cb {
* @return int BT_OTS_STOP or BT_OTS_CONTINUE. BT_OTS_STOP can * @return int BT_OTS_STOP or BT_OTS_CONTINUE. BT_OTS_STOP can
* be used to stop reading. * be used to stop reading.
*/ */
int (*obj_content_recv)(struct bt_ots_client *ots_inst, int (*obj_data_read)(struct bt_ots_client *ots_inst,
struct bt_conn *conn, uint32_t offset, struct bt_conn *conn, uint32_t offset,
uint32_t len, uint8_t *data_p, bool is_complete); uint32_t len, uint8_t *data_p, bool is_complete);
/** @brief Callback function for metadata of the selected object. /** @brief Callback function for metadata of the selected object.
* *
* Called when metadata of the selected object are read. Not all of * Called when metadata of the selected object are read using
* the metadata may have been initialized. * bt_ots_client_read_object_metadata().
* Not all of the metadata may have been initialized.
* *
* @param ots_inst Pointer to the OTC instance. * @param ots_inst Pointer to the OTC instance.
* @param conn The connection to the peer device. * @param conn The connection to the peer device.
@ -860,7 +863,7 @@ struct bt_ots_client_cb {
* @param metadata_read Bitfield of the metadata that was * @param metadata_read Bitfield of the metadata that was
* successfully read. * successfully read.
*/ */
void (*obj_metadata_recv)(struct bt_ots_client *ots_inst, void (*obj_metadata_read)(struct bt_ots_client *ots_inst,
struct bt_conn *conn, int err, struct bt_conn *conn, int err,
uint8_t metadata_read); uint8_t metadata_read);
}; };
@ -955,6 +958,8 @@ int bt_ots_client_select_prev(struct bt_ots_client *otc_inst,
struct bt_conn *conn); struct bt_conn *conn);
/** @brief Read the metadata of the current object. /** @brief Read the metadata of the current object.
*
* The metadata are returned in the obj_metadata_read() callback.
* *
* @param otc_inst Pointer to the OTC instance. * @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object. * @param conn Pointer to the connection object.
@ -972,6 +977,8 @@ int bt_ots_client_read_object_metadata(struct bt_ots_client *otc_inst,
* This will trigger an OACP read operation for the current size of the object * This will trigger an OACP read operation for the current size of the object
* with a 0 offset and then expect receiving the content via the L2CAP CoC. * with a 0 offset and then expect receiving the content via the L2CAP CoC.
* *
* The data of the object are returned in the obj_data_read() callback.
*
* @param otc_inst Pointer to the OTC instance. * @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object. * @param conn Pointer to the connection object.
* *

View file

@ -1451,13 +1451,13 @@ int bt_mcc_init(struct bt_mcc_cb *cb)
/* TODO: Have one single content callback. */ /* TODO: Have one single content callback. */
/* For now: Use the icon callback for content - it is the first, */ /* For now: Use the icon callback for content - it is the first, */
/* and this will anyway be reset later. */ /* and this will anyway be reset later. */
otc_cb.obj_content_recv = on_icon_content; otc_cb.obj_data_read = on_icon_content;
otc_cb.obj_selected = on_obj_selected; otc_cb.obj_selected = on_obj_selected;
otc_cb.obj_metadata_recv = on_object_metadata; otc_cb.obj_metadata_read = on_object_metadata;
BT_DBG("Object selected callback: %p", otc_cb.obj_selected); BT_DBG("Object selected callback: %p", otc_cb.obj_selected);
BT_DBG("Object content callback: %p", otc_cb.obj_content_recv); BT_DBG("Object content callback: %p", otc_cb.obj_data_read);
BT_DBG("Object metadata callback: %p", otc_cb.obj_metadata_recv); BT_DBG("Object metadata callback: %p", otc_cb.obj_metadata_read);
#endif /* CONFIG_BT_MCC_OTS */ #endif /* CONFIG_BT_MCC_OTS */
return 0; return 0;
@ -2667,7 +2667,7 @@ int bt_mcc_otc_read_icon_object(struct bt_conn *conn)
int err; int err;
/* TODO: Add handling for busy - either MCS or OTS */ /* TODO: Add handling for busy - either MCS or OTS */
cur_mcs_inst->otc.cb->obj_content_recv = on_icon_content; cur_mcs_inst->otc.cb->obj_data_read = on_icon_content;
err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn); err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn);
if (err) { if (err) {
@ -2684,7 +2684,7 @@ int bt_mcc_otc_read_track_segments_object(struct bt_conn *conn)
/* TODO: Add handling for busy - either MCS or OTS */ /* TODO: Add handling for busy - either MCS or OTS */
/* TODO: Assumes object is already selected */ /* TODO: Assumes object is already selected */
cur_mcs_inst->otc.cb->obj_content_recv = on_track_segments_content; cur_mcs_inst->otc.cb->obj_data_read = on_track_segments_content;
err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn); err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn);
if (err) { if (err) {
@ -2701,7 +2701,7 @@ int bt_mcc_otc_read_current_track_object(struct bt_conn *conn)
/* TODO: Add handling for busy - either MCS or OTS */ /* TODO: Add handling for busy - either MCS or OTS */
/* TODO: Assumes object is already selected */ /* TODO: Assumes object is already selected */
cur_mcs_inst->otc.cb->obj_content_recv = on_current_track_content; cur_mcs_inst->otc.cb->obj_data_read = on_current_track_content;
err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn); err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn);
if (err) { if (err) {
@ -2718,7 +2718,7 @@ int bt_mcc_otc_read_next_track_object(struct bt_conn *conn)
/* TODO: Add handling for busy - either MCS or OTS */ /* TODO: Add handling for busy - either MCS or OTS */
/* TODO: Assumes object is already selected */ /* TODO: Assumes object is already selected */
cur_mcs_inst->otc.cb->obj_content_recv = on_next_track_content; cur_mcs_inst->otc.cb->obj_data_read = on_next_track_content;
err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn); err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn);
if (err) { if (err) {
@ -2737,7 +2737,7 @@ int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn)
/* TODO: Assumes object is already selected */ /* TODO: Assumes object is already selected */
/* Reuse callback for current group */ /* Reuse callback for current group */
cur_mcs_inst->otc.cb->obj_content_recv = on_parent_group_content; cur_mcs_inst->otc.cb->obj_data_read = on_parent_group_content;
err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn); err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn);
if (err) { if (err) {
@ -2754,7 +2754,7 @@ int bt_mcc_otc_read_current_group_object(struct bt_conn *conn)
/* TODO: Add handling for busy - either MCS or OTS */ /* TODO: Add handling for busy - either MCS or OTS */
/* TODO: Assumes object is already selected */ /* TODO: Assumes object is already selected */
cur_mcs_inst->otc.cb->obj_content_recv = on_current_group_content; cur_mcs_inst->otc.cb->obj_data_read = on_current_group_content;
err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn); err = bt_ots_client_read_object_data(&cur_mcs_inst->otc, conn);
if (err) { if (err) {

View file

@ -157,9 +157,9 @@ static ssize_t rx_done(struct bt_gatt_ots_l2cap *l2cap_ctx,
cur_inst->rcvd_size, cur_object->size.cur); cur_inst->rcvd_size, cur_object->size.cur);
} }
cb_ret = cur_inst->otc_inst->cb->obj_content_recv(0, conn, offset, cb_ret = cur_inst->otc_inst->cb->obj_data_read(0, conn, offset,
buf->len, buf->data, buf->len, buf->data,
is_complete); is_complete);
if (is_complete) { if (is_complete) {
const uint32_t rcv_size = cur_object->size.cur; const uint32_t rcv_size = cur_object->size.cur;
@ -1220,8 +1220,8 @@ static void read_next_metadata(struct bt_conn *conn,
read_obj_properties_cb); read_obj_properties_cb);
} else { } else {
inst->busy = false; inst->busy = false;
if (inst->otc_inst->cb->obj_metadata_recv) { if (inst->otc_inst->cb->obj_metadata_read) {
inst->otc_inst->cb->obj_metadata_recv( inst->otc_inst->cb->obj_metadata_read(
inst->otc_inst, conn, inst->metadata_err, inst->otc_inst, conn, inst->metadata_err,
inst->metadata_read); inst->metadata_read);
} }