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

Fix slow SNTP sync from cold boot #1325

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `code:all_loaded/0` and `code:all_available/0`
- Added menuconfig option for enabling USE_USB_SERIAL, eg. serial over USB for certain ESP32-S2 boards etc.

### Fixed
- ESP32: improved sntp sync speed from a cold boot.

## [0.6.6] - Unreleased

### Added
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/esp32/components/avm_builtins/network_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_
case IP_EVENT_STA_GOT_IP: {
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP: %s", inet_ntoa(event->ip_info.ip));
// we restart sntp here for faster time sync (especially evident on coldboots)
// the sntp_restart is no-op if sntp isn't configured
esp_sntp_restart();
petermm marked this conversation as resolved.
Show resolved Hide resolved
petermm marked this conversation as resolved.
Show resolved Hide resolved
send_got_ip(data, (esp_netif_ip_info_t *) &event->ip_info.ip);
break;
}
Expand Down
Loading