def main(): # create CLI interface cli = DustCli.DustCli( quit_cb=quit_clicb, versions={ 'SmartMesh SDK': sdk_version.VERSION, }, ) cli.registerCommand( name='connect', alias='c', description='connect to a serial port', params=['portname'], callback=connect_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='on', alias='o', description='set all LEDs on, and plot response times', params=[], callback=on_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='off', alias='f', description='clear all LEDs, and plot response times', params=[], callback=off_clicb, dontCheckParamsLength=False, )
def main(): # create CLI interface cli = DustCli.DustCli( quit_cb = quit_clicb, versions = { 'SmartMesh SDK': sdk_version.VERSION, }, ) cli.registerCommand( name = 'listmanagers', alias = 'lm', description = 'list SmartMesh IP Managers', params = [], callback = listmanagers_clicb, ) cli.registerCommand( name = 'availablemanagers', alias = 'am', description = 'notify about available Managers', params = [], callback = availablemanagers_clicb, ) cli.registerCommand( name = 'full', alias = 'f', description = 'full scan WARNING: resets all DC2274 boards!', params = [], callback = full_clicb, )
def main(): # create CLI interface cli = DustCli.DustCli( quit_cb=quit_clicb, versions={ 'SmartMesh SDK': sdk_version.VERSION, }, ) cli.registerCommand( name='connect', alias='c', description='connnect to a serial port', params=['portname'], callback=connect_clicb, dontCheckParamsLength=True, ) cli.registerCommand( name='baudrate', alias='b', description='set the baudrate', params=['baurate'], callback=baudrate_clicb, ) cli.registerCommand( name='tx', alias='tx', description= 'transmit a number of bytes, represented in hexadecimal (e.g. "ab12eb44")', params=['bytesToTx'], callback=tx_clicb, )
def main(): # create CLI interface cli = DustCli.DustCli("BroadcastLeds Application", quit_clicb) cli.registerCommand( name='connect', alias='c', description='connect to a serial port', params=['portname'], callback=connect_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='on', alias='o', description='set all LEDs on, and plot response times', params=[], callback=on_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='off', alias='f', description='clear all LEDs, and plot response times', params=[], callback=off_clicb, dontCheckParamsLength=False, ) # print SmartMesh SDK version print 'SmartMesh SDK {0}'.format('.'.join( [str(i) for i in sdk_version.VERSION])) cli.start()
def main(): # create CLI interface cli = DustCli.DustCli("Raw Serial Application", quit_clicb) cli.registerCommand( name='connect', alias='c', description='connnect to a serial port', params=['portname'], callback=connect_clicb, dontCheckParamsLength=True, ) cli.registerCommand( name='baudrate', alias='b', description='set the baudrate', params=['baurate'], callback=baudrate_clicb, ) cli.registerCommand( name='tx', alias='tx', description= 'transmit a number of bytes, represented in hexadecimal (e.g. "ab12eb44")', params=['bytesToTx'], callback=tx_clicb, ) cli.start() # print SmartMesh SDK version print 'SmartMesh SDK {0}'.format('.'.join( [str(i) for i in sdk_version.VERSION]))
def __init__(self, managerconnection, serialport, tcpport, showhub, BOTTLE_STATIC_PATH, BOTTLE_TEMPLATE_PATH, LatLngClass): # store params self.managerconnection = managerconnection self.serialport = serialport self.tcpport = tcpport self.showhub = showhub self.BOTTLE_STATIC_PATH = BOTTLE_STATIC_PATH self.BOTTLE_TEMPLATE_PATH = BOTTLE_TEMPLATE_PATH self.LatLngClass = LatLngClass # start the appropriate dataGatherer subclass found = False for sc in DataGatherer.__subclasses__(): if sc.__name__[len('DataGatherer_'):].lower( ) == self.managerconnection.lower(): self.dataGatherer = sc(args={ 'serialport': serialport, }) found = True break if not found: print 'ERROR: unexpected "managerconnection" parameter' return # interfaces self.webServer = WebServer( dataGatherer=self.dataGatherer, tcpport=self.tcpport, showhub=self.showhub, BOTTLE_STATIC_PATH=self.BOTTLE_STATIC_PATH, BOTTLE_TEMPLATE_PATH=self.BOTTLE_TEMPLATE_PATH, LatLngClass=self.LatLngClass, ) self.cli = DustCli.DustCli( quit_cb=self._clihandle_quit, versions={ 'SmartMesh SDK': sdk_version.VERSION, }, ) self.cli.registerCommand( name='stats', alias='s', description='get the current stats', params=[], callback=self._clihandle_stats, ) self.cli.registerCommand( name='status', alias='u', description='get the current status', params=[], callback=self._clihandle_status, ) print 'Web interface started at http://127.0.0.1:{0}'.format( self.tcpport)
def main(): # main app findManager = FindManager() # CLI interface cli = DustCli.DustCli( quit_cb=quit_clicb, versions={ 'SmartMesh SDK': sdk_version.VERSION, }, )
def main(): # CLI interface cli = DustCli.DustCli( quit_cb=quit_clicb, versions={ 'SmartMesh SDK': sdk_version.VERSION, }, ) cli.registerCommand( name='connect', alias='c', description='connect to a serial port', params=['portname'], callback=connect_clicb, dontCheckParamsLength=False, )
def __init__(self): # init Singletons -- must be first init SolUtils.AppConfig(config_file=CONFIGFILE) SolUtils.AppStats(stats_file=STATSFILE, stats_list=ALLSTATS) # API thread self.jsonApiThread = JsonApiThread() # CLI interface self.cli = DustCli.DustCli("SolServer", self._clihandle_quit) self.cli.registerCommand( name='stats', alias='s', description='print the stats', params=[], callback=self._clihandle_stats, )
def main(): # create CLI interface cli = DustCli.DustCli( quit_cb=quit_clicb, versions={ 'SmartMesh SDK': sdk_version.VERSION, }, ) cli.registerCommand( name='connect', alias='c', description='connect to a serial port', params=['portname'], callback=connect_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='now', alias='n', description='assess the health of the network now', params=[], callback=now_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='last', alias='l', description='print the last results', params=[], callback=last_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='period', alias='p', description='set the period of the health assessment', params=['period'], callback=period_clicb, dontCheckParamsLength=False, )
def main(): # create CLI interface cli = DustCli.DustCli("NetworkHealth Application", quit_clicb) cli.registerCommand( name='connect', alias='c', description='connect to a serial port', params=['portname'], callback=connect_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='now', alias='n', description='assess the health of the network now', params=[], callback=now_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='last', alias='l', description='print the last results', params=[], callback=last_clicb, dontCheckParamsLength=False, ) cli.registerCommand( name='period', alias='p', description='set the period of the health assessment', params=['period'], callback=period_clicb, dontCheckParamsLength=False, ) # print SmartMesh SDK version print 'SmartMesh SDK {0}'.format('.'.join( [str(i) for i in sdk_version.VERSION])) cli.start()
def __init__(self, tcpport, autoaddmgr, autodeletemgr, serialport, configfilename): # store params self.tcpport = tcpport self.autoaddmgr = autoaddmgr self.autodeletemgr = autodeletemgr self.serialport = serialport self.configfilename = configfilename # local variables self.jsonManager = JsonManager.JsonManager( autoaddmgr=autoaddmgr, autodeletemgr=autodeletemgr, serialport=serialport, configfilename=configfilename, notifCb=self._notif_cb, ) #=== CLI interface self.cli = DustCli.DustCli( quit_cb=self._clihandle_quit, versions={ 'SmartMesh SDK': sdk_version.VERSION, }, ) self.cli.registerCommand( name='status', alias='s', description='get the current status of the application', params=[], callback=self._clihandle_status, ) self.cli.registerCommand( name='serialports', alias='sp', description='list the available serialports', params=[], callback=self._clihandle_serialports, ) self.cli.registerCommand( name='connectmanager', alias='cm', description='connect to a manager\'s API serial port', params=['serialport'], callback=self._clihandle_connectmanager, ) self.cli.registerCommand( name='disconnectmanager', alias='dm', description='disconnect from a manager\'s API serial port', params=['serialport'], callback=self._clihandle_disconnectmanager, ) #=== web server self.websrv = bottle.Bottle() #=== root self.websrv.route('/', 'GET', self._webhandle_root_GET) #=== static self.websrv.route('/static/<filename>', 'GET', self._webhandle_static) #=== status self.websrv.route('/api/v1/status', 'GET', self._webhandle_status_GET) #=== raw self.websrv.route('/api/v1/raw', 'POST', self._webhandle_raw_POST) #=== oap # /info self.websrv.route('/api/v1/oap/<mac>/info', 'GET', self._webhandle_oap_info_GET) self.websrv.route('/api/v1/oap/<mac>/0', 'GET', self._webhandle_oap_info_GET) # /main self.websrv.route('/api/v1/oap/<mac>/main', 'GET', self._webhandle_oap_main_GET) self.websrv.route('/api/v1/oap/<mac>/1', 'GET', self._webhandle_oap_main_GET) self.websrv.route('/api/v1/oap/<mac>/main', 'PUT', self._webhandle_oap_main_PUT) self.websrv.route('/api/v1/oap/<mac>/1', 'PUT', self._webhandle_oap_main_PUT) # /digital_in self.websrv.route('/api/v1/oap/<mac>/digital_in/D0', 'GET', self._webhandle_oap_digital_in_D0_GET) self.websrv.route('/api/v1/oap/<mac>/2/0', 'GET', self._webhandle_oap_digital_in_D0_GET) self.websrv.route('/api/v1/oap/<mac>/digital_in/D0', 'PUT', self._webhandle_oap_digital_in_D0_PUT) self.websrv.route('/api/v1/oap/<mac>/2/0', 'PUT', self._webhandle_oap_digital_in_D0_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_in/D1', 'GET', self._webhandle_oap_digital_in_D1_GET) self.websrv.route('/api/v1/oap/<mac>/2/1', 'GET', self._webhandle_oap_digital_in_D1_GET) self.websrv.route('/api/v1/oap/<mac>/digital_in/D1', 'PUT', self._webhandle_oap_digital_in_D1_PUT) self.websrv.route('/api/v1/oap/<mac>/2/1', 'PUT', self._webhandle_oap_digital_in_D1_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_in/D2', 'GET', self._webhandle_oap_digital_in_D2_GET) self.websrv.route('/api/v1/oap/<mac>/2/2', 'GET', self._webhandle_oap_digital_in_D2_GET) self.websrv.route('/api/v1/oap/<mac>/digital_in/D2', 'PUT', self._webhandle_oap_digital_in_D2_PUT) self.websrv.route('/api/v1/oap/<mac>/2/2', 'PUT', self._webhandle_oap_digital_in_D2_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_in/D3', 'GET', self._webhandle_oap_digital_in_D3_GET) self.websrv.route('/api/v1/oap/<mac>/2/3', 'GET', self._webhandle_oap_digital_in_D3_GET) self.websrv.route('/api/v1/oap/<mac>/digital_in/D3', 'PUT', self._webhandle_oap_digital_in_D3_PUT) self.websrv.route('/api/v1/oap/<mac>/2/3', 'PUT', self._webhandle_oap_digital_in_D3_PUT) # /digital_out self.websrv.route('/api/v1/oap/<mac>/digital_out/D4', 'PUT', self._webhandle_oap_digital_out_D4_PUT) self.websrv.route('/api/v1/oap/<mac>/3/0', 'PUT', self._webhandle_oap_digital_out_D4_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_out/D5', 'PUT', self._webhandle_oap_digital_out_D5_PUT) self.websrv.route('/api/v1/oap/<mac>/3/1', 'PUT', self._webhandle_oap_digital_out_D5_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_out/INDICATOR_0', 'PUT', self._webhandle_oap_digital_out_INDICATOR_0_PUT) self.websrv.route('/api/v1/oap/<mac>/3/2', 'PUT', self._webhandle_oap_digital_out_INDICATOR_0_PUT) # /analog self.websrv.route('/api/v1/oap/<mac>/analog/A0', 'GET', self._webhandle_oap_analog_A0_GET) self.websrv.route('/api/v1/oap/<mac>/4/0', 'GET', self._webhandle_oap_analog_A0_GET) self.websrv.route('/api/v1/oap/<mac>/analog/A0', 'PUT', self._webhandle_oap_analog_A0_PUT) self.websrv.route('/api/v1/oap/<mac>/4/0', 'PUT', self._webhandle_oap_analog_A0_PUT) self.websrv.route('/api/v1/oap/<mac>/analog/A1', 'GET', self._webhandle_oap_analog_A1_GET) self.websrv.route('/api/v1/oap/<mac>/4/1', 'GET', self._webhandle_oap_analog_A1_GET) self.websrv.route('/api/v1/oap/<mac>/analog/A1', 'PUT', self._webhandle_oap_analog_A1_PUT) self.websrv.route('/api/v1/oap/<mac>/4/1', 'PUT', self._webhandle_oap_analog_A1_PUT) self.websrv.route('/api/v1/oap/<mac>/analog/A2', 'GET', self._webhandle_oap_analog_A2_GET) self.websrv.route('/api/v1/oap/<mac>/4/2', 'GET', self._webhandle_oap_analog_A2_GET) self.websrv.route('/api/v1/oap/<mac>/analog/A2', 'PUT', self._webhandle_oap_analog_A2_PUT) self.websrv.route('/api/v1/oap/<mac>/4/2', 'PUT', self._webhandle_oap_analog_A2_PUT) self.websrv.route('/api/v1/oap/<mac>/analog/A3', 'GET', self._webhandle_oap_analog_A3_GET) self.websrv.route('/api/v1/oap/<mac>/4/3', 'GET', self._webhandle_oap_analog_A3_GET) self.websrv.route('/api/v1/oap/<mac>/analog/A3', 'PUT', self._webhandle_oap_analog_A3_PUT) self.websrv.route('/api/v1/oap/<mac>/4/3', 'PUT', self._webhandle_oap_analog_A3_PUT) # /temperature self.websrv.route('/api/v1/oap/<mac>/temperature', 'GET', self._webhandle_oap_temperature_GET) self.websrv.route('/api/v1/oap/<mac>/5', 'GET', self._webhandle_oap_temperature_GET) self.websrv.route('/api/v1/oap/<mac>/temperature', 'PUT', self._webhandle_oap_temperature_PUT) self.websrv.route('/api/v1/oap/<mac>/5', 'PUT', self._webhandle_oap_temperature_PUT) # /pkgen self.websrv.route('/api/v1/oap/<mac>/pkgen/echo', 'GET', self._webhandle_oap_pkgen_echo_GET) self.websrv.route('/api/v1/oap/<mac>/254/0', 'GET', self._webhandle_oap_pkgen_echo_GET) self.websrv.route('/api/v1/oap/<mac>/pkgen', 'PUT', self._webhandle_oap_pkgen_PUT) self.websrv.route('/api/v1/oap/<mac>/254', 'PUT', self._webhandle_oap_pkgen_PUT) #=== helpers self.websrv.route('/api/v1/helpers/serialports', 'GET', self._webhandle_helpers_serialports_GET) self.websrv.route('/api/v1/helpers/motes', 'GET', self._webhandle_helpers_motes_GET) self.websrv.route('/api/v1/helpers/oapmotes', 'GET', self._webhandle_helpers_oapmotes_GET) self.websrv.route('/api/v1/helpers/snapshot', 'POST', self._webhandle_helpers_snapshot_POST) self.websrv.route('/api/v1/helpers/snapshot', 'GET', self._webhandle_helpers_snapshot_GET) #=== config self.websrv.route('/api/v1/config', 'GET', self._webhandle_config_GET) self.websrv.route('/api/v1/config', 'POST', self._webhandle_config_POST) #=== managers self.websrv.route('/api/v1/config/managers', 'PUT', self._webhandle_managers_PUT) self.websrv.route('/api/v1/config/managers', 'DELETE', self._webhandle_managers_DELETE) self.websrv.error(code=404)(self._webhandler_error_404) self.websrv.error(code=500)(self._webhandler_error_500) self.websrv.hook('after_request')( self._add_JsonServer_token_if_requested) webthread = threading.Thread(target=self._bottle_try_running_forever, args=(self.websrv.run, ), kwargs={ 'host': '127.0.0.1', 'port': self.tcpport, 'quiet': True, 'debug': False, }) webthread.name = 'WebServer' webthread.daemon = True webthread.start()
def main(): # create CLI interface cli = DustCli.DustCli("OapClient",quit_clicb) cli.registerCommand( name = 'connect', alias = 'c', description = 'connect to a serial port', params = ['portname'], callback = connect_clicb, dontCheckParamsLength = False, ) cli.registerCommand( name = 'motes', alias = 'm', description = 'list all the nodes in the network', params = [], callback = list_clicb, dontCheckParamsLength = False, ) cli.registerCommand( name = 'select', alias = 's', description = 'select the mote to use', params = ['motenum'], callback = select_clicb, dontCheckParamsLength = False, ) cli.registerCommand( name = 'notifs', alias = 'n', description = 'toggle whether to print OAP notifications', params = [], callback = notifs_clicb, dontCheckParamsLength = False, ) cli.registerCommand( name = 'writelogfile', alias = 'w', description = 'toggle whether to write OAP notifications to a LOGFILE', params = [], callback = writelogfile_clicb, dontCheckParamsLength = False, ) cli.registerCommand( name = 'led', alias = 'l', description = 'set/clear blue led', params = ['moteId/all','ledState (0 or 1)'], callback = led_clicb, dontCheckParamsLength = False, ) cli.registerCommand( name = 'temp', alias = 't', description = 'interact with the OAP "temp" resource', params = ['moteId/all','active(0 or 1)','rate'], callback = temp_clicb, dontCheckParamsLength = False, ) cli.registerCommand( name = 'pkgen', alias = 'p', description = 'set the pkgen application on the mote', params = ['moteId/allu/allb','numPkt','pktPeriod','pktSize'], callback = pkgen_clicb, dontCheckParamsLength = False, ) cli.registerCommand( name = 'analog', alias = 'a', description = 'set the analog application on the mote', params = ['moteId','channel','enable','rate'], callback = analog_clicb, dontCheckParamsLength = False, ) # print SmartMesh SDK version print 'SmartMesh SDK {0}'.format('.'.join([str(i) for i in sdk_version.VERSION])) cli.start()
def __init__(self, tcpport, serialport, notifprefix, configfilename): # store params self.tcpport = tcpport self.serialport = serialport self.notifprefix = notifprefix self.configfilename = configfilename # local variables self.startTime = time.time() self.dataLock = threading.RLock() self._loadConfig() # populates self.config dictionnary self.managerHandlers = {} self.oapDispatch = OAPDispatcher.OAPDispatcher() self.oapDispatch.register_notif_handler( self._manager_oap_notif_handler) self.oapClients = {} self.outstandingEvents = {} self.responses = {} self.hrParser = HrParser.HrParser() #=== CLI interface self.cli = DustCli.DustCli("JsonServer", self._clihandle_quit) self.cli.registerCommand( name='status', alias='s', description='get the current status of the application', params=[], callback=self._clihandle_status, ) self.cli.registerCommand( name='seriaports', alias='sp', description='list the available serialports', params=[], callback=self._clihandle_serialports, ) self.cli.registerCommand( name='connectmanager', alias='cm', description='connect to a manager\'s API serial port', params=['serialport'], callback=self._clihandle_connectmanager, ) self.cli.registerCommand( name='disconnectmanager', alias='dm', description='disconnect from a manager\'s API serial port', params=['serialport'], callback=self._clihandle_disconnectmanager, ) #=== web server self.websrv = bottle.Bottle() #=== root self.websrv.route('/', 'GET', self._webhandle_root_GET) #=== static self.websrv.route('/static/<filename>', 'GET', self._webhandle_static) #=== status self.websrv.route('/api/v1/status', 'GET', self._webhandle_status_GET) #=== raw self.websrv.route('/api/v1/raw', 'POST', self._webhandle_raw_POST) #=== oap # /info self.websrv.route('/api/v1/oap/<mac>/info', 'GET', self._webhandle_oap_info_GET) self.websrv.route('/api/v1/oap/<mac>/0', 'GET', self._webhandle_oap_info_GET) # /main self.websrv.route('/api/v1/oap/<mac>/main', 'GET', self._webhandle_oap_main_GET) self.websrv.route('/api/v1/oap/<mac>/1', 'GET', self._webhandle_oap_main_GET) self.websrv.route('/api/v1/oap/<mac>/main', 'PUT', self._webhandle_oap_main_PUT) self.websrv.route('/api/v1/oap/<mac>/1', 'PUT', self._webhandle_oap_main_PUT) # /digital_in self.websrv.route('/api/v1/oap/<mac>/digital_in/D0', 'GET', self._webhandle_oap_digital_in_D0_GET) self.websrv.route('/api/v1/oap/<mac>/2/0', 'GET', self._webhandle_oap_digital_in_D0_GET) self.websrv.route('/api/v1/oap/<mac>/digital_in/D0', 'PUT', self._webhandle_oap_digital_in_D0_PUT) self.websrv.route('/api/v1/oap/<mac>/2/0', 'PUT', self._webhandle_oap_digital_in_D0_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_in/D1', 'GET', self._webhandle_oap_digital_in_D1_GET) self.websrv.route('/api/v1/oap/<mac>/2/1', 'GET', self._webhandle_oap_digital_in_D1_GET) self.websrv.route('/api/v1/oap/<mac>/digital_in/D1', 'PUT', self._webhandle_oap_digital_in_D1_PUT) self.websrv.route('/api/v1/oap/<mac>/2/1', 'PUT', self._webhandle_oap_digital_in_D1_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_in/D2', 'GET', self._webhandle_oap_digital_in_D2_GET) self.websrv.route('/api/v1/oap/<mac>/2/2', 'GET', self._webhandle_oap_digital_in_D2_GET) self.websrv.route('/api/v1/oap/<mac>/digital_in/D2', 'PUT', self._webhandle_oap_digital_in_D2_PUT) self.websrv.route('/api/v1/oap/<mac>/2/2', 'PUT', self._webhandle_oap_digital_in_D2_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_in/D3', 'GET', self._webhandle_oap_digital_in_D3_GET) self.websrv.route('/api/v1/oap/<mac>/2/3', 'GET', self._webhandle_oap_digital_in_D3_GET) self.websrv.route('/api/v1/oap/<mac>/digital_in/D3', 'PUT', self._webhandle_oap_digital_in_D3_PUT) self.websrv.route('/api/v1/oap/<mac>/2/3', 'PUT', self._webhandle_oap_digital_in_D3_PUT) # /digital_out self.websrv.route('/api/v1/oap/<mac>/digital_out/D4', 'PUT', self._webhandle_oap_digital_out_D4_PUT) self.websrv.route('/api/v1/oap/<mac>/3/0', 'PUT', self._webhandle_oap_digital_out_D4_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_out/D5', 'PUT', self._webhandle_oap_digital_out_D5_PUT) self.websrv.route('/api/v1/oap/<mac>/3/1', 'PUT', self._webhandle_oap_digital_out_D5_PUT) self.websrv.route('/api/v1/oap/<mac>/digital_out/INDICATOR_0', 'PUT', self._webhandle_oap_digital_out_INDICATOR_0_PUT) self.websrv.route('/api/v1/oap/<mac>/3/2', 'PUT', self._webhandle_oap_digital_out_INDICATOR_0_PUT) # /analog self.websrv.route('/api/v1/oap/<mac>/analog/A0', 'GET', self._webhandle_oap_analog_A0_GET) self.websrv.route('/api/v1/oap/<mac>/4/0', 'GET', self._webhandle_oap_analog_A0_GET) self.websrv.route('/api/v1/oap/<mac>/analog/A0', 'PUT', self._webhandle_oap_analog_A0_PUT) self.websrv.route('/api/v1/oap/<mac>/4/0', 'PUT', self._webhandle_oap_analog_A0_PUT) self.websrv.route('/api/v1/oap/<mac>/analog/A1', 'GET', self._webhandle_oap_analog_A1_GET) self.websrv.route('/api/v1/oap/<mac>/4/1', 'GET', self._webhandle_oap_analog_A1_GET) self.websrv.route('/api/v1/oap/<mac>/analog/A1', 'PUT', self._webhandle_oap_analog_A1_PUT) self.websrv.route('/api/v1/oap/<mac>/4/1', 'PUT', self._webhandle_oap_analog_A1_PUT) self.websrv.route('/api/v1/oap/<mac>/analog/A2', 'GET', self._webhandle_oap_analog_A2_GET) self.websrv.route('/api/v1/oap/<mac>/4/2', 'GET', self._webhandle_oap_analog_A2_GET) self.websrv.route('/api/v1/oap/<mac>/analog/A2', 'PUT', self._webhandle_oap_analog_A2_PUT) self.websrv.route('/api/v1/oap/<mac>/4/2', 'PUT', self._webhandle_oap_analog_A2_PUT) self.websrv.route('/api/v1/oap/<mac>/analog/A3', 'GET', self._webhandle_oap_analog_A3_GET) self.websrv.route('/api/v1/oap/<mac>/4/3', 'GET', self._webhandle_oap_analog_A3_GET) self.websrv.route('/api/v1/oap/<mac>/analog/A3', 'PUT', self._webhandle_oap_analog_A3_PUT) self.websrv.route('/api/v1/oap/<mac>/4/3', 'PUT', self._webhandle_oap_analog_A3_PUT) # /temperature self.websrv.route('/api/v1/oap/<mac>/temperature', 'GET', self._webhandle_oap_temperature_GET) self.websrv.route('/api/v1/oap/<mac>/5', 'GET', self._webhandle_oap_temperature_GET) self.websrv.route('/api/v1/oap/<mac>/temperature', 'PUT', self._webhandle_oap_temperature_PUT) self.websrv.route('/api/v1/oap/<mac>/5', 'PUT', self._webhandle_oap_temperature_PUT) # /pkgen self.websrv.route('/api/v1/oap/<mac>/pkgen/echo', 'GET', self._webhandle_oap_pkgen_echo_GET) self.websrv.route('/api/v1/oap/<mac>/254/0', 'GET', self._webhandle_oap_pkgen_echo_GET) self.websrv.route('/api/v1/oap/<mac>/pkgen', 'PUT', self._webhandle_oap_pkgen_PUT) self.websrv.route('/api/v1/oap/<mac>/254', 'PUT', self._webhandle_oap_pkgen_PUT) #=== helpers self.websrv.route('/api/v1/helpers/serialports', 'GET', self._webhandle_helpers_serialports_GET) self.websrv.route('/api/v1/helpers/motes', 'GET', self._webhandle_helpers_motes_GET) self.websrv.route('/api/v1/helpers/oapmotes', 'GET', self._webhandle_helpers_oapmotes_GET) #=== config self.websrv.route('/api/v1/config', 'GET', self._webhandle_config_GET) self.websrv.route('/api/v1/config', 'POST', self._webhandle_config_POST) #=== managers self.websrv.route('/api/v1/config/managers', 'PUT', self._webhandle_managers_PUT) self.websrv.route('/api/v1/config/managers', 'DELETE', self._webhandle_managers_DELETE) self.websrv.error(code=404)(self._errorhandle_404) self.websrv.error(code=500)(self._errorhandle_500) self.websrv.hook('after_request')( self._add_JsonServer_token_if_requested) webthread = threading.Thread(target=self.websrv.run, kwargs={ 'host': '127.0.0.1', 'port': self.tcpport, 'quiet': True, 'debug': False, }) webthread.name = 'WebServer' webthread.daemon = True webthread.start() # connect to managers (if any) self._syncManagers() # start CLI print 'SmartMesh SDK {0}'.format('.'.join( [str(i) for i in sdk_version.VERSION])) self.cli.start()