i am really wondering why this type of error continues to occur for every bluetooth code i try.. i am trying to connect to a bluetooth module... i am wondering why i cant connect to that module where in i can connect to other devices like mobile phone and laptops... i have tried so many code for sending a file through bluetooth but i still cant connect/send a file to our bluetooth module... here is the code hope somebody will help me on this coz we really need to make this thing work for our thesis: (thanks in advance)
code1:
from e32socket import bt_obex_discover, bt_obex_send_file
import appuifw
import e32
import dir_iter
import os
class SendFilebrowser:
def __init__(self):
self.script_lock = e32.Ao_lock()
self.dir_stack = []
self.current_dir = dir_iter.Directory_iter(e32.drive_list())
def run(self):
from key_codes import EKeyLeftArrow
entries = self.current_dir.list_repr()
if not self.current_dir.at_root:
entries.insert(0, (u"..", u""))
self.lb = appuifw.Listbox(entries, self.lbox_observe)
self.lb.bind(EKeyLeftArrow, lambda: self.lbox_observe(0))
old_title = appuifw.app.title
self.refresh()
self.script_lock.wait()
appuifw.app.title = old_title
appuifw.app.body = None
self.lb = None
def refresh(self):
appuifw.app.title = u"Send Filebrowser"
appuifw.app.menu = []
appuifw.app.exit_key_handler = self.exit_key_handler
appuifw.app.body = self.lb
def do_exit(self):
self.exit_key_handler()
def exit_key_handler(self):
appuifw.app.exit_key_handler = None
self.script_lock.signal()
def lbox_observe(self, ind = None):
if not ind == None:
index = ind
else:
index = self.lb.current()
focused_item = 0
if self.current_dir.at_root:
self.dir_stack.append(index)
self.current_dir.add(index)
elif index == 0: # ".." selected
focused_item = self.dir_stack.pop()
self.current_dir.pop()
elif os.path.isdir(self.current_dir.entry(index-1)):
self.dir_stack.append(index)
self.current_dir.add(index-1)
else:
item = self.current_dir.entry(index-1)
i = appuifw.popup_menu()
if i == 0:
try:
phone = bt_obex_discover()
bt_obex_send_file(phone[0], phone[1].values()[0], unicode(item))
appuifw.note(u'File Sent')
self.refresh()
except Exception, error:
appuifw.note(unicode(error), 'error')
return
entries = self.current_dir.list_repr()
if not self.current_dir.at_root:
entries.insert(0, (u"..", u""))
self.lb.set_list(entries, focused_item)
if __name__ == '__main__':
SendFilebrowser().run()
code2:
from appuifw import *
from e32socket import *
try:
phone = bt_obex_discover()
addr=phone[0]
port=phone[1].values()[0]
file = query(u'File Path', 'text')
bt_obex_send_file(addr, port , file)
note(u'File Sent', 'info')
except Exception, error:
note(unicode(error), 'error')