#2042: ntp_client test fixes.

This commit is contained in:
Nick Todd
2023-11-20 18:06:50 +00:00
parent 95ad55a783
commit b0b37f9da5

View File

@@ -89,8 +89,7 @@ class NTPClient(Service):
if not (isinstance(payload, NTPPacket) and payload.ntp_request.ntp_client):
_LOGGER.debug(f"{payload} is not a NTPPacket")
return False
# XXX: compare received datetime with current time. Log error if differ by more than x ms?
print(f">>>>>>>>>>>>>>>>>> payload.ntp_reply.ntp_datetime {payload.ntp_reply.ntp_datetime}")
if payload.ntp_reply.ntp_datetime:
self.sys_log.info(
f"{self.name}: Received time \
@@ -112,8 +111,9 @@ class NTPClient(Service):
super().apply_timestep(timestep)
if self.operating_state == ServiceOperatingState.RUNNING:
# request time from server
ntp_request = NTPPacket(NTPRequest())
self.send(ntp_request)
ntp_request = NTPRequest(ntp_client=self.ip_addr)
ntp_server_packet = NTPPacket(ntp_request=ntp_request)
self.send(payload=ntp_server_packet)
return True
else:
self.sys_log.debug(f"{self.name} ntp client not running")