Skip to content

Commit

Permalink
fetch bind info on receiver tab
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Mar 18, 2021
1 parent 593f790 commit 63e0fd6
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 3 deletions.
11 changes: 11 additions & 0 deletions cmd/quic-config/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,15 @@ func (s *Server) postVtxSettings(w http.ResponseWriter, r *http.Request) {
renderJSON(w, value)
}

func (s *Server) getBindInfo(w http.ResponseWriter, r *http.Request) {
value := quic.BindInfo{}
if err := s.qp.GetValue(quic.QuicValBindInfo, &value); err != nil {
handleError(w, err)
return
}
renderJSON(w, value)
}

func broadcastProgress(task string) func(total, current int) {
last := 0
return func(total, current int) {
Expand Down Expand Up @@ -738,6 +747,8 @@ func (s *Server) setupRoutes(r *mux.Router) {
f.HandleFunc("/api/vtx/settings", s.getVtxSettings).Methods("GET")
f.HandleFunc("/api/vtx/settings", s.postVtxSettings).Methods("POST")

f.HandleFunc("/api/bind/info", s.getBindInfo).Methods("GET")

f.HandleFunc("/api/osd/font", s.getOSDFont).Methods("GET")
f.HandleFunc("/api/osd/font", s.postOSDFont).Methods("POST")

Expand Down
1 change: 1 addition & 0 deletions pkg/protocol/quic/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
QuicValVtxSettings
QuicValOSDFont
QuicValBLHeliSettings
QuicValBindInfo
QuicValPerfCounters
)

Expand Down
5 changes: 5 additions & 0 deletions pkg/protocol/quic/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ type TargetInfo struct {
GyroID *uint `cbor:"gyro_id" json:"gyro_id"`
}

type BindInfo struct {
BindEnable uint `cbor:"bind_enable" json:"bind_enable"`
Raw []byte `cbor:"raw" json:"raw"`
}

type BlackboxCompact struct {
_ struct{} `cbor:",toarray"`

Expand Down
24 changes: 24 additions & 0 deletions web/src/store/bind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { get } from "@/store/api.js";


const store = {
state: {
info: {
bind_enable: 0,
}
},
getters: {},
mutations: {
set_bind_info(state, info) {
state.info = info
},
},
actions: {
fetch_bind_info({ commit }) {
return get("/api/bind/info")
.then(p => commit('set_bind_info', p))
}
}
}

export default store;
2 changes: 2 additions & 0 deletions web/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import blackboxModule from "./blackbox";
import stateModule from "./state";
import motorModule from "./motor";
import vtxModule from "./vtx";
import bindModule from "./bind";

var ws = null

Expand All @@ -25,6 +26,7 @@ const store = new Vuex.Store({
motor: motorModule,
vtx: vtxModule,
perf: perfModule,
bind: bindModule,
},
state: {
log: [],
Expand Down
33 changes: 30 additions & 3 deletions web/src/views/Receiver.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
protoNames[status.Info.rx_protocol]
}}</b-col>
</b-row>
<b-row v-if="status.Info.quic_protocol_version > 2">
<b-col sm="4" class="my-2">
<label>Bind Enabled</label>
</b-col>
<b-col sm="8" class="my-2">{{
bind.info.bind_enable ? "yes" : "no"
}}</b-col>
</b-row>
<b-row v-if="status.Info.quic_protocol_version > 2">
<b-col sm="4" class="my-2">
<label>RSSI</label>
Expand Down Expand Up @@ -38,12 +46,13 @@
</template>

<script>
import { mapState } from "vuex";
import { mapState, mapActions } from "vuex";
export default {
name: "Receiver",
data() {
return {
intervalEnabled: true,
protoNames: [
"INVALID",
"UNIFIED_SERIAL",
Expand Down Expand Up @@ -75,7 +84,7 @@ export default {
};
},
computed: {
...mapState(["status", "state"]),
...mapState(["status", "state", "bind"]),
proto() {
return this.protoNames.reduce((m, v, i) => {
m[v] = i;
Expand Down Expand Up @@ -127,7 +136,25 @@ export default {
return this.serialProtoNames[index];
},
},
methods: {},
methods: {
...mapActions(["fetch_bind_info"]),
startInterval() {
return this.fetch_bind_info().then(() => {
if (!this.intervalEnabled) {
return;
}
setTimeout(() => this.startInterval(), 5000);
});
},
},
created() {
if (this.status.Info.quic_protocol_version > 2) {
this.startInterval();
}
},
beforeDestroy() {
this.intervalEnabled = false;
},
};
</script>

Expand Down

0 comments on commit 63e0fd6

Please sign in to comment.