This commit is contained in:
2021-03-01 11:34:16 +01:00
parent 7dfac6e471
commit 577f1fbd42

View File

@ -108,9 +108,9 @@ void networkSntpEngine(void *handle) {
break; break;
case SNTP_STATE_RECV: case SNTP_STATE_RECV:
coloredMsg(LOG_BLUE, "nes, check receive"); coloredMsg(LOG_BLUE, "nes, check receive");
localHandle->retryCount += 1;
uint16_t recvLen = getSn_RX_RSR(SNTP_SOCK); uint16_t recvLen = getSn_RX_RSR(SNTP_SOCK);
if (recvLen == 0) { if (recvLen == 0) {
localHandle->retryCount += 1;
if (localHandle->retryCount > MAX_SNTP_RETRIES) { if (localHandle->retryCount > MAX_SNTP_RETRIES) {
coloredMsg(LOG_BLUE, "nes, max retry count reached, failed"); coloredMsg(LOG_BLUE, "nes, max retry count reached, failed");
localHandle->sntpState = SNTP_STATE_ERROR; localHandle->sntpState = SNTP_STATE_ERROR;
@ -149,9 +149,10 @@ void networkSntpEngine(void *handle) {
coloredMsg(LOG_BLUE, "nes, msg received from %d.%d.%d.%d:%d", coloredMsg(LOG_BLUE, "nes, msg received from %d.%d.%d.%d:%d",
srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3], srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3],
srcPort); srcPort);
coloredMsg(LOG_BLUE, "nes, received in the %d. cycles", localHandle->retryCount); coloredMsg(LOG_BLUE, "nes, received in the %d. cycles", localHandle->retryCount);
localHandle->seconds = ((uint64_t)localHandle->ntpMsg.s.xmt_h) - UNIX_NTP_EPOCH_DIFF; localHandle->seconds = ((uint64_t)localHandle->ntpMsg.s.xmt_h) - UNIX_NTP_EPOCH_DIFF;
coloredMsg(LOG_BLUE, "nes, seconds: %llu", localHandle->seconds); coloredMsg(LOG_BLUE, "nes, seconds: %lu", localHandle->seconds);
localHandle->sntpState = SNTP_STATE_DONE; localHandle->sntpState = SNTP_STATE_DONE;
} else { } else {
coloredMsg(LOG_BLUE, "nes, invalid number of octets received: %d", recvLen); coloredMsg(LOG_BLUE, "nes, invalid number of octets received: %d", recvLen);
@ -177,6 +178,7 @@ uint64_t networkSntpQuery() {
} else if (sntpEngineHandle.sntpState == SNTP_STATE_DONE) { } else if (sntpEngineHandle.sntpState == SNTP_STATE_DONE) {
coloredMsg(LOG_BLUE, "nsq, start sntp done"); coloredMsg(LOG_BLUE, "nsq, start sntp done");
res = sntpEngineHandle.seconds; res = sntpEngineHandle.seconds;
coloredMsg(LOG_BLUE, "nsq, time is %lu", res);
sntpEngineHandle.sntpState = SNTP_STATE_IDLE; sntpEngineHandle.sntpState = SNTP_STATE_IDLE;
} else if (sntpEngineHandle.sntpState == SNTP_STATE_ERROR) { } else if (sntpEngineHandle.sntpState == SNTP_STATE_ERROR) {
coloredMsg(LOG_BLUE, "nsq, start sntp failed"); coloredMsg(LOG_BLUE, "nsq, start sntp failed");