FIX | 添加重启和dau添加回复

main
yuliang 1 week ago
parent a719e39a92
commit 326b57ecb1

@ -106,7 +106,9 @@ enum DAU_P_CMD
/* 命令类型. */ /* 命令类型. */
enum DAU_SEND_TYPE enum DAU_SEND_TYPE
{ {
DAU_SEND_PRPS = 1, DAU_SEND_ADD = 1,
DAU_SEND_RESET = 2,
DAU_SEND_PRPS = 3,
DAU_SEND_MAX DAU_SEND_MAX
}; };

@ -110,6 +110,7 @@ void _dau_recv_connect(dau_t *dau, uint16_t recv_len)
dau_pkt_head_t *head = (dau_pkt_head_t*)dau->buf_recv; dau_pkt_head_t *head = (dau_pkt_head_t*)dau->buf_recv;
dau_contact_t *pnet = (dau_contact_t*)(dau->buf_recv + sizeof(dau_pkt_head_t)); dau_contact_t *pnet = (dau_contact_t*)(dau->buf_recv + sizeof(dau_pkt_head_t));
dau_ack_t *ack = (dau_ack_t*)(dau->buf_recv + sizeof(dau_pkt_head_t)); dau_ack_t *ack = (dau_ack_t*)(dau->buf_recv + sizeof(dau_pkt_head_t));
dau_contact_t *info = NULL;
/* 复制设备信息 */ /* 复制设备信息 */
memcpy(&dau->info, pnet, sizeof(dau_contact_t)); memcpy(&dau->info, pnet, sizeof(dau_contact_t));
@ -126,6 +127,24 @@ void _dau_recv_connect(dau_t *dau, uint16_t recv_len)
head_data.len = sizeof(dau_pkt_head_t) + sizeof(dau_ack_t); head_data.len = sizeof(dau_pkt_head_t) + sizeof(dau_ack_t);
dau_data_send(dau, &head_data); dau_data_send(dau, &head_data);
/* 给后台发送添加信息 */
/* 申请内存 */
info = XMALLOC(MTYPE_CSG, sizeof(dau_contact_t));
if (!info)
{
DBG(DBG_M_PD_DAU_ERR, "XMALLOC ERROR!\r\n");
return;
}
/* 复制设备信息 */
memcpy(info, &dau->info, sizeof(dau_contact_t));
/* 发送给后台 */
if (dau_msg_send_cmd(DAU_SEND_ADD, info) != E_NONE)
{
XFREE(MTYPE_CSG, info);
}
return; return;
} }

@ -59,12 +59,13 @@
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
extern void _hf_heartbeat_recv(uint8_t slot, char *pkt, uint16_t len); extern void _hf_send_reset(uint8_t slot, void *data);
extern void _hf_prps_get_recv(uint8_t slot, char *pkt, uint16_t len); extern void _hf_send_prps_get(uint8_t slot, void *data);
extern void _hf_trend_recv(uint8_t slot, char *pkt, uint16_t len);
extern void _hf_event_recv(uint8_t slot, char *pkt, uint16_t len);
extern void _hf_prps_get_send(uint8_t slot, void *data); extern void _hf_recv_heartbeat(uint8_t slot, char *pkt, uint16_t len);
extern void _hf_recv_prps_get(uint8_t slot, char *pkt, uint16_t len);
extern void _hf_recv_trend(uint8_t slot, char *pkt, uint16_t len);
extern void _hf_recv_event(uint8_t slot, char *pkt, uint16_t len);
// 命令映射表 // 命令映射表
static dau_recv_fun_cb _hf_command[] = static dau_recv_fun_cb _hf_command[] =
@ -79,7 +80,7 @@ static dau_recv_fun_cb _hf_command[] =
NULL, // DAU_C_DEV_INFO_GET 7 NULL, // DAU_C_DEV_INFO_GET 7
NULL, // 8 NULL, // 8
NULL, // DAU_C_UPDATE_RESULT 9 NULL, // DAU_C_UPDATE_RESULT 9
_hf_heartbeat_recv, // DAU_C_HEARTBEAT 10 _hf_recv_heartbeat, // DAU_C_HEARTBEAT 10
}; };
// 命令映射表 // 命令映射表
@ -90,26 +91,46 @@ static dau_recv_fun_cb _hf_prv_command[] =
NULL, // DAU_P_CONFIG_GET 2 NULL, // DAU_P_CONFIG_GET 2
NULL, // DAU_P_CONFIG_PORT_SET 3 NULL, // DAU_P_CONFIG_PORT_SET 3
NULL, // DAU_P_CONFIG_PORT_GET 4 NULL, // DAU_P_CONFIG_PORT_GET 4
_hf_prps_get_recv, // DAU_P_CONFIG_REAL_WAVE 5 _hf_recv_prps_get, // DAU_P_CONFIG_REAL_WAVE 5
NULL, // 6 NULL, // 6
NULL, // 7 NULL, // 7
NULL, // 8 NULL, // 8
NULL, // 9 NULL, // 9
_hf_trend_recv, // DAU_P_TREND 10 _hf_recv_trend, // DAU_P_TREND 10
NULL, // DAU_P_REAL_PRPS 11 NULL, // DAU_P_REAL_PRPS 11
_hf_event_recv, // DAU_P_EVENT 12 _hf_recv_event, // DAU_P_EVENT 12
}; };
// 命令映射表 // 命令映射表
static dau_send_fun_cb _hf_send_command[] = static dau_send_fun_cb _hf_send_command[] =
{ {
NULL, // 0 NULL, // 0
_hf_prps_get_send, // DAU_SEND_PRPS 1 NULL, // DAU_SEND_ADD 1
_hf_send_reset, // DAU_SEND_RESET 2
_hf_send_prps_get, // DAU_SEND_PRPS 3
}; };
/* Interface functions -------------------------------------------------------*/ /* Interface functions -------------------------------------------------------*/
/* PRPS 重启发送 */
void _hf_send_reset(uint8_t slot, void *data)
{
dau_head_init_t head_data;
dau_t *dau = &daus[slot];
/* 回复报文 */
head_data.cmd_type = DAU_REQUEST;
head_data.cmd = DAU_C_RESET;
head_data.pkt_id = dau->pkt_id++;
head_data.pkt = dau->buf_send;
head_data.len = sizeof(dau_pkt_head_t);
dau_data_send(dau, &head_data);
return;
}
/* PRPS 关注报文发送 */ /* PRPS 关注报文发送 */
void _hf_prps_get_send(uint8_t slot, void *data) void _hf_send_prps_get(uint8_t slot, void *data)
{ {
dau_head_init_t head_data; dau_head_init_t head_data;
dau_t *dau = &daus[slot]; dau_t *dau = &daus[slot];
@ -129,8 +150,35 @@ void _hf_prps_get_send(uint8_t slot, void *data)
return; return;
} }
/* 重启报文接收 */
void _hf_recv_reset(uint8_t slot, char *pkt, uint16_t len)
{
hf_ack_t *ack = (hf_ack_t*)(pkt + sizeof(dau_pkt_head_t));
hf_ack_t *data = NULL;
/* 申请内存 */
data = XMALLOC(MTYPE_CSG, sizeof(hf_ack_t));
if (!data)
{
DBG(DBG_M_PD_HF_ERR, "XMALLOC ERROR!\r\n");
return;
}
/* 装填数据 */
data->result = ack->result;
data->slot = slot;
/* 发送给后台 */
if (dau_msg_send_cmd(DAU_SEND_RESET, data) != E_NONE)
{
XFREE(MTYPE_CSG, data);
}
return;
}
/* 心跳报文接收 */ /* 心跳报文接收 */
void _hf_heartbeat_recv(uint8_t slot, char *pkt, uint16_t len) void _hf_recv_heartbeat(uint8_t slot, char *pkt, uint16_t len)
{ {
dau_head_init_t head_data; dau_head_init_t head_data;
dau_t *dau = &daus[slot]; dau_t *dau = &daus[slot];
@ -154,7 +202,7 @@ void _hf_heartbeat_recv(uint8_t slot, char *pkt, uint16_t len)
} }
/* 心跳报文接收 */ /* 心跳报文接收 */
void _hf_prps_get_recv(uint8_t slot, char *pkt, uint16_t len) void _hf_recv_prps_get(uint8_t slot, char *pkt, uint16_t len)
{ {
hf_ack_t *ack = (hf_ack_t*)(pkt + sizeof(dau_pkt_head_t)); hf_ack_t *ack = (hf_ack_t*)(pkt + sizeof(dau_pkt_head_t));
hf_ack_t *data = NULL; hf_ack_t *data = NULL;
@ -181,7 +229,7 @@ void _hf_prps_get_recv(uint8_t slot, char *pkt, uint16_t len)
} }
/* 趋势报文接收 */ /* 趋势报文接收 */
void _hf_trend_recv(uint8_t slot, char *pkt, uint16_t len) void _hf_recv_trend(uint8_t slot, char *pkt, uint16_t len)
{ {
dau_head_init_t head_data; dau_head_init_t head_data;
dau_t *dau = &daus[slot]; dau_t *dau = &daus[slot];
@ -251,7 +299,7 @@ void _hf_trend_recv(uint8_t slot, char *pkt, uint16_t len)
} }
/* 事件报文接收 */ /* 事件报文接收 */
void _hf_event_recv(uint8_t slot, char *pkt, uint16_t len) void _hf_recv_event(uint8_t slot, char *pkt, uint16_t len)
{ {
dau_head_init_t head_data; dau_head_init_t head_data;
dau_t *dau = &daus[slot]; dau_t *dau = &daus[slot];

Loading…
Cancel
Save