Skip to content

Commit

Permalink
Merge pull request #120 from rdkcentral/cli_reset
Browse files Browse the repository at this point in the history
New CLI reset and other bug fixes
  • Loading branch information
rshah-1 authored Jan 13, 2025
2 parents e01e9ff + 585386e commit 59edf7c
Show file tree
Hide file tree
Showing 18 changed files with 190 additions and 248 deletions.
12 changes: 4 additions & 8 deletions build/cli/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ include ../makefile.inc
#

PROGRAM = $(INSTALLDIR)/bin/onewifi_em_cli
PROGRAM_GO = $(INSTALLDIR)/bin/cli
EM_CLI_LIBRARY = $(INSTALLDIR)/lib/libemcli.so

INCLUDEDIRS = \
Expand Down Expand Up @@ -74,10 +73,7 @@ GENERIC_OBJECTS = $(GENERIC_SOURCES:.c=.o)
EMCLIOBJECTS = $(CLI_OBJECTS) $(GENERIC_OBJECTS)
MAIN_OBJECT = $(MAIN_SOURCE:.c=.o)

all: $(EM_CLI_LIBRARY) $(PROGRAM) $(PROGRAM_GO)

$(PROGRAM): $(MAIN_OBJECT)
$(CXX) -o $@ $(MAIN_OBJECT) $(LDFLAGS)
all: $(EM_CLI_LIBRARY) $(PROGRAM)

$(EM_CLI_LIBRARY): $(EMCLIOBJECTS)
$(CXX) -shared -o $@ $(EMCLIOBJECTS)
Expand All @@ -91,14 +87,14 @@ $(CLI_OBJECTS): %.o: %.cpp
$(MAIN_OBJECT): %.o: %.c
$(CXX) $(CFLAGS) -o $@ -c $<

$(PROGRAM_GO):
go build -o $(PROGRAM_GO) $(ONEWIFI_EM_SRC)/cli/main.go
$(PROGRAM):
go build -o $(PROGRAM) $(ONEWIFI_EM_SRC)/cli/main.go

# Clean target: "make -f Makefile.Linux clean" to remove unwanted objects and executables.
#

clean:
$(RM) $(MAIN_OBJECT) $(EMCLIOBJECTS) $(EM_CLI_LIBRARY) $(PROGRAM) $(PROGRAM_GO)
$(RM) $(MAIN_OBJECT) $(EMCLIOBJECTS) $(EM_CLI_LIBRARY) $(PROGRAM) $(PROGRAM)

#
# Run target: "make -f Makefile.Linux run" to execute the application
Expand Down
2 changes: 1 addition & 1 deletion inc/em_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extern "C"
#define EM_MAX_E4_TABLE_CHANNEL 32

#define EM_PROTO_TOUT 1
#define EM_MGR_TOUT 0.5
#define EM_MGR_TOUT 500 // in milliseconds
#define EM_METRICS_REQ_MULT 5
#define EM_2_TOUT_MULT 4
#define EM_5_TOUT_MULT 10
Expand Down
1 change: 1 addition & 0 deletions inc/em_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class em_cli_t {
int init(em_cli_params_t *params);
const char *get_first_cmd_str();
const char *get_next_cmd_str(const char *cmd);
em_network_node_t *get_reset_tree(char *platform);

void init_lib_dbg(char *file_name);
void dump_lib_dbg(char *str);
Expand Down
1 change: 1 addition & 0 deletions inc/em_cli_apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ int init(em_cli_params_t *params);

const char *get_first_cmd_str();
const char *get_next_cmd_str(const char *cmd);
em_network_node_t *get_reset_tree(char *platform);
em_network_node_t *get_network_tree_by_file(const char *file_name);
em_network_node_t *get_network_tree(char *buff);
em_network_node_t *get_child_node_at_index(em_network_node_t *node, unsigned int idx);
Expand Down
1 change: 0 additions & 1 deletion inc/em_cmd_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class em_cmd_cli_t : public em_cmd_exec_t {
public:
int get_edited_node(em_network_node_t *node, const char *header, char *buff);
int execute(char *result);
int update_platform_defaults(em_subdoc_info_t *info, em_cmd_params_t *param, em_cmd_type_t cmd_type);

em_cmd_cli_t(em_cmd_t& obj);
~em_cmd_cli_t();
Expand Down
18 changes: 0 additions & 18 deletions install/bin/Reset.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"NumberOfDevices": 1,
"TimeStamp": "2019-02-11T06:23:43.743847-08:00",
"ControllerID": "02:01:02:01:00:01",
"MSCSDisallowedStaList": ["00:01:02:03:04:05"],
"SCSDisallowedStaList": [],
"NetworkSSIDList": [{
"SSID": "private_ssid",
"PassPhrase": "test-fronthaul",
Expand Down Expand Up @@ -51,25 +49,9 @@
"HaulType": ["Backhaul"]
}
],
"STABlock": [
{
"BlockedSTA": "00:01:02:03:04:05",
"BSSID": ["0a:01:02:03:04:05","0a:01:02:03:04:06"],
"Schedule" : [
{
"Alias" : "Schedule_1",
"Day": ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],
"StartTime": "00:30",
"Duration":3600
}
]
}
],
"PreferredBackhauls" : [
{ "BackhaulMACAddress" : "02:01:02:01:04:01", "BackhaulStaMACAddress" : "02:01:02:02:04:03"}
],
"ColocatedAgentID" : "02:01:02:01:00:04"
}
}


17 changes: 17 additions & 0 deletions src/agent/em_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,23 @@ em_t *em_agent_t::find_em_for_msg_type(unsigned char *data, unsigned int len, em
return em;
}

bool em_agent_t::agent_output(void *data)
{
// send configuration to OneWifi after translating
return true;
}

void em_agent_t::io(void *data, bool input)
{
em_long_string_t result;

if (input == true) {
m_agent_cmd->execute(result);
} else {
agent_output(data);
}
}

em_agent_t::em_agent_t()
{

Expand Down
59 changes: 0 additions & 59 deletions src/agent/em_agent_io.cpp

This file was deleted.

44 changes: 44 additions & 0 deletions src/cli/em_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,45 @@

em_cli_t g_cli;

em_network_node_t *em_cli_t::get_reset_tree(char *platform)
{
unsigned int len;
mac_address_t al_mac;
dm_easy_mesh_t dm;
//mac_addr_str_t ctrl_mac, ctrl_al_mac, agent_al_mac;
em_subdoc_info_t *subdoc;
unsigned char buff[EM_IO_BUFF_SZ];
em_short_string_t interface;

if (strncmp(platform, "rpi", strlen("rpi")) == 0) {
strncpy(interface, "eth0", strlen("eth0"));
} else if (strncmp(platform, "sim", strlen("sim")) == 0) {
strncpy(interface, "ens160", strlen("ens160"));
}

subdoc = (em_subdoc_info_t *)buff;

if ((len = em_cmd_exec_t::load_params_file("Reset.json", subdoc->buff)) < 0) {
return NULL;
}

dm.init();
dm.decode_config(subdoc, "Reset");

if (dm_easy_mesh_t::mac_address_from_name("ens160", al_mac) != 0) {
return NULL;
}

dm.set_ctrl_al_interface_mac(al_mac);
dm.set_ctrl_al_interface_name("ens160");

//dm.print_config();

dm.encode_config(subdoc, "Reset");

return em_net_node_t::get_network_tree(subdoc->buff);
}

const char *em_cli_t::get_first_cmd_str()
{
return em_cmd_cli_t::m_client_cmd_spec[0].get_cmd_name();
Expand Down Expand Up @@ -312,3 +351,8 @@ extern "C" unsigned int can_expand_node(em_network_node_t *node)

return 0;
}

extern "C" em_network_node_t *get_reset_tree(char *platform)
{
return g_cli.get_reset_tree(platform);
}
Loading

0 comments on commit 59edf7c

Please sign in to comment.