Exemple #1
0
def doUpload(file_, service, remote_device, channel, *args, **kwargs):
    yield "Connecting\n\r"
    def callback(client, response=None):
      print "callback ", args, kwargs
      if client.state == common.CONNECTING_RFCOMM:
	print "connected rfcomm\r\n"
	client.connect_obex()
      elif client.state == common.CONNECTING_OBEX:
	print "connected obex\r\n"
	client.put(file_.name, file_.read())
      elif client.state == common.PUT:
	print "uploaded completed"
	loop.quit()
      else:
	print "something completed %s %s %s" % (common.STATES[client.state], args, kwargs)

    def error(client, error):
	yield "error %s %s" % client.state, error
	client.invalid=True
	loop.quit()

    import sys, gobject
    loop=gobject.MainLoop()
    client = Client(loop=loop)
    yield "connecting rfcomm\n\r"
    client.connect_rfcomm(remote_device, channel, callback, error)
    init()
    if not getattr(client, 'invalid', False):
      yield "running loop\n\r"
      loop.run()
    yield "Success: %s\n\r" % not getattr(client, 'invalid', False)
    yield "all done\n\r"
Exemple #2
0
 def SendFilesOpp(self, files, retries, timeout, channel):
     client = Client(loop=self.loop)
     client.files = files
     client.index = 0
     client.retries = retries
     client.timeout = timeout
     client.channel = channel
     client.connect_rfcomm(
         self.target, channel, self.OppCallback, self.OppErr, bind=self.dongle.GetProperties()["Address"]
     )
Exemple #3
0
 def SendFilesOpp(self, files, retries, timeout, channel):
     client = Client(loop=self.loop)
     client.files = files
     client.index = 0
     client.retries = retries
     client.timeout = timeout
     client.channel = channel
     client.connect_rfcomm(self.target,
                           channel,
                           self.OppCallback,
                           self.OppErr,
                           bind=self.dongle.GetProperties()['Address'])