X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fapp%2Frc_xapp.cpp;fp=test%2Fapp%2Frc_xapp.cpp;h=cdf46a046ddffa7714cd0ad47a65fbf680319a21;hb=05b943879d8e01e5edf28db6ae1e2a8dceb9c46b;hp=0000000000000000000000000000000000000000;hpb=95e67b4fdf339209454b05fdd845ce299f78ae61;p=ric-app%2Fts.git diff --git a/test/app/rc_xapp.cpp b/test/app/rc_xapp.cpp new file mode 100644 index 0000000..cdf46a0 --- /dev/null +++ b/test/app/rc_xapp.cpp @@ -0,0 +1,76 @@ +// vi: ts=4 sw=4 noet: +/* +================================================================================== + Copyright (c) 2021 AT&T Intellectual Property. + Copyright (c) 2021 Alexandre Huff. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ + +/* + Mnemonic: rc_xapp.cpp + Abstract: Implements a simple echo server just for testing gRPC calls + from TS xApp. + + Date: 08 Dec 2021 + Author: Alexandre Huff +*/ + +#include + +#include +#include +#include +#include + +#include "../../ext/protobuf/api.grpc.pb.h" + +using namespace std; + +class ControlServiceImpl : public api::MsgComm::Service { + ::grpc::Status SendRICControlReqServiceGrpc(::grpc::ServerContext* context, const ::api::RicControlGrpcReq* request, + ::api::RicControlGrpcRsp* response) override { + cout << "[RC] Received a new gRPC message\n"; + + /* + TODO check if this is related to RICControlAckEnum + if yes, then ACK value should be 2 (RIC_CONTROL_ACK) + api.proto assumes that 0 is an ACK + */ + response->set_rspcode(0); + response->set_description("ACK"); + + return ::grpc::Status::OK; + } +}; + +void RunServer() { + string server_address("0.0.0.0:50051"); + ControlServiceImpl service; + + grpc::ServerBuilder builder; + builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); + builder.RegisterService(&service); + + unique_ptr server(builder.BuildAndStart()); + + cout << "[RC] Server listening on " << server_address << std::endl; + server->Wait(); +} + +int main(int argc, char const *argv[]) { + RunServer(); + + return 0; +} \ No newline at end of file