Skip to content

Commit

Permalink
Enable configuring VH-109 channels from settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
patfair committed Oct 11, 2023
1 parent eb7ed00 commit ff0ea56
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
6 changes: 4 additions & 2 deletions field/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ func (arena *Arena) LoadSettings() error {
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())
if arena.EventSettings.Ap2TeamChannel != 0 {
if err = arena.accessPoint2.ConfigureAdminSettings(); err != nil {
log.Printf("Failed to configure second access point admin settings: %s", err.Error())
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions network/access_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ func (ap *AccessPoint) ConfigureAdminSettings() error {
return nil
}

commands := []string{
fmt.Sprintf("set wireless.radio0.channel='%d'", ap.teamChannel),
"commit wireless",
var device string
if ap.isVividType {
device = "wifi1"
} else {
device = "radio0"
}
command := fmt.Sprintf("uci batch <<ENDCONFIG && wifi radio0\n%s\nENDCONFIG\n", strings.Join(commands, "\n"))
command := fmt.Sprintf("uci set wireless.%s.channel=%d && uci commit wireless", device, ap.teamChannel)
_, err := ap.runCommand(command)
return err
}
Expand Down
31 changes: 28 additions & 3 deletions templates/setup_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@
<div class="col-lg-7">
<div class="radio">
<label>
<input type="radio" name="apType" value="linksys"
<input type="radio" name="apType" value="linksys" onclick="updateAccessPointType(false);"
{{if eq .ApType "linksys"}}checked{{end}}>
Linksys WRT1900ACS
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="apType" value="vivid"
<input type="radio" name="apType" value="vivid" onclick="updateAccessPointType(true);"
{{if eq .ApType "vivid"}}checked{{end}}>
Vivid-Hosting VH109
</label>
Expand Down Expand Up @@ -195,7 +195,8 @@
<div class="form-group">
<label class="col-lg-5 control-label">AP Team Channel (5GHz)</label>
<div class="col-lg-7">
<select class="form-control" name="apTeamChannel" value="{{.ApTeamChannel}}">
<select class="form-control" name="apTeamChannel5" value="{{.ApTeamChannel}}"
{{if eq .ApType "vivid"}}disabled{{end}}>
<option{{if eq .ApTeamChannel 36}} selected{{end}}>36</option>
<option{{if eq .ApTeamChannel 40}} selected{{end}}>40</option>
<option{{if eq .ApTeamChannel 44}} selected{{end}}>44</option>
Expand All @@ -207,6 +208,19 @@
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-5 control-label">AP Team Channel (6GHz)</label>
<div class="col-lg-7">
<select class="form-control" name="apTeamChannel6" value="{{.ApTeamChannel}}"
{{if ne .ApType "vivid"}}disabled{{end}}>
{{range $i, $j := seq 29}}
<option{{if eq $.ApTeamChannel (add 5 (multiply $i 8))}} selected{{end}}>
{{(add 5 (multiply $i 8))}}
</option>
{{end}}
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-5 control-label">Switch Address</label>
<div class="col-lg-7">
Expand Down Expand Up @@ -416,5 +430,16 @@ <h4 class="modal-title">Confirm</h4>
numPlayoffAlliances.val(8);
}
};
updateAccessPointType = function(isVividType) {
const apTeamChannel5 = $("select[name=apTeamChannel5]");
const apTeamChannel6 = $("select[name=apTeamChannel6]");
if (isVividType) {
apTeamChannel5.prop("disabled", true);
apTeamChannel6.prop("disabled", false);
} else {
apTeamChannel5.prop("disabled", false);
apTeamChannel6.prop("disabled", true);
}
};
</script>
{{end}}
6 changes: 5 additions & 1 deletion web/setup_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ func (web *Web) settingsPostHandler(w http.ResponseWriter, r *http.Request) {
eventSettings.ApAddress = r.PostFormValue("apAddress")
eventSettings.ApUsername = r.PostFormValue("apUsername")
eventSettings.ApPassword = r.PostFormValue("apPassword")
eventSettings.ApTeamChannel, _ = strconv.Atoi(r.PostFormValue("apTeamChannel"))
if eventSettings.ApType == "vivid" {
eventSettings.ApTeamChannel, _ = strconv.Atoi(r.PostFormValue("apTeamChannel6"))
} else {
eventSettings.ApTeamChannel, _ = strconv.Atoi(r.PostFormValue("apTeamChannel5"))
}
eventSettings.Ap2Address = r.PostFormValue("ap2Address")
eventSettings.Ap2Username = r.PostFormValue("ap2Username")
eventSettings.Ap2Password = r.PostFormValue("ap2Password")
Expand Down

0 comments on commit ff0ea56

Please sign in to comment.