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

ns: Only time sync on absolute time #211

Closed
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
5 changes: 5 additions & 0 deletions pkg/gatewayserver/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@ func (c *Connection) ScheduleDown(path *ttnpb.DownlinkPath, msg *ttnpb.DownlinkM
settings.Time = request.AbsoluteTime
case ttnpb.Class_CLASS_C:
if request.AbsoluteTime != nil {
if !c.scheduler.IsGatewayTimeSynced() {
rxErrs = append(rxErrs, errNoGPSSync.New())
continue
}

f = c.scheduler.ScheduleAt
settings.Time = request.AbsoluteTime
} else {
Expand Down
14 changes: 9 additions & 5 deletions pkg/gatewayserver/scheduling/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@

// RolloverClock is a Clock that takes roll-over of a uint32 microsecond concentrator time into account.
type RolloverClock struct {
synced bool
relative uint32
absolute ConcentratorTime
server *time.Time
gateway *time.Time
synced bool
relative uint32
absolute ConcentratorTime
server *time.Time
gateway *time.Time
absoluteSynced bool
}

// IsSynced implements Clock.
func (c *RolloverClock) IsSynced() bool { return c.synced }

func (c *RolloverClock) IsAbsoluteSynced() bool { return c.absoluteSynced }

Check warning on line 52 in pkg/gatewayserver/scheduling/clock.go

View workflow job for this annotation

GitHub Actions / Code Quality

exported: exported method RolloverClock.IsAbsoluteSynced should have comment or be unexported (revive)

// SyncTime implements Clock.
func (c *RolloverClock) SyncTime() (time.Time, bool) {
if !c.synced {
Expand Down Expand Up @@ -82,6 +85,7 @@
func (c *RolloverClock) SyncWithGatewayAbsolute(timestamp uint32, server, gateway time.Time) ConcentratorTime {
ct := c.Sync(timestamp, server)
c.gateway = &gateway
c.absoluteSynced = true
return ct
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/gatewayserver/scheduling/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (s *Scheduler) ScheduleAt(ctx context.Context, opts Options) (res Emission,
if opts.UplinkToken != nil {
s.syncWithUplinkToken(opts.UplinkToken)
}
if !s.clock.IsSynced() {
if !s.clock.IsAbsoluteSynced() {
return Emission{}, 0, errNoClockSync.New()
}
minScheduleTime := ScheduleTimeShort
Expand Down Expand Up @@ -477,7 +477,7 @@ func (s *Scheduler) SyncWithGatewayConcentrator(timestamp uint32, server time.Ti
func (s *Scheduler) IsGatewayTimeSynced() bool {
s.mu.RLock()
defer s.mu.RUnlock()
return s.clock.IsSynced() && s.clock.gateway != nil
return s.clock.IsAbsoluteSynced() && s.clock.gateway != nil
}

// Now returns an indication of the current concentrator time.
Expand Down
Loading