Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions ios/diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ func Reboot(device ios.DeviceEntry) error {
return service.Close()
}

func Shutdown(device ios.DeviceEntry) error {
service, err := New(device)
if err != nil {
return err
}
err = service.Shutdown()
if err != nil {
return err
}
return service.Close()
}

// Battery extracts the battery ioregistry stats like Temperature, Voltage, CurrentCapacity
func (diagnosticsConn *Connection) Battery() (IORegistry, error) {
req := newIORegistryRequest()
Expand Down Expand Up @@ -83,6 +95,35 @@ func (diagnosticsConn *Connection) Reboot() error {
return fmt.Errorf("could not reboot, response: %+v", plist)
}

func (diagnosticsConn *Connection) Shutdown() error {
req := rebootRequest{Request: "Shutdown", WaitForDisconnect: true, DisplayFail: true, DisplayPass: true}
reader := diagnosticsConn.deviceConn.Reader()
bytes, err := diagnosticsConn.plistCodec.Encode(req)
if err != nil {
return err
}
err = diagnosticsConn.deviceConn.Send(bytes)
if err != nil {
return err
}
response, err := diagnosticsConn.plistCodec.Decode(reader)
if err != nil {
return err
}
plist, err := ios.ParsePlist(response)
if err != nil {
return err
}
if val, ok := plist["Status"]; ok {
if statusString, yes := val.(string); yes {
if statusString == "Success" {
return nil
}
}
}
return fmt.Errorf("could not shutdown, response: %+v", plist)
}

func (diagnosticsConn *Connection) AllValues() (allDiagnosticsResponse, error) {
allReq := diagnosticsRequest{"All"}
reader := diagnosticsConn.deviceConn.Reader()
Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Usage:
ios screenshot [options] [--output=<outfile>] [--stream] [--port=<port>]
ios setlocation [options] [--lat=<lat>] [--lon=<lon>]
ios setlocationgpx [options] [--gpxfilepath=<gpxfilepath>]
ios shutdown [options]
ios syslog [--parse] [options]
ios sysmontap [options]
ios timeformat (24h | 12h | toggle | get) [--force] [options]
Expand Down Expand Up @@ -372,6 +373,8 @@ The commands work as following:
ios setlocationgpx [options] [--gpxfilepath=<gpxfilepath>] Updates the location of the device based on the data in a GPX file.
Ex.: setlocationgpx --gpxfilepath=/home/username/location.gpx

ios shutdown [options] Shuts down the device

ios syslog [--parse] [options] Prints a device's log output, Use --parse to parse the fields from the log
ios sysmontap Get system stats like MEM, CPU

Expand Down Expand Up @@ -1279,6 +1282,17 @@ The commands work as following:
return
}

b, _ = arguments.Bool("shutdown")
if b {
err := diagnostics.Shutdown(device)
if err != nil {
log.Error(err)
} else {
log.Info("ok")
}
return
}

b, _ = arguments.Bool("file")
if b {
// file command uses RemoteXPC (iOS 17+) and requires tunnel
Expand Down
Loading