def sendfile(address, channel, source): if not isinstance(source, (types.StringTypes, types.FileType)): raise TypeError("source must be string or built-in file object") if isinstance(source, types.StringTypes): try: _socket.bt_obex_send_file(address, channel, unicode(source)) except Exception, e: raise OBEXError(str(e))
def bt_send(): device = socket.bt_obex_discover() print 'device:', device address = device[0] print 'address:', address channel = device[1][u'OBEX Object Push'] print 'channel:', channel socket.bt_obex_send_file(address, channel, file) appuifw.note(u"Image sent!", "info")
def bt_send(): file=(u'e:\\Images\\picture1.jpg') device=socket.bt_obex_discover() print 'device:', device address=device[0] print 'address:', address channel=device[1][u'OBEX Object Push'] print 'channel:', channel socket.bt_obex_send_file(address,channel,file) appuifw.note(u"Picture sent","info")
def start(): image= camera.take_photo() appuifw.app.body=c=appuifw.Canvas() c.blit(image,scale=1) file=(u'e:\\Images\\picture1.jpg') image.save(file) device=socket.bt_obex_discover() address=device[0] channel=device[1][u'OBEX Object Push'] socket.bt_obex_send_file(address,channel,file) appuifw.note(u"Picture sent","info")
def start(): image = camera.take_photo() appuifw.app.body = c = appuifw.Canvas() c.blit(image, scale=1) file = u"e:\\Images\\Image.jpg" image.save(file) device = socket.bt_obex_discover() address = device[0] channel = device[1][u"OBEX Object Push"] socket.bt_obex_send_file(address, channel, file) appuifw.note(u"Picture sent", "info")
def send_photo(): try: address, services = socket.bt_obex_discover() except: appuifw.note(u"OBEX Push not available", "error") return if u'OBEX Object Push' in services: channel = services[u'OBEX Object Push'] socket.bt_obex_send_file(address, channel, PHOTO) appuifw.note(u"photo sent", "info") else: appuifw.note(u"OBEX Push not available", "error")
except Exception, e: raise OBEXError(str(e)) else: # given file object if hasattr(source, "name"): localpath = _tempfilename(source.name) else: localpath = _tempfilename() try: # write the source file object's data into a file, then send it f = file(localpath, "wb") f.write(source.read()) f.close() try: _socket.bt_obex_send_file(address, channel, unicode(localpath)) except Exception, e: raise OBEXError(str(e)) finally: # remove temporary file if os.path.isfile(localpath): try: os.remove(localpath) except Exception, e: print "[lightblue.obex] unable to remove temporary file %s: %s" %\ (localpath, str(e)) def recvfile(sock, dest): if not isinstance(dest, (types.StringTypes, types.FileType)): raise TypeError("dest must be string or built-in file object")