diff --git a/srsgnb/hdr/stack/ric/e2sm_kpm.h b/srsgnb/hdr/stack/ric/e2sm_kpm.h index f3f6e9bdf..b03a3e796 100644 --- a/srsgnb/hdr/stack/ric/e2sm_kpm.h +++ b/srsgnb/hdr/stack/ric/e2sm_kpm.h @@ -11,6 +11,7 @@ * */ #include "e2sm.h" +#include "srsran/asn1/e2ap.h" #include "srsran/asn1/e2sm.h" #include "srsran/asn1/e2sm_kpm_v2.h" #include "srsran/srsran.h" @@ -18,6 +19,10 @@ #ifndef RIC_E2SM_KPM_H #define RIC_E2SM_KPM_H +struct E2SM_KPM_RIC_event_definition { + uint64_t report_period; +}; + struct E2SM_KPM_RIC_ind_header { uint32_t collet_start_time; std::string file_formatversion; @@ -45,7 +50,8 @@ public: ~e2sm_kpm() = default; virtual bool generate_ran_function_description(RANfunction_description& desc, srsran::unique_byte_buffer_t& buf); - int process_ric_action_definition(); + bool process_subscription_request(asn1::e2ap::ricsubscription_request_s subscription_request, + E2SM_KPM_RIC_event_definition& event_def); bool generate_indication_header(E2SM_KPM_RIC_ind_header hdr, srsran::unique_byte_buffer_t& buf); bool generate_indication_message(E2SM_KPM_RIC_ind_message msg, srsran::unique_byte_buffer_t& buf); diff --git a/srsgnb/hdr/stack/ric/ric_subscription.h b/srsgnb/hdr/stack/ric/ric_subscription.h index 0b96c52b2..34020cf1a 100644 --- a/srsgnb/hdr/stack/ric/ric_subscription.h +++ b/srsgnb/hdr/stack/ric/ric_subscription.h @@ -44,7 +44,7 @@ private: uint16_t ra_nfunction_id; uint16_t ri_caction_id; - uint32_t reporting_period; // ms + uint32_t reporting_period = 0; // ms srsran::unique_timer reporting_timer; // for RIC indication reporting }; diff --git a/srsgnb/src/stack/ric/e2sm_kpm.cc b/srsgnb/src/stack/ric/e2sm_kpm.cc index c4898eae9..c6eff53b2 100644 --- a/srsgnb/src/stack/ric/e2sm_kpm.cc +++ b/srsgnb/src/stack/ric/e2sm_kpm.cc @@ -83,9 +83,20 @@ bool e2sm_kpm::generate_ran_function_description(RANfunction_description& desc, return true; } -int e2sm_kpm::process_ric_action_definition() +bool e2sm_kpm::process_subscription_request(asn1::e2ap::ricsubscription_request_s subscription_request, + E2SM_KPM_RIC_event_definition& event_def) { - return 0; + using namespace asn1::e2sm_kpm; + e2_sm_kpm_event_trigger_definition_s trigger_def; + asn1::cbit_ref bref(subscription_request->ricsubscription_details->ric_event_trigger_definition.data(), + subscription_request->ricsubscription_details->ric_event_trigger_definition.size()); + + if (trigger_def.unpack(bref) != asn1::SRSASN_SUCCESS) { + return false; + } + + event_def.report_period = trigger_def.event_definition_formats.event_definition_format1().report_period; + return true; } bool e2sm_kpm::generate_indication_header(E2SM_KPM_RIC_ind_header hdr, srsran::unique_byte_buffer_t& buf) diff --git a/srsgnb/src/stack/ric/ric_subscription.cc b/srsgnb/src/stack/ric/ric_subscription.cc index 608fd31c7..9c044388d 100644 --- a/srsgnb/src/stack/ric/ric_subscription.cc +++ b/srsgnb/src/stack/ric/ric_subscription.cc @@ -22,11 +22,20 @@ ric_client::ric_subscription::ric_subscription(ric_client* ric_cli ric_instance_id(ric_subscription_request->ri_crequest_id->ric_instance_id), ra_nfunction_id(ric_subscription_request->ra_nfunction_id->value) { - reporting_period = 1000; reporting_timer = parent->task_sched.get_unique_timer(); - // TODO: process request to know what to report parent->e2ap_.process_subscription_request(ric_subscription_request); + + RANfunction_description ran_func_desc; + if (!parent->e2ap_.get_func_desc(ra_nfunction_id, ran_func_desc)) { + return; + } + + E2SM_KPM_RIC_event_definition event_def; + e2sm_kpm* sm_kpm_ptr = dynamic_cast(ran_func_desc.sm_ptr); + if (sm_kpm_ptr->process_subscription_request(ric_subscription_request, event_def)) { + reporting_period = event_def.report_period; + } } void ric_client::ric_subscription::start_ric_indication_reporting() @@ -43,10 +52,12 @@ void ric_client::ric_subscription::start_ric_indication_reporting() e2_ap_pdu_c send_pdu = parent->e2ap_.generate_subscription_response(ric_subscription_reponse); parent->queue_send_e2ap_pdu(send_pdu); - printf("Start sending RIC indication msgs every %i ms\n", reporting_period); - parent->logger.debug("Start sending RIC indication msgs every %i ms", reporting_period); - reporting_timer.set(reporting_period, [this](uint32_t tid) { send_ric_indication(); }); - reporting_timer.run(); + if (reporting_period) { + printf("Start sending RIC indication msgs every %i ms\n", reporting_period); + parent->logger.debug("Start sending RIC indication msgs every %i ms", reporting_period); + reporting_timer.set(reporting_period, [this](uint32_t tid) { send_ric_indication(); }); + reporting_timer.run(); + } } void ric_client::ric_subscription::stop_ric_indication_reporting()