-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
e01ac9f
commit 822bca9
Showing
5 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |