Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed Nov 16, 2021
1 parent 2af8019 commit 8dda88a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/app/EventLoggingTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ struct Timestamp
{
enum class Type
{
kInvalid = 0,
kSystem,
kSystem = 0,
kEpoch
};
Timestamp() {}
Expand All @@ -129,11 +128,10 @@ struct Timestamp
return timestamp;
}

bool IsValid() { return mType != Type::kInvalid; }
bool IsSystem() { return mType == Type::kSystem; }
bool IsEpoch() { return mType == Type::kEpoch; }

Type mType = Type::kInvalid;
Type mType = Type::kSystem;
uint64_t mValue = 0;
};

Expand All @@ -148,9 +146,9 @@ class EventOptions
kUrgent = 0,
kNotUrgent,
};
EventOptions(void) : mTimestamp(Timestamp::Type::kInvalid), mpEventSchema(nullptr), mUrgent(Type::kNotUrgent) {}
EventOptions(void) : mTimestamp(Timestamp::Type::kSystem), mpEventSchema(nullptr), mUrgent(Type::kNotUrgent) {}

EventOptions(Type aType) : mTimestamp(Timestamp::Type::kInvalid), mpEventSchema(nullptr), mUrgent(aType) {}
EventOptions(Type aType) : mTimestamp(Timestamp::Type::kSystem), mpEventSchema(nullptr), mUrgent(aType) {}

EventOptions(Timestamp aTimestamp) : mTimestamp(aTimestamp), mpEventSchema(nullptr), mUrgent(Type::kNotUrgent) {}

Expand Down
1 change: 0 additions & 1 deletion src/app/EventManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ CHIP_ERROR EventManagement::ConstructEvent(EventLoadOutContext * apContext, Even
/* no-op: don't write event, but advance current event Number */);

VerifyOrExit(apOptions != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(apOptions->mTimestamp.mType != Timestamp::Type::kInvalid, err = CHIP_ERROR_INVALID_ARGUMENT);

eventReportBuilder.Init(&(apContext->mWriter));
// TODO: Update IsUrgent, issue 11386
Expand Down
4 changes: 3 additions & 1 deletion src/app/MessageDef/EventDataIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ CHIP_ERROR EventDataIB::Parser::ProcessEventTimestamp(EventHeader & aEventHeader
bool hasEpochTimestamp = false;
bool hasDeltaSystemTimestamp = false;
bool hasDeltaEpochTimestamp = false;
err = GetDeltaSystemTimestamp(&timeStampVal);

err = GetDeltaSystemTimestamp(&timeStampVal);
if (err == CHIP_END_OF_TLV)
{
err = CHIP_NO_ERROR;
Expand All @@ -424,6 +425,7 @@ CHIP_ERROR EventDataIB::Parser::ProcessEventTimestamp(EventHeader & aEventHeader
}
else if (err == CHIP_NO_ERROR)
{
VerifyOrReturnError(aEventHeader.mTimestamp.IsEpoch(), CHIP_ERROR_IM_MALFORMED_EVENT_DATA_ELEMENT);
aEventHeader.mTimestamp.mValue += timeStampVal;
hasDeltaEpochTimestamp = true;
}
Expand Down
8 changes: 5 additions & 3 deletions src/app/ReadClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class ReadClient : public Messaging::ExchangeDelegate
*
* @param[in] apReadClient: The read client object that initiated the read or subscribe transaction.
* @param[in] aEventHeader: The event header in report response.
* @param[in] apData: The event data of the given path, will be a nullptr if status is not Success.
* @param[in] apData: A TLVReader positioned right on the payload of the event. This will be set to null if the apStatus is
* not null.
* @param[in] apStatus: Event-specific status, containing an InteractionModel::Status code as well as an optional
* cluster-specific status code.
*/
Expand Down Expand Up @@ -269,12 +270,13 @@ class ReadClient : public Messaging::ExchangeDelegate
* @param [in] aEvent The event data.
*/
template <typename EventDataT>
CHIP_ERROR CheckEventHeaderWithClusterObject(const EventHeader & aEventHeader, const EventDataT & aEvent)
CHIP_ERROR CheckEventHeaderWithClusterObject(const EventHeader & aEventHeader, const EventDataT & aEvent,
TLV::TLVReader & aReader)
{
VerifyOrReturnError((aEventHeader.mPath.mEventId == aEvent.GetEventId()) &&
(aEventHeader.mPath.mClusterId == aEvent.GetClusterId()),
CHIP_ERROR_INVALID_ARGUMENT);
return CHIP_NO_ERROR;
return DataModel::Decode(aReader, aEvent);
}

/**
Expand Down

0 comments on commit 8dda88a

Please sign in to comment.