Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
bt_ots_cb Struct Reference

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_metadata *init)
 Object created callback. More...
 
void(* obj_deleted )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id)
 Object deleted callback. More...
 
void(* obj_selected )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id)
 Object selected callback. More...
 
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. More...
 
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. More...
 
void(* obj_name_written )(struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const char *name)
 Object name written callback. More...
 

Detailed Description

OTS callback structure.

Field Documentation

◆ obj_created

int(* bt_ots_cb::obj_created) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const struct bt_ots_obj_metadata *init)

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 the following function: bt_ots_obj_add().
idObject ID.
initObject initialization metadata.
Returns
0 in case of success or negative value in case of error. Possible return values: -ENOMEM if no available space for new object.

◆ obj_deleted

void(* 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.

◆ obj_name_written

void(* bt_ots_cb::obj_name_written) (struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const char *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 has been updated by the OTS service implementation.

Parameters
otsOTS instance.
connThe connection that wrote object name.
idObject ID.
nameObject 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: