Skip to content

Commit

Permalink
Merge pull request #83 from rdkcentral/go_cli_json
Browse files Browse the repository at this point in the history
Go cli json
  • Loading branch information
amarnathhullur authored Dec 13, 2024
2 parents 1a9cbe0 + 157ac2c commit 82b8967
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 49 deletions.
8 changes: 6 additions & 2 deletions build/cli/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ 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 @@ -71,7 +72,7 @@ GENERIC_OBJECTS = $(GENERIC_SOURCES:.c=.o)
EMCLIOBJECTS = $(CLI_OBJECTS) $(GENERIC_OBJECTS)
MAIN_OBJECT = $(MAIN_SOURCE:.c=.o)

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

$(PROGRAM): $(MAIN_OBJECT)
$(CXX) -o $@ $(MAIN_OBJECT) $(LDFLAGS)
Expand All @@ -88,11 +89,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

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

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

#
# Run target: "make -f Makefile.Linux run" to execute the application
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module unified-wifi-mesh/cli

go 1.18
4 changes: 2 additions & 2 deletions inc/em_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ typedef char em_subdoc_data_buff_t[EM_SUBDOC_BUFF_SZ];
typedef char em_status_string_t[EM_IO_BUFF_SZ];
typedef unsigned char em_raw_data_t[EM_SUBDOC_BUFF_SZ];

typedef int (* em_editor_callback_t)(const char *);
typedef int (* em_editor_callback_t)(char *);

typedef struct {
unsigned char dsap;
Expand Down Expand Up @@ -2742,7 +2742,7 @@ typedef enum {
} em_network_node_data_type_t;

typedef struct em_network_node {
em_short_string_t key;
em_long_string_t key;
em_network_node_data_type_t type;
em_long_string_t value_str;
unsigned int value_int;
Expand Down
8 changes: 6 additions & 2 deletions inc/em_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ class em_cli_t {
public:
em_editor_callback_t m_editor_cb;

char *exec(char *in, size_t in_len, em_status_string_t out);
char *exec(char *in, size_t in_len, em_status_string_t out);
em_network_node_t *exec(char *in, size_t in_len);
int init(em_editor_callback_t func);
const char *get_first_cmd_str();
const char *get_next_cmd_str(const char *cmd);

em_network_node_t *get_network_tree(const char *file_name);
em_network_node_t *get_network_tree_by_file(const char *file_name);
em_network_node_t *get_network_tree(char *buff);
int get_network_tree_node(cJSON *obj, em_network_node_t *root);
void free_network_tree(em_network_node_t *tree);
void free_network_tree_node(em_network_node_t *node);
void *network_tree_to_json(em_network_node_t *root);
cJSON *network_tree_node_to_json(em_network_node_t *node, cJSON *parent);
void print_network_tree(em_network_node_t *tree);
void print_network_tree_node(em_network_node_t *node, unsigned int *pident);

Expand Down
28 changes: 18 additions & 10 deletions inc/em_cli_apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@
#ifndef EM_CLI_APIS_H
#define EM_CLI_APIS_H

#include "em_base.h"

#ifdef __cplusplus
extern "C" {
char *exec(char *in, size_t in_len, em_status_string_t out);
int init(em_editor_callback_t func);
const char *get_first_cmd_str();
const char *get_next_cmd_str(const char *cmd);
em_network_node_t *get_network_tree(const char *file_name);
void free_network_tree(em_network_node_t *node);
void print_network_tree(em_network_node_t *node);
}
#endif

#include "em_base.h"

em_network_node_t *exec(char *in, size_t in_len);
int init(em_editor_callback_t func);
const char *get_first_cmd_str();
const char *get_next_cmd_str(const char *cmd);
em_network_node_t *get_network_tree_by_file(const char *file_name);
em_network_node_t *get_network_tree(char *buff);
void free_network_tree(em_network_node_t *node);
void *network_tree_to_json(em_network_node_t *node);
void print_network_tree(em_network_node_t *node);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // EM_CLI_APIS_H
7 changes: 3 additions & 4 deletions install/bin/NetworkSSID.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"wfa-dataelements:SetSSID": {

"wfa-dataelements:SetSSID": {
"NetworkSSIDList": [{
"SSID": "private_ssid",
"PassPhrase": "test-fronthaul",
Expand Down Expand Up @@ -46,6 +45,6 @@
"MobilityDomain": "00:01:02:03:04:05",
"HaulType": ["Backhaul"]
}],
"ID": "OneWifiMesh"
"ID": "OneWifiMesh"
}
}
}
Binary file removed src/cli/a.out
Binary file not shown.
Loading

0 comments on commit 82b8967

Please sign in to comment.