elif command in ["pair", "pairing"]: commandOut("p") outputToOperator("Asking Bluetooth module to go into pairing") else: outputToOperator("Unknown command: '%s'" % command) #Non-configurable settings cardinals = {} cardinals['n'] = ('North', '0') cardinals['e'] = ('East', '90') cardinals['w'] = ('West', '270') cardinals['s'] = ('South', '180') previousMsg = "" audioRecordingOn = False phoneIP = netip.displayNoLo() # Defines the dict of sensor values and their history whiteboard = {} MAX_WHITEBOARD_LENGTH = 30 # Get configurable options from the ini file, prompt user if they aren't there, and save if needed def getConfigFileValue(config, section, option, title, valueList, saveToFile): # Check if option exists in the file if config.has_option(section, option): values = config.get(section, option) values = values.split(',') # Prompt the user to pick an option if the file specified more than one option if len(values) > 1: setting = robot.pickFromList(title, values)
outputToOperator("Reset hardwares settings to default") elif command in ["pair", "pairing"]: commandOut("p") outputToOperator("Asking Bluetooth module to go into pairing") else: outputToOperator("Unknown command: '%s'" % command) #Non-configurable settings cardinals = {} cardinals['n']=('North','0') cardinals['e']=('East','90') cardinals['w']=('West','270') cardinals['s']=('South','180') previousMsg = "" audioRecordingOn = False phoneIP = netip.displayNoLo() # Defines the dict of sensor values and their history whiteboard = {} MAX_WHITEBOARD_LENGTH = 30 # Get configurable options from the ini file, prompt user if they aren't there, and save if needed def getConfigFileValue(config, section, option, title, valueList, saveToFile): # Check if option exists in the file if config.has_option(section, option): values = config.get(section, option) values = values.split(',') # Prompt the user to pick an option if the file specified more than one option if len(values) > 1: setting = robot.pickFromList(title, values) else:
def Configure(self): """List of config values to get from file or to prompt user for.""" self.mode = self.getConfigFileValue( "basics", "mode", "Select Mode", [self.kModeRobot, self.kModeRemote]) self.inputMethod = self.getConfigFileValue( "control", "inputMethod", "Select Input Method", [ 'commandByXMPP', 'commandByTelnet', 'commandByVoice', 'commandBySelf' ]) # TODO: Test that commandBySelf doesn't require mode to be set in the # config file. if self.mode == self.kModeRobot or self.inputMethod == "commandBySelf": self.outputMethod = self.getConfigFileValue( "control", "outputMethod", "Select Output Method", ['outputSerial', 'outputBluetooth', 'outputBluetoothICreate']) self.microcontroller = self.getConfigFileValue( "basics", "microcontroller", "Microcontroller Type", ['arduino', 'serialservo', 'AVR_Stepper', 'icreate']) self.audioOn = self._config.getboolean("basics", "audioOn") self.currentSpeed = self._config.getint("basics", "currentSpeed") self.cardinalMargin = self._config.getint("basics", "cardinalMargin") self.phoneIP = netip.displayNoLo() try: self.bluetoothAddress = self._config.get("control", "bluetoothAddress") except: # TODO: Make defaults for this and everything. self.bluetoothAddress = None if self.inputMethod == "commandByJSON": if self.mode == self.kModeRobot: self.msgRelayUrl = "/".join( [self._config.get("json", "msgRelayUrl"), "device"]) elif self.mode == self.kModeRemote: self.msgRelayUrl = "/".join( [self._config.get("json", "msgRelayUrl"), "controller"]) if self.mode == self.kModeRemote or self.inputMethod == "commandBySelf": self.speedScaleFactor = self.getConfigFileValue( "remote", "speedScaleFactor", "Speed scale factor", '', False) self.directionScaleFactor = self.getConfigFileValue( "remote", "directionScaleFactor", "Direction scale factor", '', False) # Only get these settings if we using XMPP if self.inputMethod == "commandByXMPP": self.xmppServer = self._config.get("xmpp", "server") self.xmppPort = self._config.getint("xmpp", "port") self.xmppRobotUsername = self.getConfigFileValue( "xmpp", "robotUsername", "Robot chat username", '') if self.mode == self.kModeRobot: self.xmppRobotPassword = self.getConfigFileValue( "xmpp", "robotPassword", "Robot chat password", '', False) elif self.mode == self.kModeRemote: self.xmppRemoteUsername = self.getConfigFileValue( "xmpp", "remoteUsername", "Remote chat username", '') self.xmppRemoteUserPassword = self.getConfigFileValue( "xmpp", "remoteUserPassword", "Remote chat user password", '', False) if self.inputMethod == "commandByTelnet": self.telnetPort = self._config.getint("telnet", "port") if self.mode == self.kModeRemote: self.robotHost = self.getConfigFileValue( "telnet", "robotHost", "Robot hostname", '')
def Configure(self): """List of config values to get from file or to prompt user for.""" self.mode = self.getConfigFileValue("basics", "mode", "Select Mode", [self.kModeRobot, self.kModeRemote]) self.inputMethod = self.getConfigFileValue("control", "inputMethod", "Select Input Method", ['commandByXMPP', 'commandByTelnet', 'commandByVoice', 'commandBySelf']) # TODO: Test that commandBySelf doesn't require mode to be set in the # config file. if self.mode == self.kModeRobot or self.inputMethod == "commandBySelf": self.outputMethod = self.getConfigFileValue("control", "outputMethod", "Select Output Method", ['outputSerial', 'outputBluetooth', 'outputBluetoothICreate']) self.microcontroller = self.getConfigFileValue("basics", "microcontroller", "Microcontroller Type", ['arduino', 'serialservo', 'AVR_Stepper', 'icreate']) self.audioOn = self._config.getboolean("basics", "audioOn") self.currentSpeed = self._config.getint("basics", "currentSpeed") self.cardinalMargin = self._config.getint("basics", "cardinalMargin") self.phoneIP = netip.displayNoLo() try: self.bluetoothAddress = self._config.get("control", "bluetoothAddress") except: # TODO: Make defaults for this and everything. self.bluetoothAddress = None if self.inputMethod == "commandByJSON": if self.mode == self.kModeRobot: self.msgRelayUrl = "/".join([self._config.get("json", "msgRelayUrl"), "device"]) elif self.mode == self.kModeRemote: self.msgRelayUrl = "/".join([self._config.get("json", "msgRelayUrl"), "controller"]) if self.mode == self.kModeRemote or self.inputMethod == "commandBySelf": self.speedScaleFactor = self.getConfigFileValue( "remote", "speedScaleFactor", "Speed scale factor", '', False) self.directionScaleFactor = self.getConfigFileValue( "remote", "directionScaleFactor", "Direction scale factor", '', False) # Only get these settings if we using XMPP if self.inputMethod == "commandByXMPP": self.xmppServer = self._config.get("xmpp", "server") self.xmppPort = self._config.getint("xmpp", "port") self.xmppRobotUsername = self.getConfigFileValue( "xmpp", "robotUsername", "Robot chat username", '') if self.mode == self.kModeRobot: self.xmppRobotPassword = self.getConfigFileValue( "xmpp", "robotPassword", "Robot chat password", '', False) elif self.mode == self.kModeRemote: self.xmppRemoteUsername = self.getConfigFileValue( "xmpp", "remoteUsername", "Remote chat username", '') self.xmppRemoteUserPassword = self.getConfigFileValue( "xmpp", "remoteUserPassword", "Remote chat user password", '', False) if self.inputMethod == "commandByTelnet": self.telnetPort = self._config.getint("telnet", "port") if self.mode == self.kModeRemote: self.robotHost = self.getConfigFileValue( "telnet", "robotHost", "Robot hostname", '')
import netip import httplib import ConfigParser from SimpleXMLRPCServer import SimpleXMLRPCServer from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler droid = android.Android() config = ConfigParser.ConfigParser() config.read("/sdcard/ase/scripts/cellbotConfig.ini") #Used as an indentifier on the app engine botname = config.get("xmpp", "username") #Public ip of the phone. Dont use WIFI unless you forwarded the port. ip = netip.displayNoLo() #Port that is open on your phone. Networks may restrict this. botport = 8000 #Location of the app. appAddress = "rcptestapp.appspot.com" # Restrict to a particular path. class RequestHandler(SimpleXMLRPCRequestHandler): rpc_paths = ('/RPC2', ) # Create server server = SimpleXMLRPCServer(("", botport), requestHandler=RequestHandler)
import netip import httplib import ConfigParser from SimpleXMLRPCServer import SimpleXMLRPCServer from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler droid = android.Android() config = ConfigParser.ConfigParser() config.read("/sdcard/ase/scripts/cellbotConfig.ini") #Used as an indentifier on the app engine botname = config.get("xmpp", "username") #Public ip of the phone. Dont use WIFI unless you forwarded the port. ip = netip.displayNoLo() #Port that is open on your phone. Networks may restrict this. botport = 8000 #Location of the app. appAddress = "rcptestapp.appspot.com" # Restrict to a particular path. class RequestHandler(SimpleXMLRPCRequestHandler): rpc_paths = ('/RPC2',) # Create server server = SimpleXMLRPCServer(("", botport), requestHandler=RequestHandler)