diff --git a/src/common/inc/sntp_client.h b/src/common/inc/sntp_client.h index 4841bb0c..447af3ac 100644 --- a/src/common/inc/sntp_client.h +++ b/src/common/inc/sntp_client.h @@ -25,6 +25,10 @@ #include "libiec61850_common_api.h" #include "hal_socket.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct sSNTPClient* SNTPClient; typedef void (*SNTPClient_UserCallback)(void* parameter, bool isSynced); @@ -62,4 +66,8 @@ SNTPClient_stop(SNTPClient self); LIB61850_API void SNTPClient_destroy(SNTPClient self); +#ifdef __cplusplus +} +#endif + #endif /* LIBIEC61850_SRC_COMMON_INC_SNTP_CLIENT_H_ */ diff --git a/src/sntp/sntp_client.c b/src/sntp/sntp_client.c index 9c6c76ee..27e9d09c 100644 --- a/src/sntp/sntp_client.c +++ b/src/sntp/sntp_client.c @@ -1,5 +1,5 @@ /* - * Copyright 2013-2020 Michael Zillgith + * Copyright 2013-2022 Michael Zillgith * * This file is part of libIEC61850. * @@ -94,7 +94,7 @@ ntpTimeToNsTime(uint32_t coarse, uint32_t fine) static void nsTimeToNtpTime(nsSinceEpoch nsTime, uint32_t* coarse, uint32_t* fine) { - uint32_t secondsPart = (nsTime / 1000000000UL) + UNIX_EPOCH_OFFSET; + uint32_t secondsPart = (uint32_t)((nsTime / 1000000000UL) + UNIX_EPOCH_OFFSET); *coarse = secondsPart; @@ -108,7 +108,7 @@ nsTimeToNtpTime(nsSinceEpoch nsTime, uint32_t* coarse, uint32_t* fine) static uint32_t nsTimeToSeconds(nsSinceEpoch nsTime) { - uint32_t secondsSinceEpoch = nsTime / 1000000000UL; + uint32_t secondsSinceEpoch = (uint32_t)(nsTime / 1000000000UL); return secondsSinceEpoch; } @@ -118,7 +118,7 @@ getUsPartFromNsTime(nsSinceEpoch nsTime) { uint64_t nsPart = nsTime % 1000000000UL; - uint32_t msPart = nsPart / 1000UL; + uint32_t msPart = (uint32_t)(nsPart / 1000UL); return msPart; }