-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update message layer logging for consistency of information and ease …
…of debugging. (#22465) * A refresh of a couple of key message layer log lines to not only contain more information needed to aid with debugging issues or building automated analyzers, but to also make it much more readable at a glance. * Review feedback * Review feedback * Review feedback * Wordlist ammendment
- Loading branch information
1 parent
bede93b
commit 3657621
Showing
20 changed files
with
473 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Message Layer | ||
|
||
## Debug Prints | ||
|
||
When progress logging is enabled, the message layer emits a number of prints | ||
that provide more details on the messages being sent or received. Most of these | ||
are fairly self explanatory with the exception of the ones listed below. | ||
|
||
### Message Transmission | ||
|
||
#### Legend | ||
|
||
On message transmission, the following print is emitted. The various fields that | ||
will be expanded are denoted with `$` . | ||
|
||
Unless specified, numerical values are represented in decimal notation. | ||
|
||
``` | ||
<<< [E:$exchange_id M: $msg_id (Ack: $ack_msg_id)] ($msg_category) Msg TX to $fabric_index:$destination [$compressed_fabric_id] --- Type $protocol_id:$msg_type ($protocol_name:$msg_type_name) | ||
``` | ||
|
||
| Field | Description | | ||
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | | ||
| exchange_id | Exchange ID + IsInitiator flag from message header ('i' if initiator, 'r' if responder') | | ||
| msg_id | Message counter | | ||
| ack_msg_id | If present, the ACK message counter. Otherwise, this entire field is omitted from display | | ||
| msg_category | U: Un-secure Unicast, S: Secure Unicast, G: Secure Groupcast | | ||
| fabric_index | Fabric index on the sending side | | ||
| destination | 64-bit Node Identifier that can represent both group, operational and temporary node identifiers depending on `$msg_category` (in hex) | | ||
| compressed_fabric_id | If present and valid, lower 16-bits of the compressed fabric ID (in hex). Otherwise, it will be set to 0000. | | ||
| protocol_id | 16-bit Protocol ID within the common vendor namespace (in hex) | | ||
| msg_type | 8-bit message type ID (in hex) | | ||
| protocol_name | If available, a logical name for the protocol | | ||
| msg_type_name | If available, a logical name for the message type | | ||
|
||
#### Examples: | ||
|
||
_Unencrypted Unicast:_ | ||
|
||
``` | ||
<<< [E:26341i M: 264589322] (U) Msg TX to 0:0000000000000000 [0000] --- Type 0000:30 (SecureChannel:CASE_Sigma1) | ||
``` | ||
|
||
_Secure Unicast:_ | ||
|
||
``` | ||
<<< [E:26347i M: 30642895 (Ack: 9203233)] (S) Msg TX to 1:0000000012344321 [1667] --- Type 0001:06 (IM:WriteRequest) | ||
``` | ||
|
||
_Secure Groupcast:_ | ||
|
||
``` | ||
<<< [E:26349i M: 2000] (G) Msg TX to 1:FFFFFFFFFFFF0102 [1667] --- Type 0001:06 (IM:WriteRequest) | ||
``` | ||
|
||
### Message Reception | ||
|
||
#### Legend | ||
|
||
On message transmission, the following print is emitted. The various fields that | ||
will be expanded are denoted with `$` . | ||
|
||
Unless specified, numerical values are represented in decimal notation. | ||
|
||
``` | ||
>>> [E:$exchange_id M: $msg_id (Ack: $ack_msg_id)] ($msg_category) Msg RX from $fabric_index:$source [$compressed_fabric_id] --- Type $protocol_id:$msg_type ($protocol_name:$msg_type_name) | ||
``` | ||
|
||
This has a similar legend to that for transmission except `$source` denotes the | ||
source's node identifier and `$fabric_index` is the index on the recipient. | ||
|
||
#### Examples | ||
|
||
_Unencrypted Unicast:_ | ||
|
||
``` | ||
>>> [E:26341i M: 264589322] (U) Msg RX from 0:0FDE2AE2EAF5D74D [0000] --- Type 0000:30 (SecureChannel:CASE_Sigma1) | ||
``` | ||
|
||
_Secure Unicast:_ | ||
|
||
``` | ||
>>> [E:26342i M: 30642885] (S) Msg RX from 1:000000000001B669 [1667] --- Type 0001:08 (IM:InvokeCommandRequest) | ||
``` | ||
|
||
_Secure Groupcast:_ | ||
|
||
``` | ||
>>> [E:26349i M: 2000] (G) Msg RX from 1:000000000001B669 [0000] --- Type 0001:06 (IM:WriteRequest) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* 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. | ||
*/ | ||
|
||
#include <protocols/bdx/BdxMessages.h> | ||
#include <protocols/echo/Echo.h> | ||
#include <protocols/interaction_model/Constants.h> | ||
#include <protocols/secure_channel/Constants.h> | ||
#include <protocols/user_directed_commissioning/UserDirectedCommissioning.h> | ||
|
||
namespace chip { | ||
namespace Protocols { | ||
|
||
static const char * sUnknownTypeName = "----"; | ||
|
||
static const char * LookupMessageTypeName(const MessageTypeNameLookup * lookupTable, size_t tableSize, uint8_t msgType) | ||
{ | ||
for (auto ptr = lookupTable; ptr != (lookupTable + tableSize); ptr++) | ||
{ | ||
if (ptr->mId == msgType) | ||
{ | ||
return ptr->mName; | ||
} | ||
} | ||
|
||
return sUnknownTypeName; | ||
} | ||
|
||
const char * GetProtocolName(Id protocolId) | ||
{ | ||
if (protocolId.GetVendorId() != VendorId::Common) | ||
{ | ||
return sUnknownTypeName; | ||
} | ||
|
||
switch (protocolId.GetProtocolId()) | ||
{ | ||
case InteractionModel::Id.GetProtocolId(): | ||
return InteractionModel::kProtocolName; | ||
break; | ||
|
||
case SecureChannel::Id.GetProtocolId(): | ||
return SecureChannel::kProtocolName; | ||
break; | ||
|
||
case BDX::Id.GetProtocolId(): | ||
return bdx::kProtocolName; | ||
break; | ||
|
||
case Echo::Id.GetProtocolId(): | ||
return Echo::kProtocolName; | ||
break; | ||
|
||
case UserDirectedCommissioning::Id.GetProtocolId(): | ||
return UserDirectedCommissioning::kProtocolName; | ||
break; | ||
|
||
default: | ||
return sUnknownTypeName; | ||
} | ||
} | ||
|
||
const char * GetMessageTypeName(Id protocolId, uint8_t msgType) | ||
{ | ||
if (protocolId.GetVendorId() != VendorId::Common) | ||
{ | ||
return sUnknownTypeName; | ||
} | ||
|
||
const MessageTypeNameLookup * lookupTable = nullptr; | ||
size_t lookupTableSize = 0; | ||
|
||
switch (protocolId.GetProtocolId()) | ||
{ | ||
case InteractionModel::Id.GetProtocolId(): | ||
lookupTable = MessageTypeTraits<InteractionModel::MsgType>::GetTypeToNameTable()->begin(); | ||
lookupTableSize = MessageTypeTraits<InteractionModel::MsgType>::GetTypeToNameTable()->size(); | ||
break; | ||
|
||
case SecureChannel::Id.GetProtocolId(): | ||
lookupTable = MessageTypeTraits<SecureChannel::MsgType>::GetTypeToNameTable()->begin(); | ||
lookupTableSize = MessageTypeTraits<SecureChannel::MsgType>::GetTypeToNameTable()->size(); | ||
break; | ||
|
||
case BDX::Id.GetProtocolId(): | ||
lookupTable = MessageTypeTraits<bdx::MessageType>::GetTypeToNameTable()->begin(); | ||
lookupTableSize = MessageTypeTraits<bdx::MessageType>::GetTypeToNameTable()->size(); | ||
break; | ||
|
||
case Echo::Id.GetProtocolId(): | ||
lookupTable = MessageTypeTraits<Echo::MsgType>::GetTypeToNameTable()->begin(); | ||
lookupTableSize = MessageTypeTraits<Echo::MsgType>::GetTypeToNameTable()->size(); | ||
break; | ||
|
||
case UserDirectedCommissioning::Id.GetProtocolId(): | ||
lookupTable = MessageTypeTraits<UserDirectedCommissioning::MsgType>::GetTypeToNameTable()->begin(); | ||
lookupTableSize = MessageTypeTraits<UserDirectedCommissioning::MsgType>::GetTypeToNameTable()->size(); | ||
break; | ||
|
||
default: | ||
// | ||
// TODO: Add support at some point to let applications to route to custom protocols defined outside of the standard | ||
// namespace in the SDK. | ||
// | ||
return sUnknownTypeName; | ||
} | ||
|
||
return LookupMessageTypeName(lookupTable, lookupTableSize, msgType); | ||
} | ||
|
||
} // namespace Protocols | ||
} // namespace chip |
Oops, something went wrong.