Monday, February 13, 2012
PYTHON APPLICATIONS....PART 1
A software for controlling the keyboard and mouse of Ur laptop with a Bluetooth enabled Symbian phone.actually this was ma mini project and we did this in two platforms QT and .NET ,later during an interview the interviewer asked me why did we u two different platforms instead of doing it in one ..........this question was stuck in ma mind for long time which forced me to do this in a single platform . later i chose python for doing this..and here it goess
we do this in two parts
1.client ie ur phone
2.server ie ur laptop
let start with client
requirements
a Symbian phone with Bluetooth and python installed .you can get the python for ur mobile from following links
http://dl.dropbox.com/u/30579529/mobile%20applications/sis/pips.sis
http://dl.dropbox.com/u/30579529/mobile%20applications/sis/pips_nokia_1_3_SS.sis
http://dl.dropbox.com/u/30579529/mobile%20applications/sis/Python_2.0.0.sis
http://dl.dropbox.com/u/30579529/mobile%20applications/sis/pythonapps_zxcyexuy.sis
http://dl.dropbox.com/u/30579529/mobile%20applications/sis/PythonScriptShell_2.0.0_3_0.sis
http://dl.dropbox.com/u/30579529/mobile%20applications/sis/PythonScriptShell_2.0.0_devcert_signed.sis
make sure that u have installed all the files in ur phone
now u can find the python shell in ur phone application menu
the best way to do this to make a .py file and run it in python>>run script option in ur phone
the following code actually
1.switch on the phone bluetooth if its off and search for a server and connects it tothe server .
2.search for each key press make and send to the server with send function(it actually sends the mobile ascii value)
code:
import appuifw
import socket
import graphics
import e32
import btsocket as socket
keyboard_state={}
last_keycode=0
def bt_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:
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 callback(event):
if event['type'] == appuifw.EEventKeyDown:
keyboard_state[event['scancode']]=1
elif event['type'] == appuifw.EEventKeyUp:
keyboard_state[event['scancode']]=0
elif event['type'] == appuifw.EEventKey:
last_keycode=event['keycode']
canvas.text((0,60),u'%s'%(last_keycode))
sock.sendall(u'%s'%(last_keycode))
bt_connect()
canvas=appuifw.Canvas(event_callback=callback)
appuifw.app.body=canvas
lock=e32.Ao_lock()
appuifw.app.exit_key_handler=lock.signal
lock.wait()
Labels:
DEVELOPMENT
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment