1 /* 2 * Copyright (c) 2020 - 2022 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef BT_GATT_OTS_OLCP_H_ 8 #define BT_GATT_OTS_OLCP_H_ 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #include <sys/types.h> 15 #include <zephyr/types.h> 16 #include <zephyr/bluetooth/gatt.h> 17 18 /* The types of OLCP procedures. */ 19 enum bt_gatt_ots_olcp_proc_type { 20 /* Select the first object.*/ 21 BT_GATT_OTS_OLCP_PROC_FIRST = 0x01, 22 /* Select the last object.*/ 23 BT_GATT_OTS_OLCP_PROC_LAST = 0x02, 24 /* Select the previous object.*/ 25 BT_GATT_OTS_OLCP_PROC_PREV = 0x03, 26 /* Select the next object.*/ 27 BT_GATT_OTS_OLCP_PROC_NEXT = 0x04, 28 /* Select the object with the given object ID.*/ 29 BT_GATT_OTS_OLCP_PROC_GOTO = 0x05, 30 /* Order the objects.*/ 31 BT_GATT_OTS_OLCP_PROC_ORDER = 0x06, 32 /* Request the number of objects.*/ 33 BT_GATT_OTS_OLCP_PROC_REQ_NUM_OBJS = 0x07, 34 /* Clear Marking.*/ 35 BT_GATT_OTS_OLCP_PROC_CLEAR_MARKING = 0x08, 36 /* Response.*/ 37 BT_GATT_OTS_OLCP_PROC_RESP = 0x70, 38 }; 39 40 /** @brief The types of OLCP sort orders. */ 41 enum bt_ots_olcp_sort_order { 42 /** Order the list by object name, ascending */ 43 BT_OTS_SORT_BY_NAME_ASCEND = 0x01, 44 /** Order the list by object type, ascending*/ 45 BT_OTS_SORT_BY_TYPE_ASCEND = 0x02, 46 /** Order the list by object current size, ascending*/ 47 BT_OTS_SORT_BY_SIZE_ASCEND = 0x03, 48 /** Order the list by object first-created timestamp, ascending*/ 49 BT_OTS_SORT_BY_FC_ASCEND = 0x04, 50 /** Order the list by object last-modified timestamp, ascending */ 51 BT_OTS_SORT_BY_LM_ASCEND = 0x05, 52 /** Order the list by object name, descending */ 53 BT_OTS_SORT_BY_NAME_DESCEND = 0x11, 54 /** Order the list by object type, descending*/ 55 BT_OTS_SORT_BY_TYPE_DESCEND = 0x12, 56 /** Order the list by object current size, descending*/ 57 BT_OTS_SORT_BY_SIZE_DESCEND = 0x13, 58 /** Order the list by object first-created timestamp, descending*/ 59 BT_OTS_SORT_BY_FC_DESCEND = 0x14, 60 /** Order the list by object last-modified timestamp, descending */ 61 BT_OTS_SORT_BY_LM_DESCEND = 0x15, 62 }; 63 64 /* Definition of a OLCP procedure. */ 65 struct bt_gatt_ots_olcp_proc { 66 enum bt_gatt_ots_olcp_proc_type type; 67 union { 68 struct { 69 uint64_t id; 70 } goto_params; 71 }; 72 }; 73 74 /* Size of Object List Control Point goto procedure */ 75 #define BT_GATT_OTS_OLCP_GOTO_PARAMS_SIZE 6 76 77 /* The return codes obtained from doing OLCP procedures. */ 78 enum bt_gatt_ots_olcp_res_code { 79 /* Response for successful operation. */ 80 BT_GATT_OTS_OLCP_RES_SUCCESS = 0x01, 81 /* Response if unsupported Op Code is received.*/ 82 BT_GATT_OTS_OLCP_RES_PROC_NOT_SUP = 0x02, 83 /* Response if Parameter received does not meet 84 * the requirements of the service. 85 */ 86 BT_GATT_OTS_OLCP_RES_INVALID_PARAMETER = 0x03, 87 /* Response if the requested procedure failed for a reason 88 * other than those enumerated below. 89 */ 90 BT_GATT_OTS_OLCP_RES_OPERATION_FAILED = 0x04, 91 /* Response if the requested procedure attempted to select an object 92 * beyond the first object or 93 * beyond the last object in the current list. 94 */ 95 BT_GATT_OTS_OLCP_RES_OUT_OF_BONDS = 0x05, 96 /* Response if the requested procedure failed due 97 * to too many objects in the current list. 98 */ 99 BT_GATT_OTS_OLCP_RES_TOO_MANY_OBJECTS = 0x06, 100 /* Response if the requested procedure failed due 101 * to there being zero objects in the current list. 102 */ 103 BT_GATT_OTS_OLCP_RES_NO_OBJECT = 0x07, 104 /* Response if the requested procedure failed due 105 * to there being no object with the requested Object ID. 106 */ 107 BT_GATT_OTS_OLCP_RES_OBJECT_ID_NOT_FOUND = 0x08, 108 }; 109 110 ssize_t bt_gatt_ots_olcp_write(struct bt_conn *conn, 111 const struct bt_gatt_attr *attr, 112 const void *buf, uint16_t len, 113 uint16_t offset, uint8_t flags); 114 115 void bt_gatt_ots_olcp_cfg_changed(const struct bt_gatt_attr *attr, 116 uint16_t value); 117 118 #ifdef __cplusplus 119 } 120 #endif 121 122 #endif /* BT_GATT_OTS_OLCP_H_ */ 123