void Joiner::HandleJoinerFinalizeResponse(Coap::Message & aMessage, const Ip6::MessageInfo *aMessageInfo, otError aResult) { OT_UNUSED_VARIABLE(aMessageInfo); StateTlv state; VerifyOrExit(mState == OT_JOINER_STATE_CONNECTED && aResult == OT_ERROR_NONE && aMessage.GetType() == OT_COAP_TYPE_ACKNOWLEDGMENT && aMessage.GetCode() == OT_COAP_CODE_CHANGED); SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kState, sizeof(state), state)); VerifyOrExit(state.IsValid()); mState = OT_JOINER_STATE_ENTRUST; mTimer.Start(kTimeout); otLogInfoMeshCoP("received joiner finalize response %d", static_cast<uint8_t>(state.GetState())); #if OPENTHREAD_ENABLE_CERT_LOG uint8_t buf[OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE]; VerifyOrExit(aMessage.GetLength() <= sizeof(buf)); aMessage.Read(aMessage.GetOffset(), aMessage.GetLength() - aMessage.GetOffset(), buf); otDumpCertMeshCoP("[THCI] direction=recv | type=JOIN_FIN.rsp |", buf, aMessage.GetLength() - aMessage.GetOffset()); #endif exit: Close(); }
void Leader::HandleKeepAlive(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { StateTlv state; CommissionerSessionIdTlv sessionId; StateTlv::State responseState; otLogInfoMeshCoP(GetInstance(), "received keep alive"); SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kState, sizeof(state), state)); VerifyOrExit(state.IsValid()); SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kCommissionerSessionId, sizeof(sessionId), sessionId)); VerifyOrExit(sessionId.IsValid()); if (sessionId.GetCommissionerSessionId() != mSessionId) { responseState = StateTlv::kReject; } else if (state.GetState() != StateTlv::kAccept) { responseState = StateTlv::kReject; ResignCommissioner(); } else { responseState = StateTlv::kAccept; mTimer.Start(TimerMilli::SecToMsec(kTimeoutLeaderPetition)); } SendKeepAliveResponse(aHeader, aMessageInfo, responseState); exit: return; }