bluetooth: ots: notify application prior to object name change

This change augments the application object name change notification to
occur prior to the actual name change done by the OTS layer.

Notifying prior to the actual name change makes it possible to inform the
application of the current name of the object as well as the new name.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
This commit is contained in:
Abe Kohandel 2022-01-16 15:35:34 -08:00 committed by Carles Cufí
commit f1e75dea50
3 changed files with 15 additions and 12 deletions

View file

@ -187,14 +187,14 @@ ssize_t ots_obj_name_write(struct bt_conn *conn,
rc = bt_gatt_ots_obj_manager_next_obj_get(ots->obj_manager, obj, &obj);
}
/* Update real object name after no duplicate detected */
strcpy(ots->cur_obj->metadata.name, name);
/* No duplicate detected, notify application and update real object name */
if (ots->cb->obj_name_written) {
ots->cb->obj_name_written(ots, conn, ots->cur_obj->id,
ots->cur_obj->metadata.name);
ots->cur_obj->metadata.name, name);
}
strcpy(ots->cur_obj->metadata.name, name);
return len;
}
#endif