bool ChangeWirelessCmd::ChangeWirelessTask::execute() { std::string ip = robot->getBestIP(); context().printLine(robot->name + ": changing wpa_supplicant config to " + toString(config)); std::string command = remoteCommand("setprofile " + toString(config), ip); ProcessRunner r(context(), fromString(command)); r = ProcessRunner(context(), fromString(command)); r.run(); if(r.error()) { context().errorLine(robot->name + ": change wireless failed."); return false; } context().printLine(robot->name + ": change wireless finished."); return true; }
bool RestartCmd::RestartTask::execute() { std::string ip = robot->getBestIP(context()); context().printLine("restart: using ip " + ip + " for " + robot->name + "."); if(type < SINGLE_COMMANDS) { if(type == BHUMAND) { std::string command = remoteCommand("bhumand restart", ip); ProcessRunner r(context(), command); r.run(); reportStatus(r); } else if(type == NAOQID) { std::string command = remoteCommand("sudo /etc/init.d/naoqi restart", ip); ProcessRunner r(context(), command); r.run(); if(r.error()) { context().errorLine(robot->name + ": Could not restart Naoqi."); return false; } else context().printLine(robot->name + ": restarted Naoqi."); } else if(type == ROBOT) { std::string command = remoteCommand("reboot", ip); ProcessRunner r(context(), command); r.run(); reportStatus(r); } else { context().errorLine("Unkown restart command."); return false; } } else if(type == BHUMAND_AND_NAOQID) { std::string command = remoteCommand("bhumand stop", ip); ProcessRunner r(context(), command); r.run(); if(r.error()) { context().errorLine(robot->name + ": Failed to stop bhumand."); return false; } else { context().printLine(robot->name + ": bhumand stopped"); } context().printLine(robot->name + ": waiting 2 seconds"); Sleeper::msleep(2000); command = remoteCommand("sudo /etc/init.d/naoqi restart", ip); r = ProcessRunner(context(), command); r.run(); if(r.error()) { context().errorLine(robot->name + ": Failed to restart naoqid."); return false; } else context().printLine(robot->name + ": naoqid restarted"); context().printLine(robot->name + ": waiting 2 seconds"); Sleeper::msleep(2000); command = remoteCommand("bhumand start", ip); r = ProcessRunner(context(), command); r.run(); if(r.error()) { context().errorLine(robot->name + ": Failed to start bhumand."); return false; } else context().printLine(robot->name + ": bhumand started"); context().printLine(robot->name + ": waiting 2 seconds"); Sleeper::msleep(2000); context().printLine(robot->name + ": Done"); } else { context().errorLine("Unkown restart command."); return false; } return true; }