From 8ae7ef3211087357333fd5170b114fb08b8b2ad0 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 8 May 2012 22:08:01 +0100 Subject: added bluetooth scanner --- wim.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'wim.py') diff --git a/wim.py b/wim.py index ccc0ac8..e8f6c78 100755 --- a/wim.py +++ b/wim.py @@ -5,7 +5,7 @@ import signal,sys def signal_handler(signal, frame): insock.close() - print "tomorrowtheground: interrupted" + print "wim: tomorrowtheground: interrupted" sys.exit(0) signal.signal(signal.SIGINT, signal_handler) @@ -16,7 +16,7 @@ from xml2obj import * if len(sys.argv)<2: - print "usage: tomorrowtheground configfile [-D] (debug)]" + print "wim: usage: tomorrowtheground configfile [-D] (debug)]" debug=False if len(sys.argv)>2: @@ -37,9 +37,9 @@ try: g.triggers.append(trigger(int(t.id),t.command,t.param)) gpslayers.append(g) except: - print "error parsing xml index entry" + print "wim: error parsing xml index entry" except: - print "no index layers found" + print "wim: no index layers found" #catch invalid xml try: @@ -50,9 +50,9 @@ try: g.setcommand(i.command) gpslayers.append(g) except: - print "error parsing xml index entry" + print "wim: error parsing xml index entry" except: - print "no scale layers found" + print "wim: no scale layers found" from gpspoller import * gpsp="" @@ -61,7 +61,14 @@ try: gpsp = GpsPoller(doc.gpsdevice) gpsp.start() except: - print "gps device not found" + print "wim: gps device not found" + +from btscan import * + +scan=scanner("127.0.0.1",5401,False) +for t in doc.bt.trigger: + scan.d.dm.triggers[t.id]=(t.command,t.param) +scan.start() import socket @@ -86,7 +93,7 @@ while True: data, addr = insock.recvfrom(128) pos.parse(data) if debug: - print "received:",data + print "wim: received:",data posChanged=True except: nothing=None @@ -102,7 +109,7 @@ while True: check=gpsp.check() if check!=False: if debug: - print "received from gps",check[0],check[1] + print "wim: received from gps",check[0],check[1] pos=latLng(check[0],check[1]) posChanged=True if posChanged: @@ -111,7 +118,7 @@ while True: r=layer.checkcoord(pos) #returns a message or None if r!=None: if (debug): - print "sending:",str(r[0]),str(r[1]) + print "wim: sending:",str(r[0]),str(r[1]) #pd needs \n at end of message outsock.sendto( str(r[0])+' '+str(r[1])+'\n', (PD_IP, PD_PORT) ) -- cgit v1.2.3