rtc/rpmsg: when a client connection, server initiates time sync

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2022-04-02 14:27:20 +08:00 committed by Xiang Xiao
parent 6e1244c274
commit 1c342328de

View File

@ -703,6 +703,8 @@ static void rpmsg_rtc_server_ns_bind(FAR struct rpmsg_device *rdev,
{
FAR struct rpmsg_rtc_server_s *server = priv;
FAR struct rpmsg_rtc_client_s *client;
struct rpmsg_rtc_set_s msg;
struct rtc_time rtctime;
if (strcmp(name, RPMSG_RTC_EPT_NAME))
{
@ -725,6 +727,14 @@ static void rpmsg_rtc_server_ns_bind(FAR struct rpmsg_device *rdev,
return;
}
if (server->lower->ops->rdtime(server->lower, &rtctime) >= 0)
{
msg.sec = timegm((FAR struct tm *)&rtctime);
msg.nsec = rtctime.tm_nsec;
msg.header.command = RPMSG_RTC_SYNC;
rpmsg_send(&client->ept, &msg, sizeof(msg));
}
nxsem_wait_uninterruptible(&server->exclsem);
list_add_tail(&server->list, &client->node);
nxsem_post(&server->exclsem);