| Reply | « Previous Thread | Next Thread » |
|
Hi Guys,
I'm having a problem where I am connecting my phone via BT to an external device. If I power down my phone, and then run the script it works perfectly however when I try to run the script again I get an error: Quote:
It happens when the script gracefully closes as well as when it crashes. Any ideas???? Below is the relevant code: Code:
import appuifw
import e32
import socket
def bt_connect():
print "starting to connect"
global sock
sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
target=''
if not target:
address,services=socket.bt_discover()
print "Discovered: %s, %s"%(address,services)
if len(services)>1:
import appuifw
choices=services.keys()
choices.sort()
choice=appuifw.popup_menu([unicode(services[x])+": "+x
for x in choices],u'Choose port:')
target=(address,services[choices[choice]])
else:
target=(address,services.values()[0])
print "Connecting to "+str(target)
sock.connect(target)
print "OK."
def bt_send_data(string): #send data to BT module. sends raw strings.
global sock
sock.send(string)
#print string
def bt_receive_data(): #return from bt.
global sock
i = 0
buffer = []
while(i <= 60):
data = sock.recv(1)
print str(ord(data))
buffer.append(data)
i = i + 1
return buffer
bt_connect() # connect to bt module.
def bt_close(): #close the bt sock when exiting
global sock
sock.close()
print "BTconnection closed"
def format_bt(type,number):
number_string = str.zfill(str(number),4)
type = type[0]
output = type + number_string
return output
def send_bt(type, number):
stringtosend = format_bt(type, number)
bt_send_data(stringtosend)
def stop_controller():
send_bt('S',1)
def flush_controller():
send_bt('S',2)
initialise_controller()
def exit_key_handler():
bt_close()
app_lock.signal()
def singleshot():
send_bt("C",1)
# create an Active Object
app_lock = e32.Ao_lock()
# create the tabs with its names in unicode as a list, include the tab handler
appuifw.app.set_tabs([u"Single Shot", u"Fast Shot", u"Intervalometer", u"Pano",u"Config"],handle_tab)
# set the title of the script
appuifw.app.title = u'Canon 400D V2.011'
# set app.body to app1 (for start of script)
appuifw.app.body = app1
#exit key handler
appuifw.app.exit_key_handler = exit_key_handler
#wait for lock
app_lock.wait()
Last edited by reg.orton : 2009-04-16 at 14:07.
Reason: Title change
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Bluesoleil Software | kencooper | Bluetooth Technology | 9 | 2008-08-29 20:46 |
| Bluetooth Sockets with L2CAP | Shilpa13 | Symbian Networking & Messaging | 2 | 2006-11-09 06:37 |
| Bluetooth Sockets with L2CAP | Shilpa13 | General Symbian C++ | 1 | 2006-11-09 03:56 |
| How To Make The S60 Emulator See My USB Bluetooth Dongle ? | Mo7ammed_01 | Symbian Tools & SDKs | 1 | 2006-07-25 01:14 |
| Nokia 7650 support Bluetooth audo? | ovjo12 | Bluetooth Technology | 5 | 2003-07-17 19:50 |