Lines Matching +full:short +full:- +full:codes
4 * Copyright (c) 2020-2022 Nordic Semiconductor ASA
6 * SPDX-License-Identifier: Apache-2.0
39 /* 64-bit value, outside of 48-bit Object ID range */
49 /**@brief String literals for the OACP result codes. Used for logging output.*/
61 /**@brief String literals for the OACP result codes. Used for logging output.*/
76 /**@brief String literals for the OLCP request codes. Used for logging output.*/
89 /**@brief String literals for the OLCP result codes. Used for logging output.*/
156 written = cur_inst->sent_size; in write_obj_tx_done()
164 if ((cur_inst->otc_inst != NULL) && (cur_inst->otc_inst->cb != NULL)) { in write_obj_tx_done()
165 if (cur_inst->otc_inst->cb->obj_data_written) { in write_obj_tx_done()
166 cur_inst->otc_inst->cb->obj_data_written(0, conn, written); in write_obj_tx_done()
176 const uint32_t offset = cur_inst->rcvd_size; in rx_done()
179 &cur_inst->otc_inst->cur_object; in rx_done()
183 (void *)conn, buf->len, offset); in rx_done()
185 cur_inst->rcvd_size += buf->len; in rx_done()
187 if (cur_inst->rcvd_size >= cur_object->size.cur) { in rx_done()
191 if (cur_inst->rcvd_size > cur_object->size.cur) { in rx_done()
192 LOG_WRN("Received %u but expected maximum %u", cur_inst->rcvd_size, in rx_done()
193 cur_object->size.cur); in rx_done()
196 cb_ret = cur_inst->otc_inst->cb->obj_data_read(0, conn, offset, in rx_done()
197 buf->len, buf->data, in rx_done()
201 const uint32_t rcv_size = cur_object->size.cur; in rx_done()
213 const uint32_t rcv_size = cur_object->size.cur; in rx_done()
257 p_date_time->year = net_buf_simple_pull_le16(buf); in date_time_decode()
258 p_date_time->month = net_buf_simple_pull_u8(buf); in date_time_decode()
259 p_date_time->day = net_buf_simple_pull_u8(buf); in date_time_decode()
260 p_date_time->hours = net_buf_simple_pull_u8(buf); in date_time_decode()
261 p_date_time->minutes = net_buf_simple_pull_u8(buf); in date_time_decode()
262 p_date_time->seconds = net_buf_simple_pull_u8(buf); in date_time_decode()
269 otc_insts[i].otc_inst->start_handle <= handle && in lookup_inst_by_handle()
270 otc_insts[i].otc_inst->end_handle >= handle) { in lookup_inst_by_handle()
284 memset(&otc_inst->cur_object, 0, sizeof(otc_inst->cur_object)); in on_object_selected()
285 otc_inst->cur_object.id = OTS_CLIENT_UNKNOWN_ID; in on_object_selected()
287 if (otc_inst->cb->obj_selected) { in on_object_selected()
288 otc_inst->cb->obj_selected(otc_inst, conn, res); in on_object_selected()
405 if (otc_inst->cb->obj_checksum_calculated) { in oacp_ind_handler()
406 otc_inst->cb->obj_checksum_calculated( in oacp_ind_handler()
426 uint16_t handle = params->value_handle; in bt_ots_client_indicate_handler()
444 inst->busy = false; in bt_ots_client_indicate_handler()
447 if (handle == inst->otc_inst->olcp_handle) { in bt_ots_client_indicate_handler()
448 olcp_ind_handler(conn, inst->otc_inst, data, length); in bt_ots_client_indicate_handler()
449 } else if (handle == inst->otc_inst->oacp_handle) { in bt_ots_client_indicate_handler()
450 oacp_ind_handler(conn, inst->otc_inst, data, length); in bt_ots_client_indicate_handler()
462 lookup_inst_by_handle(params->single.handle); in read_feature_cb()
472 inst->busy = false; in read_feature_cb()
478 inst->otc_inst->features.oacp = in read_feature_cb()
481 inst->otc_inst->features.olcp = in read_feature_cb()
484 LOG_DBG("features : oacp 0x%x, olcp 0x%x", inst->otc_inst->features.oacp, in read_feature_cb()
485 inst->otc_inst->features.olcp); in read_feature_cb()
515 return -ENOMEM; in bt_ots_client_register()
523 return -EINVAL; in bt_ots_client_unregister()
538 return -ENOTCONN; in bt_ots_client_read_feature()
541 return -EINVAL; in bt_ots_client_read_feature()
542 } else if (!otc_inst->feature_handle) { in bt_ots_client_read_feature()
544 return -EINVAL; in bt_ots_client_read_feature()
547 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_read_feature()
551 return -EINVAL; in bt_ots_client_read_feature()
552 } else if (inst->busy) { in bt_ots_client_read_feature()
553 return -EBUSY; in bt_ots_client_read_feature()
556 otc_inst->read_proc.func = read_feature_cb; in bt_ots_client_read_feature()
557 otc_inst->read_proc.handle_count = 1; in bt_ots_client_read_feature()
558 otc_inst->read_proc.single.handle = otc_inst->feature_handle; in bt_ots_client_read_feature()
559 otc_inst->read_proc.single.offset = 0U; in bt_ots_client_read_feature()
561 err = bt_gatt_read(conn, &otc_inst->read_proc); in bt_ots_client_read_feature()
563 inst->busy = true; in bt_ots_client_read_feature()
569 return -EOPNOTSUPP; in bt_ots_client_read_feature()
576 lookup_inst_by_handle(params->handle); in write_olcp_cb()
585 inst->busy = false; in write_olcp_cb()
602 inst->otc_inst->write_params.offset = 0; in write_olcp()
603 inst->otc_inst->write_params.data = otc_tx_buf.data; in write_olcp()
604 inst->otc_inst->write_params.length = otc_tx_buf.len; in write_olcp()
605 inst->otc_inst->write_params.handle = inst->otc_inst->olcp_handle; in write_olcp()
606 inst->otc_inst->write_params.func = write_olcp_cb; in write_olcp()
608 err = bt_gatt_write(conn, &inst->otc_inst->write_params); in write_olcp()
611 inst->busy = true; in write_olcp()
623 return -EINVAL; in bt_ots_client_select_id()
632 return -ENOTCONN; in bt_ots_client_select_id()
635 return -EINVAL; in bt_ots_client_select_id()
636 } else if (!otc_inst->olcp_handle) { in bt_ots_client_select_id()
638 return -EINVAL; in bt_ots_client_select_id()
641 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_select_id()
645 return -EINVAL; in bt_ots_client_select_id()
646 } else if (inst->busy) { in bt_ots_client_select_id()
647 return -EBUSY; in bt_ots_client_select_id()
651 otc_inst->cur_object.id = obj_id; in bt_ots_client_select_id()
659 return -EOPNOTSUPP; in bt_ots_client_select_id()
670 return -ENOTCONN; in bt_ots_client_select_first()
673 return -EINVAL; in bt_ots_client_select_first()
674 } else if (!otc_inst->olcp_handle) { in bt_ots_client_select_first()
676 return -EINVAL; in bt_ots_client_select_first()
679 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_select_first()
683 return -EINVAL; in bt_ots_client_select_first()
684 } else if (inst->busy) { in bt_ots_client_select_first()
685 return -EBUSY; in bt_ots_client_select_first()
693 return -EOPNOTSUPP; in bt_ots_client_select_first()
704 return -ENOTCONN; in bt_ots_client_select_last()
707 return -EINVAL; in bt_ots_client_select_last()
708 } else if (!otc_inst->olcp_handle) { in bt_ots_client_select_last()
710 return -EINVAL; in bt_ots_client_select_last()
713 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_select_last()
717 return -EINVAL; in bt_ots_client_select_last()
718 } else if (inst->busy) { in bt_ots_client_select_last()
719 return -EBUSY; in bt_ots_client_select_last()
728 return -EOPNOTSUPP; in bt_ots_client_select_last()
739 return -ENOTCONN; in bt_ots_client_select_next()
742 return -EINVAL; in bt_ots_client_select_next()
743 } else if (!otc_inst->olcp_handle) { in bt_ots_client_select_next()
745 return -EINVAL; in bt_ots_client_select_next()
748 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_select_next()
752 return -EINVAL; in bt_ots_client_select_next()
753 } else if (inst->busy) { in bt_ots_client_select_next()
754 return -EBUSY; in bt_ots_client_select_next()
762 return -EOPNOTSUPP; in bt_ots_client_select_next()
773 return -ENOTCONN; in bt_ots_client_select_prev()
776 return -EINVAL; in bt_ots_client_select_prev()
777 } else if (!otc_inst->olcp_handle) { in bt_ots_client_select_prev()
779 return -EINVAL; in bt_ots_client_select_prev()
782 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_select_prev()
786 return -EINVAL; in bt_ots_client_select_prev()
787 } else if (inst->busy) { in bt_ots_client_select_prev()
788 return -EBUSY; in bt_ots_client_select_prev()
796 return -EOPNOTSUPP; in bt_ots_client_select_prev()
804 lookup_inst_by_handle(params->single.handle); in read_object_size_cb()
809 LOG_DBG("handle %d, length %u", params->single.handle, length); in read_object_size_cb()
824 &inst->otc_inst->cur_object; in read_object_size_cb()
825 cur_object->size.cur = in read_object_size_cb()
827 cur_object->size.alloc = in read_object_size_cb()
832 cur_object->size.cur, in read_object_size_cb()
833 cur_object->size.alloc); in read_object_size_cb()
835 if (cur_object->size.cur == 0) { in read_object_size_cb()
838 } else if (cur_object->size.cur > in read_object_size_cb()
839 cur_object->size.alloc && in read_object_size_cb()
840 cur_object->size.alloc != 0) { in read_object_size_cb()
843 cur_object->size.alloc, in read_object_size_cb()
844 cur_object->size.cur); in read_object_size_cb()
847 BT_OTS_SET_METADATA_REQ_SIZE(inst->metadata_read); in read_object_size_cb()
853 if (!inst->metadata_err) { in read_object_size_cb()
854 inst->metadata_err = err; in read_object_size_cb()
868 lookup_inst_by_handle(params->single.handle); in read_obj_id_cb()
873 LOG_DBG("handle %d, length %u", params->single.handle, length); in read_obj_id_cb()
887 &inst->otc_inst->cur_object; in read_obj_id_cb()
892 if (cur_object->id != OTS_CLIENT_UNKNOWN_ID && in read_obj_id_cb()
893 cur_object->id != obj_id) { in read_obj_id_cb()
896 (void)bt_ots_obj_id_to_str(cur_object->id, str, in read_obj_id_cb()
901 cur_object->id = obj_id; in read_obj_id_cb()
903 BT_OTS_SET_METADATA_REQ_ID(inst->metadata_read); in read_obj_id_cb()
913 if (!inst->metadata_err) { in read_obj_id_cb()
914 inst->metadata_err = err; in read_obj_id_cb()
928 lookup_inst_by_handle(params->single.handle); in read_obj_name_cb()
930 LOG_DBG("handle %d, length %u", params->single.handle, length); in read_obj_name_cb()
939 memcpy(inst->otc_inst->cur_object.name_c, data, length); in read_obj_name_cb()
940 inst->otc_inst->cur_object.name_c[length] = '\0'; in read_obj_name_cb()
950 if (!inst->metadata_err) { in read_obj_name_cb()
951 inst->metadata_err = err; in read_obj_name_cb()
965 lookup_inst_by_handle(params->single.handle); in read_obj_type_cb()
967 LOG_DBG("handle %d, length %u", params->single.handle, length); in read_obj_type_cb()
978 &inst->otc_inst->cur_object.type.uuid; in read_obj_type_cb()
987 BT_OTS_SET_METADATA_REQ_TYPE(inst->metadata_read); in read_obj_type_cb()
996 if (!inst->metadata_err) { in read_obj_type_cb()
997 inst->metadata_err = err; in read_obj_type_cb()
1012 lookup_inst_by_handle(params->single.handle); in read_obj_created_cb()
1017 LOG_DBG("handle %d, length %u", params->single.handle, length); in read_obj_created_cb()
1028 &inst->otc_inst->cur_object.first_created); in read_obj_created_cb()
1038 if (!inst->metadata_err) { in read_obj_created_cb()
1039 inst->metadata_err = err; in read_obj_created_cb()
1053 lookup_inst_by_handle(params->single.handle); in read_obj_modified_cb()
1058 LOG_DBG("handle %d, length %u", params->single.handle, length); in read_obj_modified_cb()
1068 &inst->otc_inst->cur_object.modified); in read_obj_modified_cb()
1078 if (!inst->metadata_err) { in read_obj_modified_cb()
1079 inst->metadata_err = err; in read_obj_modified_cb()
1094 return -EINVAL; in read_attr()
1097 return -EINVAL; in read_attr()
1101 inst->otc_inst->read_proc.func = cb; in read_attr()
1102 inst->otc_inst->read_proc.handle_count = 1; in read_attr()
1103 inst->otc_inst->read_proc.single.handle = handle; in read_attr()
1104 inst->otc_inst->read_proc.single.offset = 0; in read_attr()
1106 return bt_gatt_read(conn, &inst->otc_inst->read_proc); in read_attr()
1115 lookup_inst_by_handle(params->single.handle); in read_obj_properties_cb()
1120 LOG_INF("handle %d, length %u", params->single.handle, length); in read_obj_properties_cb()
1131 &inst->otc_inst->cur_object; in read_obj_properties_cb()
1133 cur_object->props = net_buf_simple_pull_le32(&net_buf); in read_obj_properties_cb()
1135 LOG_INF("Object properties (raw) : 0x%x", cur_object->props); in read_obj_properties_cb()
1137 if (!BT_OTS_OBJ_GET_PROP_READ(cur_object->props)) { in read_obj_properties_cb()
1141 BT_OTS_SET_METADATA_REQ_PROPS(inst->metadata_read); in read_obj_properties_cb()
1149 if (!inst->metadata_err) { in read_obj_properties_cb()
1150 inst->metadata_err = err; in read_obj_properties_cb()
1163 lookup_inst_by_handle(params->handle); in write_oacp_cp_cb()
1172 inst->busy = false; in write_oacp_cp_cb()
1179 lookup_inst_by_handle(params->handle); in write_oacp_cp_write_req_cb()
1188 len = inst->l2cap_ctx.tx.len; in write_oacp_cp_write_req_cb()
1189 inst->l2cap_ctx.tx.len = 0; in write_oacp_cp_write_req_cb()
1190 err = bt_gatt_ots_l2cap_send(&inst->l2cap_ctx, inst->l2cap_ctx.tx.data, len); in write_oacp_cp_write_req_cb()
1196 inst->busy = false; in write_oacp_cp_write_req_cb()
1207 if (!inst->otc_inst->oacp_handle) { in oacp_read()
1209 return -EINVAL; in oacp_read()
1210 } else if (inst->busy) { in oacp_read()
1211 return -EBUSY; in oacp_read()
1213 return -EBUSY; in oacp_read()
1226 l2cap->tx_done = tx_done; in oacp_read()
1227 l2cap->rx_done = rx_done; in oacp_read()
1228 l2cap->closed = chan_closed; in oacp_read()
1239 length = inst->otc_inst->cur_object.size.cur - offset; in oacp_read()
1242 inst->otc_inst->write_params.offset = 0; in oacp_read()
1243 inst->otc_inst->write_params.data = otc_tx_buf.data; in oacp_read()
1244 inst->otc_inst->write_params.length = otc_tx_buf.len; in oacp_read()
1245 inst->otc_inst->write_params.handle = inst->otc_inst->oacp_handle; in oacp_read()
1246 inst->otc_inst->write_params.func = write_oacp_cp_cb; in oacp_read()
1248 err = bt_gatt_write(conn, &inst->otc_inst->write_params); in oacp_read()
1251 inst->busy = true; in oacp_read()
1255 inst->rcvd_size = 0; in oacp_read()
1267 if (!inst->otc_inst->oacp_handle) { in oacp_write()
1269 return -EINVAL; in oacp_write()
1270 } else if (inst->busy) { in oacp_write()
1271 return -EBUSY; in oacp_write()
1273 return -EBUSY; in oacp_write()
1282 l2cap->tx_done = write_obj_tx_done; in oacp_write()
1283 l2cap->rx_done = rx_done; in oacp_write()
1284 l2cap->closed = chan_closed; in oacp_write()
1285 l2cap->tx.data = (uint8_t *)buf; in oacp_write()
1286 l2cap->tx.len = len; in oacp_write()
1301 inst->otc_inst->write_params.offset = 0; in oacp_write()
1302 inst->otc_inst->write_params.data = otc_tx_buf.data; in oacp_write()
1303 inst->otc_inst->write_params.length = otc_tx_buf.len; in oacp_write()
1304 inst->otc_inst->write_params.handle = inst->otc_inst->oacp_handle; in oacp_write()
1305 inst->otc_inst->write_params.func = write_oacp_cp_write_req_cb; in oacp_write()
1306 inst->sent_size = len; in oacp_write()
1307 err = bt_gatt_write(conn, &inst->otc_inst->write_params); in oacp_write()
1310 inst->busy = true; in oacp_write()
1314 inst->rcvd_size = 0; in oacp_write()
1324 if (!inst->otc_inst->oacp_handle) { in oacp_checksum()
1326 return -EINVAL; in oacp_checksum()
1327 } else if (inst->busy) { in oacp_checksum()
1329 return -EBUSY; in oacp_checksum()
1332 return -EBUSY; in oacp_checksum()
1346 inst->otc_inst->write_params.offset = 0; in oacp_checksum()
1347 inst->otc_inst->write_params.data = otc_tx_buf.data; in oacp_checksum()
1348 inst->otc_inst->write_params.length = otc_tx_buf.len; in oacp_checksum()
1349 inst->otc_inst->write_params.handle = inst->otc_inst->oacp_handle; in oacp_checksum()
1350 inst->otc_inst->write_params.func = write_oacp_cp_cb; in oacp_checksum()
1352 err = bt_gatt_write(conn, &inst->otc_inst->write_params); in oacp_checksum()
1354 inst->busy = true; in oacp_checksum()
1368 return -ENOTCONN; in bt_ots_client_read_object_data()
1371 return -EINVAL; in bt_ots_client_read_object_data()
1374 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_read_object_data()
1378 return -EINVAL; in bt_ots_client_read_object_data()
1381 if (otc_inst->cur_object.size.cur == 0) { in bt_ots_client_read_object_data()
1383 return -EINVAL; in bt_ots_client_read_object_data()
1397 return -ENOTCONN; in bt_ots_client_write_object_data()
1402 return -EINVAL; in bt_ots_client_write_object_data()
1408 return -EINVAL; in bt_ots_client_write_object_data()
1416 return -EINVAL; in bt_ots_client_write_object_data()
1421 return -EINVAL; in bt_ots_client_write_object_data()
1426 return -EINVAL; in bt_ots_client_write_object_data()
1429 CHECKIF(offset > otc_inst->cur_object.size.cur) { in bt_ots_client_write_object_data()
1430 LOG_ERR("offset %ld exceeds cur size %zu", offset, otc_inst->cur_object.size.cur); in bt_ots_client_write_object_data()
1431 return -EINVAL; in bt_ots_client_write_object_data()
1434 CHECKIF((offset < otc_inst->cur_object.size.cur) && in bt_ots_client_write_object_data()
1435 !BT_OTS_OBJ_GET_PROP_PATCH(otc_inst->cur_object.props)) { in bt_ots_client_write_object_data()
1437 return -EACCES; in bt_ots_client_write_object_data()
1440 CHECKIF(((len + offset) > otc_inst->cur_object.size.alloc) && in bt_ots_client_write_object_data()
1441 !BT_OTS_OBJ_GET_PROP_APPEND(otc_inst->cur_object.props)) { in bt_ots_client_write_object_data()
1443 , (len + offset), otc_inst->cur_object.size.alloc); in bt_ots_client_write_object_data()
1444 return -EINVAL; in bt_ots_client_write_object_data()
1447 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_write_object_data()
1451 return -EINVAL; in bt_ots_client_write_object_data()
1464 return -ENOTCONN; in bt_ots_client_get_object_checksum()
1469 return -EINVAL; in bt_ots_client_get_object_checksum()
1477 return -EINVAL; in bt_ots_client_get_object_checksum()
1482 return -EINVAL; in bt_ots_client_get_object_checksum()
1487 return -EINVAL; in bt_ots_client_get_object_checksum()
1490 CHECKIF((len + offset) > otc_inst->cur_object.size.cur) { in bt_ots_client_get_object_checksum()
1492 "alloc %zu.", offset, len, (len + offset), otc_inst->cur_object.size.cur); in bt_ots_client_get_object_checksum()
1493 return -EINVAL; in bt_ots_client_get_object_checksum()
1496 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_get_object_checksum()
1499 return -EINVAL; in bt_ots_client_get_object_checksum()
1509 inst->metadata_to_read ^ inst->metadata_read_attempted; in read_next_metadata()
1515 BT_OTS_SET_METADATA_REQ_NAME(inst->metadata_read_attempted); in read_next_metadata()
1516 err = read_attr(conn, inst, inst->otc_inst->obj_name_handle, in read_next_metadata()
1519 BT_OTS_SET_METADATA_REQ_TYPE(inst->metadata_read_attempted); in read_next_metadata()
1520 err = read_attr(conn, inst, inst->otc_inst->obj_type_handle, in read_next_metadata()
1523 BT_OTS_SET_METADATA_REQ_SIZE(inst->metadata_read_attempted); in read_next_metadata()
1524 err = read_attr(conn, inst, inst->otc_inst->obj_size_handle, in read_next_metadata()
1527 BT_OTS_SET_METADATA_REQ_CREATED(inst->metadata_read_attempted); in read_next_metadata()
1528 err = read_attr(conn, inst, inst->otc_inst->obj_created_handle, in read_next_metadata()
1531 BT_OTS_SET_METADATA_REQ_MODIFIED(inst->metadata_read_attempted); in read_next_metadata()
1532 err = read_attr(conn, inst, inst->otc_inst->obj_modified_handle, in read_next_metadata()
1535 BT_OTS_SET_METADATA_REQ_ID(inst->metadata_read_attempted); in read_next_metadata()
1536 err = read_attr(conn, inst, inst->otc_inst->obj_id_handle, in read_next_metadata()
1539 BT_OTS_SET_METADATA_REQ_PROPS(inst->metadata_read_attempted); in read_next_metadata()
1541 inst->otc_inst->obj_properties_handle, in read_next_metadata()
1544 inst->busy = false; in read_next_metadata()
1545 if (inst->otc_inst->cb->obj_metadata_read) { in read_next_metadata()
1546 inst->otc_inst->cb->obj_metadata_read( in read_next_metadata()
1547 inst->otc_inst, conn, inst->metadata_err, in read_next_metadata()
1548 inst->metadata_read); in read_next_metadata()
1567 return -ENOTCONN; in bt_ots_client_read_object_metadata()
1570 return -EINVAL; in bt_ots_client_read_object_metadata()
1573 return -ENOEXEC; in bt_ots_client_read_object_metadata()
1576 inst = lookup_inst_by_handle(otc_inst->start_handle); in bt_ots_client_read_object_metadata()
1580 return -EINVAL; in bt_ots_client_read_object_metadata()
1581 } else if (inst->busy) { in bt_ots_client_read_object_metadata()
1582 return -EBUSY; in bt_ots_client_read_object_metadata()
1585 inst->metadata_read = 0; in bt_ots_client_read_object_metadata()
1586 inst->metadata_to_read = metadata & BT_OTS_METADATA_REQ_ALL; in bt_ots_client_read_object_metadata()
1587 inst->metadata_read_attempted = 0; in bt_ots_client_read_object_metadata()
1589 inst->busy = true; in bt_ots_client_read_object_metadata()
1598 uint16_t start_len = buf->len; in decode_record()
1600 rec->len = net_buf_simple_pull_le16(buf); in decode_record()
1602 if (rec->len > buf->len) { in decode_record()
1605 rec->len, buf->len); in decode_record()
1606 return -EINVAL; in decode_record()
1609 if ((start_len - buf->len) + BT_OTS_OBJ_ID_SIZE > rec->len) { in decode_record()
1610 LOG_WRN("incorrect DirListing record, reclen %u too short, " in decode_record()
1612 rec->len); in decode_record()
1613 return -EINVAL; in decode_record()
1616 rec->metadata.id = net_buf_simple_pull_le48(buf); in decode_record()
1621 (void)bt_ots_obj_id_to_str(rec->metadata.id, t, sizeof(t)); in decode_record()
1625 if ((start_len - buf->len) + sizeof(uint8_t) > rec->len) { in decode_record()
1626 LOG_WRN("incorrect DirListing record, reclen %u too short, " in decode_record()
1628 rec->len); in decode_record()
1629 return -EINVAL; in decode_record()
1632 rec->name_len = net_buf_simple_pull_u8(buf); in decode_record()
1634 if (rec->name_len > 0) { in decode_record()
1637 if ((start_len - buf->len) + rec->name_len > rec->len) { in decode_record()
1640 rec->len - (start_len - buf->len), in decode_record()
1641 rec->name_len); in decode_record()
1642 return -EINVAL; in decode_record()
1645 if (rec->name_len >= sizeof(rec->metadata.name_c)) { in decode_record()
1646 LOG_WRN("Name length %u too long, invalid record", rec->name_len); in decode_record()
1647 return -EINVAL; in decode_record()
1650 name = net_buf_simple_pull_mem(buf, rec->name_len); in decode_record()
1651 memcpy(rec->metadata.name_c, name, rec->name_len); in decode_record()
1654 rec->metadata.name_c[rec->name_len] = '\0'; in decode_record()
1655 rec->flags = 0; in decode_record()
1657 if ((start_len - buf->len) + sizeof(uint8_t) > rec->len) { in decode_record()
1658 LOG_WRN("incorrect DirListing record, reclen %u too short, " in decode_record()
1659 "does not include flags", rec->len); in decode_record()
1660 return -EINVAL; in decode_record()
1663 rec->flags = net_buf_simple_pull_u8(buf); in decode_record()
1664 LOG_DBG("flags 0x%x", rec->flags); in decode_record()
1666 if (BT_OTS_DIR_LIST_GET_FLAG_TYPE_128(rec->flags)) { in decode_record()
1669 if ((start_len - buf->len) + BT_UUID_SIZE_128 > rec->len) { in decode_record()
1671 "flags indicates uuid128, too short", in decode_record()
1672 rec->len); in decode_record()
1673 LOG_INF("flags 0x%x", rec->flags); in decode_record()
1674 return -EINVAL; in decode_record()
1678 if (!bt_uuid_create(&rec->metadata.type.uuid, uuid, BT_UUID_SIZE_128)) { in decode_record()
1680 return -EINVAL; in decode_record()
1683 if ((start_len - buf->len) + BT_UUID_SIZE_16 > rec->len) { in decode_record()
1685 "flags indicates uuid16, too short", in decode_record()
1686 rec->len); in decode_record()
1687 LOG_INF("flags 0x%x", rec->flags); in decode_record()
1688 return -EINVAL; in decode_record()
1691 rec->metadata.type.uuid_16.val = in decode_record()
1695 if (BT_OTS_DIR_LIST_GET_FLAG_CUR_SIZE(rec->flags)) { in decode_record()
1696 if ((start_len - buf->len) + sizeof(uint32_t) > rec->len) { in decode_record()
1698 "flags indicates cur_size, too short", in decode_record()
1699 rec->len); in decode_record()
1700 LOG_INF("flags 0x%x", rec->flags); in decode_record()
1701 return -EINVAL; in decode_record()
1704 rec->metadata.size.cur = net_buf_simple_pull_le32(buf); in decode_record()
1707 if (BT_OTS_DIR_LIST_GET_FLAG_ALLOC_SIZE(rec->flags)) { in decode_record()
1708 if ((start_len - buf->len) + sizeof(uint32_t) > rec->len) { in decode_record()
1710 "flags indicates allocated size, too short", in decode_record()
1711 rec->len); in decode_record()
1712 LOG_INF("flags 0x%x", rec->flags); in decode_record()
1713 return -EINVAL; in decode_record()
1716 rec->metadata.size.alloc = net_buf_simple_pull_le32(buf); in decode_record()
1719 if (BT_OTS_DIR_LIST_GET_FLAG_FIRST_CREATED(rec->flags)) { in decode_record()
1720 if ((start_len - buf->len) + BT_OTS_DATE_TIME_FIELD_SIZE > rec->len) { in decode_record()
1722 "too short flags indicates first_created", in decode_record()
1723 rec->len); in decode_record()
1724 LOG_INF("flags 0x%x", rec->flags); in decode_record()
1725 return -EINVAL; in decode_record()
1728 date_time_decode(buf, &rec->metadata.first_created); in decode_record()
1731 if (BT_OTS_DIR_LIST_GET_FLAG_LAST_MODIFIED(rec->flags)) { in decode_record()
1732 if ((start_len - buf->len) + BT_OTS_DATE_TIME_FIELD_SIZE > rec->len) { in decode_record()
1734 "flags indicates las_mod, too short", in decode_record()
1735 rec->len); in decode_record()
1736 LOG_INF("flags 0x%x", rec->flags); in decode_record()
1737 return -EINVAL; in decode_record()
1740 date_time_decode(buf, &rec->metadata.modified); in decode_record()
1743 if (BT_OTS_DIR_LIST_GET_FLAG_PROPERTIES(rec->flags)) { in decode_record()
1744 if ((start_len - buf->len) + sizeof(uint32_t) > rec->len) { in decode_record()
1746 "flags indicates properties, too short", in decode_record()
1747 rec->len); in decode_record()
1748 LOG_INF("flags 0x%x", rec->flags); in decode_record()
1749 return -EINVAL; in decode_record()
1752 rec->metadata.props = net_buf_simple_pull_le32(buf); in decode_record()
1755 return rec->len; in decode_record()
1768 return -EINVAL; in bt_ots_client_decode_dirlisting()
1777 LOG_WRN("incorrect DirListing record, len %u too short", net_buf.len); in bt_ots_client_decode_dirlisting()
1778 return -EINVAL; in bt_ots_client_decode_dirlisting()
1802 LOG_INF("--- Displaying %u metadata records ---", count); in bt_ots_metadata_display()
1807 (void)bt_ots_obj_id_to_str(metadata->id, t, sizeof(t)); in bt_ots_metadata_display()
1809 LOG_INF("Object name: %s", metadata->name_c); in bt_ots_metadata_display()
1810 LOG_INF("Object Current Size: %u", metadata->size.cur); in bt_ots_metadata_display()
1811 LOG_INF("Object Allocate Size: %u", metadata->size.alloc); in bt_ots_metadata_display()
1813 if (!bt_uuid_cmp(&metadata->type.uuid, in bt_ots_metadata_display()
1816 } else if (!bt_uuid_cmp(&metadata->type.uuid, in bt_ots_metadata_display()
1819 } else if (!bt_uuid_cmp(&metadata->type.uuid, in bt_ots_metadata_display()
1822 } else if (!bt_uuid_cmp(&metadata->type.uuid, in bt_ots_metadata_display()
1825 } else if (!bt_uuid_cmp(&metadata->type.uuid, in bt_ots_metadata_display()
1831 LOG_INF("Properties:0x%x", metadata->props); in bt_ots_metadata_display()
1833 if (BT_OTS_OBJ_GET_PROP_APPEND(metadata->props)) { in bt_ots_metadata_display()
1834 LOG_INF(" - append permitted"); in bt_ots_metadata_display()
1837 if (BT_OTS_OBJ_GET_PROP_DELETE(metadata->props)) { in bt_ots_metadata_display()
1838 LOG_INF(" - delete permitted"); in bt_ots_metadata_display()
1841 if (BT_OTS_OBJ_GET_PROP_EXECUTE(metadata->props)) { in bt_ots_metadata_display()
1842 LOG_INF(" - execute permitted"); in bt_ots_metadata_display()
1845 if (BT_OTS_OBJ_GET_PROP_MARKED(metadata->props)) { in bt_ots_metadata_display()
1846 LOG_INF(" - marked"); in bt_ots_metadata_display()
1849 if (BT_OTS_OBJ_GET_PROP_PATCH(metadata->props)) { in bt_ots_metadata_display()
1850 LOG_INF(" - patch permitted"); in bt_ots_metadata_display()
1853 if (BT_OTS_OBJ_GET_PROP_READ(metadata->props)) { in bt_ots_metadata_display()
1854 LOG_INF(" - read permitted"); in bt_ots_metadata_display()
1857 if (BT_OTS_OBJ_GET_PROP_TRUNCATE(metadata->props)) { in bt_ots_metadata_display()
1858 LOG_INF(" - truncate permitted"); in bt_ots_metadata_display()
1861 if (BT_OTS_OBJ_GET_PROP_WRITE(metadata->props)) { in bt_ots_metadata_display()
1862 LOG_INF(" - write permitted"); in bt_ots_metadata_display()