Skip to content

Commit

Permalink
xApp test
Browse files Browse the repository at this point in the history
muriloAvlis committed May 28, 2024
1 parent e01ac9f commit 822bca9
Showing 5 changed files with 97 additions and 9 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -10,7 +10,10 @@ add_subdirectory(libs)
add_executable(iqos_xapp src/main.cpp)

## Link libraries
target_include_directories(iqos_xapp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(iqos_xapp PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/libs/flexric/src/xApp
)
target_link_libraries(iqos_xapp PUBLIC
e42_xapp
-pthread
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,8 +4,31 @@ Add a paragraph about the application here...

## Requirements

- Swig v4.1 or newer (for xapp_sdk);
- libsctp-dev
- libpcre2-dev
- Near-RT RIC FlexRIC;

## Getting Started
## Getting Started

### Installing the xApp

After installing FlexRIC, clone the xApp repository with the following command.

```shell
git clone --recurse-submodules -j8 git@github.com:gercom-ufpa/iqos-xapp.git
```

Build the xApp.

```shell
cd iqos-xapp
mkdir -p build && cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DE2AP_VERSION=E2AP_V3 -DKPM_VERSION=KPM_V3_00 ..
ninja iqos-xapp
```

### Running the xApp

After building, the xApp can be run with the following command.

```shell
./iqos-xapp -c xApp.conf
```
6 changes: 6 additions & 0 deletions configs/xApp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[NEAR-RIC]
NEAR_RIC_IP = 127.0.0.1

[XAPP]
DB_DIR = /tmp/
DB_NAME = iqos_xapp_db
27 changes: 27 additions & 0 deletions include/defer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef DEFER_HPP
#define DEFER_HPP

#pragma once

template <typename F>
struct privDefer
{
F f;
explicit privDefer(F f) : f(f) {}
~privDefer() { f(); }
};

template <typename F>
privDefer<F> defer_func(F f)
{
return privDefer<F>(f);
}

#if !defined(DEFER_1) && !defined(DEFER_2) && !defined(DEFER_3) && !defined(defer)
#define DEFER_1(x, y) x##y
#define DEFER_2(x, y) DEFER_1(x, y)
#define DEFER_3(x) DEFER_2(x, __COUNTER__)
#define defer(code) auto DEFER_3(_defer_) = defer_func([&]() { code; })
#endif

#endif //DEFER_HPP
37 changes: 33 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
#include <iostream>
#include <unistd.h>

int main() {
std::cout << "Hello, FlexRIC!" << '\n';
return 0;
}
#include "../libs/flexric/src/xApp/e42_xapp_api.h"
#include "defer.hpp"

int main(int argc, char *argv[]) {
// format args
fr_args_t args{init_fr_args(argc, argv)};

// set FlexRIC IP (just for development)
args.ip = {"192.168.122.20"};

// init xApp
init_xapp_api(&args);
sleep(1);

// get E2 Nodes
e2_node_arr_xapp_t e2Nodes{e2_nodes_xapp_api()};
assert(e2Nodes.len > 0 && "There are no E2 nodes connected!");

// free memory allocated to E2 Nodes when finished
defer(free_e2_node_arr_xapp(&e2Nodes));

// TODO: print E2 nodes infos
std::cout << "There are " << static_cast<unsigned>(e2Nodes.len) << " E2 nodes connected" << '\n';

// wait until all xApp processes have been completed
while (try_stop_xapp_api() == false) {
usleep(1000); // 1 ms
}

std::cout << "Hello, FlexRIC :)!" << '\n';
return EXIT_SUCCESS;
}

0 comments on commit 822bca9

Please sign in to comment.