|
|
|
@ -65,7 +65,7 @@
|
|
|
|
|
pd_data_t pd_data;
|
|
|
|
|
pd_config_t pd_config;
|
|
|
|
|
pd_state_t pd_state;
|
|
|
|
|
cmd_node_t pd_port_node =
|
|
|
|
|
cmd_node_t pd_slot_node =
|
|
|
|
|
{
|
|
|
|
|
PORT_NODE,
|
|
|
|
|
CONFIG_NODE,
|
|
|
|
@ -77,6 +77,24 @@ cmd_node_t pd_port_node =
|
|
|
|
|
extern int32_t _pd_port_str_to_unit_port(const char *port_str, uint8_t *unit, uint8_t *port);
|
|
|
|
|
|
|
|
|
|
/* Internal functions --------------------------------------------------------*/
|
|
|
|
|
/* 进入 DAU 端口模式. */
|
|
|
|
|
CMD(pd_slot_terminal,
|
|
|
|
|
pd_slot_terminal_cmd,
|
|
|
|
|
"slot <1-8>",
|
|
|
|
|
"Slot\n"
|
|
|
|
|
"Port id: Ex: 1/1\n")
|
|
|
|
|
{
|
|
|
|
|
uint8_t slot = 0;
|
|
|
|
|
|
|
|
|
|
/* 取出端口号. */
|
|
|
|
|
slot = strtol(argv[0], NULL, 10);
|
|
|
|
|
pd_slot_node.param_num = slot;
|
|
|
|
|
snprintf(pd_slot_node.prompt, PD_PORT_PROMPT_LEN, "%%s(slot %d)# ", slot);
|
|
|
|
|
|
|
|
|
|
vty->node = PORT_NODE;
|
|
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 4G 模块是否使能. */
|
|
|
|
|
CMD(pd_4G_enable,
|
|
|
|
@ -232,6 +250,43 @@ int _pd_config_save(vty_t* vty)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* config模式配置保存函数: vty -- 相应的终端 */
|
|
|
|
|
void _pd_slot_config_save_all(vty_t *vty, uint8_t unit)
|
|
|
|
|
{
|
|
|
|
|
array_t *configs = pd_slot_node.configs;
|
|
|
|
|
pd_port_cmd_save_config_f *func = NULL;
|
|
|
|
|
uint8_t i = 0;
|
|
|
|
|
|
|
|
|
|
vty_out(vty, "slot %d%s", unit + 1, VTY_NEWLINE);
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < array_active(configs); i++)
|
|
|
|
|
{
|
|
|
|
|
func = array_lookup(configs, i);
|
|
|
|
|
if (!func)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func(vty, unit, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vty_out(vty, "!%s", VTY_NEWLINE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* config模式配置保存函数: vty -- 相应的终端 */
|
|
|
|
|
int32_t _pd_slot_config_save(vty_t *vty)
|
|
|
|
|
{
|
|
|
|
|
uint8_t unit = 0;
|
|
|
|
|
|
|
|
|
|
/* 其他配置保存 */
|
|
|
|
|
for(unit = 0; unit < PD_SLOTS_MAX; unit++)
|
|
|
|
|
{
|
|
|
|
|
_pd_slot_config_save_all(vty, unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 将端口字符串, 转换成 unit port 格式. */
|
|
|
|
|
int32_t _pd_port_str_to_unit_port(const char *port_str, uint8_t *unit, uint8_t *port)
|
|
|
|
|
{
|
|
|
|
@ -490,7 +545,7 @@ int32_t _pd_main_init(void)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pd_config.config.protocol_type = PD_PROTOCOL_LAND;
|
|
|
|
|
pd_config.config.protocol_type = PD_PROTOCOL_LAND;
|
|
|
|
|
pd_config.config.power_frequency = 500;
|
|
|
|
|
pd_config.config.sync_mode = PD_SYNC_PT;
|
|
|
|
|
pd_config.config.is_4G_enable = FALSE;
|
|
|
|
@ -510,15 +565,16 @@ int32_t _pd_main_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 注册端口节点. */
|
|
|
|
|
pd_port_node.prompt = XMALLOC(MTYPE_DAU, PD_PORT_PROMPT_LEN);
|
|
|
|
|
pd_port_node.configs = array_init(PD_PORT_CMD_PRI_COUNT, MTYPE_DAU);
|
|
|
|
|
cmd_install_node(&pd_slot_node, _pd_slot_config_save);
|
|
|
|
|
pd_slot_node.prompt = XMALLOC(MTYPE_DAU, PD_PORT_PROMPT_LEN);
|
|
|
|
|
pd_slot_node.configs = array_init(PD_PORT_CMD_PRI_COUNT, MTYPE_DAU);
|
|
|
|
|
|
|
|
|
|
cmd_install_element(CONFIG_NODE, &pd_4G_enable_cmd);
|
|
|
|
|
cmd_install_element(CONFIG_NODE, &pd_4G_APN_cmd);
|
|
|
|
|
cmd_install_element(CONFIG_NODE, &pd_protocol_type_cmd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_install_element(CONFIG_NODE, &pd_slot_terminal_cmd);
|
|
|
|
|
|
|
|
|
|
cmd_install_element(COMMON_NODE, &show_pd_cmd);
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
@ -535,7 +591,7 @@ int32_t _pd_main_init_after(void)
|
|
|
|
|
{
|
|
|
|
|
param.arg = NULL;
|
|
|
|
|
param.priority = 20;
|
|
|
|
|
param.thread_name = "4G";
|
|
|
|
|
snprintf(param.thread_name, THREAD_NAME_LEN, "4G");
|
|
|
|
|
param.log_module = LOG_PD;
|
|
|
|
|
create_thread(_pd_4G_handle, ¶m);
|
|
|
|
|
}
|
|
|
|
@ -581,7 +637,7 @@ int32_t pd_main_after(void)
|
|
|
|
|
|
|
|
|
|
int32_t pd_port_cmd_config_register(int32_t pri, pd_port_cmd_save_config_f *func)
|
|
|
|
|
{
|
|
|
|
|
cmd_node_t *node = &pd_port_node;
|
|
|
|
|
cmd_node_t *node = &pd_slot_node;
|
|
|
|
|
|
|
|
|
|
/* 参数检查 */
|
|
|
|
|
if (pri >= PD_PORT_CMD_PRI_COUNT || !func)
|
|
|
|
|