Rdzleo dbdd304905 代码初始化:
本项目为触摸版项目代码复制而来,基于此版本进行按键功能的适配!
2026-03-23 11:14:56 +08:00
..
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00

ESP-Brookesia SNTP Service

Overview

brookesia_service_sntp is an SNTP (Simple Network Time Protocol) service for the ESP-Brookesia ecosystem, providing:

  • NTP Server Management: Supports configuring multiple NTP servers and automatically selects available servers from the server list for time synchronization
  • Timezone Settings: Supports setting system timezone and automatically applies timezone offset
  • Automatic Time Synchronization: Automatically detects network connection status and starts time synchronization when network is available
  • Status Query: Supports querying time synchronization status, currently configured server list, and timezone information
  • Persistent Storage: Optionally works with brookesia_service_nvs service to persistently save NTP server list and timezone information

Table of Contents

Features

NTP Server Management

The SNTP service supports configuring multiple NTP servers:

  • Default Server: Uses "pool.ntp.org" as the default NTP server
  • Multiple Server Support: Can configure multiple NTP servers, and the service will automatically select available servers
  • Server List: Supports getting the list of all currently configured NTP servers

Timezone Settings

The SNTP service supports setting system timezone:

  • Default Timezone: Default timezone is "CST-8" (China Standard Time, UTC+8)
  • Timezone Format: Supports standard timezone string formats (such as "UTC", "CST-8", "EST-5", etc.)
  • Automatic Application: Automatically applies to system time after setting timezone

Core Functions

  • Set NTP Servers: Supports setting one or multiple NTP servers
  • Set Timezone: Supports setting system timezone
  • Start Service: Starts the SNTP service and begins time synchronization
  • Stop Service: Stops the SNTP service and stops time synchronization
  • Get Server List: Gets the list of currently configured NTP servers
  • Get Timezone: Gets the currently configured timezone
  • Check Sync Status: Checks whether system time has been synchronized with NTP servers
  • Reset Data: Resets all configuration data to default values

Automatic Management

  • Automatic Configuration Loading: Automatically loads saved configuration from NVS when service starts
  • Automatic Configuration Saving: Automatically saves configuration to NVS after configuration changes
  • Network Detection: Automatically detects network connection status and starts time synchronization when network is available
  • Status Monitoring: Automatically monitors time synchronization status and updates sync flag

Development Environment Requirements

Before using this library, please ensure the following SDK development environment is installed:

Note

For SDK installation instructions, please refer to ESP-IDF Programming Guide - Installation

Adding to Project

brookesia_service_sntp has been uploaded to the Espressif Component Registry. You can add it to your project in the following ways:

  1. Using Command Line

    Run the following command in your project directory:

    idf.py add-dependency "espressif/brookesia_service_sntp"
    
  2. Modify Configuration File

    Create or modify the idf_component.yml file in your project directory:

    dependencies:
      espressif/brookesia_service_sntp: "*"
    

For detailed instructions, please refer to Espressif Documentation - IDF Component Manager.