7#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_H_
8#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_H_
32#define BT_OTS_OBJ_ID_SIZE 6
35#define BT_OTS_OBJ_ID_MIN 0x000000000100
38#define BT_OTS_OBJ_ID_MAX 0xFFFFFFFFFFFF
41#define OTS_OBJ_ID_DIR_LIST 0x000000000000
44#define BT_OTS_OBJ_ID_MASK BIT64_MASK(48)
47#define BT_OTS_OBJ_ID_STR_LEN 15
101#define BT_OTS_OBJ_SET_PROP_DELETE(prop) \
102 WRITE_BIT(prop, BT_OTS_OBJ_PROP_DELETE, 1)
108#define BT_OTS_OBJ_SET_PROP_EXECUTE(prop) \
109 WRITE_BIT(prop, BT_OTS_OBJ_PROP_EXECUTE, 1)
115#define BT_OTS_OBJ_SET_PROP_READ(prop) \
116 WRITE_BIT(prop, BT_OTS_OBJ_PROP_READ, 1)
122#define BT_OTS_OBJ_SET_PROP_WRITE(prop) \
123 WRITE_BIT(prop, BT_OTS_OBJ_PROP_WRITE, 1)
129#define BT_OTS_OBJ_SET_PROP_APPEND(prop) \
130 WRITE_BIT(prop, BT_OTS_OBJ_PROP_APPEND, 1)
136#define BT_OTS_OBJ_SET_PROP_TRUNCATE(prop) \
137 WRITE_BIT(prop, BT_OTS_OBJ_PROP_TRUNCATE, 1)
143#define BT_OTS_OBJ_SET_PROP_PATCH(prop) \
144 WRITE_BIT(prop, BT_OTS_OBJ_PROP_PATCH, 1)
150#define BT_OTS_OBJ_SET_PROP_MARKED(prop) \
151 WRITE_BIT(prop, BT_OTS_OBJ_PROP_MARKED, 1)
157#define BT_OTS_OBJ_GET_PROP_DELETE(prop) \
158 ((prop) & BIT(BT_OTS_OBJ_PROP_DELETE))
164#define BT_OTS_OBJ_GET_PROP_EXECUTE(prop) \
165 ((prop) & BIT(BT_OTS_OBJ_PROP_EXECUTE))
171#define BT_OTS_OBJ_GET_PROP_READ(prop) \
172 ((prop) & BIT(BT_OTS_OBJ_PROP_READ))
178#define BT_OTS_OBJ_GET_PROP_WRITE(prop) \
179 ((prop) & BIT(BT_OTS_OBJ_PROP_WRITE))
185#define BT_OTS_OBJ_GET_PROP_APPEND(prop) \
186 ((prop) & BIT(BT_OTS_OBJ_PROP_APPEND))
192#define BT_OTS_OBJ_GET_PROP_TRUNCATE(prop) \
193 ((prop) & BIT(BT_OTS_OBJ_PROP_TRUNCATE))
199#define BT_OTS_OBJ_GET_PROP_PATCH(prop) \
200 ((prop) & BIT(BT_OTS_OBJ_PROP_PATCH))
206#define BT_OTS_OBJ_GET_PROP_MARKED(prop) \
207 ((prop) & BIT(BT_OTS_OBJ_PROP_MARKED))
255#define BT_OTS_OACP_SET_FEAT_CREATE(feat) \
256 WRITE_BIT(feat, BT_OTS_OACP_FEAT_CREATE, 1)
262#define BT_OTS_OACP_SET_FEAT_DELETE(feat) \
263 WRITE_BIT(feat, BT_OTS_OACP_FEAT_DELETE, 1)
269#define BT_OTS_OACP_SET_FEAT_CHECKSUM(feat) \
270 WRITE_BIT(feat, BT_OTS_OACP_FEAT_CHECKSUM, 1)
276#define BT_OTS_OACP_SET_FEAT_EXECUTE(feat) \
277 WRITE_BIT(feat, BT_OTS_OACP_FEAT_EXECUTE, 1)
283#define BT_OTS_OACP_SET_FEAT_READ(feat) \
284 WRITE_BIT(feat, BT_OTS_OACP_FEAT_READ, 1)
290#define BT_OTS_OACP_SET_FEAT_WRITE(feat) \
291 WRITE_BIT(feat, BT_OTS_OACP_FEAT_WRITE, 1)
297#define BT_OTS_OACP_SET_FEAT_APPEND(feat) \
298 WRITE_BIT(feat, BT_OTS_OACP_FEAT_APPEND, 1)
304#define BT_OTS_OACP_SET_FEAT_TRUNCATE(feat) \
305 WRITE_BIT(feat, BT_OTS_OACP_FEAT_TRUNCATE, 1)
311#define BT_OTS_OACP_SET_FEAT_PATCH(feat) \
312 WRITE_BIT(feat, BT_OTS_OACP_FEAT_PATCH, 1)
318#define BT_OTS_OACP_SET_FEAT_ABORT(feat) \
319 WRITE_BIT(feat, BT_OTS_OACP_FEAT_ABORT, 1)
325#define BT_OTS_OACP_GET_FEAT_CREATE(feat) \
326 ((feat) & BIT(BT_OTS_OACP_FEAT_CREATE))
332#define BT_OTS_OACP_GET_FEAT_DELETE(feat) \
333 ((feat) & BIT(BT_OTS_OACP_FEAT_DELETE))
339#define BT_OTS_OACP_GET_FEAT_CHECKSUM(feat) \
340 ((feat) & BIT(BT_OTS_OACP_FEAT_CHECKSUM))
346#define BT_OTS_OACP_GET_FEAT_EXECUTE(feat) \
347 ((feat) & BIT(BT_OTS_OACP_FEAT_EXECUTE))
353#define BT_OTS_OACP_GET_FEAT_READ(feat) \
354 ((feat) & BIT(BT_OTS_OACP_FEAT_READ))
360#define BT_OTS_OACP_GET_FEAT_WRITE(feat) \
361 ((feat) & BIT(BT_OTS_OACP_FEAT_WRITE))
367#define BT_OTS_OACP_GET_FEAT_APPEND(feat) \
368 ((feat) & BIT(BT_OTS_OACP_FEAT_APPEND))
374#define BT_OTS_OACP_GET_FEAT_TRUNCATE(feat) \
375 ((feat) & BIT(BT_OTS_OACP_FEAT_TRUNCATE))
381#define BT_OTS_OACP_GET_FEAT_PATCH(feat) \
382 ((feat) & BIT(BT_OTS_OACP_FEAT_PATCH))
388#define BT_OTS_OACP_GET_FEAT_ABORT(feat) \
389 ((feat) & BIT(BT_OTS_OACP_FEAT_ABORT))
410#define BT_OTS_OLCP_SET_FEAT_GO_TO(feat) \
411 WRITE_BIT(feat, BT_OTS_OLCP_FEAT_GO_TO, 1)
417#define BT_OTS_OLCP_SET_FEAT_ORDER(feat) \
418 WRITE_BIT(feat, BT_OTS_OLCP_FEAT_ORDER, 1)
424#define BT_OTS_OLCP_SET_FEAT_NUM_REQ(feat) \
425 WRITE_BIT(feat, BT_OTS_OLCP_FEAT_NUM_REQ, 1)
431#define BT_OTS_OLCP_SET_FEAT_CLEAR(feat) \
432 WRITE_BIT(feat, BT_OTS_OLCP_FEAT_CLEAR, 1)
438#define BT_OTS_OLCP_GET_FEAT_GO_TO(feat) \
439 ((feat) & BIT(BT_OTS_OLCP_FEAT_GO_TO))
445#define BT_OTS_OLCP_GET_FEAT_ORDER(feat) \
446 ((feat) & BIT(BT_OTS_OLCP_FEAT_ORDER))
452#define BT_OTS_OLCP_GET_FEAT_NUM_REQ(feat) \
453 ((feat) & BIT(BT_OTS_OLCP_FEAT_NUM_REQ))
459#define BT_OTS_OLCP_GET_FEAT_CLEAR(feat) \
460 ((feat) & BIT(BT_OTS_OLCP_FEAT_CLEAR))
630 const void *
data,
size_t len, off_t offset,
728 return snprintk(str, len,
"0x%02X%02X%02X%02X%02X%02X",
729 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
Bluetooth connection handling.
int bt_ots_obj_delete(struct bt_ots *ots, uint64_t id)
Delete an object from the OTS instance.
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.
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:722
struct bt_ots * bt_ots_free_instance_get(void)
Get a free instance of OTS from the pool.
@ BT_OTS_OACP_FEAT_ABORT
Definition: ots.h:248
@ BT_OTS_OACP_FEAT_DELETE
Definition: ots.h:224
@ BT_OTS_OACP_FEAT_APPEND
Definition: ots.h:239
@ BT_OTS_OACP_FEAT_READ
Definition: ots.h:233
@ BT_OTS_OACP_FEAT_TRUNCATE
Definition: ots.h:242
@ BT_OTS_OACP_FEAT_CHECKSUM
Definition: ots.h:227
@ BT_OTS_OACP_FEAT_WRITE
Definition: ots.h:236
@ BT_OTS_OACP_FEAT_EXECUTE
Definition: ots.h:230
@ BT_OTS_OACP_FEAT_PATCH
Definition: ots.h:245
@ BT_OTS_OACP_FEAT_CREATE
Definition: ots.h:221
@ BT_OTS_OBJ_PROP_MARKED
Definition: ots.h:94
@ BT_OTS_OBJ_PROP_DELETE
Definition: ots.h:66
@ BT_OTS_OBJ_PROP_TRUNCATE
Definition: ots.h:84
@ BT_OTS_OBJ_PROP_APPEND
Bit 4 Appending data to this object is permitted.
Definition: ots.h:81
@ BT_OTS_OBJ_PROP_READ
Definition: ots.h:72
@ BT_OTS_OBJ_PROP_EXECUTE
Definition: ots.h:69
@ BT_OTS_OBJ_PROP_PATCH
Bit 6 Patching this object is permitted.
Definition: ots.h:91
@ BT_OTS_OBJ_PROP_WRITE
Definition: ots.h:75
@ BT_OTS_OLCP_FEAT_ORDER
Definition: ots.h:397
@ BT_OTS_OLCP_FEAT_NUM_REQ
Definition: ots.h:400
@ BT_OTS_OLCP_FEAT_CLEAR
Definition: ots.h:403
@ BT_OTS_OLCP_FEAT_GO_TO
Definition: ots.h:394
__SIZE_TYPE__ ssize_t
Definition: types.h:28
int snprintk(char *str, size_t size, const char *fmt,...)
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
OTS callback structure.
Definition: ots.h:517
void(* obj_name_written)(struct bt_ots *ots, struct bt_conn *conn, uint64_t id, const char *name)
Object name written callback.
Definition: ots.h:644
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:540
int(* obj_deleted)(struct bt_ots *ots, struct bt_conn *conn, uint64_t id)
Object deleted callback.
Definition: ots.h:565
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:599
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:629
void(* obj_selected)(struct bt_ots *ots, struct bt_conn *conn, uint64_t id)
Object selected callback.
Definition: ots.h:576
Features of the OTS.
Definition: ots.h:463
uint32_t olcp
Definition: ots.h:468
uint32_t oacp
Definition: ots.h:465
Descriptor for OTS initialization.
Definition: ots.h:649
struct bt_ots_feat features
Definition: ots.h:651
struct bt_ots_cb * cb
Definition: ots.h:654
Descriptor for OTS object addition.
Definition: ots.h:475
uint32_t size
Object size to allocate.
Definition: ots.h:477
struct bt_ots_obj_type type
Object type.
Definition: ots.h:480
Descriptor for OTS created object.
Definition: ots.h:489
uint32_t props
Object properties.
Definition: ots.h:513
struct bt_ots_obj_size size
Object size.
Definition: ots.h:510
char * name
Object name.
Definition: ots.h:499
Descriptor for OTS Object Size parameter.
Definition: ots.h:210
uint32_t cur
Definition: ots.h:212
uint32_t alloc
Definition: ots.h:215
Type of an OTS object.
Definition: ots.h:50
struct bt_uuid uuid
Definition: ots.h:53
struct bt_uuid_16 uuid_16
Definition: ots.h:56
struct bt_uuid_128 uuid_128
Definition: ots.h:59
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