diff --git a/lib/include/srsran/asn1/asn1_utils.h b/lib/include/srsran/asn1/asn1_utils.h index c50038b6a..af8c3770e 100644 --- a/lib/include/srsran/asn1/asn1_utils.h +++ b/lib/include/srsran/asn1/asn1_utils.h @@ -599,7 +599,7 @@ public: IntType value; integer() = default; integer(IntType value_) : value(value_) {} - operator IntType() { return value; } + operator IntType() const { return value; } SRSASN_CODE pack(bit_ref& bref) const { return pack_integer(bref, value, lb, ub, has_ext, is_aligned); } SRSASN_CODE unpack(cbit_ref& bref) { return unpack_integer(value, bref, lb, ub, has_ext, is_aligned); } }; @@ -1359,6 +1359,33 @@ private: separator_t sep; }; +template +inline auto to_json(json_writer& j, const T& obj) -> decltype(obj.to_json(j)) +{ + obj.to_json(j); +} + +template +inline void to_json(json_writer& j, const asn1::enumerated& obj) +{ + j.write_str(obj.to_string()); +} + +template +inline void to_json(json_writer& j, const asn1::dyn_array& lst) +{ + j.start_array(); + for (const auto& o : lst) { + to_json(j, o); + } + j.end_array(); +} + +inline void to_json(json_writer& j, int64_t number) +{ + j.write_int(number); +} + /******************* Test pack/unpack *******************/ diff --git a/lib/include/srsran/asn1/rrc_nr.h b/lib/include/srsran/asn1/rrc_nr.h index 8e1362f56..2eba2ff82 100644 --- a/lib/include/srsran/asn1/rrc_nr.h +++ b/lib/include/srsran/asn1/rrc_nr.h @@ -2254,7 +2254,7 @@ struct setup_release_c { // choice methods setup_release_c() = default; - types type() const { return type_; } + types type() const { return type_; } // getters elem_type_paramT_& setup() @@ -2267,7 +2267,7 @@ struct setup_release_c { assert_choice_type(types::setup, type_, "SetupRelease"); return c; } - void set_release() { set(types::release); } + void set_release() { set(types::release); } void set(typename types::options e) { type_ = e; } @@ -2276,8 +2276,11 @@ struct setup_release_c { j.start_obj(); switch (type_) { case types::release: + j.write_null("release"); break; case types::setup: + j.write_fieldname("setup"); + asn1::to_json(j, setup()); break; default: log_invalid_choice_id(type_, "setup_release_c");