Sending files via OBEX (lightblue/OBEXFTP)
I'm trying desperately to send files via OBEX, using python. I have two functioning codes, the first using lightblue and the other using obexftp. We've got here two android phones, the first is a Samsung Galaxy S and the second is HTC desire HD (running CyanogenMod 7.1). I'm trying to send files to these phones from a computer running Ubuntu (both natty and lucid).
The thing is, each code works with only one phone. And only sometimes.
The first one is:
import lightblue
client=lightblue.obex.OBEXClient('MACADDR',CHANNEL)
client.connect()
client.put({'name':'file.png'},file('file.png',"rb"))
client.disconnect()
this one only works with the galaxy s. If I try to send files to the desire hd I get:
<OBEXRespnse reason='Internal Server Error' code=0x50 (0xd0) headers={}>
The second code is:
import obexftp
cli=obexftp.client(obexftp.BLUETOOTH)
channel=obexftp.browsebt('MACADDR',obexftp.PU开发者_运维问答SH)
print channel #it is the correct channel, I've doubled checked
cli.connect ('MACADDR',channel)
cli.put_file("./file.png") #I also noticed you need to wait a second before this
cli.disconnect()
This one only works with the desire hd (sometimes).
All devices were paired using the bluez-simple-agent script, which is available in Ubuntu.
I'm trying to figure out what's causing this inconsistency, unsuccessfully. I'd happy if someone here point out what am I doing wrong or show me a code that actually works.
OBEX can be notoriusly buggy, there are a lot of Headset/Handsfree manufacturers investing massive amounts of money in testing OBEX and other BT protocols... Maybe this is the problem! Can you try more phones to test this?!
精彩评论