rtc/rpmsg: when a client connection, server initiates time sync
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
6e1244c274
commit
1c342328de
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user