Skip to content

Commit

Permalink
add epoch timestamp in IM Event
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed Nov 30, 2021
1 parent 46fbb06 commit 0775c5e
Show file tree
Hide file tree
Showing 24 changed files with 371 additions and 99 deletions.
2 changes: 1 addition & 1 deletion config/python/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#define CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT 1

#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2

Expand Down
2 changes: 1 addition & 1 deletion config/standalone/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#define CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT 1

#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2

Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-app/p6/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/include/CHIPProjectAppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#define CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT 1

#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/p6/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/qpg/project_include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
2 changes: 1 addition & 1 deletion examples/shell/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 0

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
Expand Down
22 changes: 10 additions & 12 deletions src/app/EventLoggingTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct Timestamp
Timestamp(Type aType) : mType(aType) { mValue = 0; }
Timestamp(Type aType, uint64_t aValue) : mType(aType), mValue(aValue) {}
Timestamp(System::Clock::Timestamp aValue) : mType(Type::kSystem), mValue(aValue.count()) {}
static Timestamp UTC(uint64_t aValue)
static Timestamp Epoch(uint64_t aValue)
{
Timestamp timestamp(Type::kEpoch, aValue);
return timestamp;
Expand All @@ -128,8 +128,8 @@ struct Timestamp
return timestamp;
}

bool IsSystem() { return mType == Type::kSystem; }
bool IsEpoch() { return mType == Type::kEpoch; }
bool IsSystem() const { return mType == Type::kSystem; }
bool IsEpoch() const { return mType == Type::kEpoch; }

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

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

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

Expand All @@ -168,18 +168,16 @@ class EventOptions
struct EventLoadOutContext
{
EventLoadOutContext(TLV::TLVWriter & aWriter, PriorityLevel aPriority, EventNumber aStartingEventNumber) :
mWriter(aWriter), mPriority(aPriority), mStartingEventNumber(aStartingEventNumber),
mCurrentSystemTime(Timestamp::Type::kSystem), mCurrentEventNumber(0), mCurrentUTCTime(Timestamp::Type::kEpoch), mFirst(true)
mWriter(aWriter), mPriority(aPriority), mStartingEventNumber(aStartingEventNumber), mCurrentEventNumber(0), mFirst(true)
{}

TLV::TLVWriter & mWriter;
PriorityLevel mPriority = PriorityLevel::Invalid;
EventNumber mStartingEventNumber = 0;
Timestamp mPreviousSystemTime;
Timestamp mCurrentSystemTime;
EventNumber mCurrentEventNumber = 0;
size_t mEventCount = 0;
Timestamp mCurrentUTCTime;
Timestamp mPreviousTime;
Timestamp mCurrentTime;
EventNumber mCurrentEventNumber = 0;
size_t mEventCount = 0;
ClusterInfo * mpInterestedEventPaths = nullptr;
bool mFirst = true;
};
Expand Down
Loading

0 comments on commit 0775c5e

Please sign in to comment.