def addAll(self): cfgMotes = configuration.c.getCfgValueAsList("motes") for portName in cfgMotes: Motelist.addMote(portName, "A statically added mote", "") Motelist.initialize(self.motesUpdated, startPeriodicUpdate = True) self.refreshMotes(Motelist.getMotelist(False)) self.retrieveSelected()
def addAll(self): cfgMotes = configuration.c.getCfgValueAsList("motes") for portName in cfgMotes: Motelist.addMote(portName, "A statically added mote", "") Motelist.initialize(self.motesUpdated, False, False) Motelist.startPeriodicUpdate() self.refreshMotes(Motelist.getMotelist(False))
# Try to manually add previously found motes, should fail! print "\nTrying to add back previously manualy found motes(this should FAIL)" for port in ports: print "\tAdding mote on port {}, result: {}".format( port, "Success" if Motelist.addMote(port, "TestMote", "Test description") else "Failure") readKey() print "\nStarting periodic updates, press enter to stop!" print "\nTry to attach and reattach motes, to see any changes!" # Add our function to callbacks. # Start periodic update, which checks for motelist changes # each second and calls all callbacks only if motelist have changed. # Note that this is not blocking, it runs on different thread. Motelist.initialize(periodicUpdateCallback, True) readKey() print "\nMotelist once again:" # Simple check, to see if no problems are caused by this. Motelist.getMotelist(False) Motelist.getMotelist(True) Motelist.printMotelist() # Clean up. Motelist.removeUpdateCallback(periodicUpdateCallback) Motelist.stopPeriodicUpdate() # Cya. print "\nThe end, to understand more, please look into the source of this test."