Skip to content

Commit

Permalink
Restore mistakenly removed ability to configure AP channel (fixes #160).
Browse files Browse the repository at this point in the history
  • Loading branch information
patfair committed Oct 9, 2023
1 parent 6d6e3be commit 9e03243
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions field/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ func (arena *Arena) LoadSettings() error {
arena.Plc.SetAddress(settings.PlcAddress)
arena.TbaClient = partner.NewTbaClient(settings.TbaEventCode, settings.TbaSecretId, settings.TbaSecret)

if arena.EventSettings.NetworkSecurityEnabled && arena.MatchState == PreMatch {
if err = arena.accessPoint.ConfigureAdminSettings(); err != nil {
log.Printf("Failed to configure access point admin settings: %s", err.Error())
}
if err = arena.accessPoint2.ConfigureAdminSettings(); err != nil {
log.Printf("Failed to configure second access point admin settings: %s", err.Error())
}
}

game.MatchTiming.WarmupDurationSec = settings.WarmupDurationSec
game.MatchTiming.AutoDurationSec = settings.AutoDurationSec
game.MatchTiming.PauseDurationSec = settings.PauseDurationSec
Expand Down
15 changes: 15 additions & 0 deletions network/access_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ func (ap *AccessPoint) Run() {
}
}

// Calls the access point to configure the non-team-related settings.
func (ap *AccessPoint) ConfigureAdminSettings() error {
if !ap.networkSecurityEnabled {
return nil
}

commands := []string{
fmt.Sprintf("set wireless.radio0.channel='%d'", ap.teamChannel),
"commit wireless",
}
command := fmt.Sprintf("uci batch <<ENDCONFIG && wifi radio0\n%s\nENDCONFIG\n", strings.Join(commands, "\n"))
_, err := ap.runCommand(command)
return err
}

// Adds a request to set up wireless networks for the given set of teams to the asynchronous queue.
func (ap *AccessPoint) ConfigureTeamWifi(teams [6]*model.Team) error {
// Use a channel to serialize configuration requests; the monitoring goroutine will service them.
Expand Down

0 comments on commit 9e03243

Please sign in to comment.