mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 06:37:46 +00:00
[config] sntp client (#4020)
This commit is contained in:
+2
-3
@@ -71,7 +71,8 @@ python --version || die
|
||||
-DOPENTHREAD_CONFIG_JOINER_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
|
||||
-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1 \
|
||||
-DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1"
|
||||
|
||||
scan-build ./configure \
|
||||
--enable-builtin-mbedtls=no \
|
||||
@@ -87,7 +88,6 @@ python --version || die
|
||||
--enable-ncp \
|
||||
--enable-radio-only \
|
||||
--enable-service \
|
||||
--enable-sntp-client \
|
||||
--enable-udp-forward \
|
||||
--with-examples=posix || die
|
||||
|
||||
@@ -108,7 +108,6 @@ python --version || die
|
||||
--enable-ncp \
|
||||
--enable-radio-only \
|
||||
--enable-service \
|
||||
--enable-sntp-client \
|
||||
--enable-udp-forward \
|
||||
--with-examples=posix || die
|
||||
|
||||
|
||||
@@ -946,36 +946,6 @@ AC_SUBST(OPENTHREAD_NCP_SPINEL_ENCRYPTER_LIBS)
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER],[${OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER}],[Define to 1 if using NCP Spinel Encrypter])
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER], [test "${OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER}" = "1"])
|
||||
|
||||
#
|
||||
# SNTP Client
|
||||
#
|
||||
|
||||
AC_ARG_ENABLE(sntp_client,
|
||||
[AS_HELP_STRING([--enable-sntp-client],[Enable SNTP client support @<:@default=no@:>@.])],
|
||||
[
|
||||
case "${enableval}" in
|
||||
|
||||
no|yes)
|
||||
enable_sntp_client=${enableval}
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_ERROR([Invalid value ${enable_sntp_client} for --enable-sntp-client])
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[enable_sntp_client=no])
|
||||
|
||||
if test "$enable_sntp_client" = "yes"; then
|
||||
OPENTHREAD_ENABLE_SNTP_CLIENT=1
|
||||
else
|
||||
OPENTHREAD_ENABLE_SNTP_CLIENT=0
|
||||
fi
|
||||
|
||||
AC_SUBST(OPENTHREAD_ENABLE_SNTP_CLIENT)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_SNTP_CLIENT], [test "${enable_sntp_client}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_SNTP_CLIENT],[${OPENTHREAD_ENABLE_SNTP_CLIENT}],[Define to 1 if you want to enable SNTP Client])
|
||||
|
||||
#
|
||||
# Service
|
||||
#
|
||||
@@ -1466,7 +1436,6 @@ AC_MSG_NOTICE([
|
||||
OpenThread UDP forward support : ${enable_udp_forward}
|
||||
OpenThread Jam Detection support : ${enable_jam_detection}
|
||||
OpenThread Legacy network support : ${enable_legacy}
|
||||
OpenThread SNTP Client support : ${enable_sntp_client}
|
||||
OpenThread Service support : ${enable_service}
|
||||
OpenThread ECDSA support : ${enable_ecdsa}
|
||||
OpenThread Examples : ${with_examples}
|
||||
|
||||
@@ -173,7 +173,7 @@ COMMONCFLAGS += -DOPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1
|
||||
endif
|
||||
|
||||
ifeq ($(SNTP_CLIENT),1)
|
||||
configure_OPTIONS += --enable-sntp-client
|
||||
COMMONCFLAGS += -DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1
|
||||
endif
|
||||
|
||||
ifeq ($(TIME_SYNC),1)
|
||||
|
||||
@@ -85,7 +85,7 @@ typedef void (*otSntpResponseHandler)(void *aContext, uint64_t aTime, otError aR
|
||||
/**
|
||||
* This function sends a SNTP query.
|
||||
*
|
||||
* This function is available only if feature `OPENTHREAD_ENABLE_SNTP_CLIENT` is enabled.
|
||||
* This function is available only if feature `OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE_CLIENT` is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aQuery A pointer to specify SNTP query parameters.
|
||||
|
||||
+2
-2
@@ -208,7 +208,7 @@ const struct Command Interpreter::sCommands[] = {
|
||||
{"service", &Interpreter::ProcessService},
|
||||
#endif
|
||||
{"singleton", &Interpreter::ProcessSingleton},
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
{"sntp", &Interpreter::ProcessSntp},
|
||||
#endif
|
||||
{"state", &Interpreter::ProcessState},
|
||||
@@ -2857,7 +2857,7 @@ void Interpreter::ProcessSingleton(int argc, char *argv[])
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
void Interpreter::ProcessSntp(int argc, char *argv[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
+4
-4
@@ -315,7 +315,7 @@ private:
|
||||
void ProcessRloc16(int argc, char *argv[]);
|
||||
void ProcessScan(int argc, char *argv[]);
|
||||
void ProcessSingleton(int argc, char *argv[]);
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
void ProcessSntp(int argc, char *argv[]);
|
||||
#endif
|
||||
void ProcessState(int argc, char *argv[]);
|
||||
@@ -349,7 +349,7 @@ private:
|
||||
otError aResult);
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
static void HandleSntpResponse(void *aContext, uint64_t aTime, otError aResult);
|
||||
#endif
|
||||
|
||||
@@ -362,7 +362,7 @@ private:
|
||||
#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
void HandleDnsResponse(const char *aHostname, Ip6::Address &aAddress, uint32_t aTtl, otError aResult);
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
void HandleSntpResponse(uint64_t aTime, otError aResult);
|
||||
#endif
|
||||
static Interpreter &GetOwner(OwnerLocator &aOwnerLocator);
|
||||
@@ -382,7 +382,7 @@ private:
|
||||
char mResolvingHostname[OT_DNS_MAX_HOSTNAME_LENGTH];
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
bool mSntpQueryingInProgress;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -340,6 +340,7 @@ HEADERS_COMMON = \
|
||||
config/openthread-core-default-config.h \
|
||||
config/parent_search.h \
|
||||
config/platform.h \
|
||||
config/sntp_client.h \
|
||||
crypto/aes_ccm.hpp \
|
||||
crypto/aes_ecb.hpp \
|
||||
crypto/ecdsa.hpp \
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
using namespace ot;
|
||||
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
otError otSntpClientQuery(otInstance * aInstance,
|
||||
const otSntpQuery * aQuery,
|
||||
otSntpResponseHandler aHandler,
|
||||
|
||||
@@ -626,7 +626,7 @@ template <> inline Utils::JamDetector &Instance::Get(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
template <> inline Sntp::Client &Instance::Get(void)
|
||||
{
|
||||
return mThreadNetif.mSntpClient;
|
||||
|
||||
@@ -217,26 +217,6 @@
|
||||
#define OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_SNTP_RESPONSE_TIMEOUT
|
||||
*
|
||||
* Maximum time that SNTP Client waits for response in milliseconds.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_SNTP_RESPONSE_TIMEOUT
|
||||
#define OPENTHREAD_CONFIG_SNTP_RESPONSE_TIMEOUT 3000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_SNTP_MAX_RETRANSMIT
|
||||
*
|
||||
* Maximum number of retransmissions for SNTP client.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_SNTP_MAX_RETRANSMIT
|
||||
#define OPENTHREAD_CONFIG_SNTP_MAX_RETRANSMIT 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_STORE_FRAME_COUNTER_AHEAD
|
||||
*
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2019, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes compile-time configurations for the SNTP Client.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_SNTP_CLIENT_H_
|
||||
#define CONFIG_SNTP_CLIENT_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
*
|
||||
* Define to 1 to enable SNTP Client support.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
#define OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_SNTP_CLIENT_RESPONSE_TIMEOUT
|
||||
*
|
||||
* Maximum time that SNTP Client waits for response in milliseconds.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_SNTP_CLIENT_RESPONSE_TIMEOUT
|
||||
#define OPENTHREAD_CONFIG_SNTP_CLIENT_RESPONSE_TIMEOUT 3000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_SNTP_CLIENT_MAX_RETRANSMIT
|
||||
*
|
||||
* Maximum number of retransmissions for SNTP client.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_SNTP_CLIENT_MAX_RETRANSMIT
|
||||
#define OPENTHREAD_CONFIG_SNTP_CLIENT_MAX_RETRANSMIT 2
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_SNTP_CLIENT_H_
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "net/udp6.hpp"
|
||||
#include "thread/thread_netif.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -399,4 +399,4 @@ exit:
|
||||
} // namespace Sntp
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#endif // OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
|
||||
@@ -596,8 +596,8 @@ private:
|
||||
*/
|
||||
enum
|
||||
{
|
||||
kResponseTimeout = OPENTHREAD_CONFIG_SNTP_RESPONSE_TIMEOUT,
|
||||
kMaxRetransmit = OPENTHREAD_CONFIG_SNTP_MAX_RETRANSMIT,
|
||||
kResponseTimeout = OPENTHREAD_CONFIG_SNTP_CLIENT_RESPONSE_TIMEOUT,
|
||||
kMaxRetransmit = OPENTHREAD_CONFIG_SNTP_CLIENT_MAX_RETRANSMIT,
|
||||
};
|
||||
|
||||
Message *NewMessage(const Header &aHeader);
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#include "config/mle.h"
|
||||
#include "config/parent_search.h"
|
||||
#include "config/platform.h"
|
||||
#include "config/sntp_client.h"
|
||||
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \
|
||||
OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_JOINER_ENABLE
|
||||
|
||||
@@ -62,9 +62,9 @@ ThreadNetif::ThreadNetif(Instance &aInstance)
|
||||
#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
, mDnsClient(Get<ThreadNetif>())
|
||||
#endif // OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
, mSntpClient(Get<ThreadNetif>())
|
||||
#endif // OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#endif // OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
, mActiveDataset(aInstance)
|
||||
, mPendingDataset(aInstance)
|
||||
, mKeyManager(aInstance)
|
||||
@@ -131,7 +131,7 @@ void ThreadNetif::Up(void)
|
||||
#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
Get<Dns::Client>().Start();
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
Get<Sntp::Client>().Start();
|
||||
#endif
|
||||
Get<Notifier>().Signal(OT_CHANGED_THREAD_NETIF_STATE);
|
||||
@@ -147,7 +147,7 @@ void ThreadNetif::Down(void)
|
||||
#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
Get<Dns::Client>().Stop();
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
Get<Sntp::Client>().Stop();
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_DTLS_ENABLE
|
||||
|
||||
@@ -176,9 +176,9 @@ private:
|
||||
#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
Dns::Client mDnsClient;
|
||||
#endif // OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
Sntp::Client mSntpClient;
|
||||
#endif // OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
#endif // OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
|
||||
MeshCoP::ActiveDataset mActiveDataset;
|
||||
MeshCoP::PendingDataset mPendingDataset;
|
||||
Ip6::Filter mIp6Filter;
|
||||
|
||||
Reference in New Issue
Block a user