1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
"""
Shows how to send a file over OBEX.
"""
import lightblue
import sys
if len(sys.argv) == 1:
print "Usage: file_send.py [filename]"
sys.exit(1)
sourcefile = sys.argv[1]
# Ask user to choose the device and service to send the file to.
address, serviceport, servicename = lightblue.selectservice()
# Send the file
lightblue.obex.sendfile(address, serviceport, sourcefile)
print "Done!"
# Note:
# Instead of calling selectservice(), you could do:
#
# services = lightblue.findservices(addr=lightblue.selectdevice()[0],
# servicetype=lightblue.OBEX)
# address, serviceport, servicename = services[0]
# lightblue.obex.sendfile(address, serviceport, sourcefile)
#
# This will ask the user to select a device, and then just send the file to the
# first OBEX service found on that device. Then you don't have to ask the
# user to select a particular service.
#
|