Commit e9d28504 authored by Niuhaiwen's avatar Niuhaiwen

add heart-beat but not test

parent 1c2f46f3
......@@ -48,6 +48,10 @@ void ausf_app_task(void*){
{
case SBI_REGISTER_NF_INSTANCE_RESPONSE:
Logger::ausf_app().debug("handle register response");
if (itti_n11_register_nf_instance_response* m =
dynamic_cast<itti_n11_register_nf_instance_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case TIME_OUT:
if (itti_msg_timeout *to = dynamic_cast<itti_msg_timeout *>(msg))
......@@ -139,6 +143,32 @@ void ausf_app::trigger_nf_registration_request(){
}
void ausf_app::timer_nrf_heartbeat_timeout(timer_id_t timer_id, uint64_t arg2_user){
Logger::ausf_app().debug("Send ITTI msg to N11 task to trigger NRF Heartbeat");
std::shared_ptr<itti_sbi_update_nf_instance_request> itti_msg =
std::make_shared<itti_sbi_update_nf_instance_request>(
TASK_AUSF_APP, TASK_AUSF_APP);
oai::ausf::model::PatchItem patch_item = {};
patch_item.setOp("replace");
patch_item.setPath("/nfStatus");
patch_item.setValue("REGISTERED");
itti_msg->patch_items.push_back(patch_item);
itti_msg->smf_instance_id = ausf_instance_id;
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_AUSF_APP",
itti_msg->get_msg_name());
} else {
Logger::smf_app().debug(
"Set a timer to the next Heart-beat (%d)",
nf_instance_profile.get_nf_heartBeat_timer());
timer_nrf_heartbeat = itti_inst->timer_setup(
nf_instance_profile.get_nf_heartBeat_timer(), 0, TASK_AUSF_APP,
TASK_AUSF_APP_TIMEOUT_NRF_HEARTBEAT,
0); // TODO arg2_user
}
}
void ausf_app::generate_uuid(){
ausf_instance_id = to_string(boost::uuids::random_generator()());
......@@ -233,3 +263,16 @@ void ausf_app::register_nf_instance(std::shared_ptr<itti_sbi_register_nf_instanc
}
curl_global_cleanup();
}
void ausf_app::handle_itti_msg(itti_sbi_register_nf_instance_response& r) {
Logger::ausf_app().debug("Handle NF Instance Registration response");
nf_instance_profile = r.profile;
// Set heartbeat timer
Logger::smf_app().debug(
"Set value of NRF Heartbeat timer to %d",
r.profile.get_nf_heartBeat_timer());
timer_nrf_heartbeat = itti_inst->timer_setup(
r.profile.get_nf_heartBeat_timer(), 0, TASK_AUSF_APP,
TASK_AUSF_APP_TIMEOUT_NRF_HEARTBEAT,
0); // TODO arg2_user
}
\ No newline at end of file
......@@ -24,6 +24,8 @@ namespace ausf_application{
void generate_uuid();
void timer_nrf_heartbeat_timeout(timer_id_t timer_id, uint64_t arg2_user);
void register_nf_instance(std::shared_ptr<itti_sbi_register_nf_instance_request> msg);
void handle_itti_msg(itti_sbi_register_nf_instance_response &r);
private:
std::string ausf_instance_id;
ausf_profile nf_instance_profile;
......
/**
* NRF NFManagement Service
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "PatchItem.h"
namespace oai {
namespace ausf {
namespace model {
PatchItem::PatchItem() {
m_Path = "";
m_From = "";
m_FromIsSet = false;
m_ValueIsSet = false;
}
PatchItem::~PatchItem() {}
void PatchItem::validate() {
// TODO: implement validation
}
void to_json(nlohmann::json& j, const PatchItem& o) {
j = nlohmann::json();
j["op"] = o.m_Op;
j["path"] = o.m_Path;
if (o.fromIsSet()) j["from"] = o.m_From;
if (o.valueIsSet()) j["value"] = o.m_Value;
}
void from_json(const nlohmann::json& j, PatchItem& o) {
j.at("op").get_to(o.m_Op);
j.at("path").get_to(o.m_Path);
if (j.find("from") != j.end()) {
j.at("from").get_to(o.m_From);
o.m_FromIsSet = true;
}
if (j.find("value") != j.end()) {
j.at("value").get_to(o.m_Value);
o.m_ValueIsSet = true;
}
}
std::string PatchItem::getOp() const {
return m_Op;
}
void PatchItem::setOp(std::string const& value) {
m_Op = value;
}
std::string PatchItem::getPath() const {
return m_Path;
}
void PatchItem::setPath(std::string const& value) {
m_Path = value;
}
std::string PatchItem::getFrom() const {
return m_From;
}
void PatchItem::setFrom(std::string const& value) {
m_From = value;
m_FromIsSet = true;
}
bool PatchItem::fromIsSet() const {
return m_FromIsSet;
}
void PatchItem::unsetFrom() {
m_FromIsSet = false;
}
std::string PatchItem::getValue() const {
return m_Value;
}
void PatchItem::setValue(std::string const& value) {
m_Value = value;
m_ValueIsSet = true;
}
bool PatchItem::valueIsSet() const {
return m_ValueIsSet;
}
void PatchItem::unsetValue() {
m_ValueIsSet = false;
}
} // namespace model
} // namespace smf_server
} // namespace oai
/**
* NRF NFManagement Service
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* PatchItem.h
*
*
*/
#ifndef PatchItem_H_
#define PatchItem_H_
#include <string>
#include <nlohmann/json.hpp>
namespace oai {
namespace ausf {
namespace model {
/// <summary>
///
/// </summary>
class PatchItem {
public:
PatchItem();
virtual ~PatchItem();
void validate();
/////////////////////////////////////////////
/// PatchItem members
/// <summary>
///
/// </summary>
std::string getOp() const;
void setOp(std::string const& value);
/// <summary>
///
/// </summary>
std::string getPath() const;
void setPath(std::string const& value);
/// <summary>
///
/// </summary>
std::string getFrom() const;
void setFrom(std::string const& value);
bool fromIsSet() const;
void unsetFrom();
/// <summary>
///
/// </summary>
std::string getValue() const;
void setValue(std::string const& value);
bool valueIsSet() const;
void unsetValue();
friend void to_json(nlohmann::json& j, const PatchItem& o);
friend void from_json(const nlohmann::json& j, PatchItem& o);
protected:
std::string m_Op;
std::string m_Path;
std::string m_From;
bool m_FromIsSet;
std::string m_Value;
bool m_ValueIsSet;
};
} // namespace model
} // namespace smf_server
} // namespace oai
#endif /* PatchItem_H_ */
......@@ -55,6 +55,7 @@ typedef enum {
POLLING_GET_INFO = ITTI_MSG_TYPE_FIRST,
SBI_REGISTER_NF_INSTANCE_REQUEST,
SBI_REGISTER_NF_INSTANCE_RESPONSE,
SBI_UPDATE_NF_INSTANCE_REQUEST,
TIME_OUT,
HEALTH_PING,
TERMINATE,
......
......@@ -5,6 +5,7 @@
#include "bstrlib.h"
#include "itti_msg.hpp"
#include "ausf_profile.hpp"
#include "PatchItem.h"
class itti_sbi_msg : public itti_msg {
public:
......@@ -38,10 +39,23 @@ class itti_sbi_register_nf_instance_response : public itti_sbi_msg {
const task_id_t orig, const task_id_t dest)
: itti_sbi_msg(SBI_REGISTER_NF_INSTANCE_RESPONSE, orig, dest),
http_version(1) {}
const char* get_msg_name() { return "N11_REGISTER_NF_INSTANCE_RESPONSE"; };
const char* get_msg_name() { return "SBI_REGISTER_NF_INSTANCE_RESPONSE"; };
ausf_application::ausf_profile profile;
uint8_t http_version;
uint8_t http_response_code;
};
//-----------------------------------------------------------------------------
class itti_sbi_update_nf_instance_request : public itti_sbi_msg {
public:
itti_sbi_update_nf_instance_request(
const task_id_t orig, const task_id_t dest)
: itti_sbi_msg(SBI_UPDATE_NF_INSTANCE_REQUEST, orig, dest),
http_version(1) {}
const char* get_msg_name() { return "SBI_UPDATE_NF_INSTANCE_REQUEST"; };
std::vector<oai::ausf::model::PatchItem> patch_items;
uint8_t http_version;
std::string ausf_instance_id;
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment