def __init__(self, server, xbee, remote_id, starting_mid, callback, cb_ignore_read_exception=None, cb_ignore_write_exception=None): """ Initialize the client. :param xbee: the xbee device :param remote_id: the remote xbee device :param callback:the callback function to be invoked when a response is received :param starting_mid: used for testing purposes :param sock: if a socket has been created externally, it can be used directly :param cb_ignore_read_exception: Callback function to handle exception raised during the socket read operation :param cb_ignore_write_exception: Callback function to handle exception raised during the socket write operation """ self.xbee = xbee self.xbee.open() logger.info('xbee address %s' % xbee.get_64bit_addr()) logger.info('xbee node id %s' % xbee.get_node_id()) xnet = xbee.get_network() self.remote = xnet.discover_device(remote_id) logger.info(self.remote) UDP_CoAP.__init__(self, server, starting_mid, callback, sock=None, cb_ignore_read_exception=cb_ignore_read_exception, cb_ignore_write_exception=cb_ignore_write_exception)
def __init__(self, host, port, message): CoAP.__init__(self, server=(host, port), starting_mid=None, callback=None) try: self.send_message(message) except Exception as e: print "Exception: ", str(e) self.close()