adb: pair/connect support

This commit is contained in:
2025-10-13 19:21:06 +02:00
parent d1da3deb8d
commit 050ee6f0f7

18
adb.go
View File

@@ -6,6 +6,24 @@ import (
"strings" "strings"
) )
// Pair a device using the 6 digit code
func PairDevice(endpoint string, code string) error {
_, err := ExecuteCommand(fmt.Sprintf("pair %s %s", endpoint, code))
return err
}
// Connect to a device
func ConnectDevice(endpoint string) (*Device,error) {
//todo: check if the device is paired before connecting
_, err := ExecuteCommand("connect " + endpoint)
if err != nil {
return nil,err
}
d := &Device{Serial: endpoint}
return d,err
}
// Get the already connected adb devices // Get the already connected adb devices
func GetConnectedDevices() ([]Device, error) { func GetConnectedDevices() ([]Device, error) {
var devices []Device var devices []Device