|
|
|
@ -146,6 +146,18 @@ CMD(csg_show,
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMD(csg_upgrade_test,
|
|
|
|
|
csg_upgrade_test_cmd,
|
|
|
|
|
"upgrade test",
|
|
|
|
|
"Upgrade\n"
|
|
|
|
|
"Test\n")
|
|
|
|
|
{
|
|
|
|
|
pd_upg_start(PD_UPG_FROM_CSG, 1);
|
|
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _print_sockaddr_in(const struct sockaddr_in *addr)
|
|
|
|
|
{
|
|
|
|
|
// 将IP地址从网络字节序转换为点分十进制格式
|
|
|
|
@ -379,9 +391,8 @@ void _csg_add_dau_recv(char *pkt)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
slot--;
|
|
|
|
|
log_out(LOG_CSG, LOG_LVL_WARN, "_csg_add_dau_recv slot = %d\n", slot);
|
|
|
|
|
daus[slot].state.is_insert = TRUE;
|
|
|
|
|
daus[slot-1].state.is_insert = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _csg_remove_dau_recv(char *pkt)
|
|
|
|
@ -394,10 +405,9 @@ void _csg_remove_dau_recv(char *pkt)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
slot--;
|
|
|
|
|
log_out(LOG_CSG, LOG_LVL_WARN, "_csg_remove_dau_recv slot = %d\n", slot);
|
|
|
|
|
daus[slot].state.is_insert = FALSE;
|
|
|
|
|
daus[slot].state.is_connect = FALSE;
|
|
|
|
|
daus[slot-1].state.is_insert = FALSE;
|
|
|
|
|
daus[slot-1].state.is_connect = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -406,7 +416,7 @@ void _csg_heartbeat_recv(char *pkt)
|
|
|
|
|
{
|
|
|
|
|
uint32_t server_time = *(uint32_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
|
|
|
|
|
|
//printf("server_time:%d now:%ld\n", server_time, time(NULL));
|
|
|
|
|
DBG(DBG_M_PD_CSG, "server_time:%d now:%ld\n", server_time, time(NULL));
|
|
|
|
|
if (abs(server_time - time(NULL)) > 3)
|
|
|
|
|
{
|
|
|
|
|
time_set(server_time); //北京时间
|
|
|
|
@ -421,7 +431,7 @@ int32_t _csg_reboot_recv(char *pkt)
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -463,7 +473,7 @@ int32_t _csg_dev_info_set_recv(char *pkt)
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -527,7 +537,7 @@ int32_t _csg_dev_info_get_recv(char *pkt)
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -580,7 +590,7 @@ int32_t _csg_config_set_recv(char *pkt)
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -630,10 +640,10 @@ int32_t _csg_config_get_recv(char *pkt)
|
|
|
|
|
{
|
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
|
int *data = NULL;
|
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -678,7 +688,7 @@ int32_t _csg_port_config_set_recv(char *pkt)
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot > PD_SLOTS_MAX && slot != 0)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
DBG(DBG_M_PD_CSG, "_csg_port_config_set_recv slot:%d \r\n", head->slot);
|
|
|
|
@ -707,7 +717,7 @@ int32_t _csg_port_config_get_recv(char *pkt)
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot > PD_SLOTS_MAX && slot != 0)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -735,9 +745,10 @@ int32_t _csg_real_image_recv(char *pkt)
|
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
|
if (slot > PD_SLOTS_MAX && slot != 0)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "slot:%d error\r\n", head->slot);
|
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
|
}
|
|
|
|
|
DBG(DBG_M_PD_CSG, "_csg_real_image_recv slot:%d \r\n", head->slot);
|
|
|
|
|
|
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_real_image_get_t));
|
|
|
|
|
if (!data)
|
|
|
|
@ -746,6 +757,7 @@ int32_t _csg_real_image_recv(char *pkt)
|
|
|
|
|
return E_MEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
param->vport = param->vport % 8;
|
|
|
|
|
memcpy(data, param, sizeof(csg_real_image_get_t));
|
|
|
|
|
if (_csg_msg_send_dau(slot - 1, DAU_SEND_PRPS_GET, data) != E_NONE)
|
|
|
|
|
{
|
|
|
|
@ -803,8 +815,8 @@ int32_t _csg_update_slot(uint8_t type)
|
|
|
|
|
{
|
|
|
|
|
dau = &daus[slot];
|
|
|
|
|
if (dau->info.type_m == 0x03 && (dau->info.type_s == 0x01
|
|
|
|
|
|| dau->info.type_s == 0x02
|
|
|
|
|
|| dau->info.type_s == 0x03))
|
|
|
|
|
|| dau->info.type_s == 0x02
|
|
|
|
|
|| dau->info.type_s == 0x03))
|
|
|
|
|
{
|
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_upate_msg_t));
|
|
|
|
|
if (!data)
|
|
|
|
@ -824,13 +836,14 @@ int32_t _csg_update_slot(uint8_t type)
|
|
|
|
|
}
|
|
|
|
|
snprintf(data->name, 128, "%s/%s", buff, PD_UPG_SOFTWARE);
|
|
|
|
|
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "upgrade name:%s slot=%d\r\n", data->name, slot);
|
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_UPDATE, data) != E_NONE)
|
|
|
|
|
{
|
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ENABLE_NODE;
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 升级文件接收 */
|
|
|
|
@ -916,6 +929,30 @@ int32_t _csg_slot_match(uint8_t slot, uint8_t *type_m, uint8_t *type_s)
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t _csg_slot_is_valid(char *pkt, uint8_t *type_m, uint8_t *type_s)
|
|
|
|
|
{
|
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t *)pkt;
|
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
|
uint8_t cmd = head->cmd;
|
|
|
|
|
dau_t *dau = &daus[slot];
|
|
|
|
|
|
|
|
|
|
// 如果相应卡槽不存在,暂时先不回复平台
|
|
|
|
|
if ( dau->state.is_insert == FALSE && cmd != CSG_C_ADD_DAU)
|
|
|
|
|
{
|
|
|
|
|
//char *pkt = csg.buf_send;
|
|
|
|
|
//csg_ack_t ack = {0};
|
|
|
|
|
//ack.result = FALSE;
|
|
|
|
|
//memcpy(pkt + sizeof(csg_pkt_head_t), (char *)&ack, sizeof(csg_ack_t));
|
|
|
|
|
//_csg_send_data(head->cmd_type, head->cmd, pkt, sizeof(csg_ack_t), slot + 1);
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
}
|
|
|
|
|
*type_m = dau->info.type_m;
|
|
|
|
|
*type_s = dau->info.type_s;
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32_t _csg_recv_process(char *pkt, uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
uint8_t typem, types;
|
|
|
|
@ -925,10 +962,13 @@ int32_t _csg_recv_process(char *pkt, uint32_t len)
|
|
|
|
|
LD_E_RETURN(DBG_M_PD_CSG_ERR, _csg_pkt_check(pkt));
|
|
|
|
|
csg.heartbeat_timeout_cnt = 0;
|
|
|
|
|
|
|
|
|
|
if (_csg_slot_match(head->slot - 1, &typem, &types) != E_NONE)
|
|
|
|
|
if (head->slot > 0)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "Invalid slot=%d typem=%d types=%d\n", head->slot, typem, types);
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
if (_csg_slot_is_valid(pkt, &typem, &types) != E_NONE)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "Invalid slot=%d\n", head->slot);
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (DEVICE_M_TYPE == typem && DEVICE_IR_TYPE == types
|
|
|
|
@ -2296,7 +2336,8 @@ void *_csg_heartbeat_handle(void *arg)
|
|
|
|
|
if (dau->state.is_connect == TRUE
|
|
|
|
|
&& dau->state.is_insert != TRUE)
|
|
|
|
|
{
|
|
|
|
|
if (dau->info.type_m == 0x03 && dau->info.type_m == 0x04)
|
|
|
|
|
if (dau->info.type_m == 0x03 && (dau->info.type_s == 0x04
|
|
|
|
|
|| dau->info.type_s == 0x05))
|
|
|
|
|
{
|
|
|
|
|
csg_contact_t info = {0};
|
|
|
|
|
info.type_m = dau->info.type_m;
|
|
|
|
@ -2365,6 +2406,7 @@ int32_t csg_handle_init(void)
|
|
|
|
|
|
|
|
|
|
cmd_install_element(CONFIG_NODE, &csg_server_set_cmd);
|
|
|
|
|
cmd_install_element(COMMON_NODE, &csg_show_cmd);
|
|
|
|
|
cmd_install_element(COMMON_NODE, &csg_upgrade_test_cmd);
|
|
|
|
|
|
|
|
|
|
/* 注册配置保存函数 */
|
|
|
|
|
rv = cmd_config_node_config_register(CONFIG_PRI_CSG, _csg_config_save);
|
|
|
|
|