Zephyr API 3.6.99
Loading...
Searching...
No Matches

OTS callback structure. More...

#include <ots.h>

Data Fields

int(* obj_created )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const struct bt_ots_obj_add_param *add_param, struct bt_ots_obj_created_desc *created_desc)
 Object created callback.
 
int(* obj_deleted )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id)
 Object deleted callback.
 
void(* obj_selected )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id)
 Object selected callback.
 
ssize_t(* obj_read )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id, void **data, size_t len, off_t offset)
 Object read callback.
 
ssize_t(* obj_write )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const void *data, size_t len, off_t offset, size_t rem)
 Object write callback.
 
void(* obj_name_written )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const char *cur_name, const char *new_name)
 Object name written callback.
 
int(* obj_cal_checksum )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id, off_t offset, size_t len, void **data)
 Object Calculate checksum callback.
 

Detailed Description

OTS callback structure.

Field Documentation

◆ obj_cal_checksum

int(* bt_ots_cb::obj_cal_checksum) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id, off_t offset, size_t len, void **data)

Object Calculate checksum callback.

This callback is called when the OACP Calculate Checksum procedure is performed. Because object data is opaque to OTS, the application is the only one who knows where data is and should return pointer of actual object data.

Parameters
[in]otsOTS instance.
[in]connThe connection that wrote object.
[in]idObject ID.
[in]offsetThe first octet of the object contents need to be calculated.
[in]lenThe length number of octets object name.
[out]dataPointer of actual object data.
Returns
0 to accept, or any negative value to reject.

◆ obj_created

int(* bt_ots_cb::obj_created) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const struct bt_ots_obj_add_param *add_param, struct bt_ots_obj_created_desc *created_desc)

Object created callback.

This callback is called whenever a new object is created. Application can reject this request by returning an error when it does not have necessary resources to hold this new object. This callback is also triggered when the server creates a new object with bt_ots_obj_add() API.

Parameters
otsOTS instance.
connThe connection that is requesting object creation or NULL if object is created by bt_ots_obj_add().
idObject ID.
add_paramObject creation requested parameters.
created_descCreated object descriptor that shall be filled by the receiver of this callback.
Returns
0 in case of success or negative value in case of error.
-ENOTSUP if object type is not supported
-ENOMEM if no available space for new object.
-EINVAL if an invalid parameter is provided
other negative values are treated as a generic operation failure

◆ obj_deleted

int(* bt_ots_cb::obj_deleted) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id)

Object deleted callback.

This callback is called whenever an object is deleted. It is also triggered when the server deletes an object with bt_ots_obj_delete() API.

Parameters
otsOTS instance.
connThe connection that deleted the object or NULL if this request came from the server.
idObject ID.
Return values
Whenan error is indicated by using a negative value, the object delete procedure is aborted and a corresponding failed status is returned to the client.
Returns
0 in case of success.
-EBUSY if the object is locked. This is generally not expected to be returned by the application as the OTS layer tracks object accesses. An object locked status is returned to the client.
Other negative values in case of error. A generic operation failed status is returned to the client.

◆ obj_name_written

void(* bt_ots_cb::obj_name_written) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const char *cur_name, const char *new_name)

Object name written callback.

This callback is called when the object name is written. This is a notification to the application that the object name will be updated by the OTS service implementation.

Parameters
otsOTS instance.
connThe connection that wrote object name.
idObject ID.
cur_nameCurrent object name.
new_nameNew object name.

◆ obj_read

ssize_t(* bt_ots_cb::obj_read) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id, void **data, size_t len, off_t offset)

Object read callback.

This callback is called multiple times during the Object read operation. OTS module will keep requesting successive Object fragments from the application until the read operation is completed. The end of read operation is indicated by NULL data parameter.

Parameters
otsOTS instance.
connThe connection that read object.
idObject ID.
dataIn: NULL once the read operations is completed. Out: Next chunk of data to be sent.
lenRemaining length requested by the client.
offsetObject data offset.
Returns
Data length to be sent via data parameter. This value shall be smaller or equal to the len parameter.
Negative value in case of an error.

◆ obj_selected

void(* bt_ots_cb::obj_selected) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id)

Object selected callback.

This callback is called on successful object selection.

Parameters
otsOTS instance.
connThe connection that selected new object.
idObject ID.

◆ obj_write

ssize_t(* bt_ots_cb::obj_write) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const void *data, size_t len, off_t offset, size_t rem)

Object write callback.

This callback is called multiple times during the Object write operation. OTS module will keep providing successive Object fragments to the application until the write operation is completed. The offset and length of each write fragment is validated by the OTS module to be within the allocated size of the object. The remaining length indicates data length remaining to be written and will decrease each write iteration until it reaches 0 in the last write fragment.

Parameters
otsOTS instance.
connThe connection that wrote object.
idObject ID.
dataNext chunk of data to be written.
lenLength of the current chunk of data in the buffer.
offsetObject data offset.
remRemaining length in the write operation.
Returns
Number of bytes written in case of success, if the number of bytes written does not match len, -EIO is returned to the L2CAP layer.
A negative value in case of an error.
-EINPROGRESS has a special meaning and is unsupported at the moment. It should not be returned.

The documentation for this struct was generated from the following file: