Skip to content

Commit b81c0e5

Browse files
authored
[meshcop] use milliseconds for leader petition timeout constant (openthread#12154)
This commit replaces `kTimeoutLeaderPetition` (in seconds) with `kLeaderPetitionTimeout` (in milliseconds). This change avoids repeated calls to `Time::SecToMsec()` when starting the commissioner session timer.
1 parent b03053b commit b81c0e5

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/core/meshcop/meshcop_leader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ template <> void Leader::HandleTmf<kUriLeaderPetition>(Coap::Message &aMessage,
7878
IgnoreError(StringCopy(mCommissionerId, commissionerId));
7979

8080
state = StateTlv::kAccept;
81-
mTimer.Start(Time::SecToMsec(kTimeoutLeaderPetition));
81+
mTimer.Start(kLeaderPetitionTimeout);
8282

8383
exit:
8484
SendPetitionResponse(aMessage, aMessageInfo, state);
@@ -152,7 +152,7 @@ template <> void Leader::HandleTmf<kUriLeaderKeepAlive>(Coap::Message &aMessage,
152152
}
153153

154154
responseState = StateTlv::kAccept;
155-
mTimer.Start(Time::SecToMsec(kTimeoutLeaderPetition));
155+
mTimer.Start(kLeaderPetitionTimeout);
156156
}
157157

158158
SendKeepAliveResponse(aMessage, aMessageInfo, responseState);

src/core/meshcop/meshcop_leader.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Leader : public InstanceLocator, private NonCopyable
9898
void SetEmptyCommissionerData(void);
9999

100100
private:
101-
static constexpr uint32_t kTimeoutLeaderPetition = 50; // TIMEOUT_LEAD_PET (seconds)
101+
static constexpr uint32_t kLeaderPetitionTimeout = 50 * Time::kOneSecondInMsec; // TIMEOUT_LEAD_PET (in msec)
102102

103103
OT_TOOL_PACKED_BEGIN
104104
class CommissioningData
@@ -131,10 +131,8 @@ class Leader : public InstanceLocator, private NonCopyable
131131

132132
using LeaderTimer = TimerMilliIn<Leader, &Leader::HandleTimer>;
133133

134-
LeaderTimer mTimer;
135-
136-
uint32_t mDelayTimerMinimal;
137-
134+
LeaderTimer mTimer;
135+
uint32_t mDelayTimerMinimal;
138136
CommissionerIdTlv::StringType mCommissionerId;
139137
uint16_t mSessionId;
140138
};

0 commit comments

Comments
 (0)