diff --git a/src/core/coap/coap.cpp b/src/core/coap/coap.cpp index d2136ea03..c02d63b3b 100644 --- a/src/core/coap/coap.cpp +++ b/src/core/coap/coap.cpp @@ -49,10 +49,10 @@ namespace ot { namespace Coap { -Coap::Coap(ThreadNetif &aNetif): +Coap::Coap(ThreadNetif &aNetif, Timer::Handler aRetransmissionHandler): ThreadNetifLocator(aNetif), mSocket(aNetif.GetIp6().mUdp), - mRetransmissionTimer(aNetif.GetInstance(), &Coap::HandleRetransmissionTimer, this), + mRetransmissionTimer(aNetif.GetInstance(), aRetransmissionHandler, this), mResources(NULL), mContext(NULL), mInterceptor(NULL), diff --git a/src/core/coap/coap.hpp b/src/core/coap/coap.hpp index 05637c261..442aac11c 100644 --- a/src/core/coap/coap.hpp +++ b/src/core/coap/coap.hpp @@ -443,10 +443,11 @@ public: /** * This constructor initializes the object. * - * @param[in] aNetif A reference to the Netif object. + * @param[in] aNetif A reference to the Netif object. + * @param[in] aRetransmissionHandler An optional pointer to the retransmission handler, used by CoapSecure. * */ - Coap(ThreadNetif &aNetif); + Coap(ThreadNetif &aNetif, Timer::Handler aRetransmissionHandler = &Coap::HandleRetransmissionTimer); /** * This method starts the CoAP service. @@ -646,6 +647,12 @@ public: const MessageQueue &GetCachedResponses(void) const { return mResponsesQueue.GetResponses(); } protected: + /** + * Retransmission timer handler. + * + */ + void HandleRetransmissionTimer(void); + /** * This method send a message. * @@ -688,8 +695,8 @@ private: otError SendCopy(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); otError SendEmptyMessage(Header::Type aType, const Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo); + static void HandleRetransmissionTimer(Timer &aTimer); - void HandleRetransmissionTimer(void); static Coap &GetOwner(const Context &aContext); diff --git a/src/core/coap/coap_secure.cpp b/src/core/coap/coap_secure.cpp index 25f5117a8..379b2d8cc 100644 --- a/src/core/coap/coap_secure.cpp +++ b/src/core/coap/coap_secure.cpp @@ -48,7 +48,7 @@ namespace ot { namespace Coap { CoapSecure::CoapSecure(ThreadNetif &aNetif): - Coap(aNetif), + Coap(aNetif, &CoapSecure::HandleRetransmissionTimer), mConnectedCallback(NULL), mConnectedContext(NULL), mTransportCallback(NULL), @@ -320,6 +320,11 @@ CoapSecure &CoapSecure::GetOwner(const Context &aContext) return coap; } +void CoapSecure::HandleRetransmissionTimer(Timer &aTimer) +{ + GetOwner(aTimer).Coap::HandleRetransmissionTimer(); +} + } // namespace Coap } // namespace ot diff --git a/src/core/coap/coap_secure.hpp b/src/core/coap/coap_secure.hpp index 8ef72ea8d..6a98ac36e 100644 --- a/src/core/coap/coap_secure.hpp +++ b/src/core/coap/coap_secure.hpp @@ -214,6 +214,8 @@ private: static void HandleUdpTransmit(Tasklet &aTasklet); void HandleUdpTransmit(void); + static void HandleRetransmissionTimer(Timer &aTimer); + static CoapSecure &GetOwner(const Context &aContext); Ip6::MessageInfo mPeerAddress;