GoogleCloudPlatform / iot-device-sdk-embedded-c

Cloud IoT Device SDK for Connectivity to IoT Core.
Other
247 stars 83 forks source link

Add API to get monotonic time #43

Closed sungjud closed 5 years ago

sungjud commented 5 years ago

Support getting monotonic time.

DellaBitta commented 5 years ago

I see that this PR adds the functions but nobody calls it? Why are we adding this exactly?

Concerns: What if a device doesn't have monotonic time support? Most tick counters are in milliseconds.

Is this for Roughtime? If so, then I would add some comments in the BSP header that says that this is an optional function & is needed for Roughtime support only. Then add a link to our roughtime documentation for the client.

fredrec commented 5 years ago

I see that this PR adds the functions but nobody calls it? Why are we adding this exactly?

Answered bellow.

Concerns: What if a device doesn't have monotonic time support? Most tick counters are in milliseconds.

All devices must have monotonic time counter (granted, some might overflow). That's the base for implementing anything that require measuring elapsed time, including time of day.

It seems indeed that most ticks are in milliseconds, we should set the precision to that.

Is this for Roughtime? If so, then I would add some comments in the BSP header that says that this is an optional function & is needed for Roughtime support only. Then add a link to our roughtime documentation for the client.

This is for Roughtime, but it might be used by any other code that need to measure elapsed time. Also, the added code size should be minimal. Given those two, I don't think it needs to be optional