|
|
@ -8,6 +8,7 @@ |
|
|
|
#include "def.h" |
|
|
|
#include "encoder.h" |
|
|
|
#include "zport.h" |
|
|
|
#include "config.h" |
|
|
|
|
|
|
|
#define cmd_checksum(data) \ |
|
|
|
if (computesum8((char *)data, recv_datalen - 1) != data->checksum) \ |
|
|
@ -188,6 +189,21 @@ static void udp_client_trigger_cmd_receipt(protocol_trigger_order_t *order, prot |
|
|
|
printf("send basic_response error\r\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* 修改网络相关配置指令回执 */ |
|
|
|
static void udp_client_modify_network_configurations_cmd_receipt(protocol_modify_network_configurations_order_t *order, protocol_status_code_type state_code) |
|
|
|
{ |
|
|
|
protocol_modify_network_configurations_receipt_t receipt; |
|
|
|
receipt.index = order->index; |
|
|
|
receipt.cmd_id = order->cmd_id + ORDER_RECEIPT_INTERCONVERSION; |
|
|
|
receipt.status_code = state_code; |
|
|
|
receipt.checksum = computesum8((char *)&receipt, sizeof(protocol_modify_network_configurations_receipt_t) - 1); |
|
|
|
if (sendto(sock_Client, &receipt, sizeof(protocol_modify_network_configurations_receipt_t), 0, (struct sockaddr *)&addr_server, sizeof(struct sockaddr_in)) == SOCKET_ERROR) |
|
|
|
{ |
|
|
|
printf("send basic_response error\r\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* ===================================================================== */ |
|
|
|
|
|
|
|
void udp_client_recv_data_dump(int recv_datalen) |
|
|
@ -300,7 +316,7 @@ void udp_client_parse(int recv_datalen) |
|
|
|
protocol_read_encoder_order_t *protocol_read_encoder_cmd = (protocol_read_encoder_order_t *)s_receBuf; |
|
|
|
protocol_active_order_t *protocol_active_cmd = (protocol_active_order_t *)s_receBuf; |
|
|
|
protocol_trigger_order_t *protocol_trigger_cmd = (protocol_trigger_order_t *)s_receBuf; |
|
|
|
// protocol_modify_network_configurations_order_t *protocol_modify_network_configurations_cmd = (protocol_modify_network_configurations_order_t *)s_receBuf; |
|
|
|
protocol_modify_network_configurations_order_t *protocol_modify_network_configurations_cmd = (protocol_modify_network_configurations_order_t *)s_receBuf; |
|
|
|
switch (protocol_basic_cmd->cmd_id) |
|
|
|
{ |
|
|
|
case PROTOCOL_CMD_CLEAR_ENCODER: /* 清除编码器数据指令 */ |
|
|
@ -383,9 +399,39 @@ void udp_client_parse(int recv_datalen) |
|
|
|
} |
|
|
|
break; |
|
|
|
case PROTOCOL_CMD_MODIFY_NETWORK_CONFIGURATIONS: /* 配置网络相关指令 */ |
|
|
|
cmd_checksum(protocol_modify_network_configurations_cmd); |
|
|
|
if (checksum_flag) |
|
|
|
{ |
|
|
|
switch (protocol_modify_network_configurations_cmd->configuration_option) |
|
|
|
{ |
|
|
|
case OPTION_IP: |
|
|
|
config_get()->ip = protocol_modify_network_configurations_cmd->data; |
|
|
|
break; |
|
|
|
case OPTION_GW: |
|
|
|
config_get()->gw = protocol_modify_network_configurations_cmd->data; |
|
|
|
break; |
|
|
|
case OPTION_NETMASK: |
|
|
|
config_get()->netmask = protocol_modify_network_configurations_cmd->data; |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
if (config_flash_write() == 0) |
|
|
|
{ |
|
|
|
udp_client_modify_network_configurations_cmd_receipt(protocol_modify_network_configurations_cmd, PROTOCOL_STATUS_SUCCESS); |
|
|
|
} |
|
|
|
else |
|
|
|
{ /* 存在修改了配置,但是写入到flash失败的问题,暂时不处理,处理的话就整一个temp,保存修改前的数据, |
|
|
|
然后写入失败,把temp的数据赋值给修改的字段,通过指令的option来确定修改了啥字段 */ |
|
|
|
udp_client_modify_network_configurations_cmd_receipt(protocol_modify_network_configurations_cmd, PROTOCOL_STATUS_HARDWARE_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
udp_client_modify_network_configurations_cmd_receipt(protocol_modify_network_configurations_cmd, PROTOCOL_STATUS_PARAMETER_ERROR); |
|
|
|
} |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|