SNTP
Component registry: espressif/brookesia_service_sntp
Helper header:
#include "brookesia/service_helper/sntp.hpp"Helper class:
esp_brookesia::service::helper::SNTP
Overview
brookesia_service_sntp provides SNTP (Simple Network Time Protocol) for the ESP-Brookesia ecosystem:
NTP servers: Multiple servers; picks an available one.
Time zone: System time zone with offset applied.
Auto sync: Starts when the network is up.
Status: Query sync state, server list, and zone.
Persistence: Optional brookesia_service_nvs for servers and zone.
Features
NTP Servers
Default:
"pool.ntp.org".Multiple servers with automatic selection.
Query the configured list.
Time Zone
Default: CST-8 (China, UTC+8).
Standard zone strings (
UTC,CST-8,EST-5, …).Applied to system time when set.
Core Operations
Set NTP servers: Configure one or more NTP servers.
Set time zone: Configure the system time zone.
Start / stop service: Start or stop SNTP and time synchronization.
Get server list: Read the configured NTP server list.
Get time zone: Read the configured time zone.
Check sync status: Check whether system time is synchronized with NTP.
Reset data: Reset all configuration to defaults.
Auto Management
Load from NVS on start.
Save after changes.
Detect network and start sync when available.
Monitor sync status and flags.
Standard Include / Helper Class
Standard include:
#include \"brookesia/service_helper/sntp.hpp\"Helper class:
esp_brookesia::service::helper::SNTP
Service Interfaces
Functions
SetServers
Description
Set NTP servers.
Execution
Requires scheduler: Not required
Parameters
ServersType:
ArrayRequired: required
Description: NTP servers as JSON array<string>. Example: [“pool.ntp.org”,”cn.pool.ntp.org”]
Schema JSON
Show raw JSON
{
"name": "SetServers",
"description": "Set NTP servers.",
"require_scheduler": false,
"parameters": [
{
"name": "Servers",
"description": "NTP servers as JSON array<string>. Example: [\"pool.ntp.org\",\"cn.pool.ntp.org\"]",
"type": "Array",
"required": true,
"default_value": null
}
]
}
CLI Command
svc_call SNTP SetServers {"Servers":null}
SetTimezone
Description
Set timezone.
Execution
Requires scheduler: Not required
Parameters
TimezoneType:
StringRequired: required
Description: Timezone string.
Schema JSON
Show raw JSON
{
"name": "SetTimezone",
"description": "Set timezone.",
"require_scheduler": false,
"parameters": [
{
"name": "Timezone",
"description": "Timezone string.",
"type": "String",
"required": true,
"default_value": null
}
]
}
CLI Command
svc_call SNTP SetTimezone {"Timezone":null}
Start
Description
Start SNTP service.
Execution
Requires scheduler: Required
Parameters
No parameters.
Schema JSON
Show raw JSON
{
"name": "Start",
"description": "Start SNTP service.",
"require_scheduler": true,
"parameters": []
}
CLI Command
svc_call SNTP Start
Stop
Description
Stop SNTP service.
Execution
Requires scheduler: Required
Parameters
No parameters.
Schema JSON
Show raw JSON
{
"name": "Stop",
"description": "Stop SNTP service.",
"require_scheduler": true,
"parameters": []
}
CLI Command
svc_call SNTP Stop
GetServers
Description
Get NTP servers. Return type: JSON array<string>. Example: [“pool.ntp.org”,”cn.pool.ntp.org”]
Execution
Requires scheduler: Required
Parameters
No parameters.
Schema JSON
Show raw JSON
{
"name": "GetServers",
"description": "Get NTP servers. Return type: JSON array<string>. Example: [\"pool.ntp.org\",\"cn.pool.ntp.org\"]",
"require_scheduler": true,
"parameters": []
}
CLI Command
svc_call SNTP GetServers
GetTimezone
Description
Get timezone. Return type: string. Example: “CST-8”
Execution
Requires scheduler: Required
Parameters
No parameters.
Schema JSON
Show raw JSON
{
"name": "GetTimezone",
"description": "Get timezone. Return type: string. Example: \"CST-8\"",
"require_scheduler": true,
"parameters": []
}
CLI Command
svc_call SNTP GetTimezone
IsTimeSynced
Description
Check whether time is synced. Return type: boolean. Example: true
Execution
Requires scheduler: Required
Parameters
No parameters.
Schema JSON
Show raw JSON
{
"name": "IsTimeSynced",
"description": "Check whether time is synced. Return type: boolean. Example: true",
"require_scheduler": true,
"parameters": []
}
CLI Command
svc_call SNTP IsTimeSynced
ResetData
Description
Reset NTP servers, timezone, and sync status.
Execution
Requires scheduler: Required
Parameters
No parameters.
Schema JSON
Show raw JSON
{
"name": "ResetData",
"description": "Reset NTP servers, timezone, and sync status.",
"require_scheduler": true,
"parameters": []
}
CLI Command
svc_call SNTP ResetData
Events
This contract does not publish standard event schemas.