Skip to content

Time migration#177

Open
rslater-cs wants to merge 16 commits intomigration-basefrom
time-migration
Open

Time migration#177
rslater-cs wants to merge 16 commits intomigration-basefrom
time-migration

Conversation

@rslater-cs
Copy link
Contributor

@rslater-cs rslater-cs commented Mar 17, 2026

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Description

This is the migration of the time service to the new fibers library, as well as annotations and linting fixes.

The previous iteration of devicecode did not faithfully follow the distinction of what should be done via HAL, this mean service restarts and commands which should have been abstracted via the capability interface were instead being directly called in the time service. The new time service now interacts with a time driver which supplies time sync events and time accuracy metadata.

Added to HAL:

  • A time manager, takes an empty config and constructs a time driver
  • A time driver, restarts ntp and monitors ubus for time sync events, exposes a time capability
  • A time backend which detects linux with ubus and provides a ntp_sync op

The time service currently only listens to once time capability, but will now be more capable to be extended to multiple time capabilities once modems expose their time functionalities in the future. Check the time spec for more detail.

Manual test

  • 👍 yes
  • 🙅 no

Manual test description

On a bigbox:
date -s "2025-11-18 15:00:00"
DEVICECODE_CONFIG_DIR=./configs/ DEVICECODE_SERVICES=config,hal,gsm,time luajit main.lua
You should see the time in the logs jump from 15:00 to the current real time along with a log from the time service notifying of a time event

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation?

  • 📜 docs/specs/time.md
  • 🙅 no documentation needed

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the time service to the newer fibers APIs and moves OS-facing time-sync responsibilities into HAL via a new time manager/driver that emits a time capability for services to consume.

Changes:

  • Added a new time service that discovers a HAL time capability, consumes retained sync state + transition events, and publishes system-wide svc/time/synced.
  • Added a HAL time manager + time driver that restarts sysntpd, listens for NTP hotplug/ubus events, and emits capability meta/state/events.
  • Added time configuration stub plus a new time service spec document.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/services/time.lua New time service consuming HAL time capability and publishing sync state/events.
src/services/hal/types/capabilities.lua Refactors capability constructors to use fixed classes for several capability types.
src/services/hal/managers/time/ntp Hotplug script to forward NTP updates via ubus events.
src/services/hal/managers/time.lua New HAL time manager that installs the hotplug script and manages the time driver lifecycle.
src/services/hal/drivers/time.lua New HAL time driver that restarts sysntpd, monitors ubus NTP events, and emits capability state/meta/events.
src/configs/config.json Adds an empty time config section for HAL manager configuration consistency.
docs/specs/time.md Documents the new time service behavior and bus topics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@rslater-cs rslater-cs marked this pull request as ready for review March 17, 2026 13:09
@rslater-cs rslater-cs deleted the branch migration-base March 24, 2026 16:07
@rslater-cs rslater-cs closed this Mar 24, 2026
@rslater-cs rslater-cs reopened this Mar 24, 2026
@rslater-cs rslater-cs changed the base branch from hal-migration to migration-base March 24, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants