-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwifi.go
56 lines (38 loc) · 1.44 KB
/
wifi.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"encoding/json"
"net/http"
log "github.com/sirupsen/logrus"
)
// WifiAPModeHandler responds to /wifi/ap GET requests
func WifiAPModeHandler(w http.ResponseWriter, r *http.Request) {
log.Info("Retrieving Wifi APMode")
responseData, code := rpcCommand("getApMode", map[string]interface{}{})
log.Debug(code)
log.Debug(responseData)
json.NewEncoder(w).Encode(responseData.Result)
}
// WifiConfigHandler responds to /wifi/config GET requests
func WifiConfigHandler(w http.ResponseWriter, r *http.Request) {
log.Info("Retrieving Wifi Configuration from Local API")
responseData, code := rpcCommand("getWifiParams", map[string]interface{}{})
log.Debug(code)
log.Debug(responseData)
// Let's not broadcast this as it just weakens the user's security
delete(responseData.Result, "wifiPassword")
json.NewEncoder(w).Encode(responseData.Result)
}
// WifiIPHandler responds to /wifi/ipv4 GET requests
func WifiIPHandler(w http.ResponseWriter, r *http.Request) {
log.Info("Retrieving Wifi IPv4 Address")
wifiIPAddress := getStickIPAddress()
json.NewEncoder(w).Encode(wifiIPAddress)
}
// WifiNetworkHandler responds to /wifi/network GET requests
func WifiNetworkHandler(w http.ResponseWriter, r *http.Request) {
log.Info("Retrieving Wifi Network Status")
responseData, code := rpcCommand("getNetworkStatus", map[string]interface{}{})
log.Debug(code)
log.Debug(responseData)
json.NewEncoder(w).Encode(responseData.Result)
}