-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Sntp_ReceiveTimeResponse API #16
Add Sntp_ReceiveTimeResponse API #16
Conversation
1cc09f7
to
81c79f5
Compare
81c79f5
to
47adf0a
Compare
SntpStatus_t Sntp_Init( SntpContext_t * pContext, | ||
const SntpServerInfo_t * pTimeServers, | ||
size_t numOfServers, | ||
uint32_t serverResponseTimeoutMs, | ||
uint8_t * pNetworkBuffer, | ||
size_t bufferSize, | ||
SntpResolveDns_t resolveDnsFunc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a caller of this function, it's hard for me to tell how each parameter is related to one another. Might it be worth grouping parameters into separate structs to make the relationships self-documenting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, can take that hygiene in a separate PR 🙂
Co-authored-by: Oscar Michael Abrina <[email protected]>
Add a
Sntp_ReceiveTimeResponse
API to allow application to obtain the response for a time request that was made to a server (withSntp_SendTimeRequest
API).The API looks at 3 different timeouts in its operations:
Server Response timeout - This PR adds a responseTimeoutMs state to the
SntpContext_t
to allow the application to specify timeouts for server responses (to time requests). The timeout period for a server starts after theSntp_SendTimeRequest
API is called to send a request to the server. TheSntp_ReceiveTimeResponse
API keeps a track of whether server response has timed out whenever it is called, and returns aSntpServerResponseTimeout
error code (even if the blockTimeMs value still allows more time window for waiting on server response).Block Time - The API takes a blockTimeMs parameter which determines the maximum amount of time the function will block waiting for the server response UNLESS either the server response is received OR the server response has timed out OR there is a network read error encountered (like hitting a read retry timeout)
Read Retry Timeout - This PR adds an
SNTP_RECV_POLLING_TIMEOUT_MS
configuration macro that represents the maximum time window of retrying zero data reads. This window is only initiated after some partial data is initially read from the network. The rationale is that when some initial data is available from the network, then it is likely that the remaining SNTP response packet will be available and thus, the read retry timeout window starts. TheSntp_ReceiveTimeResponse
API uses this configuration value to retry partial data reads on the network.