Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Add ability to disable rcv and send debug messages #615

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ $(nl_public_WeaveSupport_source_dirstem)/FibonacciUtils.h \
$(nl_public_WeaveSupport_source_dirstem)/FlagUtils.hpp \
$(nl_public_WeaveSupport_source_dirstem)/ManagedNamespace.hpp \
$(nl_public_WeaveSupport_source_dirstem)/MathUtils.h \
$(nl_public_WeaveSupport_source_dirstem)/ProfileUtils.h \
$(nl_public_WeaveSupport_source_dirstem)/NLDLLUtil.h \
$(nl_public_WeaveSupport_source_dirstem)/NestCerts.h \
$(nl_public_WeaveSupport_source_dirstem)/PersistedCounter.h \
Expand Down
5 changes: 4 additions & 1 deletion src/lib/core/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,12 @@ WEAVE_ERROR ExchangeContext::SendMessage(uint32_t profileId, uint8_t msgType, Pa
exit:
if (sendCalled)
{
WeaveLogRetain(ExchangeManager, "Msg %s %08" PRIX32 ":%d %d %016" PRIX64 " %04" PRIX16 " %04" PRIX16 " %ld MsgId:%08" PRIX32,
if(!nl::Weave::Platform::IsProfileSilenced(static_cast<nl::Weave::Profiles::WeaveProfileId>(profileId)))
{
WeaveLogRetain(ExchangeManager, "Msg %s %08" PRIX32 ":%d %d %016" PRIX64 " %04" PRIX16 " %04" PRIX16 " %ld MsgId:%08" PRIX32,
"sent", profileId, msgType, (int)payloadLen, msgInfo->DestNodeId,
(Con ? Con->LogId() : 0), ExchangeId, (long)err, msgInfo->MessageId);
}
}
if (err != WEAVE_NO_ERROR && IsResponseExpected())
{
Expand Down
11 changes: 7 additions & 4 deletions src/lib/core/WeaveExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,13 @@ void WeaveExchangeManager::DispatchMessage(WeaveMessageInfo *msgInfo, PacketBuff

msgCon = msgInfo->InCon;

WeaveLogRetain(ExchangeManager, "Msg %s %08" PRIX32 ":%d %d %016" PRIX64 " %04" PRIX16 " %04" PRIX16 " %ld MsgId:%08" PRIX32,
"rcvd", exchangeHeader.ProfileId, exchangeHeader.MessageType,
(int)msgBuf->DataLength(), msgInfo->SourceNodeId, msgCon->LogId(), exchangeHeader.ExchangeId,
(long)err, msgInfo->MessageId);
if(!nl::Weave::Platform::IsProfileSilenced(static_cast<nl::Weave::Profiles::WeaveProfileId>(exchangeHeader.ProfileId)))
{
WeaveLogRetain(ExchangeManager, "Msg %s %08" PRIX32 ":%d %d %016" PRIX64 " %04" PRIX16 " %04" PRIX16 " %ld MsgId:%08" PRIX32,
"rcvd", exchangeHeader.ProfileId, exchangeHeader.MessageType,
(int)msgBuf->DataLength(), msgInfo->SourceNodeId, msgCon->LogId(), exchangeHeader.ExchangeId,
(long)err, msgInfo->MessageId);
}

#if WEAVE_CONFIG_USE_APP_GROUP_KEYS_FOR_MSG_ENC
isMsgCounterSyncResp = exchangeHeader.ProfileId == nl::Weave::Profiles::kWeaveProfile_Security &&
Expand Down
1 change: 1 addition & 0 deletions src/lib/core/WeaveExchangeMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define WEAVE_EXCHANGE_MGR_H

#include <Weave/Support/NLDLLUtil.h>
#include <Weave/Support/ProfileUtils.h>
#include <Weave/Core/WeaveWRMPConfig.h>
#include <SystemLayer/SystemTimer.h>

Expand Down
90 changes: 90 additions & 0 deletions src/lib/support/ProfileUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
*
* Copyright (c) 2020 Google, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file
* This file implements default platform-specific profile utility functions.
*
*/

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif

#include <inttypes.h>
#include <Weave/Core/WeaveConfig.h>

#include "ProfileUtils.h"

namespace nl {
namespace Weave {
namespace Platform {

uint64_t local_common_profile;
uint64_t local_nest_profile;

void SilenceProfilePrints(nl::Weave::Profiles::WeaveProfileId aProfileId)
{
if((0x235A0000 & aProfileId) != 0)
{
uint64_t interm_val = (0x0000FFFF & aProfileId);
local_nest_profile |= (1 << interm_val);
}
else
{
local_common_profile |= (1 << aProfileId);
}
}
bool IsProfileSilenced(nl::Weave::Profiles::WeaveProfileId aProfileId)
{
bool retVal = false;
if((0x235A0000 & aProfileId) != 0)
{
uint64_t interm_val = (0x0000FFFF & aProfileId);
if((local_nest_profile & (1 << interm_val)) != 0)
{
retVal = true;
}
}
else
{
if((local_common_profile & (1 << aProfileId)) != 0)
{
retVal = true;
}
}
return retVal;
}

void UnSilenceProfile(nl::Weave::Profiles::WeaveProfileId aProfileId)
{
if((0x235A0000 & aProfileId) != 0)
{
uint64_t interm_val = (0x0000FFFF & aProfileId);
local_nest_profile &= (~(1 << interm_val));
}
else
{
local_common_profile &= (~(1 << aProfileId));
}

}

} // namespace Platform
} // namespace Weave
} // namespace nl
57 changes: 57 additions & 0 deletions src/lib/support/ProfileUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
*
* Copyright (c) 2020 Google, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file
* This file defines platform-specific profile utility functions.
*
*/

#ifndef PROFILEUTILS_H_
#define PROFILEUTILS_H_

#include <Weave/Profiles/WeaveProfiles.h>
#include <Weave/Support/NLDLLUtil.h>

namespace nl {
namespace Weave {
namespace Platform {

/**
* @brief
* Reads in a profile type and stores it to be compared for silencing.
*/
void SilenceProfilePrints(nl::Weave::Profiles::WeaveProfileId aProfileId);

/**
* @brief
* Returns if the profile has been silenced.
*/
bool IsProfileSilenced(nl::Weave::Profiles::WeaveProfileId aProfileId);

/**
* @brief
* Clears a profile type ( unsilences the profile type)
*/
NL_DLL_EXPORT void UnSilenceProfile(nl::Weave::Profiles::WeaveProfileId);

} // namespace Platform
} // namespace Weave
} // namespace nl

#endif /* PROFILEUTILS_H_ */
1 change: 1 addition & 0 deletions src/lib/support/WeaveSupport.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ nl_WeaveSupport_sources
@top_builddir@/src/lib/support/ErrorStr.cpp \
@top_builddir@/src/lib/support/FibonacciUtils.cpp \
@top_builddir@/src/lib/support/MathUtils.cpp \
@top_builddir@/src/lib/support/ProfileUtils.cpp \
@top_builddir@/src/lib/support/NestCerts.cpp \
@top_builddir@/src/lib/support/NonProductionMarker.cpp \
@top_builddir@/src/lib/support/PersistedCounter.cpp \
Expand Down