diff --git a/app/drivers/sertrf/protocol/resend_protl.c b/app/drivers/sertrf/protocol/resend_protl.c index 519f477..b713223 100644 --- a/app/drivers/sertrf/protocol/resend_protl.c +++ b/app/drivers/sertrf/protocol/resend_protl.c @@ -153,7 +153,7 @@ int resend_recv_data(resend_device_t *resend_device, int timeout) { if(!resend_decode(resend_device, data[ret - ret_later - 1])) { - printf("tx_req %d rx_req %d retry_cnt %d cmd %d\r\n", resend_device->tx_frame.seq, resend_device->rx_frame.seq, resend_device->rx_frame.retry_cnt, resend_device->rx_frame.cmd); + // printf("tx_req %d rx_req %d retry_cnt %d cmd %d\r\n", resend_device->tx_frame.seq, resend_device->rx_frame.seq, resend_device->rx_frame.retry_cnt, resend_device->rx_frame.cmd); if(seq_lat == resend_device->rx_frame.seq){ resend_device->status.resend_flag = 1; @@ -221,12 +221,14 @@ int resend_send_data(resend_device_t *resend_device, uint8_t cmd, void* data, ui os_thread_sleep(1); } // 超过允许的等待次数 - if(resend_device->tx_frame.retry_cnt > RESEND_MAX_RETRY_CNT) + if(resend_device->tx_frame.retry_cnt > RESEND_MAX_RETRY_CNT && resend_device->status.ack_flag) { printf("timeout cnt max\n"); resend_device->tx_frame.retry_cnt = 0; resend_device->status.ack_flag = 0; return -1; + } else if(!resend_device->status.ack_flag){ + return ret; } } @@ -254,14 +256,14 @@ int resend_parse_data(resend_device_t *resend_device) case RESEND_CMD_SET_PARAM: break; case RESEND_CMD_DATA_ACK: - for (size_t i = 0; i < resend_device->rx_frame.len; i++) - { - printf("%02X ", resend_device->rx_frame.payload[i]); - } - printf("\r\n"); resend_send_cmd(resend_device, RESEND_CMD_ACK, 0); break; + case RESEND_CMD_OTA_GET_PARAM: + //针对OTA的应答 + resend_device->status.ack_flag = 0; + break; case RESEND_CMD_OTA_START: + resend_device->handle_flag = RESEND_CMD_OTA_GET_PARAM; break; case RESEND_CMD_OTA_DATA: break; diff --git a/app/drivers/sertrf/protocol/resend_protl.h b/app/drivers/sertrf/protocol/resend_protl.h index 9fd4c8d..3232c6b 100644 --- a/app/drivers/sertrf/protocol/resend_protl.h +++ b/app/drivers/sertrf/protocol/resend_protl.h @@ -22,7 +22,7 @@ #define RESEND_HEADER_0 0xFD #define RESEND_HEADER_1 0xFE -#define RESEND_MAX_RETRY_CNT 5 +#define RESEND_MAX_RETRY_CNT 0 // 命令类型 typedef enum { @@ -34,6 +34,7 @@ typedef enum RESEND_CMD_DATA_ACK = 0x06, + RESEND_CMD_OTA_GET_PARAM = 0x010, RESEND_CMD_OTA_START = 0x011, RESEND_CMD_OTA_DATA = 0x012, RESEND_CMD_OTA_END = 0x013