Пример #1
0
def set_my_requestors():
    #set_requestors(requestors)
    positioning.set_requestors([{
        "type": "service",
        "format": "application",
        "data": "test_app"
    }])
Пример #2
0
 def __initgps(self):
     try:
         import positioning as gps
         gps.select_module(gps.default_module())
         gps.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
         gps.position(course=1,satellites=0,callback=self.__gps_cb, interval=5000000,partial=0)#intervall at 5 seconds atm
         e32.ao_sleep(3)
     except ImportError:
         self.gps_result="Error"
Пример #3
0
 def StartGPS():
     positioning.select_module(positioning.default_module())
     positioning.set_requestors([{
         "type":"service",
         "format":"application",
         "data":"test_app"
         }])
     positioning.position(course=1,satellites=1,
                          callback=S60DataProvider.CallBack,
                          interval=S60DataProvider.interval,
                          partial=1)
def get_position_with_requestor():
    positioning.set_requestors([{
        "type": "service",
        "format": "application",
        "data": "test_app"
    }])
    print "Starting position feed again - with requestor."
    print positioning.position(course=1,
                               satellites=1,
                               callback=cb,
                               interval=1000000,
                               partial=1)
Пример #5
0
 def Update(self):
     positioning.select_module(positioning.default_module())
     positioning.set_requestors([{"type":"service", 
                          "format":"application",
                          "data":"GpsLocProvider"}])  
     
     # open log file
     if(self.logmode):
         self.FILE = open(self.logpath, "w+")
         self.FILE.write("LOGFILE START:\r")
         self.FILE.write("GPS Modules detected:\r")
         self.FILE.write(str(positioning.modules()))
         self.FILE.write("Using default: " + str(positioning.default_module()) + "\r")
    
     global keep_scanning
     
     while keep_scanning: 
         # get current location, compare to old current location
         newLoc = self.getCurrentLocation()
         if newLoc['lat'] != newLoc['lat']: # if we got a "NaN" response from positioning, this will abort and try again
         	continue
         # if no(or little) change, don't do anything
         #latDif = math.fabs(newLoc["lat"] - self.current_location["lat"])
         #lngDif = math.fabs(newLoc["lng"] - self.current_location["lng"])
         # if latDif < 0.0001 or lngDif < .001:
         #     print "Haven't moved far enough.  Cancelling update."
         #self.current_location = newLoc
         
         #self.nearbyLock.signal()
         self.addPOIs(self.get_nearby_locations(self.current_location["lat"], self.current_location["lng"]))
            
         self.actives = self.get_active_list()
         if len(self.actives) != 0:
             self.newActives = 1
         else:
         	self.newActives = 0
             	
    #     for poi in actives:
     #        self.GUI.location_cache.appendLocation(poi)       
      #       self.GUI.notifyOfNewLocation(poi["name"])
             
       #  print "Update in :" + str(time.clock() - initialTime) + " ms."       
                        
         if self.logmode:                 
         	self.FILE.flush()
         e32.ao_yield()
         e32.ao_sleep(5)
     
     if self.logmode:
     	self.FILE.write("Total GPS scans performed: " + str(self.total_scans) + "\r")
     	self.FILE.write("Avg time per scan: " + str(self.total_scan_time / self.total_scans) + "\r")
     	self.FILE.close()
     print "Update thread done."
Пример #6
0
 def StartGps(self):
     Log("ngps", "NativeGps::StartGps()")
     import positioning
     positioning.select_module(positioning.default_module())
     positioning.set_requestors([{
         "type": "service",
         "format": "application",
         "data": "tracker-py"
     }])
     positioning.position(course=1,
                          satellites=1,
                          callback=self.CallBack,
                          interval=500000,
                          partial=1)
Пример #7
0
def getCoordinates():
    positioning.select_module(positioning.default_module())
    positioning.set_requestors([{
        'type': 'service',
        'format': 'application',
        'data': 'position'
    }])
    try:
        sys.stdout.write('Retrieving GPS co-ordinates ...\n')
        data = positioning.position(course=1, satellites=1)
    except:
        sys.stdout.write('Could not retrieve GPS co-ordinates\n\n\n')
        sys.exit(-1)
    else:
        sys.stdout.write('GPS co-ordinates retrieved\n')
    return (data['position']['latitude'], data['position']['longitude'])
Пример #8
0
 def initialize_gps():
         appuifw.note(u'Intializing GPS')
         
         global gps_data
         gps_data = {'satellites':{'horizontal_dop': 0.0, 'used_satellites': 0, 'vertical_dop': 0.0, 'time': 0.0,'satellites': 0,'time_dop':0.0},
                                         'position':{'latitude': 0.0, 'altitude': 0.0, 'vertical_accuracy': 0.0, 'longitude': 0.0,'horizontal_accuracy': 0.0},
                                         'course': {'speed': 0.0, 'heading': 0.0, 'heading_accuracy': 0.0, 'speed_accuracy': 0.0}}
         try:
 # Set requesters - it is mandatory to set at least one
                 
                 positioning.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
 # Request for a fix every 0.5 seconds
                 positioning.position(course=1,satellites=1,callback=cb_gps, interval=500000,partial=0)
 # Sleep for 3 seconds for the intitial fix
                 e32.ao_sleep(5)
         except:
                 appuifw.note(u'Problem with GPS','error')
Пример #9
0
def gps_init():
	#This function will start the updating of global variable (dictionary) 'gps_data' every 0.2 sec.
	#0.2 sec comes form 'interval = 200000' set according to your needs
	#This function uses callback funtion gps
	global gps_data
	#First this fills the gps_data with 0.0 so that there is something before the first gps update
	gps_data = {
	'satellites': {'horizontal_dop': 0.0, 'used_satellites': 0, 'vertical_dop': 0.0, 'time': 0.0,'satellites': 0, 'time_dop':0.0}, 
	'position': {'latitude': 0.0, 'altitude': 0.0, 'vertical_accuracy': 0.0, 'longitude': 0.0, 'horizontal_accuracy': 0.0}, 
	'course': {'speed': 0.0, 'heading': 0.0, 'heading_accuracy': 0.0, 'speed_accuracy': 0.0}
	}
	try:
		positioning.select_module(positioning.default_module())
		positioning.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
		positioning.position(course=1,satellites=1,callback=gps, interval=200000,partial=0)
		e32.ao_sleep(3)
	except:
		appuifw.note(u'Problem with GPS','error')
Пример #10
0
  def open(self, id=None):

    self.id       = id

    if id == None:
      id = positioning.default_module()
    self.id       = id
    self.info = positioning.module_info(self.id)
    self.name = PositioningProvider.name + " using " + self.info["name"]
    # HACK ALERT: undocumented, but otherwise bluetooth stays open!
    if e32.pys60_version < '1.4.5':
      positioning._positioner=positioning._pos_serv.positioner(self.id)
    else:
      positioning.select_module(self.id)

    positioning.set_requestors([{"type":"service",
                                 "format":"application",
                                 "data":"test_app"}])
    positioning.position(course=True, satellites=True, callback=self.__callback,
                         interval=int(self.interval*1.0E6), partial=True)
    self.ok = True
Пример #11
0
    def test_positioning_info(self):
        positioning.set_requestors([{
            "type": "service",
            "format": "application",
            "data": "test_app"
        }])
        event = positioning.position(course=1, satellites=1, partial=1)
        positioning.stop_position()
        self.failUnlessEqual(len(event), len(gps_data['position_info']),
                             "position API erroneous")
        self.failUnlessEqual(
            event.keys(), gps_data['position_info'].keys(),
            "Testing the keys returned by postion API failed")
        compare_keys = (event['satellites'].keys()
                        == gps_data['position_info']['satellites'].keys()
                        and event['position'].keys()
                        == gps_data['position_info']['position'].keys()
                        and event['course'].keys()
                        == gps_data['position_info']['course'].keys())
        self.assert_(
            compare_keys,
            "comparision of satellites, course or " + "position keys failed")

        event = positioning.position(course=0, satellites=1, partial=1)
        positioning.stop_position()
        self.assert_(
            event['course'] is None and event['satellites'] is not None,
            'Only course info was set to zero')

        event = positioning.position(course=1, satellites=0, partial=1)
        positioning.stop_position()
        self.assert_(
            event['satellites'] is None and event['course'] is not None,
            'only satellites info was set to zero')

        event = positioning.position(course=0, satellites=0, partial=1)
        positioning.stop_position()
        self.assert_(event['course'] is None and event['satellites'] is None,
                     'course and satellites info were not requested for')
Пример #12
0
def initialize_gps():
	'''This function initializes the GPS. The select_module(module_id) can be used to select the GPS module in this function. 
	In this case we are using the default GPS (integrated GPS) hence we do not need to select it.'''
	print "Intializing GPS"
	global gps_data
	global gpson
	#Intitialize the global dictionary with some initial dummy value (0.0 in this case)
	gps_data = {
	'satellites': {'horizontal_dop': 0.0, 'used_satellites': 0, 'vertical_dop': 0.0, 'time': 0.0,'satellites': 0, 'time_dop':0.0}, 
	'position': {'latitude': 0.0, 'altitude': 0.0, 'vertical_accuracy': 0.0, 'longitude': 0.0, 'horizontal_accuracy': 0.0}, 
	'course': {'speed': 0.0, 'heading': 0.0, 'heading_accuracy': 0.0, 'speed_accuracy': 0.0}
	}
	try:
		# Set requesters - it is mandatory to set at least one
		positioning.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
		# Request for a fix every 0.5 seconds
		positioning.position(course=1,satellites=1,callback=cb_gps, interval=1000000,partial=1)
		# Sleep for 30 seconds for the intitial fix
		e32.ao_sleep(30)
		gpson = 1
	except:
		print "Problem with GPS"
def go_thread():
    try:
        debug("GPS thread launching")
        positioning.set_requestors([{
            "type": "service",
            "format": "application",
            "data": "test_app"
        }])

        # interval: position update periof when gps is on (microseconds)
        # callback: callable to call when position update is available
        positioning.position(callback=cb,
                             interval=5 * 1000 * 1000,
                             satellites=1,
                             course=1,
                             partial=1)

        death_point = time.time() + 10
        while time.time() < death_point:
            debug("GPS thread looping")
            e32.ao_sleep(1)
    except:
        info = sys.exc_info()
        debug(traceback.format_exception(*info))
Пример #14
0
# import httplib
from time import time

import positioning

# SERVER_URL = "server.url"
# SERVER_PATH = "/some/path"
# HTTP_METHOD = "POST"

LOG_FILE = "E:\\gps_log.txt"

positioning.select_module(positioning.default_module())
positioning.set_requestors([{
    "type": "service",
    "format": "application",
    "data": "gps_info_getter"
}])

positioning.last_position()


def callback_fn(e):
    """Callback to log GPS info
    
    Arguments:
    - `event`: The info from a GPS event
    """
    fp = open(LOG_FILE, "a")
    fp.write("%s,%s,%s,%s\n" %
             (e['position']['latitude'], e['position']['longitude'],
Пример #15
0
import positioning,appuifw,time,e32

positioning.select_module(positioning.default_module())
positioning.set_requestors([{"type":"service",
                             "format":"application",
                             "data":"test_app"}])

def getmyposition():
    print 'Reading GPS. Wait...'
    result = positioning.position()
    print 'all gps data: ', result    
    coordinates=result["position"]
    mylatitude = coordinates["latitude"]
    mylongitude = coordinates["longitude"]
    browserApp ='BrowserNG.exe'
    url = 'http://www.marinetraffic.com/ais/m/mob_map.aspx?&zoom=12&centerx='+str(mylongitude)+'&centery='+str(mylatitude)
    e32.start_exe(browserApp, ' "4 %s"' %url, 1)
    appuifw.app.set_exit()

getmyposition()
Пример #16
0
 def start(self):
   appuifw.note(u"starting location scan", 'info')
   positioning.set_requestors([{"type":"service", "format":"application", "data":"test_app"}]) 
   positioning.position(course=1,satellites=1, callback=self.run, interval=1000000, partial=1)
   self.running = True
Пример #17
0
    #print 'Sound ready!'
except:
    print 'Oops! NOT available: %s!' % media

print
print 'IMEI:%s\nUserAgent:%s' % (imei, uagent)
mod = pos.default_module()  # A-GPS as first time fixer
pos.select_module(mod)
modinfo = pos.module_info(mod)
print '%s:%s,QoD:%s' % (modinfo['name'], modinfo['id'],
                        modinfo['status']['data_quality'])
try:
    # set_requestors() must follows select_module()
    pos.set_requestors([{
        "type": "service",
        "format": "application",
        "data": "test_app"
    }])
    gpsdict = pos.position(satellites=True)
except:
    print 'Oops! GPS failed!'
    pos.stop_position()
    sys.exit(1)

mod -= 2
pos.select_module(mod)  # Built-in GPS
modinfo = pos.module_info(mod)
pos.set_requestors([{
    "type": "service",
    "format": "application",
    "data": "test_app"
Пример #18
0
 def __init__(self, moduleID=positioning.default_module()):
     self.callbacks = []
     positioning.select_module(moduleID)
     positioning.set_requestors([{"type":"service", \
                                  "format":"application", \
                                  "data":"test_app"}])
Пример #19
0
 def get_position(self):
     positioning.select_module(270526860) # A-GPS -- you need at least a working GPRS connection
     positioning.set_requestors([{"type":"service","format":"application","data":"iamhere"}])
     sys.stdout.write(u"Retrieving position ...\n")
     return positioning.position()['position']
Пример #20
0
 def __init__(self, moduleID = positioning.default_module()):
     self.callbacks = []
     positioning.select_module(moduleID)
     positioning.set_requestors([{"type":"service", \
                                  "format":"application", \
                                  "data":"test_app"}])