-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59c7d45
commit 9c4ffcc
Showing
4 changed files
with
93 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {Platform} from '../interfaces'; | ||
import {execBinarySync} from './sdk'; | ||
import Logger from '../../../logger'; | ||
|
||
export async function connectToWifiADB(adbLocation: string, platform: Platform) { | ||
try { | ||
const devicesOutput = execBinarySync(adbLocation, 'adb', platform, 'devices'); | ||
if (devicesOutput === null) { | ||
|
||
return; | ||
} | ||
if (!devicesOutput.includes('attached')) { | ||
Logger.log('No devices connected. Please connect your device using a USB cable.'); | ||
|
||
return; | ||
} | ||
|
||
const ipAddressOutput = execBinarySync(adbLocation, 'adb', platform, 'shell ifconfig wlan0'); | ||
if (ipAddressOutput === null) { | ||
|
||
return; | ||
} | ||
const ipAddressRegExp = /inet addr:([^ ]+)/; | ||
const match = ipAddressOutput.match(ipAddressRegExp); | ||
if (!match) { | ||
Logger.log('Failed to retrieve device IP address.'); | ||
|
||
return; | ||
} | ||
const deviceIP = match[1]; | ||
|
||
execBinarySync(adbLocation, 'adb', platform, 'tcpip 5555'); | ||
|
||
execBinarySync(adbLocation, 'adb', platform, `connect ${deviceIP}:5555`); | ||
|
||
const connectedDevicesOutput = execBinarySync(adbLocation, 'adb', platform, 'devices'); | ||
if (connectedDevicesOutput === null) { | ||
|
||
return; | ||
} | ||
if (connectedDevicesOutput.includes(`${deviceIP}:5555`)) { | ||
Logger.log('Device successfully connected wirelessly.'); | ||
} else { | ||
Logger.log('Failed to connect to device wirelessly.'); | ||
} | ||
} catch (error) { | ||
Logger.log('Error connecting to wifi ADB'); | ||
} | ||
} |