You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.2 KiB
Go

package device
import (
"encoding/json"
"fmt"
"os/exec"
"strings"
)
func GetIOSDevices() []sibDevice {
out := struct {
DeviceList []sibDevice
}{}
cmd := exec.Command("sib", "devices", "-f", "-d")
output, err := cmd.Output()
if err != nil {
fmt.Println(err)
return out.DeviceList
}
err = json.Unmarshal(output, &out)
if err != nil {
fmt.Println(err)
return out.DeviceList
}
return out.DeviceList
}
type sibDevice struct {
RemoteAddr string `json:"remoteAddr"`
DeviceID int `json:"deviceId"`
ConnectionSpeed int `json:"connectionSpeed"`
ConnectionType string `json:"connectionType"`
LocationID int `json:"locationId"`
ProductID int `json:"productId"`
SerialNumber string `json:"serialNumber"`
Status string `json:"status"`
DeviceDetail struct {
GenerationName string `json:"generationName"`
DeviceName string `json:"deviceName"`
DeviceColor string `json:"deviceColor"`
DeviceClass string `json:"deviceClass"`
ProductVersion string `json:"productVersion"`
ProductType string `json:"productType"`
ProductName string `json:"productName"`
ModelNumber string `json:"modelNumber"`
SerialNumber string `json:"serialNumber"`
SimStatus string `json:"simStatus"`
CPUArchitecture string `json:"cpuArchitecture"`
ProtocolVersion string `json:"protocolVersion"`
RegionInfo string `json:"regionInfo"`
TelephonyCapability bool `json:"telephonyCapability"`
TimeZone string `json:"timeZone"`
UniqueDeviceID string `json:"uniqueDeviceID"`
WifiAddress string `json:"wifiAddress"`
WirelessBoardSerialNumber string `json:"wirelessBoardSerialNumber"`
BluetoothAddress string `json:"bluetoothAddress"`
BuildVersion string `json:"buildVersion"`
} `json:"deviceDetail"`
}
// 检查sib是否已安装
func CheckSib() bool {
cmd := exec.Command("sib")
output, err := cmd.Output()
if err != nil {
fmt.Println(err)
return false
}
if strings.Contains(string(output), "SonicCloudOrg") {
return true
} else {
return false
}
}