-
-
Notifications
You must be signed in to change notification settings - Fork 226
/
devicedetail.go
61 lines (58 loc) · 2.74 KB
/
devicedetail.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
/*
* sonic-ios-bridge Connect to your iOS Devices.
* Copyright (C) 2022 SonicCloudOrg
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package entity
import (
"encoding/json"
"fmt"
giDevice "github.com/SonicCloudOrg/sonic-gidevice"
)
type DeviceDetail struct {
GenerationName string `json:"generationName,omitempty"`
DeviceName string `json:"deviceName,omitempty"`
DeviceColor string `json:"deviceColor,omitempty"`
DeviceClass string `json:"deviceClass,omitempty"`
ProductVersion string `json:"productVersion,omitempty"`
ProductType string `json:"productType,omitempty"`
ProductName string `json:"productName,omitempty"`
PasswordProtected bool `json:"passwordProtected,omitempty"`
ModelNumber string `json:"modelNumber,omitempty"`
SerialNumber string `json:"serialNumber,omitempty"`
SIMStatus string `json:"simStatus,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
CPUArchitecture string `json:"cpuArchitecture,omitempty"`
ProtocolVersion string `json:"protocolVersion,omitempty"`
RegionInfo string `json:"regionInfo,omitempty"`
TelephonyCapability bool `json:"telephonyCapability,omitempty"`
TimeZone string `json:"timeZone,omitempty"`
UniqueDeviceID string `json:"uniqueDeviceID,omitempty"`
WiFiAddress string `json:"wifiAddress,omitempty"`
WirelessBoardSerialNumber string `json:"wirelessBoardSerialNumber,omitempty"`
BluetoothAddress string `json:"bluetoothAddress,omitempty"`
BuildVersion string `json:"buildVersion,omitempty"`
}
func GetDetail(device giDevice.Device) (*DeviceDetail, error) {
value, err1 := device.GetValue("", "")
if err1 != nil {
return &DeviceDetail{}, fmt.Errorf("get %s device detail fail : %w", device.Properties().SerialNumber, err1)
}
detailByte, _ := json.Marshal(value)
detail := &DeviceDetail{}
json.Unmarshal(detailByte, detail)
detail.GenerationName = detail.GetGenerationName()
return detail, nil
}