|
|
@@ -103,3 +103,50 @@ func cameraStatusHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
"avar5": avar5, "avar6": avar6,
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+func cameraPowerHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+ if r.Method != http.MethodPost {
|
|
|
+ http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var req struct {
|
|
|
+ Enable string `json:"enable"`
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
|
+ http.Error(w, err.Error(), http.StatusBadRequest)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var result any
|
|
|
+ err := callRPCResult(r.Context(), 7003, "core.setGigeCameraPower", map[string]string{"enable": req.Enable}, &result)
|
|
|
+ if err != nil {
|
|
|
+ http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ w.Header().Set("Content-Type", "application/json")
|
|
|
+ json.NewEncoder(w).Encode(map[string]bool{
|
|
|
+ "ok": true,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func cameraPingHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+ if r.Method != http.MethodPost {
|
|
|
+ http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ avar6 := noValue
|
|
|
+ check := ""
|
|
|
+
|
|
|
+ callRPCResult(r.Context(), 7003, "core.checkGigeCamera",
|
|
|
+ map[string]string{"ip": "192.168.100.100", "prefix": "24"}, &check)
|
|
|
+ if check == "success" {
|
|
|
+ avar6 = "🟢正常"
|
|
|
+ }
|
|
|
+
|
|
|
+ w.Header().Set("Content-Type", "application/json")
|
|
|
+ json.NewEncoder(w).Encode(map[string]string{"avar6": avar6})
|
|
|
+}
|