Skip to content

Commit

Permalink
add epoch timestamp in IM Event (#12185)
Browse files Browse the repository at this point in the history
* add epoch timestamp in IM Event

* update epoch with type safe
  • Loading branch information
yunhanw-google authored and pull[bot] committed Jan 25, 2022
1 parent f6d2780 commit 1031280
Show file tree
Hide file tree
Showing 26 changed files with 423 additions and 166 deletions.
2 changes: 0 additions & 2 deletions config/python/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#define CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT 1

#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2

#define CHIP_CONFIG_EVENT_LOGGING_EXTERNAL_EVENT_SUPPORT 1
Expand Down
2 changes: 0 additions & 2 deletions config/standalone/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

#define CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT 1

#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2

#define CHIP_CONFIG_EVENT_LOGGING_EXTERNAL_EVENT_SUPPORT 1
Expand Down
7 changes: 0 additions & 7 deletions examples/all-clusters-app/p6/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@
*/
#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN"

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
2 changes: 0 additions & 2 deletions examples/chip-tool/include/CHIPProjectAppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#define CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT 1

#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2

#define CHIP_CONFIG_EVENT_LOGGING_EXTERNAL_EVENT_SUPPORT 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@
*/
#define CHIP_CONFIG_EVENT_LOGGING_WDM_OFFLOAD 1

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
7 changes: 0 additions & 7 deletions examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@
*/
#define CHIP_CONFIG_EVENT_LOGGING_WDM_OFFLOAD 1

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
7 changes: 0 additions & 7 deletions examples/lock-app/p6/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@
*/
#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN"

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
7 changes: 0 additions & 7 deletions examples/platform/qpg/project_include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@
*/
#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN"

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
7 changes: 0 additions & 7 deletions examples/shell/nxp/k32w/k32w0/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@
*/
#define CHIP_CONFIG_EVENT_LOGGING_WDM_OFFLOAD 1

/**
* CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS
*
* Enable recording UTC timestamps.
*/
#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down
24 changes: 11 additions & 13 deletions src/app/EventLoggingTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ 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(System::Clock::Timestamp aValue)
{
Timestamp timestamp(Type::kEpoch, aValue);
Timestamp timestamp(Type::kEpoch, aValue.count());
return timestamp;
}
static Timestamp System(System::Clock::Timestamp aValue)
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 1031280

Please sign in to comment.