-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_monitoring.go
163 lines (147 loc) · 5.66 KB
/
client_monitoring.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package huwlte
import (
"context"
"encoding/xml"
"fmt"
)
type ClientMonitoring struct {
*Client
}
type MonitoringStatusConnectionStatus int16
const (
MonitoringStatusConnectionConnecting MonitoringStatusConnectionStatus = 900
MonitoringStatusConnectionConnected MonitoringStatusConnectionStatus = 901
MonitoringStatusConnectionDisconnected MonitoringStatusConnectionStatus = 902
MonitoringStatusConnectionDisconnecting MonitoringStatusConnectionStatus = 903
)
func (v MonitoringStatusConnectionStatus) String() string {
switch v {
case MonitoringStatusConnectionConnecting:
return "connecting"
case MonitoringStatusConnectionConnected:
return "connected"
case MonitoringStatusConnectionDisconnected:
return "disconnected"
case MonitoringStatusConnectionDisconnecting:
return "disconnecting"
default:
return fmt.Sprintf("unknown(%d)", v)
}
}
type MonitoringStatusNetworkType int16
const (
MonitoringStatusNetworkTypeNoService MonitoringStatusNetworkType = iota
MonitoringStatusNetworkTypeGSM
MonitoringStatusNetworkTypeGPRS
MonitoringStatusNetworkTypeEDGE
MonitoringStatusNetworkTypeWCDMA
MonitoringStatusNetworkTypeHSDPA
MonitoringStatusNetworkTypeHSUPA
MonitoringStatusNetworkTypeHSPA
MonitoringStatusNetworkTypeTDSCDMA
MonitoringStatusNetworkTypeHSPAPlus
MonitoringStatusNetworkTypeEVDORev0
MonitoringStatusNetworkTypeEVDORevA
MonitoringStatusNetworkTypeEVDORevB
MonitoringStatusNetworkType1xRTT
MonitoringStatusNetworkTypeUMB
MonitoringStatusNetworkType1xEVDV
MonitoringStatusNetworkType3xRTT
MonitoringStatusNetworkTypeHSPAPlus64QAM
MonitoringStatusNetworkTypeHSPAPlusMIMO
MonitoringStatusNetworkTypeLTE
)
func (v MonitoringStatusNetworkType) String() string {
switch v {
case MonitoringStatusNetworkTypeNoService:
return "No Service"
case MonitoringStatusNetworkTypeGSM:
return "GSM"
case MonitoringStatusNetworkTypeGPRS:
return "GPRS"
case MonitoringStatusNetworkTypeEDGE:
return "EDGE"
case MonitoringStatusNetworkTypeWCDMA:
return "WCDMA"
case MonitoringStatusNetworkTypeHSDPA:
return "HSDPA"
case MonitoringStatusNetworkTypeHSUPA:
return "HSUPA"
case MonitoringStatusNetworkTypeHSPA:
return "HSPA"
case MonitoringStatusNetworkTypeTDSCDMA:
return "TDSCDMA"
case MonitoringStatusNetworkTypeHSPAPlus:
return "HSPA Plus"
case MonitoringStatusNetworkTypeEVDORev0:
return "EVDORev0"
case MonitoringStatusNetworkTypeEVDORevA:
return "EVDORevA"
case MonitoringStatusNetworkTypeEVDORevB:
return "EVDORevB"
case MonitoringStatusNetworkType1xRTT:
return "1xRTT"
case MonitoringStatusNetworkTypeUMB:
return "UMB"
case MonitoringStatusNetworkType1xEVDV:
return "1xEVDV"
case MonitoringStatusNetworkType3xRTT:
return "3xRTT"
case MonitoringStatusNetworkTypeHSPAPlus64QAM:
return "HSPA Plus 64QAM"
case MonitoringStatusNetworkTypeHSPAPlusMIMO:
return "HSPA Plus MIMO"
case MonitoringStatusNetworkTypeLTE:
return "LTE"
default:
return fmt.Sprintf("unknown(%d)", v)
}
}
type MonitoringStatusService int8
const (
MonitoringStatusServiceAvailable MonitoringStatusService = 2
)
type MonitoringStatus struct {
XMLName xml.Name `xml:"response" human:"-"`
// Represents current connection link.
// Use MonitoringStatusConnectionStatus constants to get the string representation and equality.
ConnectionStatus MonitoringStatusConnectionStatus `xml:"ConnectionStatus"`
WifiConnectionStatus string `xml:"WifiConnectionStatus"`
SignalStrength string `xml:"SignalStrength"`
SignalIcon int `xml:"SignalIcon"`
// Represents current network type.
CurrentNetworkType MonitoringStatusNetworkType `xml:"CurrentNetworkType"`
CurrentServiceDomain int `xml:"CurrentServiceDomain"`
RoamingStatus int `xml:"RoamingStatus"`
BatteryStatus string `xml:"BatteryStatus"`
BatteryLevel string `xml:"BatteryLevel"`
BatteryPercent string `xml:"BatteryPercent"`
SimLockStatus string `xml:"simlockStatus"`
PrimaryDNS string `xml:"PrimaryDns"`
SecondaryDNS string `xml:"SecondaryDns"`
PrimaryIPv6DNS string `xml:"PrimaryIPv6Dns"`
SecondaryIPv6DNS string `xml:"SecondaryIPv6Dns"`
CurrentWiFiUser string `xml:"CurrentWifiUser"`
TotalWiFiUser string `xml:"TotalWifiUser"`
CurrentTotalWiFiUser string `xml:"currenttotalwifiuser"`
ServiceStatus string `xml:"ServiceStatus"`
SimStatus string `xml:"SimStatus"`
WifiStatus string `xml:"WifiStatus"`
CurrentNetworkTypeEx string `xml:"CurrentNetworkTypeEx"`
MaxSignal int `xml:"maxsignal"`
WifiInDoorOnly string `xml:"wifiindooronly"`
WiFiFrequence string `xml:"wififrequence"`
Classify string `xml:"classify"`
Flymode string `xml:"flymode"`
CellRoam string `xml:"cellroam"`
LTECAStatus string `xml:"ltecastatus"`
}
func (monitoring *ClientMonitoring) Status(ctx context.Context) (*MonitoringStatus, error) {
var result MonitoringStatus
if err := monitoring.withSessionRetry(ctx, func(ctx context.Context) error {
return monitoring.get(ctx, "/api/monitoring/status", &result)
}); err != nil {
return nil, err
}
return &result, nil
}