Hi
I have managed to get a SNTP client working. I want to update the date-time clock with the SNTP timestamp. From the SNTP client I get a sntp_time object:
/** * @brief Perform SNTP query * * @param ctx Address of sntp context. * @param timeout Timeout of waiting for sntp response (in milliseconds). * @param time Timestamp including integer and fractional seconds since * 1 Jan 1970 (output). * * @return 0 if ok, <0 if error (-ETIMEDOUT if timeout). */ int sntp_query(struct sntp_ctx *ctx, uint32_t timeout, struct sntp_time *time);
While the date_time_set function takes a tm object.
/** @brief Set the current date time. * * @note See http://www.cplusplus.com/reference/ctime/tm/ for accepted input * format. * * @param[in] new_date_time Pointer to a tm structure. * * @return 0 If the operation was successful. * @return -EINVAL If a member of the passing variable new_date_time does not * adhere to the tm structure format, or pointer is passed in as NULL. */ int date_time_set(const struct tm *new_date_time);
How would I convert this sntp_time object to a tm object. And would it be possible to just send in the sntp_time object directly somehow?
The reason I have to send the timestamps manually is due to having to support both Ethernet and WiFi, where the WiFi stack is not running in Zephyr.