def main(): sock = socket(AF_ZIGBEE, SOCK_DGRAM, ZBS_PROT_TRANSPORT) sock.bind(("", 0xe8, 0, 0)) # Create a suitable RCI callback that wraps the socket callback = lambda d,s=sock: transmit_data(s, d) rci.add_rci_callback("sparkfun", callback) sock.close()
def __init__(self, xig_core): self.__core = xig_core self.__targets_desc = "" self.__started = False if 'idigidata' in sys.modules and hasattr(idigidata, 'register_callback'): # new style idigidata.register_callback( "xig", lambda target, data: self.__rci_callback(data)) self.__targets_desc = '"data_service"' self.__started = True if 'rci' in sys.modules and hasattr(rci, 'add_rci_callback'): # old style rci_thread = threading.Thread(name="XIG RCI Handler", target=lambda: rci.add_rci_callback( "xig", self.__rci_callback)) rci_thread.setDaemon(True) rci_thread.start() self.__targets_desc = ' '.join( (self.__targets_desc, '"do_command"')) self.__started = True if not self.__started: raise Exception, "unable to start: no RCI callback registration methods"
def start(self): """Start listening for messages on the specified target""" target_name = SettingsBase.get_setting(self, 'target_name') add_callback = lambda name=target_name: rci.add_rci_callback( name, self.__rci_callback) threading.Thread(target=add_callback).start()
def start(self): """Start listening for messages on the specified target""" target_name = SettingsBase.get_setting(self, 'target_name') if not RCI_NONBLOCKING: add_callback = lambda name=target_name: rci.add_rci_callback( name, self.__rci_callback) self._handle = threading.Thread(name="RCI Handler", target=add_callback) self._handle.start() else: self._handle = rci.RciCallback(target_name, self.__rci_callback)
def start(self): """Start listening for messages on the specified target""" target_name = SettingsBase.get_setting(self, 'target_name') if not RCI_NONBLOCKING: add_callback = lambda name=target_name: rci.add_rci_callback( name, self.__rci_callback) self.__handle = threading.Thread(name="RCI Handler", target=add_callback) self.__handle.start() else: self.__handle = rci.RciCallback(target_name, self.__rci_callback)
def __init__(self, xig_core): self.__core = xig_core self.__targets_desc = "" self.__started = False if 'idigidata' in sys.modules and hasattr(idigidata, 'register_callback'): # new style idigidata.register_callback("xig", lambda target, data: self.__rci_callback(data)) self.__targets_desc = '"data_service"' self.__started = True if 'rci' in sys.modules and hasattr(rci, 'add_rci_callback'): # old style rci_thread = threading.Thread(name="XIG RCI Handler", target=lambda: rci.add_rci_callback( "xig", self.__rci_callback)) rci_thread.setDaemon(True) rci_thread.start() self.__targets_desc = ' '.join((self.__targets_desc,'"do_command"')) self.__started = True if not self.__started: raise Exception, "unable to start: no RCI callback registration methods"
dispatcher = Dispatcher(controller) print "xgw: Starting XBee name resolver thread" resolver.start() print "xgw: Starting XBee conection thread" xbee.start() print "xgw: Starting HTTP uploader thread" uploader.start() print "xgw: Starting time sender thread" timeSender.start() print "xgw: Registering RCI callback ", RCI_CALLBACK_NAME rci.add_rci_callback(RCI_CALLBACK_NAME, dispatcher.callback) # --- terminating --- print "xgw: Stopping time sender thread" timeSender.close() print "xgw: Stopping HTTP uploader thread" uploader.close() print "xgw: Stopping XBee conection thread" xbee.close() print "xgw: Stopping XBee name resolver thread" resolver.close()