Skip to content

Commit

Permalink
Rename messageId into messageCounter
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost committed Sep 14, 2021
1 parent 64d8f13 commit effb14e
Show file tree
Hide file tree
Showing 34 changed files with 163 additions and 160 deletions.
2 changes: 1 addition & 1 deletion examples/minimal-mdns/PacketReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void PrintQName(mdns::Minimal::SerializedQNameIterator it)

void PacketReporter::OnHeader(mdns::Minimal::ConstHeaderRef & header)
{
printf("%s%s %d (%d, %d, %d, %d):\n", mPrefix, header.GetFlags().IsQuery() ? "QUERY" : "REPLY", header.GetMessageId(),
printf("%s%s %d (%d, %d, %d, %d):\n", mPrefix, header.GetFlags().IsQuery() ? "QUERY" : "REPLY", header.GetMessageCounter(),
header.GetQueryCount(), header.GetAnswerCount(), header.GetAuthorityCount(), header.GetAdditionalCount());
}

Expand Down
6 changes: 3 additions & 3 deletions examples/minimal-mdns/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ struct Options
mdns::Minimal::QType type = mdns::Minimal::QType::ANY;
} gOptions;

constexpr uint32_t kTestMessageId = 0x1234;
constexpr size_t kMdnsMaxPacketSize = 1'024;
constexpr uint32_t kTestMessageCounter = 0x1234;
constexpr size_t kMdnsMaxPacketSize = 1'024;

using namespace chip::ArgParser;

Expand Down Expand Up @@ -263,7 +263,7 @@ void BroadcastPacket(mdns::Minimal::ServerBase * server)

mdns::Minimal::QueryBuilder builder(std::move(buffer));

builder.Header().SetMessageId(kTestMessageId);
builder.Header().SetMessageCounter(kTestMessageCounter);
builder.AddQuery(query
.MdnsQuery() //
.SetClass(mdns::Minimal::QClass::IN) //
Expand Down
6 changes: 3 additions & 3 deletions examples/minimal-mdns/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ class ReplyDelegate : public mdns::Minimal::ServerDelegate, public mdns::Minimal
}

// ParserDelegate
void OnHeader(mdns::Minimal::ConstHeaderRef & header) override { mMessageId = header.GetMessageId(); }
void OnHeader(mdns::Minimal::ConstHeaderRef & header) override { mMessageCounter = header.GetMessageCounter(); }
void OnResource(mdns::Minimal::ResourceType type, const mdns::Minimal::ResourceData & data) override {}

void OnQuery(const mdns::Minimal::QueryData & data) override
{
if (mResponder->Respond(mMessageId, data, mCurrentSource) != CHIP_NO_ERROR)
if (mResponder->Respond(mMessageCounter, data, mCurrentSource) != CHIP_NO_ERROR)
{
printf("FAILED to respond!\n");
}
Expand All @@ -158,7 +158,7 @@ class ReplyDelegate : public mdns::Minimal::ServerDelegate, public mdns::Minimal

mdns::Minimal::ResponseSender * mResponder;
const Inet::IPPacketInfo * mCurrentSource = nullptr;
uint32_t mMessageId = 0;
uint32_t mMessageCounter = 0;
};

} // namespace
Expand Down
26 changes: 13 additions & 13 deletions src/app/clusters/messaging-client/messaging-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void emAfPluginMessagingClientClearMessage(EndpointId endpoint)
{
messageTable[ep].valid = false;
messageTable[ep].active = false;
messageTable[ep].messageId = 0x00000000UL;
messageTable[ep].messageCounter = 0x00000000UL;
messageTable[ep].messageControl = 0x00;
messageTable[ep].startTime = 0x00000000UL;
messageTable[ep].endTime = 0x00000000UL;
Expand Down Expand Up @@ -123,9 +123,9 @@ void emberAfMessagingClusterClientTickCallback(EndpointId endpoint)
}
}

bool emberAfMessagingClusterDisplayMessageCallback(app::CommandHandler * commandObj, uint32_t messageId, uint8_t messageControl,
uint32_t startTime, uint16_t durationInMinutes, uint8_t * msg,
uint8_t optionalExtendedMessageControl)
bool emberAfMessagingClusterDisplayMessageCallback(app::CommandHandler * commandObj, uint32_t messageCounter,
uint8_t messageControl, uint32_t startTime, uint16_t durationInMinutes,
uint8_t * msg, uint8_t optionalExtendedMessageControl)
{
EndpointId endpoint = emberAfCurrentEndpoint();
uint8_t ep = emberAfFindClusterClientEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID);
Expand All @@ -134,11 +134,11 @@ bool emberAfMessagingClusterDisplayMessageCallback(app::CommandHandler * command

emberAfMessagingClusterPrint("RX: DisplayMessage"
" 0x%4x, 0x%x, 0x%4x, 0x%2x, \"",
messageId, messageControl, startTime, durationInMinutes);
messageCounter, messageControl, startTime, durationInMinutes);
emberAfMessagingClusterPrintString(msg);
emberAfMessagingClusterPrintln("\"");

if (emberAfPluginMessagingClientPreDisplayMessageCallback(messageId, messageControl, startTime, durationInMinutes, msg,
if (emberAfPluginMessagingClientPreDisplayMessageCallback(messageCounter, messageControl, startTime, durationInMinutes, msg,
optionalExtendedMessageControl))
{
goto kickout;
Expand All @@ -159,7 +159,7 @@ bool emberAfMessagingClusterDisplayMessageCallback(app::CommandHandler * command
if (messageTable[ep].active)
{
// First check whether it is a duplicate message
if (messageId == messageTable[ep].messageId)
if (messageCounter == messageTable[ep].messageCounter)
{
// Duplicate message from a different ESI, add the ESI to the bitmask
if (esiIndex < EMBER_AF_PLUGIN_ESI_MANAGEMENT_ESI_TABLE_SIZE &&
Expand Down Expand Up @@ -187,7 +187,7 @@ bool emberAfMessagingClusterDisplayMessageCallback(app::CommandHandler * command
}

messageTable[ep].clientEndpoint = emberAfCurrentCommand()->apsFrame->destinationEndpoint;
messageTable[ep].messageId = messageId;
messageTable[ep].messageCounter = messageCounter;
messageTable[ep].messageControl = messageControl;
messageTable[ep].startTime = (startTime == ZCL_MESSAGING_CLUSTER_START_TIME_NOW ? now : startTime);
messageTable[ep].endTime =
Expand Down Expand Up @@ -244,7 +244,7 @@ bool emberAfMessagingClusterDisplayMessageCallback(app::CommandHandler * command
return true;
}

bool emberAfMessagingClusterCancelMessageCallback(app::CommandHandler * commandObj, uint32_t messageId, uint8_t messageControl)
bool emberAfMessagingClusterCancelMessageCallback(app::CommandHandler * commandObj, uint32_t messageCounter, uint8_t messageControl)
{
EndpointId endpoint = emberAfCurrentEndpoint();
uint8_t ep = emberAfFindClusterClientEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID);
Expand All @@ -255,9 +255,9 @@ bool emberAfMessagingClusterCancelMessageCallback(app::CommandHandler * commandO
return false;
}

emberAfMessagingClusterPrintln("RX: CancelMessage 0x%4x, 0x%x", messageId, messageControl);
emberAfMessagingClusterPrintln("RX: CancelMessage 0x%4x, 0x%x", messageCounter, messageControl);

if (messageTable[ep].active && messageTable[ep].messageId == messageId)
if (messageTable[ep].active && messageTable[ep].messageCounter == messageCounter)
{
messageTable[ep].active = false;
messageTable[ep].messageControl = messageControl;
Expand Down Expand Up @@ -288,7 +288,7 @@ void emAfPluginMessagingClientPrintInfo(EndpointId endpoint)

emberAfMessagingClusterPrintln(" vld: %p", (messageTable[ep].valid ? "YES" : "NO"));
emberAfMessagingClusterPrintln(" act: %p", (messageTable[ep].active ? "YES" : "NO"));
emberAfMessagingClusterPrintln(" id: 0x%4x", messageTable[ep].messageId);
emberAfMessagingClusterPrintln(" id: 0x%4x", messageTable[ep].messageCounter);
emberAfMessagingClusterPrintln(" mc: 0x%x", messageTable[ep].messageControl);
emberAfMessagingClusterPrintln(" st: 0x%4x", messageTable[ep].startTime);
emberAfMessagingClusterPrintln(" et: 0x%4x", messageTable[ep].endTime);
Expand Down Expand Up @@ -326,7 +326,7 @@ EmberAfStatus emberAfPluginMessagingClientConfirmMessage(EndpointId endpoint)
nodeId = emberLookupNodeIdByEui64(esiEntry->eui64);

emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER), ZCL_MESSAGING_CLUSTER_ID,
ZCL_MESSAGE_CONFIRMATION_COMMAND_ID, "wwus", messageTable[ep].messageId,
ZCL_MESSAGE_CONFIRMATION_COMMAND_ID, "wwus", messageTable[ep].messageCounter,
emberAfGetCurrentTime(), 0x00, "");
// The source and destination are reversed for the confirmation.
emberAfSetCommandEndpoints(messageTable[ep].clientEndpoint, esiEntry->endpoint);
Expand Down
14 changes: 7 additions & 7 deletions src/app/clusters/messaging-server/messaging-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool emberAfMessagingClusterGetLastMessageCallback(app::CommandHandler * command
if (emberAfPluginMessagingServerGetMessage(endpoint, &message))
{
emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_MESSAGING_CLUSTER_ID,
ZCL_DISPLAY_MESSAGE_COMMAND_ID, "wuwvsu", message.messageId, message.messageControl,
ZCL_DISPLAY_MESSAGE_COMMAND_ID, "wuwvsu", message.messageCounter, message.messageControl,
message.startTime, message.durationInMinutes, message.message, message.extendedMessageControl);
emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64;
emberAfSendResponse();
Expand All @@ -109,15 +109,15 @@ bool emberAfMessagingClusterGetLastMessageCallback(app::CommandHandler * command
#if defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_0) || defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_1B) || \
defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_0) || defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_1) || \
defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_1A)
bool emberAfMessagingClusterMessageConfirmationCallback(app::CommandHandler * commandObj, uint32_t messageId,
bool emberAfMessagingClusterMessageConfirmationCallback(app::CommandHandler * commandObj, uint32_t messageCounter,
uint32_t confirmationTime)
#else
bool emberAfMessagingClusterMessageConfirmationCallback(app::CommandHandler * commandObj, uint32_t messageId,
bool emberAfMessagingClusterMessageConfirmationCallback(app::CommandHandler * commandObj, uint32_t messageCounter,
uint32_t confirmationTime, uint8_t messageConfirmationControl,
uint8_t * messageResponse)
#endif
{
emberAfMessagingClusterPrintln("RX: MessageConfirmation 0x%4x, 0x%4x", messageId, confirmationTime);
emberAfMessagingClusterPrintln("RX: MessageConfirmation 0x%4x, 0x%4x", messageCounter, confirmationTime);
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS);
return true;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ void emAfPluginMessagingServerPrintInfo(EndpointId endpoint)

emberAfMessagingClusterPrintln(" vld: %s", (messageIsValid(ep) ? "YES" : "NO"));
emberAfMessagingClusterPrintln(" act: %s", (messageIsCurrentOrScheduled(endpoint) ? "YES" : "NO"));
emberAfMessagingClusterPrintln(" id: 0x%4x", msgTable[ep].messageId);
emberAfMessagingClusterPrintln(" id: 0x%4x", msgTable[ep].messageCounter);
emberAfMessagingClusterPrintln(" mc: 0x%x", (msgTable[ep].messageControl & ~ZCL_MESSAGING_CLUSTER_RESERVED_MASK));
emberAfMessagingClusterPrintln(" st: 0x%4x", msgTable[ep].startTime);
emberAfMessagingClusterPrintln(" now: %s", (messageIsNow(ep) ? "YES" : "NO"));
Expand All @@ -222,7 +222,7 @@ void emberAfPluginMessagingServerDisplayMessage(EmberNodeId nodeId, uint8_t srcE
}

emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_MESSAGING_CLUSTER_ID,
ZCL_DISPLAY_MESSAGE_COMMAND_ID, "wuwvsu", message.messageId, message.messageControl,
ZCL_DISPLAY_MESSAGE_COMMAND_ID, "wuwvsu", message.messageCounter, message.messageControl,
message.startTime, message.durationInMinutes, message.message, message.extendedMessageControl);
emberAfSetCommandEndpoints(srcEndpoint, dstEndpoint);
emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64;
Expand All @@ -245,7 +245,7 @@ void emberAfPluginMessagingServerCancelMessage(EmberNodeId nodeId, uint8_t srcEn
emberAfPluginMessagingServerGetMessage(srcEndpoint, &message);

emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_MESSAGING_CLUSTER_ID,
ZCL_CANCEL_MESSAGE_COMMAND_ID, "wu", message.messageId, message.messageControl);
ZCL_CANCEL_MESSAGE_COMMAND_ID, "wu", message.messageCounter, message.messageControl);
emberAfSetCommandEndpoints(srcEndpoint, dstEndpoint);
emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64;
status = emberAfSendCommandUnicast(MessageSendDestination::Direct(nodeId));
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/messaging-server/messaging-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
typedef struct
{
/** The unique unsigned 32-bit number identifier for this message. */
uint32_t messageId;
uint32_t messageCounter;
/** The control bitmask for this message. */
uint8_t messageControl;
/** The time at which the message becomes valid. */
Expand Down
2 changes: 1 addition & 1 deletion src/app/util/af-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ typedef struct
bool active;
EmberAfPluginEsiManagementBitmask esiBitmask;
chip::EndpointId clientEndpoint;
uint32_t messageId;
uint32_t messageCounter;
uint8_t messageControl;
uint32_t startTime;
uint32_t endTime;
Expand Down
8 changes: 4 additions & 4 deletions src/app/zap-templates/zcl/data-model/silabs/ami.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ limitations under the License.
<description>
Command description for DisplayMessage
</description>
<arg name="messageId" type="INT32U"/>
<arg name="messageCounter" type="INT32U"/>
<arg name="messageControl" type="MessagingControlMask"/>
<arg name="startTime" type="UTC"/>
<arg name="durationInMinutes" type="INT16U"/>
Expand All @@ -86,14 +86,14 @@ limitations under the License.
<description>
The CancelMessage command provides the ability to cancel the sending or acceptance of previously sent messages.
</description>
<arg name="messageId" type="INT32U"/>
<arg name="messageCounter" type="INT32U"/>
<arg name="messageControl" type="MessagingControlMask"/>
</command>
<command source="server" code="0x02" name="DisplayProtectedMessage" optional="true" introducedIn="se-1.2a-07-5356-19" cli="zcl msg disp-protd">
<description>
The DisplayProtected Message command is for use with messages that are protected by a password or PIN.
</description>
<arg name="messageId" type="INT32U"/>
<arg name="messageCounter" type="INT32U"/>
<arg name="messageControl" type="MessagingControlMask"/>
<arg name="startTime" type="UTC"/>
<arg name="durationInMinutes" type="INT16U"/>
Expand All @@ -116,7 +116,7 @@ limitations under the License.
<description>
The Message Confirmation command provides an indication that a Utility Customer has acknowledged and/or accepted the contents of a previously sent message. Enhanced Message Confirmation commands shall contain an answer of 'NO', 'YES' and/or a message confirmation string.
</description>
<arg name="messageId" type="INT32U"/>
<arg name="messageCounter" type="INT32U"/>
<arg name="confirmationTime" type="UTC"/>
<arg name="messageConfirmationControl" type="BITMAP8" introducedIn="se-1.2a-07-5356-19"/>
<arg name="messageResponse" type="OCTET_STRING" introducedIn="se-1.2a-07-5356-19"/>
Expand Down
6 changes: 3 additions & 3 deletions src/lib/mdns/Advertiser_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class AdvertiserMinMdns : public ServiceAdvertiser,
void OnMdnsPacketData(const BytesRange & data, const chip::Inet::IPPacketInfo * info) override;

// ParserDelegate
void OnHeader(ConstHeaderRef & header) override { mMessageId = header.GetMessageId(); }
void OnHeader(ConstHeaderRef & header) override { mMessageCounter = header.GetMessageCounter(); }
void OnResource(ResourceType type, const ResourceData & data) override {}
void OnQuery(const QueryData & data) override;

Expand Down Expand Up @@ -159,7 +159,7 @@ class AdvertiserMinMdns : public ServiceAdvertiser,

// current request handling
const chip::Inet::IPPacketInfo * mCurrentSource = nullptr;
uint32_t mMessageId = 0;
uint32_t mMessageCounter = 0;

const char * mEmptyTextEntries[1] = {
"=",
Expand Down Expand Up @@ -190,7 +190,7 @@ void AdvertiserMinMdns::OnQuery(const QueryData & data)

LogQuery(data);

CHIP_ERROR err = mResponseSender.Respond(mMessageId, data, mCurrentSource);
CHIP_ERROR err = mResponseSender.Respond(mMessageCounter, data, mCurrentSource);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Discovery, "Failed to reply to query: %s", ErrorStr(err));
Expand Down
4 changes: 2 additions & 2 deletions src/lib/mdns/Resolver_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ CHIP_ERROR MinMdnsResolver::SendQuery(mdns::Minimal::FullQName qname, mdns::Mini
ReturnErrorCodeIf(buffer.IsNull(), CHIP_ERROR_NO_MEMORY);

QueryBuilder builder(std::move(buffer));
builder.Header().SetMessageId(0);
builder.Header().SetMessageCounter(0);

mdns::Minimal::Query query(qname);
query.SetType(type).SetClass(mdns::Minimal::QClass::IN);
Expand Down Expand Up @@ -490,7 +490,7 @@ CHIP_ERROR MinMdnsResolver::ResolveNodeId(const PeerId & peerId, Inet::IPAddress
ReturnErrorCodeIf(buffer.IsNull(), CHIP_ERROR_NO_MEMORY);

QueryBuilder builder(std::move(buffer));
builder.Header().SetMessageId(0);
builder.Header().SetMessageCounter(0);

{
char nameBuffer[64] = "";
Expand Down
6 changes: 3 additions & 3 deletions src/lib/mdns/minimal/ResponseSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ CHIP_ERROR ResponseSender::AddQueryResponder(QueryResponderBase * queryResponder
return CHIP_ERROR_NO_MEMORY;
}

CHIP_ERROR ResponseSender::Respond(uint32_t messageId, const QueryData & query, const chip::Inet::IPPacketInfo * querySource)
CHIP_ERROR ResponseSender::Respond(uint32_t messageCounter, const QueryData & query, const chip::Inet::IPPacketInfo * querySource)
{
mSendState.Reset(messageId, query, querySource);
mSendState.Reset(messageCounter, query, querySource);

// Responder has a stateful 'additional replies required' that is used within the response
// loop. 'no additionals required' is set at the start and additionals are marked as the query
Expand Down Expand Up @@ -185,7 +185,7 @@ CHIP_ERROR ResponseSender::PrepareNewReplyPacket()
ReturnErrorCodeIf(buffer.IsNull(), CHIP_ERROR_NO_MEMORY);

mResponseBuilder.Reset(std::move(buffer));
mResponseBuilder.Header().SetMessageId(mSendState.GetMessageId());
mResponseBuilder.Header().SetMessageCounter(mSendState.GetMessageCounter());

if (mSendState.IncludeQuery())
{
Expand Down
Loading

0 comments on commit effb14e

Please sign in to comment.