[time-sync] fix time sync and typo (#3637)

* fix typo in common-switches
* fix segment fault with time sync enabled
This commit is contained in:
Yakun Xu
2019-02-28 10:28:16 -08:00
committed by Jonathan Hui
parent 74ad300556
commit 6705fe83f3
3 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -60,6 +60,7 @@ SNTP_CLIENT ?= 1
UDP_FORWARD ?= 1
COMMONCFLAGS := \
-g \
$(NULL)
# If the user has asserted COVERAGE, alter the configuration options
@@ -80,7 +81,6 @@ configure_OPTIONS = \
ifneq ($(DEBUG),1)
COMMONCFLAGS += \
-O2 \
-g \
$(NULL)
endif
+1 -1
View File
@@ -169,7 +169,7 @@ configure_OPTIONS += --enable-sntp-client
endif
ifeq ($(TIME_SYNC),1)
COMMONCFLAGS += -DPENTHREAD_CONFIG_ENABLE_TIME_SYNC=1
COMMONCFLAGS += -DOPENTHREAD_CONFIG_ENABLE_TIME_SYNC=1 -DOPENTHREAD_CONFIG_HEADER_IE_SUPPORT=1
endif
ifeq ($(UDP_FORWARD),1)
+10 -7
View File
@@ -663,13 +663,16 @@ otError MleRouter::HandleLinkRequest(const Message &aMessage, const Ip6::Message
}
#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
if (Tlv::GetTlv(aMessage, Tlv::kTimeRequest, sizeof(timeRequest), timeRequest) == OT_ERROR_NONE)
if (neighbor != NULL)
{
neighbor->SetTimeSyncEnabled(true);
}
else
{
neighbor->SetTimeSyncEnabled(false);
if (Tlv::GetTlv(aMessage, Tlv::kTimeRequest, sizeof(timeRequest), timeRequest) == OT_ERROR_NONE)
{
neighbor->SetTimeSyncEnabled(true);
}
else
{
neighbor->SetTimeSyncEnabled(false);
}
}
#endif
@@ -745,7 +748,7 @@ otError MleRouter::SendLinkAccept(const Ip6::MessageInfo &aMessageInfo,
}
#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
if (aNeighbor->IsTimeSyncEnabled())
if (aNeighbor != NULL && aNeighbor->IsTimeSyncEnabled())
{
message->SetTimeSync(true);
}