7#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_H_
8#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_H_
34#define BT_OTS_OBJ_ID_SIZE 6
37#define BT_OTS_OBJ_ID_MIN 0x000000000100
40#define BT_OTS_OBJ_ID_MAX 0xFFFFFFFFFFFF
43#define OTS_OBJ_ID_DIR_LIST 0x000000000000
46#define BT_OTS_OBJ_ID_MASK BIT64_MASK(48)
49#define BT_OTS_OBJ_ID_STR_LEN 15
103#define BT_OTS_OBJ_SET_PROP_DELETE(prop) \
104 WRITE_BIT(prop, BT_OTS_OBJ_PROP_DELETE, 1)
110#define BT_OTS_OBJ_SET_PROP_EXECUTE(prop) \
111 WRITE_BIT(prop, BT_OTS_OBJ_PROP_EXECUTE, 1)
117#define BT_OTS_OBJ_SET_PROP_READ(prop) \
118 WRITE_BIT(prop, BT_OTS_OBJ_PROP_READ, 1)
124#define BT_OTS_OBJ_SET_PROP_WRITE(prop) \
125 WRITE_BIT(prop, BT_OTS_OBJ_PROP_WRITE, 1)
131#define BT_OTS_OBJ_SET_PROP_APPEND(prop) \
132 WRITE_BIT(prop, BT_OTS_OBJ_PROP_APPEND, 1)
138#define BT_OTS_OBJ_SET_PROP_TRUNCATE(prop) \
139 WRITE_BIT(prop, BT_OTS_OBJ_PROP_TRUNCATE, 1)
145#define BT_OTS_OBJ_SET_PROP_PATCH(prop) \
146 WRITE_BIT(prop, BT_OTS_OBJ_PROP_PATCH, 1)
152#define BT_OTS_OBJ_SET_PROP_MARKED(prop) \
153 WRITE_BIT(prop, BT_OTS_OBJ_PROP_MARKED, 1)
159#define BT_OTS_OBJ_GET_PROP_DELETE(prop) \
160 ((prop) & BIT(BT_OTS_OBJ_PROP_DELETE))
166#define BT_OTS_OBJ_GET_PROP_EXECUTE(prop) \
167 ((prop) & BIT(BT_OTS_OBJ_PROP_EXECUTE))
173#define BT_OTS_OBJ_GET_PROP_READ(prop) \
174 ((prop) & BIT(BT_OTS_OBJ_PROP_READ))
180#define BT_OTS_OBJ_GET_PROP_WRITE(prop) \
181 ((prop) & BIT(BT_OTS_OBJ_PROP_WRITE))
187#define BT_OTS_OBJ_GET_PROP_APPEND(prop) \
188 ((prop) & BIT(BT_OTS_OBJ_PROP_APPEND))
194#define BT_OTS_OBJ_GET_PROP_TRUNCATE(prop) \
195 ((prop) & BIT(BT_OTS_OBJ_PROP_TRUNCATE))
201#define BT_OTS_OBJ_GET_PROP_PATCH(prop) \
202 ((prop) & BIT(BT_OTS_OBJ_PROP_PATCH))
208#define BT_OTS_OBJ_GET_PROP_MARKED(prop) \
209 ((prop) & BIT(BT_OTS_OBJ_PROP_MARKED))
266#define BT_OTS_OACP_SET_FEAT_CREATE(feat) \
267 WRITE_BIT(feat, BT_OTS_OACP_FEAT_CREATE, 1)
273#define BT_OTS_OACP_SET_FEAT_DELETE(feat) \
274 WRITE_BIT(feat, BT_OTS_OACP_FEAT_DELETE, 1)
280#define BT_OTS_OACP_SET_FEAT_CHECKSUM(feat) \
281 WRITE_BIT(feat, BT_OTS_OACP_FEAT_CHECKSUM, 1)
287#define BT_OTS_OACP_SET_FEAT_EXECUTE(feat) \
288 WRITE_BIT(feat, BT_OTS_OACP_FEAT_EXECUTE, 1)
294#define BT_OTS_OACP_SET_FEAT_READ(feat) \
295 WRITE_BIT(feat, BT_OTS_OACP_FEAT_READ, 1)
301#define BT_OTS_OACP_SET_FEAT_WRITE(feat) \
302 WRITE_BIT(feat, BT_OTS_OACP_FEAT_WRITE, 1)
308#define BT_OTS_OACP_SET_FEAT_APPEND(feat) \
309 WRITE_BIT(feat, BT_OTS_OACP_FEAT_APPEND, 1)
315#define BT_OTS_OACP_SET_FEAT_TRUNCATE(feat) \
316 WRITE_BIT(feat, BT_OTS_OACP_FEAT_TRUNCATE, 1)
322#define BT_OTS_OACP_SET_FEAT_PATCH(feat) \
323 WRITE_BIT(feat, BT_OTS_OACP_FEAT_PATCH, 1)
329#define BT_OTS_OACP_SET_FEAT_ABORT(feat) \
330 WRITE_BIT(feat, BT_OTS_OACP_FEAT_ABORT, 1)
336#define BT_OTS_OACP_GET_FEAT_CREATE(feat) \
337 ((feat) & BIT(BT_OTS_OACP_FEAT_CREATE))
343#define BT_OTS_OACP_GET_FEAT_DELETE(feat) \
344 ((feat) & BIT(BT_OTS_OACP_FEAT_DELETE))
350#define BT_OTS_OACP_GET_FEAT_CHECKSUM(feat) \
351 ((feat) & BIT(BT_OTS_OACP_FEAT_CHECKSUM))
357#define BT_OTS_OACP_GET_FEAT_EXECUTE(feat) \
358 ((feat) & BIT(BT_OTS_OACP_FEAT_EXECUTE))
364#define BT_OTS_OACP_GET_FEAT_READ(feat) \
365 ((feat) & BIT(BT_OTS_OACP_FEAT_READ))
371#define BT_OTS_OACP_GET_FEAT_WRITE(feat) \
372 ((feat) & BIT(BT_OTS_OACP_FEAT_WRITE))
378#define BT_OTS_OACP_GET_FEAT_APPEND(feat) \
379 ((feat) & BIT(BT_OTS_OACP_FEAT_APPEND))
385#define BT_OTS_OACP_GET_FEAT_TRUNCATE(feat) \
386 ((feat) & BIT(BT_OTS_OACP_FEAT_TRUNCATE))
392#define BT_OTS_OACP_GET_FEAT_PATCH(feat) \
393 ((feat) & BIT(BT_OTS_OACP_FEAT_PATCH))
399#define BT_OTS_OACP_GET_FEAT_ABORT(feat) \
400 ((feat) & BIT(BT_OTS_OACP_FEAT_ABORT))
421#define BT_OTS_OLCP_SET_FEAT_GO_TO(feat) \
422 WRITE_BIT(feat, BT_OTS_OLCP_FEAT_GO_TO, 1)
428#define BT_OTS_OLCP_SET_FEAT_ORDER(feat) \
429 WRITE_BIT(feat, BT_OTS_OLCP_FEAT_ORDER, 1)
435#define BT_OTS_OLCP_SET_FEAT_NUM_REQ(feat) \
436 WRITE_BIT(feat, BT_OTS_OLCP_FEAT_NUM_REQ, 1)
442#define BT_OTS_OLCP_SET_FEAT_CLEAR(feat) \
443 WRITE_BIT(feat, BT_OTS_OLCP_FEAT_CLEAR, 1)
449#define BT_OTS_OLCP_GET_FEAT_GO_TO(feat) \
450 ((feat) & BIT(BT_OTS_OLCP_FEAT_GO_TO))
456#define BT_OTS_OLCP_GET_FEAT_ORDER(feat) \
457 ((feat) & BIT(BT_OTS_OLCP_FEAT_ORDER))
463#define BT_OTS_OLCP_GET_FEAT_NUM_REQ(feat) \
464 ((feat) & BIT(BT_OTS_OLCP_FEAT_NUM_REQ))
470#define BT_OTS_OLCP_GET_FEAT_CLEAR(feat) \
471 ((feat) & BIT(BT_OTS_OLCP_FEAT_CLEAR))
511#define BT_OTS_DATE_TIME_FIELD_SIZE 7
520#if defined(CONFIG_BT_OTS)
525#if defined(CONFIG_BT_OTS_CLIENT)
528 char name_c[CONFIG_BT_OTS_OBJ_MAX_NAME_LEN + 1];
537#if defined(CONFIG_BT_OTS_CLIENT)
711 const void *
data,
size_t len,
off_t offset,
727 uint64_t id,
const char *cur_name,
const char *new_name);
794#define BT_OTS_CONTINUE 1
840 struct bt_conn *conn,
int err);
860 struct bt_conn *conn,
uint32_t offset,
877 struct bt_conn *conn,
int err,
890 struct bt_conn *conn,
size_t len);
928 struct bt_conn *conn);
939 struct bt_conn *conn,
950 struct bt_conn *conn);
960 struct bt_conn *conn);
970 struct bt_conn *conn);
980 struct bt_conn *conn);
994 struct bt_conn *conn,
1010 struct bt_conn *conn);
1029 const void *buf,
size_t len,
off_t offset,
1073 return snprintk(str, len,
"0x%02X%02X%02X%02X%02X%02X",
1074 id[5],
id[4],
id[3],
id[2],
id[1],
id[0]);
static void sys_put_le48(uint64_t val, uint8_t dst[6])
Put a 48-bit integer as little-endian to arbitrary location.
Definition: byteorder.h:346
ZTEST_BMEM int count
Definition: main.c:33
Bluetooth connection handling.
Generic Attribute Profile handling.
int bt_ots_client_select_id(struct bt_ots_client *otc_inst, struct bt_conn *conn, uint64_t obj_id)
Select an object by its Object ID.
int bt_ots_client_select_first(struct bt_ots_client *otc_inst, struct bt_conn *conn)
Select the first object.
int bt_ots_client_select_next(struct bt_ots_client *otc_inst, struct bt_conn *conn)
Select the next object.
void bt_ots_metadata_display(struct bt_ots_obj_metadata *metadata, uint16_t count)
Displays one or more object metadata as text with BT_INFO.
int bt_ots_obj_delete(struct bt_ots *ots, uint64_t id)
Delete an object from the OTS instance.
int bt_ots_client_select_last(struct bt_ots_client *otc_inst, struct bt_conn *conn)
Select the last object.
int bt_ots_client_read_object_data(struct bt_ots_client *otc_inst, struct bt_conn *conn)
Read the data of the current selected object.
int bt_ots_client_read_object_metadata(struct bt_ots_client *otc_inst, struct bt_conn *conn, uint8_t metadata)
Read the metadata of the current object.
int bt_ots_client_write_object_data(struct bt_ots_client *otc_inst, struct bt_conn *conn, const void *buf, size_t len, off_t offset, enum bt_ots_oacp_write_op_mode mode)
Write the data of the current selected object.
int(* bt_ots_client_dirlisting_cb)(struct bt_ots_obj_metadata *meta)
Directory listing object metadata callback.
Definition: ots.h:1042
int bt_ots_client_decode_dirlisting(uint8_t *data, uint16_t length, bt_ots_client_dirlisting_cb cb)
Decode Directory Listing object into object metadata.
void * bt_ots_svc_decl_get(struct bt_ots *ots)
Get the service declaration attribute.
int bt_ots_obj_add(struct bt_ots *ots, const struct bt_ots_obj_add_param *param)
Add an object to the OTS instance.
int bt_ots_init(struct bt_ots *ots, struct bt_ots_init *ots_init)
Initialize the OTS instance.
uint8_t bt_ots_client_indicate_handler(struct bt_conn *conn, struct bt_gatt_subscribe_params *params, const void *data, uint16_t length)
OTS Indicate Handler function.
int bt_ots_client_select_prev(struct bt_ots_client *otc_inst, struct bt_conn *conn)
Select the previous object.
static int bt_ots_obj_id_to_str(uint64_t obj_id, char *str, size_t len)
Converts binary OTS Object ID to string.
Definition: ots.h:1067
int bt_ots_client_register(struct bt_ots_client *ots_inst)
Register an Object Transfer Service Instance.
bt_ots_oacp_write_op_mode
Definition: ots.h:257
int bt_ots_client_read_feature(struct bt_ots_client *otc_inst, struct bt_conn *conn)
Read the OTS feature characteristic.
struct bt_ots * bt_ots_free_instance_get(void)
Get a free instance of OTS from the pool.
@ BT_OTS_METADATA_REQ_ALL
Request all object metadata.
Definition: ots.h:499
@ BT_OTS_METADATA_REQ_MODIFIED
Request object last modified time.
Definition: ots.h:493
@ BT_OTS_METADATA_REQ_ID
Request object ID.
Definition: ots.h:495
@ BT_OTS_METADATA_REQ_CREATED
Request object first created time.
Definition: ots.h:491
@ BT_OTS_METADATA_REQ_SIZE
Request object size.
Definition: ots.h:489
@ BT_OTS_METADATA_REQ_NAME
Request object name.
Definition: ots.h:485
@ BT_OTS_METADATA_REQ_PROPS
Request object properties.
Definition: ots.h:497
@ BT_OTS_METADATA_REQ_TYPE
Request object type.
Definition: ots.h:487
@ BT_OTS_OACP_FEAT_ABORT
Definition: ots.h:250
@ BT_OTS_OACP_FEAT_DELETE
Definition: ots.h:226
@ BT_OTS_OACP_FEAT_APPEND
Definition: ots.h:241
@ BT_OTS_OACP_FEAT_READ
Definition: ots.h:235
@ BT_OTS_OACP_FEAT_TRUNCATE
Definition: ots.h:244
@ BT_OTS_OACP_FEAT_CHECKSUM
Definition: ots.h:229
@ BT_OTS_OACP_FEAT_WRITE
Definition: ots.h:238
@ BT_OTS_OACP_FEAT_EXECUTE
Definition: ots.h:232
@ BT_OTS_OACP_FEAT_PATCH
Definition: ots.h:247
@ BT_OTS_OACP_FEAT_CREATE
Definition: ots.h:223
@ BT_OTS_OBJ_PROP_MARKED
Definition: ots.h:96
@ BT_OTS_OBJ_PROP_DELETE
Definition: ots.h:68
@ BT_OTS_OBJ_PROP_TRUNCATE
Definition: ots.h:86
@ BT_OTS_OBJ_PROP_APPEND
Bit 4 Appending data to this object is permitted.
Definition: ots.h:83
@ BT_OTS_OBJ_PROP_READ
Definition: ots.h:74
@ BT_OTS_OBJ_PROP_EXECUTE
Definition: ots.h:71
@ BT_OTS_OBJ_PROP_PATCH
Bit 6 Patching this object is permitted.
Definition: ots.h:93
@ BT_OTS_OBJ_PROP_WRITE
Definition: ots.h:77
@ BT_OTS_OLCP_FEAT_ORDER
Definition: ots.h:408
@ BT_OTS_OLCP_FEAT_NUM_REQ
Definition: ots.h:411
@ BT_OTS_OLCP_FEAT_CLEAR
Definition: ots.h:414
@ BT_OTS_OLCP_FEAT_GO_TO
Definition: ots.h:405
@ BT_OTS_OACP_WRITE_OP_MODE_NONE
Definition: ots.h:258
@ BT_OTS_OACP_WRITE_OP_MODE_TRUNCATE
Definition: ots.h:259
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
__SIZE_TYPE__ ssize_t
Definition: types.h:28
__INTPTR_TYPE__ off_t
Definition: types.h:36
int snprintk(char *str, size_t size, const char *fmt,...)
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
GATT Discover Attributes parameters.
Definition: gatt.h:1430
GATT Read parameters.
Definition: gatt.h:1518
GATT Subscribe parameters.
Definition: gatt.h:1788
GATT Write parameters.
Definition: gatt.h:1609
OTS callback structure.
Definition: ots.h:598
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.
Definition: ots.h:621
int(* obj_deleted)(struct bt_ots *ots, struct bt_conn *conn, uint64_t id)
Object deleted callback.
Definition: ots.h:646
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.
Definition: ots.h:726
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.
Definition: ots.h:680
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.
Definition: ots.h:710
void(* obj_selected)(struct bt_ots *ots, struct bt_conn *conn, uint64_t id)
Object selected callback.
Definition: ots.h:657
void(* obj_data_written)(struct bt_ots_client *ots_inst, struct bt_conn *conn, size_t len)
Callback function for the data of the write object.
Definition: ots.h:889
void(* obj_metadata_read)(struct bt_ots_client *ots_inst, struct bt_conn *conn, int err, uint8_t metadata_read)
Callback function for metadata of the selected object.
Definition: ots.h:876
void(* obj_selected)(struct bt_ots_client *ots_inst, struct bt_conn *conn, int err)
Callback function when a new object is selected.
Definition: ots.h:839
int(* obj_data_read)(struct bt_ots_client *ots_inst, struct bt_conn *conn, uint32_t offset, uint32_t len, uint8_t *data_p, bool is_complete)
Callback function for the data of the selected object.
Definition: ots.h:859
OTS client instance.
Definition: ots.h:798
struct bt_gatt_write_params write_params
Definition: ots.h:817
uint16_t start_handle
Definition: ots.h:799
struct bt_ots_client_cb * cb
Definition: ots.h:819
uint16_t feature_handle
Definition: ots.h:801
uint16_t obj_id_handle
Definition: ots.h:808
struct bt_gatt_subscribe_params olcp_sub_params
Definition: ots.h:814
uint16_t obj_size_handle
Definition: ots.h:804
uint16_t obj_modified_handle
Definition: ots.h:807
struct bt_gatt_read_params read_proc
Definition: ots.h:818
struct bt_gatt_discover_params oacp_sub_disc_params
Definition: ots.h:813
struct bt_ots_feat features
Definition: ots.h:821
struct bt_gatt_subscribe_params oacp_sub_params
Definition: ots.h:812
uint16_t end_handle
Definition: ots.h:800
uint16_t olcp_handle
Definition: ots.h:810
uint16_t obj_properties_handle
Definition: ots.h:805
struct bt_ots_obj_metadata cur_object
Definition: ots.h:823
struct bt_gatt_discover_params olcp_sub_disc_params
Definition: ots.h:815
uint16_t oacp_handle
Definition: ots.h:809
uint16_t obj_type_handle
Definition: ots.h:803
uint16_t obj_name_handle
Definition: ots.h:802
uint16_t obj_created_handle
Definition: ots.h:806
Date and Time structure.
Definition: ots.h:503
uint8_t day
Definition: ots.h:506
uint8_t seconds
Definition: ots.h:509
uint8_t month
Definition: ots.h:505
uint8_t minutes
Definition: ots.h:508
uint8_t hours
Definition: ots.h:507
uint16_t year
Definition: ots.h:504
Features of the OTS.
Definition: ots.h:474
uint32_t olcp
Definition: ots.h:479
uint32_t oacp
Definition: ots.h:476
Descriptor for OTS initialization.
Definition: ots.h:731
struct bt_ots_feat features
Definition: ots.h:733
struct bt_ots_cb * cb
Definition: ots.h:736
Descriptor for OTS object addition.
Definition: ots.h:556
uint32_t size
Object size to allocate.
Definition: ots.h:558
struct bt_ots_obj_type type
Object type.
Definition: ots.h:561
Descriptor for OTS created object.
Definition: ots.h:570
uint32_t props
Object properties.
Definition: ots.h:594
struct bt_ots_obj_size size
Object size.
Definition: ots.h:591
char * name
Object name.
Definition: ots.h:580
Descriptor for OTS Object Size parameter.
Definition: ots.h:212
uint32_t cur
Current Size.
Definition: ots.h:214
uint32_t alloc
Allocated Size.
Definition: ots.h:217
Type of an OTS object.
Definition: ots.h:52
struct bt_uuid uuid
Definition: ots.h:55
struct bt_uuid_16 uuid_16
Definition: ots.h:58
struct bt_uuid_128 uuid_128
Definition: ots.h:61
This is a 'tentative' type and should be used as a pointer only.
Definition: uuid.h:46
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
static qdata_t data_p[2]
Definition: test_queue_contexts.c:19