Hello to everybody,
I want to know does it possible to make a bluetooth application
on a phone which is developped on Python language ?
Thanks
Hello to everybody,
I want to know does it possible to make a bluetooth application
on a phone which is developped on Python language ?
Thanks
Download and review Python for Series 60 Documentation bundle at http://forum.nokia.com/main/0,6566,0...ml&fileID=6534
At "Programming with Python for Series 60 Platform" there is section dedicated to the topic - Bluetooth Sockets. There is example of services discovery and reference to Python's Bluetooth console and Bluetooth socket stdio.
May be some other examples would be useful. ;-)
Hi,
Here is a sample BT program that reads a position from a BT GPS and displays it.
import socket
class BTReader:
def connect(self):
self.sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
address,services=socket.bt_discover()
print "Discovered: %s, %s"%(address,services)
target=(address,services.values()[0])
print "Connecting to "+str(target)
self.sock.connect(target)
def readposition(self):
try:
while 1:
buffer=""
ch=self.sock.recv(1)
while(ch!='$'):
ch=self.sock.recv(1)
while 1:
if (ch=='\r'):
break
buffer+=ch
ch=self.sock.recv(1)
if (buffer[0:6]=="$GPGGA"):
(GPGGA,hhmmssss,l1ddmmmmmm,l1,l2dddmmmmmm,l2,q,xx,pp,ab,M,cd,M,xx,nnnn)=buffer.split(",")
return (l1+l1ddmmmmmm, l2+l2dddmmmmmm)
except Error:
return None
def close(self):
self.sock.close()
bt=BTReader()
bt.connect()
print bt.readposition()
print bt.readposition()
print bt.readposition()
bt.close()
I am aware that the above is oversimplification, but yet I would like to point out that:
GPGGA is not enough to read GPS position, with all receivers, since not all receiver use it.
I think you should be able decode at least :
GPGGA
GPRMC
GPGLL
messages. Possible others, I have only practical xp on subject.
One other thing is that __some__ receivers and sending some of the above messages without cordinates, if they do not hear satellites. You should not crash on it.
Just because your code work with one NMEA receiver does not meat that it works with them all.
You' re right, but I didn't pretend it to be very robust always working code. For example, in the same GPGGA string the validness etc is also stored but not used in the code.
My BT GPS unit only sends GPGSA, GPGSV, GPGGA and GPRMC strings, which again shows that different unit use different parts of the standard!
I have been trying to make a socket connection over bluetooth to a Bluez enabled GNU/Linux box, without much luck.
Is there any more information on the Python bluetooth interface, than in the 3 pdf's? I would like more examples :)
There are instructions in the postneo wiki for using Bluetooth on various platforms. See http://www.postneo.com/postwiki/moin...honForSeries60Originally posted by sverrejoh
I have been trying to make a socket connection over bluetooth to a Bluez enabled GNU/Linux box, without much luck.
Is there any more information on the Python bluetooth interface, than in the 3 pdf's? I would like more examples![]()
Is someone can check out if indentation is OK ???
ThanksCode:import socket class BTReader: def connect(self): self.sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM) address,services=socket.bt_discover() print "Discovered: %s, %s"%(address,services) target=(address,services.values()[0]) print "Connecting to "+str(target) self.sock.connect(target) def readposition(self): try: while 1: buffer="" ch=self.sock.recv(1) while(ch!='$'): ch=self.sock.recv(1) while 1: if (ch=='\r'): break buffer+=ch ch=self.sock.recv(1) if (buffer[0:6]=="$GPGGA"): (GPGGA,hhmmssss,l1ddmmmmmm,l1,l2dddmmmmmm,l2,q,xx,pp,ab,M,cd,M,xx,nnnn)=buffer.split(",") return (l1+l1ddmmmmmm, l2+l2dddmmmmmm) except Error: return None def close(self): self.sock.close() bt=BTReader() bt.connect() print bt.readposition() print bt.readposition() print bt.readposition() bt.close()
Cyke64
pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !
Find my pys60 extension modules on cyke64.googlepages.com
Originally Posted by cyke64
yes there is an error in indentation after try.
you should give a space before while
Thanks Sagars
Cyke64
pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !
Find my pys60 extension modules on cyke64.googlepages.com