Skip to content
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

Periodically update boards' local time and synchronize flushes #54

Closed
marcomicera opened this issue Nov 18, 2019 · 10 comments
Closed

Periodically update boards' local time and synchronize flushes #54

marcomicera opened this issue Nov 18, 2019 · 10 comments
Assignees
Labels
board Code concerning ESP32 firmware

Comments

@marcomicera
Copy link
Owner

Could be done:

  • Periodically, by another task
  • Every time the boards gets an IP address from the AP

Second one looks easier.

@marcomicera marcomicera added the board Code concerning ESP32 firmware label Nov 18, 2019
@marcomicera marcomicera added this to the Soft requirements milestone Nov 18, 2019
@suidpit
Copy link
Collaborator

suidpit commented Nov 19, 2019

Agreed, second one looks cool and we stay super in sync. Maybe we can establish a counter, like every 5 flushes. I don't think the performance would improve any noticeably, but still I think syncining at every flush is not needed.

@marcomicera
Copy link
Owner Author

marcomicera commented Nov 19, 2019

So the only way to send an SNTP request via a method exposed by sntp.h is through void sntp_init(void), which is defined here and this is its definition. At this line sntp_request gets called only if (sntp_pcb == NULL).

sntp_pcb can only be set to NULL inside the sntp_stop function, which would make me think that I'd need to stop and start the SNTP module every time I want to synchronize the board's current date/time.

However, this makes me think that the board is already sending SNTP requests periodically in the background, and the board is already set in this mode:

/* Choices:
*
* - SNTP_OPMODE_POLL: polling mode using unicast.
* - SNTP_OPMODE_LISTENONLY
*/
sntp_setoperatingmode(SNTP_OPMODE_POLL);

@madt1m what do you think?

@suidpit
Copy link
Collaborator

suidpit commented Nov 20, 2019

Let's sniff and see if NTP requests are sent periodically. I will also check the source code of the sntp module.

@marcomicera
Copy link
Owner Author

Nope, NTP requests are not sent periodically, I was wrong. I'll keep diving in.

@marcomicera marcomicera removed their assignment Nov 21, 2019
@simonasaitta
Copy link
Collaborator

What about have it set up by the server together with the synchronization? I have some idea of how it could be done. I can work on it tonight

@simonasaitta simonasaitta self-assigned this Nov 22, 2019
@suidpit suidpit changed the title Periodically update boards' local time Periodically update boards' local time and synchronize flushes Nov 23, 2019
@suidpit
Copy link
Collaborator

suidpit commented Nov 23, 2019

After a brief discussion, we've come up with some ideas to mantain timestamps synced and use that information to sync flushes on the same timeslot for every board.
Basically, once the boards are synced, it will be enough for the board to wait until the threshold of the minute (hh:mm:00) and then trigger the flush. This should ensure somewhat synced flushes among all the system.

@marcomicera marcomicera assigned suidpit and unassigned simonasaitta Nov 23, 2019
@simonasaitta simonasaitta self-assigned this Nov 27, 2019
@simonasaitta
Copy link
Collaborator

Synchronization among boards should have been fixed here 23c7c08. Only synchronization with server is left

@marcomicera
Copy link
Owner Author

Needed for long-term statistics.

@marcomicera marcomicera self-assigned this Dec 21, 2019
@suidpit
Copy link
Collaborator

suidpit commented Dec 21, 2019

Cherry-picked in 177eb20. After a few tests, we can close this.

@marcomicera
Copy link
Owner Author

I'll test this one out since I'm the only one that has more than one board. If I'm wrong, please let me know...

@marcomicera marcomicera pinned this issue Jan 22, 2020
suprmat95 pushed a commit to suprmat95/followifier-1 that referenced this issue Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
board Code concerning ESP32 firmware
Projects
None yet
Development

No branches or pull requests

3 participants