From 3f963c3026cbeabfea5007d43529bc9464bdc14f Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 25 Apr 2020 15:09:41 +0100 Subject: [PATCH] auto use ipaddress --- pages/pages.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/pages/pages.js b/pages/pages.js index d923a74..6f99b8c 100644 --- a/pages/pages.js +++ b/pages/pages.js @@ -34,7 +34,35 @@ module.exports = { const miwatchData = JSON.parse(fs.readFileSync('./data/MiWatch.json', 'utf8')); common.header('Connect Wifi') if (miwatchData.ipAddress !== "") { - console.log('pooooooo') + console.log('Trying to connect with stored ipAddress') + shellExec('adb connect ' + miwatchData.ipAddress).then(async function (result) { + if (result.stdout.includes('unable to connect')) { + console.log(chalk.red('MiWatch not found')) + await common.pause(2000) + console.log(chalk.white('Try Again')) + files.writeIpAddress('') + await common.pause(1000) + module.exports.connectWifi() + } else if (result.stdout.includes('cannot connect')) { + console.log(chalk.red('MiWatch not found')) + await common.pause(2000) + console.log(chalk.white('Try Again')) + files.writeIpAddress('') + await common.pause(1000) + module.exports.connectWifi() + } else if (result.stdout.includes('cannot resolve host')) { + console.log(chalk.red('MiWatch not found')) + await common.pause(2000) + console.log(chalk.white('Try Again')) + files.writeIpAddress('') + await common.pause(1000) + module.exports.connectWifi() + } else { + console.log(chalk.green('MiWatch Connected')) + await common.pause(3000) + module.exports.mainMenu() + } + }).catch() } else { const value = await inquirer.connectWifi(); const miWatchIpaddress = value.connectWifi