Bluetooth: OTS - Merge server and client header files
- Move content of client header file to common header file. - Rename content from "otc" to "ots_client". - Remove empty client header file. - Update users. Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is contained in:
parent
adfd1d16e0
commit
70eefae1d2
8 changed files with 317 additions and 347 deletions
|
@ -923,7 +923,7 @@ int bt_mcc_otc_read_current_group_object(struct bt_conn *conn);
|
||||||
int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn);
|
int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn);
|
||||||
|
|
||||||
#if defined(CONFIG_BT_MCC_SHELL)
|
#if defined(CONFIG_BT_MCC_SHELL)
|
||||||
struct bt_otc_instance_t *bt_mcc_otc_inst(void);
|
struct bt_ots_client *bt_mcc_otc_inst(void);
|
||||||
#endif /* defined(CONFIG_BT_MCC_SHELL) */
|
#endif /* defined(CONFIG_BT_MCC_SHELL) */
|
||||||
#endif /* CONFIG_BT_OTS_CLIENT */
|
#endif /* CONFIG_BT_OTS_CLIENT */
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,14 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <zephyr/types.h>
|
#include <zephyr/types.h>
|
||||||
#include <sys/byteorder.h>
|
#include <sys/byteorder.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/util.h>
|
#include <sys/util.h>
|
||||||
#include <bluetooth/conn.h>
|
#include <bluetooth/conn.h>
|
||||||
#include <bluetooth/uuid.h>
|
#include <bluetooth/uuid.h>
|
||||||
|
#include <bluetooth/gatt.h>
|
||||||
|
|
||||||
/** @brief Size of OTS object ID (in bytes). */
|
/** @brief Size of OTS object ID (in bytes). */
|
||||||
#define BT_OTS_OBJ_ID_SIZE 6
|
#define BT_OTS_OBJ_ID_SIZE 6
|
||||||
|
@ -778,6 +780,230 @@ int bt_ots_init(struct bt_ots *ots, struct bt_ots_init *ots_init);
|
||||||
*/
|
*/
|
||||||
struct bt_ots *bt_ots_free_instance_get(void);
|
struct bt_ots *bt_ots_free_instance_get(void);
|
||||||
|
|
||||||
|
#define BT_OTS_STOP 0
|
||||||
|
#define BT_OTS_CONTINUE 1
|
||||||
|
|
||||||
|
/* TODO: Merge server and client instance as opaque type */
|
||||||
|
/** @brief OTS client instance */
|
||||||
|
struct bt_ots_client {
|
||||||
|
uint16_t start_handle;
|
||||||
|
uint16_t end_handle;
|
||||||
|
uint16_t feature_handle;
|
||||||
|
uint16_t obj_name_handle;
|
||||||
|
uint16_t obj_type_handle;
|
||||||
|
uint16_t obj_size_handle;
|
||||||
|
uint16_t obj_properties_handle;
|
||||||
|
uint16_t obj_created_handle;
|
||||||
|
uint16_t obj_modified_handle;
|
||||||
|
uint16_t obj_id_handle;
|
||||||
|
uint16_t oacp_handle;
|
||||||
|
uint16_t olcp_handle;
|
||||||
|
|
||||||
|
struct bt_gatt_subscribe_params oacp_sub_params;
|
||||||
|
struct bt_gatt_discover_params oacp_sub_disc_params;
|
||||||
|
struct bt_gatt_subscribe_params olcp_sub_params;
|
||||||
|
struct bt_gatt_discover_params olcp_sub_disc_params;
|
||||||
|
|
||||||
|
struct bt_gatt_write_params write_params;
|
||||||
|
struct bt_gatt_read_params read_proc;
|
||||||
|
struct bt_ots_client_cb *cb;
|
||||||
|
|
||||||
|
struct bt_ots_feat features;
|
||||||
|
|
||||||
|
struct bt_ots_obj_metadata cur_object;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** OTS client callback structure */
|
||||||
|
struct bt_ots_client_cb {
|
||||||
|
/** @brief Callback function when a new object is selected.
|
||||||
|
*
|
||||||
|
* Called when the a new object is selected and the current
|
||||||
|
* object has changed. The `cur_object` in `ots_inst` will
|
||||||
|
* have been reset, and metadata should be read again with
|
||||||
|
* bt_ots_client_read_object_metadata().
|
||||||
|
*
|
||||||
|
* @param conn The connection to the peer device.
|
||||||
|
* @param err Error code (bt_ots_olcp_res_code).
|
||||||
|
* @param ots_inst Pointer to the OTC instance.
|
||||||
|
*/
|
||||||
|
void (*obj_selected)(struct bt_conn *conn, int err,
|
||||||
|
struct bt_ots_client *ots_inst);
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Callback function for content of the selected object.
|
||||||
|
*
|
||||||
|
* Called when the object content is received.
|
||||||
|
*
|
||||||
|
* @param conn The connection to the peer device.
|
||||||
|
* @param offset Offset of the received data.
|
||||||
|
* @param len Length of the received data.
|
||||||
|
* @param data_p Pointer to the received data.
|
||||||
|
* @param is_complete Indicate if the whole object has been received.
|
||||||
|
* @param ots_inst Pointer to the OTC instance.
|
||||||
|
*
|
||||||
|
* @return int BT_OTS_STOP or BT_OTS_CONTINUE. BT_OTS_STOP can
|
||||||
|
* be used to stop reading.
|
||||||
|
*/
|
||||||
|
int (*content_cb)(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
||||||
|
uint8_t *data_p, bool is_complete,
|
||||||
|
struct bt_ots_client *ots_inst);
|
||||||
|
|
||||||
|
/** @brief Callback function for metadata of the selected object.
|
||||||
|
*
|
||||||
|
* Called when metadata of the selected object are read. Not all of
|
||||||
|
* the metadata may have been initialized.
|
||||||
|
*
|
||||||
|
* @param conn The connection to the peer device.
|
||||||
|
* @param err Error value. 0 on success,
|
||||||
|
* GATT error or ERRNO on fail.
|
||||||
|
* @param ots_inst Pointer to the OTC instance.
|
||||||
|
* @param metadata_read Bitfield of the metadata that was
|
||||||
|
* successfully read.
|
||||||
|
*/
|
||||||
|
void (*metadata_cb)(struct bt_conn *conn, int err,
|
||||||
|
struct bt_ots_client *ots_inst,
|
||||||
|
uint8_t metadata_read);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @brief Register an Object Transfer Service Instance.
|
||||||
|
*
|
||||||
|
* Register an Object Transfer Service instance discovered on the peer.
|
||||||
|
* Call this function when an OTS instance is discovered
|
||||||
|
* (discovery is to be handled by the higher layer).
|
||||||
|
*
|
||||||
|
* @param[in] ots_inst Discovered OTS instance.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_register(struct bt_ots_client *ots_inst);
|
||||||
|
|
||||||
|
/** @brief OTS Indicate Handler function.
|
||||||
|
*
|
||||||
|
* Set this function as callback for indicate handler when discovering OTS.
|
||||||
|
*
|
||||||
|
* @param conn Connection object. May be NULL, indicating that the
|
||||||
|
* peer is being unpaired.
|
||||||
|
* @param params Subscription parameters.
|
||||||
|
* @param data Attribute value data. If NULL then subscription was
|
||||||
|
* removed.
|
||||||
|
* @param length Attribute value length.
|
||||||
|
*/
|
||||||
|
uint8_t bt_ots_client_indicate_handler(struct bt_conn *conn,
|
||||||
|
struct bt_gatt_subscribe_params *params,
|
||||||
|
const void *data, uint16_t length);
|
||||||
|
|
||||||
|
/** @brief Read the OTS feature characteristic.
|
||||||
|
*
|
||||||
|
* @param conn Pointer to the connection object.
|
||||||
|
* @param otc_inst Pointer to the OTC instance.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_read_feature(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst);
|
||||||
|
|
||||||
|
/** @brief Select an object by its Object ID.
|
||||||
|
*
|
||||||
|
* @param conn Pointer to the connection object.
|
||||||
|
* @param obj_id Object's ID.
|
||||||
|
* @param otc_inst Pointer to the OTC instance.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_select_id(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst,
|
||||||
|
uint64_t obj_id);
|
||||||
|
|
||||||
|
/** @brief Select the first object.
|
||||||
|
*
|
||||||
|
* @param conn Pointer to the connection object.
|
||||||
|
* @param otc_inst Pointer to the OTC instance.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_select_first(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst);
|
||||||
|
|
||||||
|
/** @brief Select the last object.
|
||||||
|
*
|
||||||
|
* @param conn Pointer to the connection object.
|
||||||
|
* @param otc_inst Pointer to the OTC instance.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_select_last(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst);
|
||||||
|
|
||||||
|
/** @brief Select the next object.
|
||||||
|
*
|
||||||
|
* @param conn Pointer to the connection object.
|
||||||
|
* @param otc_inst Pointer to the OTC instance.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_select_next(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst);
|
||||||
|
|
||||||
|
/** @brief Select the previous object.
|
||||||
|
*
|
||||||
|
* @param conn Pointer to the connection object.
|
||||||
|
* @param otc_inst Pointer to the OTC instance.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_select_prev(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst);
|
||||||
|
|
||||||
|
/** @brief Read the metadata of the current object.
|
||||||
|
*
|
||||||
|
* @param conn Pointer to the connection object.
|
||||||
|
* @param otc_inst Pointer to the OTC instance.
|
||||||
|
* @param metadata Bitfield (`BT_OTS_METADATA_REQ_*`) of the metadata
|
||||||
|
* to read.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_read_object_metadata(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst,
|
||||||
|
uint8_t metadata);
|
||||||
|
|
||||||
|
/** @brief Read the data of the current selected 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.
|
||||||
|
*
|
||||||
|
* @param conn Pointer to the connection object.
|
||||||
|
* @param otc_inst Pointer to the OTC instance.
|
||||||
|
*
|
||||||
|
* @return int 0 if success, ERRNO on failure.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_read_object_data(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst);
|
||||||
|
|
||||||
|
/** @brief Directory listing object metadata callback
|
||||||
|
*
|
||||||
|
* If a directory listing is decoded using bt_ots_client_decode_dirlisting(),
|
||||||
|
* this callback will be called for each object in the directory listing.
|
||||||
|
*
|
||||||
|
* @param meta The metadata of the decoded object
|
||||||
|
*
|
||||||
|
* @return int BT_OTS_STOP or BT_OTS_CONTINUE. BT_OTS_STOP can be used to
|
||||||
|
* stop the decoding.
|
||||||
|
*/
|
||||||
|
typedef int (*bt_ots_client_dirlisting_cb)(struct bt_ots_obj_metadata *meta);
|
||||||
|
|
||||||
|
/** @brief Decode Directory Listing object into object metadata.
|
||||||
|
*
|
||||||
|
* If the Directory Listing object contains multiple objects, then the
|
||||||
|
* callback will be called for each of them.
|
||||||
|
*
|
||||||
|
* @param data The data received for the directory listing object.
|
||||||
|
* @param length Length of the data.
|
||||||
|
* @param cb The callback that will be called for each object.
|
||||||
|
*/
|
||||||
|
int bt_ots_client_decode_dirlisting(uint8_t *data, uint16_t length,
|
||||||
|
bt_ots_client_dirlisting_cb cb);
|
||||||
|
|
||||||
/** @brief Converts binary OTS Object ID to string.
|
/** @brief Converts binary OTS Object ID to string.
|
||||||
*
|
*
|
||||||
* @param obj_id Object ID.
|
* @param obj_id Object ID.
|
||||||
|
@ -799,6 +1025,14 @@ static inline int bt_ots_obj_id_to_str(uint64_t obj_id, char *str, size_t len)
|
||||||
id[5], id[4], id[3], id[2], id[1], id[0]);
|
id[5], id[4], id[3], id[2], id[1], id[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Displays one or more object metadata as text with BT_INFO.
|
||||||
|
*
|
||||||
|
* @param metadata Pointer to the first (or only) metadata in an array.
|
||||||
|
* @param count Number of metadata objects to display information of.
|
||||||
|
*/
|
||||||
|
void bt_ots_metadata_display(struct bt_ots_obj_metadata *metadata,
|
||||||
|
uint16_t count);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,269 +0,0 @@
|
||||||
/* @file
|
|
||||||
* @brief Object Transfer Service client header
|
|
||||||
*
|
|
||||||
* For use with the Object Transfer Service Client
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 - 2022 Nordic Semiconductor ASA
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_CLIENT_H_
|
|
||||||
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_CLIENT_H_
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Object Transfer Service Client (OTC)
|
|
||||||
* @defgroup bt_otc Object Transfer Service Client (OTC)
|
|
||||||
* @ingroup bluetooth
|
|
||||||
* @{
|
|
||||||
*
|
|
||||||
* [Experimental] Users should note that the APIs can change
|
|
||||||
* as a part of ongoing development.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <zephyr/types.h>
|
|
||||||
#include <bluetooth/gatt.h>
|
|
||||||
#include <bluetooth/services/ots.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BT_OTC_STOP 0
|
|
||||||
#define BT_OTC_CONTINUE 1
|
|
||||||
|
|
||||||
struct bt_otc_instance_t {
|
|
||||||
uint16_t start_handle;
|
|
||||||
uint16_t end_handle;
|
|
||||||
uint16_t feature_handle;
|
|
||||||
uint16_t obj_name_handle;
|
|
||||||
uint16_t obj_type_handle;
|
|
||||||
uint16_t obj_size_handle;
|
|
||||||
uint16_t obj_properties_handle;
|
|
||||||
uint16_t obj_created_handle;
|
|
||||||
uint16_t obj_modified_handle;
|
|
||||||
uint16_t obj_id_handle;
|
|
||||||
uint16_t oacp_handle;
|
|
||||||
uint16_t olcp_handle;
|
|
||||||
|
|
||||||
struct bt_gatt_subscribe_params oacp_sub_params;
|
|
||||||
struct bt_gatt_discover_params oacp_sub_disc_params;
|
|
||||||
struct bt_gatt_subscribe_params olcp_sub_params;
|
|
||||||
struct bt_gatt_discover_params olcp_sub_disc_params;
|
|
||||||
|
|
||||||
struct bt_gatt_write_params write_params;
|
|
||||||
struct bt_gatt_read_params read_proc;
|
|
||||||
struct bt_otc_cb *cb;
|
|
||||||
|
|
||||||
struct bt_ots_feat features;
|
|
||||||
|
|
||||||
struct bt_ots_obj_metadata cur_object;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Directory listing object metadata callback
|
|
||||||
*
|
|
||||||
* If a directory listing is decoded using bt_otc_decode_dirlisting(),
|
|
||||||
* this callback will be called for each object in the directory listing.
|
|
||||||
*
|
|
||||||
* @param meta The metadata of the decoded object
|
|
||||||
*
|
|
||||||
* @return int BT_OTC_STOP or BT_OTC_CONTINUE. BT_OTC_STOP can be used to
|
|
||||||
* stop the decoding.
|
|
||||||
*/
|
|
||||||
typedef int (*bt_otc_dirlisting_cb)(struct bt_ots_obj_metadata *meta);
|
|
||||||
|
|
||||||
/** OTC callback structure */
|
|
||||||
struct bt_otc_cb {
|
|
||||||
/** @brief Callback function when a new object is selected.
|
|
||||||
*
|
|
||||||
* Called when the a new object is selected and the current object
|
|
||||||
* has changed. The `cur_object` in `ots_inst` will have been reset,
|
|
||||||
* and metadata should be read again with bt_otc_read_object_metadata().
|
|
||||||
*
|
|
||||||
* @param conn The connection to the peer device.
|
|
||||||
* @param err Error code (bt_ots_olcp_res_code).
|
|
||||||
* @param ots_inst Pointer to the OTC instance.
|
|
||||||
*/
|
|
||||||
void (*obj_selected)(struct bt_conn *conn, int err,
|
|
||||||
struct bt_otc_instance_t *ots_inst);
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Callback function for content of the selected object.
|
|
||||||
*
|
|
||||||
* Called when the object content is received.
|
|
||||||
*
|
|
||||||
* @param conn The connection to the peer device.
|
|
||||||
* @param offset Offset of the received data.
|
|
||||||
* @param len Length of the received data.
|
|
||||||
* @param data_p Pointer to the received data.
|
|
||||||
* @param is_complete Indicate if the whole object has been received.
|
|
||||||
* @param ots_inst Pointer to the OTC instance.
|
|
||||||
*
|
|
||||||
* @return int BT_OTC_STOP or BT_OTC_CONTINUE. BT_OTC_STOP can
|
|
||||||
* be used to stop reading.
|
|
||||||
*/
|
|
||||||
int (*content_cb)(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
|
||||||
uint8_t *data_p, bool is_complete,
|
|
||||||
struct bt_otc_instance_t *ots_inst);
|
|
||||||
|
|
||||||
/** @brief Callback function for metadata of the selected object.
|
|
||||||
*
|
|
||||||
* Called when metadata of the selected object are read. Not all of
|
|
||||||
* the metadata may have been initialized.
|
|
||||||
*
|
|
||||||
* @param conn The connection to the peer device.
|
|
||||||
* @param err Error value. 0 on success,
|
|
||||||
* GATT error or ERRNO on fail.
|
|
||||||
* @param ots_inst Pointer to the OTC instance.
|
|
||||||
* @param metadata_read Bitfield of the metadata that was
|
|
||||||
* successfully read.
|
|
||||||
*/
|
|
||||||
void (*metadata_cb)(struct bt_conn *conn, int err,
|
|
||||||
struct bt_otc_instance_t *ots_inst,
|
|
||||||
uint8_t metadata_read);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Register an Object Transfer Service Instance.
|
|
||||||
*
|
|
||||||
* Register an Object Transfer Service instance discovered on the peer.
|
|
||||||
* Call this function when an OTS instance is discovered
|
|
||||||
* (discovery is to be handled by the higher layer).
|
|
||||||
*
|
|
||||||
* @param[in] ots_inst Discovered OTS instance.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_register(struct bt_otc_instance_t *ots_inst);
|
|
||||||
|
|
||||||
/** @brief OTS Indicate Handler function.
|
|
||||||
*
|
|
||||||
* Set this function as callback for indicate handler when discovering OTS.
|
|
||||||
*
|
|
||||||
* @param conn Connection object. May be NULL, indicating that the
|
|
||||||
* peer is being unpaired.
|
|
||||||
* @param params Subscription parameters.
|
|
||||||
* @param data Attribute value data. If NULL then subscription was
|
|
||||||
* removed.
|
|
||||||
* @param length Attribute value length.
|
|
||||||
*/
|
|
||||||
uint8_t bt_otc_indicate_handler(struct bt_conn *conn,
|
|
||||||
struct bt_gatt_subscribe_params *params,
|
|
||||||
const void *data, uint16_t length);
|
|
||||||
|
|
||||||
/** @brief Read the OTS feature characteristic.
|
|
||||||
*
|
|
||||||
* @param conn Pointer to the connection object.
|
|
||||||
* @param otc_inst Pointer to the OTC instance.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_read_feature(struct bt_conn *conn,
|
|
||||||
struct bt_otc_instance_t *otc_inst);
|
|
||||||
|
|
||||||
/** @brief Select an object by its Object ID.
|
|
||||||
*
|
|
||||||
* @param conn Pointer to the connection object.
|
|
||||||
* @param obj_id Object's ID.
|
|
||||||
* @param otc_inst Pointer to the OTC instance.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_select_id(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst,
|
|
||||||
uint64_t obj_id);
|
|
||||||
|
|
||||||
/** @brief Select the first object.
|
|
||||||
*
|
|
||||||
* @param conn Pointer to the connection object.
|
|
||||||
* @param otc_inst Pointer to the OTC instance.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_select_first(struct bt_conn *conn,
|
|
||||||
struct bt_otc_instance_t *otc_inst);
|
|
||||||
|
|
||||||
/** @brief Select the last object.
|
|
||||||
*
|
|
||||||
* @param conn Pointer to the connection object.
|
|
||||||
* @param otc_inst Pointer to the OTC instance.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_select_last(struct bt_conn *conn,
|
|
||||||
struct bt_otc_instance_t *otc_inst);
|
|
||||||
|
|
||||||
/** @brief Select the next object.
|
|
||||||
*
|
|
||||||
* @param conn Pointer to the connection object.
|
|
||||||
* @param otc_inst Pointer to the OTC instance.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_select_next(struct bt_conn *conn,
|
|
||||||
struct bt_otc_instance_t *otc_inst);
|
|
||||||
|
|
||||||
/** @brief Select the previous object.
|
|
||||||
*
|
|
||||||
* @param conn Pointer to the connection object.
|
|
||||||
* @param otc_inst Pointer to the OTC instance.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_select_prev(struct bt_conn *conn,
|
|
||||||
struct bt_otc_instance_t *otc_inst);
|
|
||||||
|
|
||||||
/** @brief Read the metadata of the current object.
|
|
||||||
*
|
|
||||||
* @param conn Pointer to the connection object.
|
|
||||||
* @param otc_inst Pointer to the OTC instance.
|
|
||||||
* @param metadata Bitfield (`BT_OTS_METADATA_REQ_*`) of the metadata
|
|
||||||
* to read.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_read_object_metadata(struct bt_conn *conn,
|
|
||||||
struct bt_otc_instance_t *otc_inst,
|
|
||||||
uint8_t metadata);
|
|
||||||
|
|
||||||
/** @brief Read the (data of the) current selected 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.
|
|
||||||
*
|
|
||||||
* @param conn Pointer to the connection object.
|
|
||||||
* @param otc_inst Pointer to the OTC instance.
|
|
||||||
*
|
|
||||||
* @return int 0 if success, ERRNO on failure.
|
|
||||||
*/
|
|
||||||
int bt_otc_read_object_data(struct bt_conn *conn,
|
|
||||||
struct bt_otc_instance_t *otc_inst);
|
|
||||||
|
|
||||||
/** @brief Used to decode the Directory Listing object into object metadata.
|
|
||||||
*
|
|
||||||
* If the Directory Listing object contains multiple objects, then the
|
|
||||||
* callback will be called for each of them.
|
|
||||||
*
|
|
||||||
* @param data The data received for the directory listing object.
|
|
||||||
* @param length Length of the data.
|
|
||||||
* @param cb The callback that will be called for each object.
|
|
||||||
*/
|
|
||||||
int bt_otc_decode_dirlisting(uint8_t *data, uint16_t length,
|
|
||||||
bt_otc_dirlisting_cb cb);
|
|
||||||
|
|
||||||
/** @brief Displays one or more object metadata as text with BT_INFO.
|
|
||||||
*
|
|
||||||
* @param metadata Pointer to the first (or only) metadata in an array.
|
|
||||||
* @param count Number of metadata objects to display information of.
|
|
||||||
*/
|
|
||||||
void bt_ots_metadata_display(struct bt_ots_obj_metadata *metadata,
|
|
||||||
uint16_t count);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_CLIENT_H_ */
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <bluetooth/gatt.h>
|
#include <bluetooth/gatt.h>
|
||||||
#include <bluetooth/audio/mcc.h>
|
#include <bluetooth/audio/mcc.h>
|
||||||
|
|
||||||
#include <bluetooth/services/ots_client.h>
|
#include <bluetooth/services/ots.h>
|
||||||
#include "../services/ots/ots_client_internal.h"
|
#include "../services/ots/ots_client_internal.h"
|
||||||
|
|
||||||
/* TODO: Temporarily copied here from media_proxy_internal.h - clean up */
|
/* TODO: Temporarily copied here from media_proxy_internal.h - clean up */
|
||||||
|
@ -143,7 +143,7 @@ struct mcs_instance_t {
|
||||||
bool busy;
|
bool busy;
|
||||||
|
|
||||||
#ifdef CONFIG_BT_MCC_OTS
|
#ifdef CONFIG_BT_MCC_OTS
|
||||||
struct bt_otc_instance_t otc;
|
struct bt_ots_client otc;
|
||||||
#endif /* CONFIG_BT_MCC_OTS */
|
#endif /* CONFIG_BT_MCC_OTS */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -160,22 +160,22 @@ static bool subscribe_all;
|
||||||
|
|
||||||
#ifdef CONFIG_BT_MCC_OTS
|
#ifdef CONFIG_BT_MCC_OTS
|
||||||
NET_BUF_SIMPLE_DEFINE_STATIC(otc_obj_buf, CONFIG_BT_MCC_OTC_OBJ_BUF_SIZE);
|
NET_BUF_SIMPLE_DEFINE_STATIC(otc_obj_buf, CONFIG_BT_MCC_OTC_OBJ_BUF_SIZE);
|
||||||
static struct bt_otc_cb otc_cb;
|
static struct bt_ots_client_cb otc_cb;
|
||||||
#endif /* CONFIG_BT_MCC_OTS */
|
#endif /* CONFIG_BT_MCC_OTS */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_MCC_OTS
|
#ifdef CONFIG_BT_MCC_OTS
|
||||||
void on_obj_selected(struct bt_conn *conn, int err,
|
void on_obj_selected(struct bt_conn *conn, int err,
|
||||||
struct bt_otc_instance_t *otc_inst);
|
struct bt_ots_client *otc_inst);
|
||||||
|
|
||||||
void on_object_metadata(struct bt_conn *conn, int err,
|
void on_object_metadata(struct bt_conn *conn, int err,
|
||||||
struct bt_otc_instance_t *otc_inst,
|
struct bt_ots_client *otc_inst,
|
||||||
uint8_t metadata_read);
|
uint8_t metadata_read);
|
||||||
|
|
||||||
int on_icon_content(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
int on_icon_content(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
||||||
uint8_t *data_p,
|
uint8_t *data_p,
|
||||||
bool is_complete, struct bt_otc_instance_t *otc_inst);
|
bool is_complete, struct bt_ots_client *otc_inst);
|
||||||
#endif /* CONFIG_BT_MCC_OTS */
|
#endif /* CONFIG_BT_MCC_OTS */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1105,7 +1105,7 @@ static uint8_t discover_otc_char_func(struct bt_conn *conn,
|
||||||
sub_params->end_handle = cur_mcs_inst->otc.end_handle;
|
sub_params->end_handle = cur_mcs_inst->otc.end_handle;
|
||||||
sub_params->value = BT_GATT_CCC_INDICATE;
|
sub_params->value = BT_GATT_CCC_INDICATE;
|
||||||
sub_params->value_handle = chrc->value_handle;
|
sub_params->value_handle = chrc->value_handle;
|
||||||
sub_params->notify = bt_otc_indicate_handler;
|
sub_params->notify = bt_ots_client_indicate_handler;
|
||||||
|
|
||||||
bt_gatt_subscribe(conn, sub_params);
|
bt_gatt_subscribe(conn, sub_params);
|
||||||
}
|
}
|
||||||
|
@ -1115,7 +1115,7 @@ static uint8_t discover_otc_char_func(struct bt_conn *conn,
|
||||||
|
|
||||||
/* No more attributes found */
|
/* No more attributes found */
|
||||||
cur_mcs_inst->otc.cb = &otc_cb;
|
cur_mcs_inst->otc.cb = &otc_cb;
|
||||||
bt_otc_register(&cur_mcs_inst->otc);
|
bt_ots_client_register(&cur_mcs_inst->otc);
|
||||||
|
|
||||||
BT_DBG("Setup complete for included OTS");
|
BT_DBG("Setup complete for included OTS");
|
||||||
(void)memset(params, 0, sizeof(*params));
|
(void)memset(params, 0, sizeof(*params));
|
||||||
|
@ -2300,7 +2300,7 @@ int bt_mcc_read_content_control_id(struct bt_conn *conn)
|
||||||
#ifdef CONFIG_BT_MCC_OTS
|
#ifdef CONFIG_BT_MCC_OTS
|
||||||
|
|
||||||
void on_obj_selected(struct bt_conn *conn, int result,
|
void on_obj_selected(struct bt_conn *conn, int result,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
BT_DBG("Current object selected");
|
BT_DBG("Current object selected");
|
||||||
/* TODO: Read metadata here? */
|
/* TODO: Read metadata here? */
|
||||||
|
@ -2320,7 +2320,7 @@ void on_obj_selected(struct bt_conn *conn, int result,
|
||||||
/* Use a notion of the "active" object, as done in mpl.c, for tracking */
|
/* Use a notion of the "active" object, as done in mpl.c, for tracking */
|
||||||
int on_icon_content(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
int on_icon_content(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
||||||
uint8_t *data_p, bool is_complete,
|
uint8_t *data_p, bool is_complete,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
int cb_err = 0;
|
int cb_err = 0;
|
||||||
|
|
||||||
|
@ -2348,7 +2348,7 @@ int on_icon_content(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
||||||
net_buf_simple_reset(&otc_obj_buf);
|
net_buf_simple_reset(&otc_obj_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BT_OTC_CONTINUE;
|
return BT_OTS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_BT_DEBUG_MCC
|
#if CONFIG_BT_DEBUG_MCC
|
||||||
|
@ -2405,7 +2405,7 @@ static void decode_track_segments(struct net_buf_simple *buff,
|
||||||
|
|
||||||
int on_track_segments_content(struct bt_conn *conn, uint32_t offset,
|
int on_track_segments_content(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,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
int cb_err = 0;
|
int cb_err = 0;
|
||||||
|
|
||||||
|
@ -2444,12 +2444,12 @@ int on_track_segments_content(struct bt_conn *conn, uint32_t offset,
|
||||||
net_buf_simple_reset(&otc_obj_buf);
|
net_buf_simple_reset(&otc_obj_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BT_OTC_CONTINUE;
|
return BT_OTS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int on_current_track_content(struct bt_conn *conn, uint32_t offset,
|
int on_current_track_content(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,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
int cb_err = 0;
|
int cb_err = 0;
|
||||||
|
|
||||||
|
@ -2476,12 +2476,12 @@ int on_current_track_content(struct bt_conn *conn, uint32_t offset,
|
||||||
net_buf_simple_reset(&otc_obj_buf);
|
net_buf_simple_reset(&otc_obj_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BT_OTC_CONTINUE;
|
return BT_OTS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int on_next_track_content(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
int on_next_track_content(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
||||||
uint8_t *data_p, bool is_complete,
|
uint8_t *data_p, bool is_complete,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
int cb_err = 0;
|
int cb_err = 0;
|
||||||
|
|
||||||
|
@ -2508,7 +2508,7 @@ int on_next_track_content(struct bt_conn *conn, uint32_t offset, uint32_t len,
|
||||||
net_buf_simple_reset(&otc_obj_buf);
|
net_buf_simple_reset(&otc_obj_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BT_OTC_CONTINUE;
|
return BT_OTS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2540,7 +2540,7 @@ static void decode_group(struct net_buf_simple *buff,
|
||||||
|
|
||||||
int on_parent_group_content(struct bt_conn *conn, uint32_t offset,
|
int on_parent_group_content(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,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
int cb_err = 0;
|
int cb_err = 0;
|
||||||
|
|
||||||
|
@ -2581,12 +2581,12 @@ int on_parent_group_content(struct bt_conn *conn, uint32_t offset,
|
||||||
net_buf_simple_reset(&otc_obj_buf);
|
net_buf_simple_reset(&otc_obj_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BT_OTC_CONTINUE;
|
return BT_OTS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int on_current_group_content(struct bt_conn *conn, uint32_t offset,
|
int on_current_group_content(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,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
int cb_err = 0;
|
int cb_err = 0;
|
||||||
|
|
||||||
|
@ -2627,11 +2627,11 @@ int on_current_group_content(struct bt_conn *conn, uint32_t offset,
|
||||||
net_buf_simple_reset(&otc_obj_buf);
|
net_buf_simple_reset(&otc_obj_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BT_OTC_CONTINUE;
|
return BT_OTS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_object_metadata(struct bt_conn *conn, int err,
|
void on_object_metadata(struct bt_conn *conn, int err,
|
||||||
struct bt_otc_instance_t *otc_inst,
|
struct bt_ots_client *otc_inst,
|
||||||
uint8_t metadata_read)
|
uint8_t metadata_read)
|
||||||
{
|
{
|
||||||
BT_INFO("Object's meta data:");
|
BT_INFO("Object's meta data:");
|
||||||
|
@ -2652,8 +2652,8 @@ int bt_mcc_otc_read_object_metadata(struct bt_conn *conn)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = bt_otc_read_object_metadata(conn, &cur_mcs_inst->otc,
|
err = bt_ots_client_read_object_metadata(conn, &cur_mcs_inst->otc,
|
||||||
BT_OTS_METADATA_REQ_ALL);
|
BT_OTS_METADATA_REQ_ALL);
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_DBG("Error reading the object: %d", err);
|
BT_DBG("Error reading the object: %d", err);
|
||||||
}
|
}
|
||||||
|
@ -2669,7 +2669,7 @@ int bt_mcc_otc_read_icon_object(struct bt_conn *conn)
|
||||||
|
|
||||||
cur_mcs_inst->otc.cb->content_cb = on_icon_content;
|
cur_mcs_inst->otc.cb->content_cb = on_icon_content;
|
||||||
|
|
||||||
err = bt_otc_read_object_data(conn, &cur_mcs_inst->otc);
|
err = bt_ots_client_read_object_data(conn, &cur_mcs_inst->otc);
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_DBG("Error reading the object: %d", err);
|
BT_DBG("Error reading the object: %d", err);
|
||||||
}
|
}
|
||||||
|
@ -2686,7 +2686,7 @@ int bt_mcc_otc_read_track_segments_object(struct bt_conn *conn)
|
||||||
/* TODO: Assumes object is already selected */
|
/* TODO: Assumes object is already selected */
|
||||||
cur_mcs_inst->otc.cb->content_cb = on_track_segments_content;
|
cur_mcs_inst->otc.cb->content_cb = on_track_segments_content;
|
||||||
|
|
||||||
err = bt_otc_read_object_data(conn, &cur_mcs_inst->otc);
|
err = bt_ots_client_read_object_data(conn, &cur_mcs_inst->otc);
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_DBG("Error reading the object: %d", err);
|
BT_DBG("Error reading the object: %d", err);
|
||||||
}
|
}
|
||||||
|
@ -2703,7 +2703,7 @@ int bt_mcc_otc_read_current_track_object(struct bt_conn *conn)
|
||||||
/* TODO: Assumes object is already selected */
|
/* TODO: Assumes object is already selected */
|
||||||
cur_mcs_inst->otc.cb->content_cb = on_current_track_content;
|
cur_mcs_inst->otc.cb->content_cb = on_current_track_content;
|
||||||
|
|
||||||
err = bt_otc_read_object_data(conn, &cur_mcs_inst->otc);
|
err = bt_ots_client_read_object_data(conn, &cur_mcs_inst->otc);
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_DBG("Error reading the object: %d", err);
|
BT_DBG("Error reading the object: %d", err);
|
||||||
}
|
}
|
||||||
|
@ -2720,7 +2720,7 @@ int bt_mcc_otc_read_next_track_object(struct bt_conn *conn)
|
||||||
/* TODO: Assumes object is already selected */
|
/* TODO: Assumes object is already selected */
|
||||||
cur_mcs_inst->otc.cb->content_cb = on_next_track_content;
|
cur_mcs_inst->otc.cb->content_cb = on_next_track_content;
|
||||||
|
|
||||||
err = bt_otc_read_object_data(conn, &cur_mcs_inst->otc);
|
err = bt_ots_client_read_object_data(conn, &cur_mcs_inst->otc);
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_DBG("Error reading the object: %d", err);
|
BT_DBG("Error reading the object: %d", err);
|
||||||
}
|
}
|
||||||
|
@ -2739,7 +2739,7 @@ int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn)
|
||||||
/* Reuse callback for current group */
|
/* Reuse callback for current group */
|
||||||
cur_mcs_inst->otc.cb->content_cb = on_parent_group_content;
|
cur_mcs_inst->otc.cb->content_cb = on_parent_group_content;
|
||||||
|
|
||||||
err = bt_otc_read_object_data(conn, &cur_mcs_inst->otc);
|
err = bt_ots_client_read_object_data(conn, &cur_mcs_inst->otc);
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_DBG("Error reading the object: %d", err);
|
BT_DBG("Error reading the object: %d", err);
|
||||||
}
|
}
|
||||||
|
@ -2756,7 +2756,7 @@ int bt_mcc_otc_read_current_group_object(struct bt_conn *conn)
|
||||||
/* TODO: Assumes object is already selected */
|
/* TODO: Assumes object is already selected */
|
||||||
cur_mcs_inst->otc.cb->content_cb = on_current_group_content;
|
cur_mcs_inst->otc.cb->content_cb = on_current_group_content;
|
||||||
|
|
||||||
err = bt_otc_read_object_data(conn, &cur_mcs_inst->otc);
|
err = bt_ots_client_read_object_data(conn, &cur_mcs_inst->otc);
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_DBG("Error reading the object: %d", err);
|
BT_DBG("Error reading the object: %d", err);
|
||||||
}
|
}
|
||||||
|
@ -2765,7 +2765,7 @@ int bt_mcc_otc_read_current_group_object(struct bt_conn *conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_BT_MCC_SHELL)
|
#if defined(CONFIG_BT_MCC_SHELL)
|
||||||
struct bt_otc_instance_t *bt_mcc_otc_inst(void)
|
struct bt_ots_client *bt_mcc_otc_inst(void)
|
||||||
{
|
{
|
||||||
return &cur_mcs_inst->otc;
|
return &cur_mcs_inst->otc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "../../host/conn_internal.h" /* To avoid build errors on use of struct bt_conn" */
|
#include "../../host/conn_internal.h" /* To avoid build errors on use of struct bt_conn" */
|
||||||
|
|
||||||
#include <bluetooth/services/ots.h>
|
#include <bluetooth/services/ots.h>
|
||||||
#include <bluetooth/services/ots_client.h>
|
|
||||||
#include "ots_internal.h"
|
#include "ots_internal.h"
|
||||||
#include "ots_client_internal.h"
|
#include "ots_client_internal.h"
|
||||||
#include "ots_l2cap_internal.h"
|
#include "ots_l2cap_internal.h"
|
||||||
|
@ -100,7 +99,7 @@ static const char * const lit_olcp_result[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bt_otc_internal_instance_t {
|
struct bt_otc_internal_instance_t {
|
||||||
struct bt_otc_instance_t *otc_inst;
|
struct bt_ots_client *otc_inst;
|
||||||
struct bt_gatt_ots_l2cap l2cap_ctx;
|
struct bt_gatt_ots_l2cap l2cap_ctx;
|
||||||
bool busy;
|
bool busy;
|
||||||
/** Bitfield that is used to determine how much metadata to read */
|
/** Bitfield that is used to determine how much metadata to read */
|
||||||
|
@ -176,7 +175,7 @@ static ssize_t rx_done(struct bt_gatt_ots_l2cap *l2cap_ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_inst = NULL;
|
cur_inst = NULL;
|
||||||
} else if (cb_ret == BT_OTC_STOP) {
|
} else if (cb_ret == BT_OTS_STOP) {
|
||||||
const uint32_t rcv_size = cur_object->size.cur;
|
const uint32_t rcv_size = cur_object->size.cur;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -245,7 +244,7 @@ static struct bt_otc_internal_instance_t *lookup_inst_by_handle(uint16_t handle)
|
||||||
|
|
||||||
static void on_object_selected(struct bt_conn *conn,
|
static void on_object_selected(struct bt_conn *conn,
|
||||||
enum bt_gatt_ots_olcp_res_code res,
|
enum bt_gatt_ots_olcp_res_code res,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
memset(&otc_inst->cur_object, 0, sizeof(otc_inst->cur_object));
|
memset(&otc_inst->cur_object, 0, sizeof(otc_inst->cur_object));
|
||||||
otc_inst->cur_object.id = BT_OTC_UNKNOWN_ID;
|
otc_inst->cur_object.id = BT_OTC_UNKNOWN_ID;
|
||||||
|
@ -258,7 +257,7 @@ static void on_object_selected(struct bt_conn *conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void olcp_ind_handler(struct bt_conn *conn,
|
static void olcp_ind_handler(struct bt_conn *conn,
|
||||||
struct bt_otc_instance_t *otc_inst,
|
struct bt_ots_client *otc_inst,
|
||||||
const void *data, uint16_t length)
|
const void *data, uint16_t length)
|
||||||
{
|
{
|
||||||
enum bt_gatt_ots_olcp_proc_type op_code;
|
enum bt_gatt_ots_olcp_proc_type op_code;
|
||||||
|
@ -324,7 +323,7 @@ static void olcp_ind_handler(struct bt_conn *conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oacp_ind_handler(struct bt_conn *conn,
|
static void oacp_ind_handler(struct bt_conn *conn,
|
||||||
struct bt_otc_instance_t *otc_inst,
|
struct bt_ots_client *otc_inst,
|
||||||
const void *data, uint16_t length)
|
const void *data, uint16_t length)
|
||||||
{
|
{
|
||||||
enum bt_gatt_ots_oacp_proc_type op_code;
|
enum bt_gatt_ots_oacp_proc_type op_code;
|
||||||
|
@ -347,9 +346,9 @@ static void oacp_ind_handler(struct bt_conn *conn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bt_otc_indicate_handler(struct bt_conn *conn,
|
uint8_t bt_ots_client_indicate_handler(struct bt_conn *conn,
|
||||||
struct bt_gatt_subscribe_params *params,
|
struct bt_gatt_subscribe_params *params,
|
||||||
const void *data, uint16_t length)
|
const void *data, uint16_t length)
|
||||||
{
|
{
|
||||||
uint16_t handle = params->value_handle;
|
uint16_t handle = params->value_handle;
|
||||||
struct bt_otc_internal_instance_t *inst =
|
struct bt_otc_internal_instance_t *inst =
|
||||||
|
@ -417,7 +416,7 @@ static uint8_t read_feature_cb(struct bt_conn *conn, uint8_t err,
|
||||||
return BT_GATT_ITER_STOP;
|
return BT_GATT_ITER_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_register(struct bt_otc_instance_t *otc_inst)
|
int bt_ots_client_register(struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ARRAY_SIZE(otc_insts); i++) {
|
for (int i = 0; i < ARRAY_SIZE(otc_insts); i++) {
|
||||||
int err;
|
int err;
|
||||||
|
@ -440,7 +439,7 @@ int bt_otc_register(struct bt_otc_instance_t *otc_inst)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_unregister(uint8_t index)
|
int bt_ots_client_unregister(uint8_t index)
|
||||||
{
|
{
|
||||||
if (index < ARRAY_SIZE(otc_insts)) {
|
if (index < ARRAY_SIZE(otc_insts)) {
|
||||||
memset(&otc_insts[index], 0, sizeof(otc_insts[index]));
|
memset(&otc_insts[index], 0, sizeof(otc_insts[index]));
|
||||||
|
@ -451,8 +450,8 @@ int bt_otc_unregister(uint8_t index)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_read_feature(struct bt_conn *conn,
|
int bt_ots_client_read_feature(struct bt_conn *conn,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
if (OTS_CLIENT_INST_COUNT > 0) {
|
if (OTS_CLIENT_INST_COUNT > 0) {
|
||||||
struct bt_otc_internal_instance_t *inst;
|
struct bt_otc_internal_instance_t *inst;
|
||||||
|
@ -537,8 +536,9 @@ static int write_olcp(struct bt_otc_internal_instance_t *inst,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_select_id(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst,
|
int bt_ots_client_select_id(struct bt_conn *conn,
|
||||||
uint64_t obj_id)
|
struct bt_ots_client *otc_inst,
|
||||||
|
uint64_t obj_id)
|
||||||
{
|
{
|
||||||
if (OTS_CLIENT_INST_COUNT > 0) {
|
if (OTS_CLIENT_INST_COUNT > 0) {
|
||||||
struct bt_otc_internal_instance_t *inst;
|
struct bt_otc_internal_instance_t *inst;
|
||||||
|
@ -576,8 +576,8 @@ int bt_otc_select_id(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst,
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_select_first(struct bt_conn *conn,
|
int bt_ots_client_select_first(struct bt_conn *conn,
|
||||||
struct bt_otc_instance_t *otc_inst)
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
if (OTS_CLIENT_INST_COUNT > 0) {
|
if (OTS_CLIENT_INST_COUNT > 0) {
|
||||||
struct bt_otc_internal_instance_t *inst;
|
struct bt_otc_internal_instance_t *inst;
|
||||||
|
@ -610,7 +610,8 @@ int bt_otc_select_first(struct bt_conn *conn,
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_select_last(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst)
|
int bt_ots_client_select_last(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
if (OTS_CLIENT_INST_COUNT > 0) {
|
if (OTS_CLIENT_INST_COUNT > 0) {
|
||||||
struct bt_otc_internal_instance_t *inst;
|
struct bt_otc_internal_instance_t *inst;
|
||||||
|
@ -644,7 +645,8 @@ int bt_otc_select_last(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_select_next(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst)
|
int bt_ots_client_select_next(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
if (OTS_CLIENT_INST_COUNT > 0) {
|
if (OTS_CLIENT_INST_COUNT > 0) {
|
||||||
struct bt_otc_internal_instance_t *inst;
|
struct bt_otc_internal_instance_t *inst;
|
||||||
|
@ -677,7 +679,8 @@ int bt_otc_select_next(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_select_prev(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst)
|
int bt_ots_client_select_prev(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
if (OTS_CLIENT_INST_COUNT > 0) {
|
if (OTS_CLIENT_INST_COUNT > 0) {
|
||||||
struct bt_otc_internal_instance_t *inst;
|
struct bt_otc_internal_instance_t *inst;
|
||||||
|
@ -1151,7 +1154,8 @@ static int oacp_read(struct bt_conn *conn,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_read_object_data(struct bt_conn *conn, struct bt_otc_instance_t *otc_inst)
|
int bt_ots_client_read_object_data(struct bt_conn *conn,
|
||||||
|
struct bt_ots_client *otc_inst)
|
||||||
{
|
{
|
||||||
struct bt_otc_internal_instance_t *inst;
|
struct bt_otc_internal_instance_t *inst;
|
||||||
|
|
||||||
|
@ -1232,9 +1236,9 @@ static void read_next_metadata(struct bt_conn *conn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_read_object_metadata(struct bt_conn *conn,
|
int bt_ots_client_read_object_metadata(struct bt_conn *conn,
|
||||||
struct bt_otc_instance_t *otc_inst,
|
struct bt_ots_client *otc_inst,
|
||||||
uint8_t metadata)
|
uint8_t metadata)
|
||||||
{
|
{
|
||||||
struct bt_otc_internal_instance_t *inst;
|
struct bt_otc_internal_instance_t *inst;
|
||||||
|
|
||||||
|
@ -1430,8 +1434,8 @@ static int decode_record(struct net_buf_simple *buf,
|
||||||
return rec->len;
|
return rec->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bt_otc_decode_dirlisting(uint8_t *data, uint16_t length,
|
int bt_ots_client_decode_dirlisting(uint8_t *data, uint16_t length,
|
||||||
bt_otc_dirlisting_cb cb)
|
bt_ots_client_dirlisting_cb cb)
|
||||||
{
|
{
|
||||||
struct net_buf_simple net_buf;
|
struct net_buf_simple net_buf;
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
|
@ -1464,7 +1468,7 @@ int bt_otc_decode_dirlisting(uint8_t *data, uint16_t length,
|
||||||
|
|
||||||
ret = cb(&record.metadata);
|
ret = cb(&record.metadata);
|
||||||
|
|
||||||
if (ret == BT_OTC_STOP) {
|
if (ret == BT_OTS_STOP) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "bt.h"
|
#include "bt.h"
|
||||||
|
|
||||||
#include <bluetooth/services/ots_client.h>
|
#include <bluetooth/services/ots.h>
|
||||||
#include "../services/ots/ots_client_internal.h"
|
#include "../services/ots/ots_client_internal.h"
|
||||||
#include "../audio/media_proxy_internal.h"
|
#include "../audio/media_proxy_internal.h"
|
||||||
|
|
||||||
|
@ -1164,7 +1164,7 @@ int cmd_mcc_otc_read_features(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_read_feature(default_conn, bt_mcc_otc_inst());
|
result = bt_ots_client_read_feature(default_conn, bt_mcc_otc_inst());
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1175,7 +1175,7 @@ int cmd_mcc_otc_read(const struct shell *sh, size_t argc, char *argv[])
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_read_object_data(default_conn, bt_mcc_otc_inst());
|
result = bt_ots_client_read_object_data(default_conn, bt_mcc_otc_inst());
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1187,8 +1187,9 @@ int cmd_mcc_otc_read_metadata(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_read_object_metadata(default_conn, bt_mcc_otc_inst(),
|
result = bt_ots_client_read_object_metadata(default_conn,
|
||||||
BT_OTS_METADATA_REQ_ALL);
|
bt_mcc_otc_inst(),
|
||||||
|
BT_OTS_METADATA_REQ_ALL);
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1207,7 +1208,7 @@ int cmd_mcc_otc_select(const struct shell *sh, size_t argc, char *argv[])
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = bt_otc_select_id(default_conn, bt_mcc_otc_inst(), id);
|
result = bt_ots_client_select_id(default_conn, bt_mcc_otc_inst(), id);
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1219,7 +1220,7 @@ int cmd_mcc_otc_select_first(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_select_first(default_conn, bt_mcc_otc_inst());
|
result = bt_ots_client_select_first(default_conn, bt_mcc_otc_inst());
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1231,7 +1232,7 @@ int cmd_mcc_otc_select_last(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_select_last(default_conn, bt_mcc_otc_inst());
|
result = bt_ots_client_select_last(default_conn, bt_mcc_otc_inst());
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1243,7 +1244,7 @@ int cmd_mcc_otc_select_next(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_select_next(default_conn, bt_mcc_otc_inst());
|
result = bt_ots_client_select_next(default_conn, bt_mcc_otc_inst());
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1255,7 +1256,7 @@ int cmd_mcc_otc_select_prev(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_select_prev(default_conn, bt_mcc_otc_inst());
|
result = bt_ots_client_select_prev(default_conn, bt_mcc_otc_inst());
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1351,7 +1352,7 @@ int cmd_mcc_ots_select_first(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_select_first(default_conn, 0);
|
result = bt_ots_client_select_first(default_conn, 0);
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1363,7 +1364,7 @@ int cmd_mcc_ots_select_last(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_select_last(default_conn, 0);
|
result = bt_ots_client_select_last(default_conn, 0);
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1375,7 +1376,7 @@ int cmd_mcc_ots_select_next(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_select_next(default_conn, 0);
|
result = bt_ots_client_select_next(default_conn, 0);
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
@ -1387,7 +1388,7 @@ int cmd_mcc_ots_select_prev(const struct shell *sh, size_t argc,
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = bt_otc_select_prev(default_conn, 0);
|
result = bt_ots_client_select_prev(default_conn, 0);
|
||||||
if (result) {
|
if (result) {
|
||||||
shell_error(sh, "Fail: %d", result);
|
shell_error(sh, "Fail: %d", result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <bluetooth/audio/mcc.h>
|
#include <bluetooth/audio/mcc.h>
|
||||||
|
|
||||||
#include <bluetooth/audio/media_proxy.h>
|
#include <bluetooth/audio/media_proxy.h>
|
||||||
#include <bluetooth/services/ots_client.h>
|
#include <bluetooth/services/ots.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ static void select_read_meta(int64_t id)
|
||||||
|
|
||||||
/* TODO: Fix the instance pointer - it is neither valid nor used */
|
/* TODO: Fix the instance pointer - it is neither valid nor used */
|
||||||
UNSET_FLAG(object_selected);
|
UNSET_FLAG(object_selected);
|
||||||
err = bt_otc_select_id(default_conn, bt_mcc_otc_inst(), id);
|
err = bt_ots_client_select_id(default_conn, bt_mcc_otc_inst(), id);
|
||||||
if (err) {
|
if (err) {
|
||||||
FAIL("Failed to select object\n");
|
FAIL("Failed to select object\n");
|
||||||
return;
|
return;
|
||||||
|
@ -603,8 +603,8 @@ static void select_read_meta(int64_t id)
|
||||||
|
|
||||||
/* TODO: Fix the instance pointer - it is neither valid nor used */
|
/* TODO: Fix the instance pointer - it is neither valid nor used */
|
||||||
UNSET_FLAG(metadata_read);
|
UNSET_FLAG(metadata_read);
|
||||||
err = bt_otc_read_object_metadata(default_conn, bt_mcc_otc_inst(),
|
err = bt_ots_client_read_object_metadata(default_conn, bt_mcc_otc_inst(),
|
||||||
BT_OTS_METADATA_REQ_ALL);
|
BT_OTS_METADATA_REQ_ALL);
|
||||||
if (err) {
|
if (err) {
|
||||||
FAIL("Failed to read object metadata\n");
|
FAIL("Failed to read object metadata\n");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <bluetooth/audio/mcc.h>
|
#include <bluetooth/audio/mcc.h>
|
||||||
|
|
||||||
#include <bluetooth/audio/media_proxy.h>
|
#include <bluetooth/audio/media_proxy.h>
|
||||||
#include <bluetooth/services/ots_client.h>
|
#include <bluetooth/services/ots.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue