I am currently working on a project using your device (nRF9161), and I need some assistance with incorporating the current date and time into my log messages. Specifically, I want to include the hour, minute, second, and millisecond of the current day in the log outputs.
Here is what I have tried so far:
-
Initially, I attempted to use the
gettimeofday
function to obtain the current time with microsecond precision and format it accordingly. However, this resulted in the following error during the build process: - I then switched to using
clock_gettime
, which led to a similar error indicating thatclock_gettime
is not supported in the current environment. - Finally, I attempted to use Zephyr's
k_uptime_get
to get the system uptime in milliseconds, but this approach only provides the time since the system booted up, not the current wall-clock time of the day.
Given these challenges, I would appreciate your guidance on how to achieve the desired functionality within the constraints of the Zephyr environment. Is there a recommended way to get the current wall-clock time with millisecond precision on this platform?
Below is a snippet of my current attempt using gettimeofday
:
Thank you for your support.