Skip to content

Commit

Permalink
Merge pull request #84 from rdkcentral/cli_optmization
Browse files Browse the repository at this point in the history
CLI Optimization
  • Loading branch information
amarnathhullur authored Dec 15, 2024
2 parents 82b8967 + ad94a0d commit fc5175b
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 173 deletions.
7 changes: 5 additions & 2 deletions inc/em.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@
#include "dm_easy_mesh.h"
#include "em_sm.h"

class em_mgr_t;

class em_t :
public em_configuration_t, public em_discovery_t,
public em_provisioning_t, public em_channel_t,
public em_capability_t, public em_metrics_t,
public em_steering_t, public em_policy_cfg_t {

dm_easy_mesh_t* m_data_model;
em_mgr_t *m_mgr;

em_orch_state_t m_orch_state;
em_cmd_t *m_cmd;
Expand All @@ -65,7 +68,7 @@ class em_t :
int start_al_interface();
int send_frame(unsigned char *buff, unsigned int len, bool multicast = false);
int send_cmd(em_cmd_type_t type, em_service_type_t svc, unsigned char *buff, unsigned int len);

int push_event(em_event_t *evt);


public:
Expand Down Expand Up @@ -168,7 +171,7 @@ class em_t :
static const char *get_band_type_str(em_freq_band_t band);
static const char *state_2_str(em_state_t state);

em_t(em_interface_t *ruid, em_freq_band_t band, dm_easy_mesh_t *dm, em_profile_type_t profile, em_service_type_t type);
em_t(em_interface_t *ruid, em_freq_band_t band, dm_easy_mesh_t *dm, em_mgr_t *mgr, em_profile_type_t profile, em_service_type_t type);
~em_t();

};
Expand Down
2 changes: 1 addition & 1 deletion inc/em_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ 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)(char *);

typedef struct {
unsigned char dsap;
Expand Down Expand Up @@ -2750,5 +2749,6 @@ typedef struct em_network_node {
struct em_network_node *child[EM_MAX_DM_CHILDREN];
} em_network_node_t;

typedef int (* em_editor_callback_t)(em_network_node_t *);

#endif // EM_BASE_H
1 change: 1 addition & 0 deletions inc/em_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class em_cmd_t;
class em_channel_t {

virtual int send_frame(unsigned char *buff, unsigned int len, bool multicast = false) = 0;
virtual int push_event(em_event_t *evt) = 0;

public:
virtual dm_easy_mesh_t *get_data_model() = 0;
Expand Down
1 change: 0 additions & 1 deletion inc/em_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ 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);
em_network_node_t *exec(char *in, size_t in_len);
int init(em_editor_callback_t func);
const char *get_first_cmd_str();
Expand Down
3 changes: 1 addition & 2 deletions inc/em_cmd_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class em_cmd_cli_t : public em_cmd_exec_t {
static em_cmd_t m_client_cmd_spec[];
public:
static int load_params_file(const char *filename, char *buff);
int write_params_file(const char *filename, char *buff, const char *net_id, const char *header = NULL);
int edit_params_file(const char *filename);
int get_edited_node(em_network_node_t *node, const char *header, char *buff);
int execute(em_long_string_t result);
int update_platform_defaults(em_subdoc_info_t *info, em_cmd_params_t *param, em_cmd_type_t cmd_type);

Expand Down
1 change: 1 addition & 0 deletions inc/em_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class em_configuration_t {
virtual em_crypto_info_t *get_crypto_info() = 0;
virtual em_crypto_t *get_crypto() = 0;
virtual int send_frame(unsigned char *buff, unsigned int len, bool multicast = false) = 0;
virtual int push_event(em_event_t *evt) = 0;
virtual em_cmd_t *get_current_cmd() = 0;
virtual short create_ap_radio_basic_cap(unsigned char *buff) = 0;
virtual bool is_al_interface_em() = 0;
Expand Down
26 changes: 0 additions & 26 deletions src/cli/em_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,32 +471,6 @@ em_cmd_t& em_cli_t::get_command(char *in, size_t in_len)
return em_cmd_cli_t::m_client_cmd_spec[idx];
}

char *em_cli_t::exec(char *in, size_t sz, em_status_string_t out)
{
em_long_string_t cmd;
em_status_string_t res;
em_cmd_cli_t *cli_cmd;

snprintf(cmd, sizeof(cmd), "%s", in);
cli_cmd = new em_cmd_cli_t(get_command(cmd, sz));

cli_cmd->init();

if (cli_cmd->validate() == false) {
cli_cmd->m_cmd.status_to_string(em_cmd_out_status_invalid_input, res);
} else {
if (cli_cmd->execute(res) != 0) {
cli_cmd->m_cmd.status_to_string(em_cmd_out_status_invalid_input, res);

}
}

snprintf(out, EM_IO_BUFF_SZ, "%s", res);
delete cli_cmd;

return out;
}

em_network_node_t *em_cli_t::exec(char *in, size_t sz)
{
em_long_string_t cmd;
Expand Down
Loading

0 comments on commit fc5175b

Please sign in to comment.