Lines Matching full:fd
302 static int init_object_name_parameters(struct json_out_formatter_data *fd, in init_object_name_parameters() argument
307 if (fd->add_base_name_to_start) { in init_object_name_parameters()
309 ret = snprintk(fd->bn_string, sizeof(fd->bn_string), "/%u/%u/", path->obj_id, in init_object_name_parameters()
317 if (fd->writer_flags & WRITER_RESOURCE_INSTANCE) { in init_object_name_parameters()
318 ret = snprintk(fd->name_string, sizeof(fd->name_string), "%u/%u", path->res_id, in init_object_name_parameters()
321 ret = snprintk(fd->name_string, sizeof(fd->name_string), "%u", path->res_id); in init_object_name_parameters()
334 struct json_out_formatter_data *fd; in put_begin() local
336 fd = engine_get_out_user_data(out); in put_begin()
337 if (!fd) { in put_begin()
347 fd->base_name.level = LWM2M_PATH_LEVEL_NONE; in put_begin()
353 struct json_out_formatter_data *fd; in put_end() local
356 fd = engine_get_out_user_data(out); in put_end()
357 if (!fd) { in put_end()
371 struct json_out_formatter_data *fd; in put_begin_oi() local
374 fd = engine_get_out_user_data(out); in put_begin_oi()
375 if (!fd) { in put_begin_oi()
379 if (fd->base_name.level == LWM2M_PATH_LEVEL_NONE) { in put_begin_oi()
382 } else if (fd->base_name.obj_id != path->obj_id || in put_begin_oi()
383 fd->base_name.obj_inst_id != path->obj_inst_id) { in put_begin_oi()
388 fd->base_name.level = LWM2M_PATH_LEVEL_OBJECT_INST; in put_begin_oi()
389 fd->base_name.obj_id = path->obj_id; in put_begin_oi()
390 fd->base_name.obj_inst_id = path->obj_inst_id; in put_begin_oi()
393 fd->add_base_name_to_start = update_base_name; in put_begin_oi()
400 struct json_out_formatter_data *fd; in put_begin_ri() local
402 fd = engine_get_out_user_data(out); in put_begin_ri()
403 if (!fd) { in put_begin_ri()
407 fd->writer_flags |= WRITER_RESOURCE_INSTANCE; in put_begin_ri()
413 struct json_out_formatter_data *fd; in put_end_ri() local
415 fd = engine_get_out_user_data(out); in put_end_ri()
416 if (!fd) { in put_end_ri()
420 fd->writer_flags &= ~WRITER_RESOURCE_INSTANCE; in put_end_ri()
426 struct json_out_formatter_data *fd; in put_end_r() local
428 fd = engine_get_out_user_data(out); in put_end_r()
429 if (!fd) { in put_end_r()
434 fd->historical_data = false; in put_end_r()
435 fd->base_time = 0; in put_end_r()
473 static int json_add_separator(struct lwm2m_output_context *out, struct json_out_formatter_data *fd) in json_add_separator() argument
477 if (fd->writer_flags & WRITER_OUTPUT_VALUE) { in json_add_separator()
490 static void json_postprefix(struct json_out_formatter_data *fd) in json_postprefix() argument
492 fd->writer_flags |= WRITER_OUTPUT_VALUE; in json_postprefix()
493 fd->add_base_name_to_start = false; in json_postprefix()
497 struct json_out_formatter_data *fd, int float_string_length) in json_float_object_write() argument
505 len = json_add_separator(out, fd); in json_float_object_write()
510 if (fd->add_base_name_to_start) { in json_float_object_write()
511 if (fd->historical_data) { in json_float_object_write()
514 obj_payload = &fd->json.obj.float_bn_t_obj; in json_float_object_write()
515 fd->json.obj.float_bn_t_obj.base_name = fd->bn_string; in json_float_object_write()
516 fd->json.obj.float_bn_t_obj.name = fd->name_string; in json_float_object_write()
517 fd->json.obj.float_bn_t_obj.val_float.start = pt_buffer; in json_float_object_write()
518 fd->json.obj.float_bn_t_obj.val_float.length = float_string_length; in json_float_object_write()
519 fd->json.obj.float_bn_t_obj.base_time.start = fd->timestamp_buffer; in json_float_object_write()
520 fd->json.obj.float_bn_t_obj.base_time.length = fd->timestamp_length; in json_float_object_write()
524 obj_payload = &fd->json.obj.float_bn_obj; in json_float_object_write()
525 fd->json.obj.float_bn_obj.base_name = fd->bn_string; in json_float_object_write()
526 fd->json.obj.float_bn_obj.name = fd->name_string; in json_float_object_write()
527 fd->json.obj.float_bn_obj.val_float.start = pt_buffer; in json_float_object_write()
528 fd->json.obj.float_bn_obj.val_float.length = float_string_length; in json_float_object_write()
532 if (fd->historical_data) { in json_float_object_write()
535 obj_payload = &fd->json.obj.float_t_obj; in json_float_object_write()
536 fd->json.obj.float_t_obj.name = fd->name_string; in json_float_object_write()
537 fd->json.obj.float_t_obj.val_float.start = pt_buffer; in json_float_object_write()
538 fd->json.obj.float_t_obj.val_float.length = float_string_length; in json_float_object_write()
539 fd->json.obj.float_t_obj.time.start = fd->timestamp_buffer; in json_float_object_write()
540 fd->json.obj.float_t_obj.time.length = fd->timestamp_length; in json_float_object_write()
544 obj_payload = &fd->json.obj.float_obj; in json_float_object_write()
545 fd->json.obj.float_obj.name = fd->name_string; in json_float_object_write()
546 fd->json.obj.float_obj.val_float.start = pt_buffer; in json_float_object_write()
547 fd->json.obj.float_obj.val_float.length = float_string_length; in json_float_object_write()
566 json_postprefix(fd); in json_float_object_write()
571 struct json_out_formatter_data *fd, char *buf) in json_string_object_write() argument
579 len = json_add_separator(out, fd); in json_string_object_write()
584 if (fd->add_base_name_to_start) { in json_string_object_write()
587 obj_payload = &fd->json.obj.string_bn_obj; in json_string_object_write()
588 fd->json.obj.string_bn_obj.base_name = fd->bn_string; in json_string_object_write()
589 fd->json.obj.string_bn_obj.name = fd->name_string; in json_string_object_write()
590 fd->json.obj.string_bn_obj.val_string = buf; in json_string_object_write()
595 obj_payload = &fd->json.obj.string_obj; in json_string_object_write()
596 fd->json.obj.string_obj.name = fd->name_string; in json_string_object_write()
597 fd->json.obj.string_obj.val_string = buf; in json_string_object_write()
615 json_postprefix(fd); in json_string_object_write()
620 struct json_out_formatter_data *fd, bool value) in json_boolean_object_write() argument
628 len = json_add_separator(out, fd); in json_boolean_object_write()
633 if (fd->add_base_name_to_start) { in json_boolean_object_write()
634 if (fd->historical_data) { in json_boolean_object_write()
637 obj_payload = &fd->json.obj.boolean_bn_t_obj; in json_boolean_object_write()
638 fd->json.obj.boolean_bn_t_obj.base_name = fd->bn_string; in json_boolean_object_write()
639 fd->json.obj.boolean_bn_t_obj.name = fd->name_string; in json_boolean_object_write()
640 fd->json.obj.boolean_bn_t_obj.base_time.start = fd->timestamp_buffer; in json_boolean_object_write()
641 fd->json.obj.boolean_bn_t_obj.base_time.length = fd->timestamp_length; in json_boolean_object_write()
642 fd->json.obj.boolean_bn_t_obj.val_bool = value; in json_boolean_object_write()
646 obj_payload = &fd->json.obj.boolean_bn_obj; in json_boolean_object_write()
647 fd->json.obj.boolean_bn_obj.base_name = fd->bn_string; in json_boolean_object_write()
648 fd->json.obj.boolean_bn_obj.name = fd->name_string; in json_boolean_object_write()
649 fd->json.obj.boolean_bn_obj.val_bool = value; in json_boolean_object_write()
653 if (fd->historical_data) { in json_boolean_object_write()
656 obj_payload = &fd->json.obj.boolean_t_obj; in json_boolean_object_write()
657 fd->json.obj.boolean_t_obj.name = fd->name_string; in json_boolean_object_write()
658 fd->json.obj.boolean_t_obj.time.start = fd->timestamp_buffer; in json_boolean_object_write()
659 fd->json.obj.boolean_t_obj.time.length = fd->timestamp_length; in json_boolean_object_write()
660 fd->json.obj.boolean_t_obj.val_bool = value; in json_boolean_object_write()
664 obj_payload = &fd->json.obj.boolean_obj; in json_boolean_object_write()
665 fd->json.obj.boolean_obj.name = fd->name_string; in json_boolean_object_write()
666 fd->json.obj.boolean_obj.val_bool = value; in json_boolean_object_write()
685 json_postprefix(fd); in json_boolean_object_write()
690 struct json_out_formatter_data *fd) in json_objlnk_object_write() argument
698 len = json_add_separator(out, fd); in json_objlnk_object_write()
703 if (fd->add_base_name_to_start) { in json_objlnk_object_write()
706 obj_payload = &fd->json.obj.string_bn_obj; in json_objlnk_object_write()
707 fd->json.obj.string_bn_obj.base_name = fd->bn_string; in json_objlnk_object_write()
708 fd->json.obj.string_bn_obj.name = fd->name_string; in json_objlnk_object_write()
709 fd->json.obj.string_bn_obj.val_string = pt_buffer; in json_objlnk_object_write()
714 obj_payload = &fd->json.obj.string_obj; in json_objlnk_object_write()
715 fd->json.obj.string_obj.name = fd->name_string; in json_objlnk_object_write()
716 fd->json.obj.string_obj.val_string = pt_buffer; in json_objlnk_object_write()
734 json_postprefix(fd); in json_objlnk_object_write()
740 struct json_out_formatter_data *fd; in put_s32() local
743 fd = engine_get_out_user_data(out); in put_s32()
745 if (!out->out_cpkt || !fd) { in put_s32()
749 if (init_object_name_parameters(fd, path)) { in put_s32()
758 return json_float_object_write(out, fd, len); in put_s32()
773 struct json_out_formatter_data *fd; in put_s64() local
776 fd = engine_get_out_user_data(out); in put_s64()
778 if (!out->out_cpkt || !fd) { in put_s64()
782 if (init_object_name_parameters(fd, path)) { in put_s64()
791 return json_float_object_write(out, fd, len); in put_s64()
802 struct json_out_formatter_data *fd; in put_string() local
804 fd = engine_get_out_user_data(out); in put_string()
806 if (!out->out_cpkt || !fd) { in put_string()
810 if (init_object_name_parameters(fd, path)) { in put_string()
814 return json_string_object_write(out, fd, buf); in put_string()
821 struct json_out_formatter_data *fd; in put_float() local
824 fd = engine_get_out_user_data(out); in put_float()
826 if (!out->out_cpkt || !fd) { in put_float()
830 if (init_object_name_parameters(fd, path)) { in put_float()
839 return json_float_object_write(out, fd, len); in put_float()
844 struct json_out_formatter_data *fd; in put_bool() local
846 fd = engine_get_out_user_data(out); in put_bool()
848 if (!out->out_cpkt || !fd) { in put_bool()
852 if (init_object_name_parameters(fd, path)) { in put_bool()
856 return json_boolean_object_write(out, fd, value); in put_bool()
882 static bool json_base64_encode_data(struct json_out_formatter_data *fd, const char *buf) in json_base64_encode_data() argument
884 if (fd->add_base_name_to_start) { in json_base64_encode_data()
885 if (fd->json.obj.opaque_bn_obj.val_opaque.start == buf) { in json_base64_encode_data()
888 } else if (fd->json.obj.opaque_obj.val_opaque.start == buf) { in json_base64_encode_data()
896 struct json_out_formatter_data *fd = data; in json_append_bytes_base64() local
900 out = fd->out; in json_append_bytes_base64()
902 if (json_base64_encode_data(fd, bytes)) { in json_append_bytes_base64()
911 if (buf_append(CPKT_BUF_WRITE(fd->out->out_cpkt), bytes, len) < 0) { in json_append_bytes_base64()
922 struct json_out_formatter_data *fd; in put_opaque() local
929 fd = engine_get_out_user_data(out); in put_opaque()
931 if (!out->out_cpkt || !fd) { in put_opaque()
935 if (init_object_name_parameters(fd, path)) { in put_opaque()
944 len = json_add_separator(out, fd); in put_opaque()
949 if (fd->add_base_name_to_start) { in put_opaque()
952 obj_payload = &fd->json.obj.opaque_bn_obj; in put_opaque()
953 fd->json.obj.opaque_bn_obj.base_name = fd->bn_string; in put_opaque()
954 fd->json.obj.opaque_bn_obj.name = fd->name_string; in put_opaque()
955 fd->json.obj.opaque_bn_obj.val_opaque.start = buf; in put_opaque()
956 fd->json.obj.opaque_bn_obj.val_opaque.length = encoded_length; in put_opaque()
960 obj_payload = &fd->json.obj.opaque_obj; in put_opaque()
961 fd->json.obj.opaque_obj.name = fd->name_string; in put_opaque()
962 fd->json.obj.opaque_obj.val_opaque.start = buf; in put_opaque()
963 fd->json.obj.opaque_obj.val_opaque.length = encoded_length; in put_opaque()
966 fd->out = out; in put_opaque()
975 if (fd->add_base_name_to_start) { in put_opaque()
976 fd->json.obj.opaque_bn_obj.val_opaque.length = buflen; in put_opaque()
978 fd->json.obj.opaque_obj.val_opaque.length = buflen; in put_opaque()
982 res = json_obj_encode(descr, descr_len, obj_payload, json_append_bytes_base64, fd); in put_opaque()
987 json_postprefix(fd); in put_opaque()
996 struct json_out_formatter_data *fd; in put_objlnk() local
998 fd = engine_get_out_user_data(out); in put_objlnk()
1000 if (!out->out_cpkt || !fd) { in put_objlnk()
1004 if (init_object_name_parameters(fd, path)) { in put_objlnk()
1012 return json_objlnk_object_write(out, fd); in put_objlnk()
1017 struct json_in_formatter_data *fd; in read_int() local
1026 fd = engine_get_in_user_data(in); in read_int()
1027 if (!fd || !JSON_BIT_CHECK(fd->object_bit_field, JSON_V_TYPE)) { in read_int()
1031 size_t value_length = fd->senml_object.val_float.length; in read_int()
1037 buf = fd->senml_object.val_float.start; in read_int()
1089 struct json_in_formatter_data *fd; in get_string() local
1092 fd = engine_get_in_user_data(in); in get_string()
1093 if (!fd || !JSON_BIT_CHECK(fd->object_bit_field, JSON_VS_TYPE)) { in get_string()
1097 string_length = strlen(fd->senml_object.val_string); in get_string()
1103 memcpy(buf, fd->senml_object.val_string, string_length); in get_string()
1113 struct json_in_formatter_data *fd; in get_float() local
1120 fd = engine_get_in_user_data(in); in get_float()
1121 if (!fd || !JSON_BIT_CHECK(fd->object_bit_field, JSON_V_TYPE)) { in get_float()
1125 size_t value_length = fd->senml_object.val_float.length; in get_float()
1131 json_buf = fd->senml_object.val_float.start; in get_float()
1164 struct json_in_formatter_data *fd; in get_bool() local
1166 fd = engine_get_in_user_data(in); in get_bool()
1167 if (!fd || !JSON_BIT_CHECK(fd->object_bit_field, JSON_VB_TYPE)) { in get_bool()
1171 *value = fd->senml_object.val_bool; in get_bool()
1217 struct json_in_formatter_data *fd; in get_opaque() local
1225 fd = engine_get_in_user_data(in); in get_opaque()
1226 if (!fd || !JSON_BIT_CHECK(fd->object_bit_field, JSON_VD_TYPE)) { in get_opaque()
1229 val_opaque = &fd->senml_object.val_opaque; in get_opaque()
1290 struct json_in_formatter_data *fd; in get_objlnk() local
1293 fd = engine_get_in_user_data(in); in get_objlnk()
1294 if (!fd || !JSON_BIT_CHECK(fd->object_bit_field, JSON_VLO_TYPE)) { in get_objlnk()
1298 demiliter_pos = strchr(fd->senml_object.val_object_link, ':'); in get_objlnk()
1303 fd->object_bit_field |= JSON_V_TYPE; in get_objlnk()
1304 fd->senml_object.val_float.start = fd->senml_object.val_object_link; in get_objlnk()
1305 fd->senml_object.val_float.length = strlen(fd->senml_object.val_object_link); in get_objlnk()
1320 fd->senml_object.val_float.start = demiliter_pos; in get_objlnk()
1321 fd->senml_object.val_float.length = strlen(demiliter_pos); in get_objlnk()
1336 struct json_out_formatter_data *fd; in put_data_timestamp() local
1339 fd = engine_get_out_user_data(out); in put_data_timestamp()
1341 if (!out->out_cpkt || !fd) { in put_data_timestamp()
1346 len = number_to_string(fd->timestamp_buffer, sizeof(fd->timestamp_buffer), "%lld", in put_data_timestamp()
1347 value - fd->base_time); in put_data_timestamp()
1353 if (fd->base_time == 0) { in put_data_timestamp()
1355 fd->base_time = value; in put_data_timestamp()
1358 fd->timestamp_length = len; in put_data_timestamp()
1359 fd->historical_data = true; in put_data_timestamp()
1400 struct json_out_formatter_data fd; in do_read_op_senml_json() local
1402 (void)memset(&fd, 0, sizeof(fd)); in do_read_op_senml_json()
1403 engine_set_out_user_data(&msg->out, &fd); in do_read_op_senml_json()
1417 static int lwm2m_senml_write_operation(struct lwm2m_message *msg, struct json_in_formatter_data *fd) in lwm2m_senml_write_operation() argument
1467 struct json_in_formatter_data fd; in do_write_op_senml_json() local
1476 (void)memset(&fd, 0, sizeof(fd)); in do_write_op_senml_json()
1477 engine_set_in_user_data(&msg->in, &fd); in do_write_op_senml_json()
1495 (void)memset(&fd.senml_object, 0, sizeof(fd.senml_object)); in do_write_op_senml_json()
1496 fd.object_bit_field = json_arr_separate_parse_object(&json_object, senml_descr, in do_write_op_senml_json()
1497 ARRAY_SIZE(senml_descr), &fd.senml_object); in do_write_op_senml_json()
1498 if (fd.object_bit_field == 0) { in do_write_op_senml_json()
1501 } else if (fd.object_bit_field < 0 || in do_write_op_senml_json()
1502 ((fd.object_bit_field & JSON_NAME_MASK) == 0 || in do_write_op_senml_json()
1503 (fd.object_bit_field & JSON_VALUE_MASK) == 0)) { in do_write_op_senml_json()
1504 LOG_ERR("Json Write Parse object fail %d", fd.object_bit_field); in do_write_op_senml_json()
1509 if (JSON_BIT_CHECK(fd.object_bit_field, JSON_BN_TYPE)) { in do_write_op_senml_json()
1510 base_name_ptr = fd.senml_object.base_name; in do_write_op_senml_json()
1515 if (JSON_BIT_CHECK(fd.object_bit_field, JSON_N_TYPE)) { in do_write_op_senml_json()
1517 fd.senml_object.name); in do_write_op_senml_json()
1522 ret = snprintk(full_name, sizeof(full_name), "%s", fd.senml_object.name); in do_write_op_senml_json()
1538 ret = lwm2m_senml_write_operation(msg, &fd); in do_write_op_senml_json()
1624 struct json_out_formatter_data fd; in do_composite_read_op_for_parsed_list_senml_json() local
1626 (void)memset(&fd, 0, sizeof(fd)); in do_composite_read_op_for_parsed_list_senml_json()
1627 engine_set_out_user_data(&msg->out, &fd); in do_composite_read_op_for_parsed_list_senml_json()
1661 struct json_out_formatter_data fd; in do_send_op_senml_json() local
1664 (void)memset(&fd, 0, sizeof(fd)); in do_send_op_senml_json()
1665 engine_set_out_user_data(&msg->out, &fd); in do_send_op_senml_json()