Example #1
0
    def update_gps_coord(self):
        '''
        Update the gps coordinates (own position).
        '''
        # start the GPS
        self.gps_context = gpsbt.start()
        
        # wait for the gps to start (Needed?)
        time.sleep(2)

        # create the device
        gpsdevice = gpsbt.gps()
        
        # get the gps coordinates
        (x,y) = (0,0)
        tries = 0
        while (x,y) == (0,0):
            coords = gpsdevice.get_position()
            (x,y) = (coords[1],coords[0])
            tries += 1
            if tries >= self.try_limit:
                break
            time.sleep(1)

        # Stop the GPS
        gpsbt.stop(self.gps_context)

        # set gps coordinates
        if not (x,y) == (0,0):
            self.gps_coord = (x,y)
            self.signal_new_gps_coord(str(x), str(y))
Example #2
0
	def stop(self):
		""" Shutdown scanners """
		if self.running:
			if self.kismet.run_flag:
				self.kismet.shutdown()
			if config.EnableGPS and self.gpscontext != None:
				gpsbt.stop(self.gpscontext)
		self.running = False
Example #3
0
 def close(self):
     print "Shutting down QoS-Manager"
     self.running = False
     try:
         # Stop the GPS
         gpsbt.stop(self.gps_context)
     except:
         # No GPS-device loaded/started
         pass
     sys.exit(0)
Example #4
0
def gps_pos():
    #Startar GPS:en
    context = gpsbt.start()
    time.sleep(2)
    #Väntar för att se att GPSen startats och kan ta emot kommandon

    gpsdevice = gpsbt.gps()
    #Skriver ut Longitud och Latitud
    x,y = (0,0)
    while (x,y) == (0,0):
        x, y = gpsdevice.get_position()
        time.sleep(1)
    print "Longitud: ",x
    print "Latitud: ",y
    # Stänger av GPS:en
    gpsbt.stop(context)
Example #5
0
def main():
    rpc.set_name("rpcsender")
    context = gpsbt.start()
    # ensure that GPS device is ready to connect and to receive commands
    time.sleep(2)
    gpsdevice = gpsbt.gps()
    while True:
        # read 3 times and show information
        for a in range(4):
            gpsdevice.get_fix()
            time.sleep(15)
        while gpsdevice.get_position() == (0,0):
            time.sleep(1)  
        lon, lat = gpsdevice.get_position()
        print rpc.send("main", "ping_with_coordinates", lon=lon, lat=lat)
    #stop gps devices
    gpsbt.stop(context)
Example #6
0
def main():
    print 'Connecting...'
    context = gpsbt.start()

    if context == None:
        print 'Problem while connecting!'
        return

    # ensure that GPS device is ready to connect and to receive commands
    time.sleep(2)
    gpsdevice = gpsbt.gps()

    # read 4 times and show information
    for a in range(4):
        gpsdevice.get_fix()
        # print information stored under 'fix' variable
        print 'Altitude: %.3f' % gpsdevice.fix.altitude
        # dump all information available
        print gpsdevice
        time.sleep(2)

    # ends Bluetooth connection
    gpsbt.stop(context)
Example #7
0
import time, gpsbt

def has_a_fix(gps):
    gps.get_fix()
    return gps.satellites_used > 0

con = gpsbt.start()
time.sleep(2.0) # wait for gps to come up
gps = gpsbt.gps()

print "Waiting for the sun... err... a fix"
while not has_a_fix(gps):
    print "Wai-ting..."
    time.sleep(5)

# do something
gpsbt.stop(con)