def get_position_without_requestor(): print "Starting position feed again- without requestor." print positioning.position(course=1, satellites=1, callback=cb, interval=1000000, partial=1)
def start(self): if self.active: return positioning.position(course = 1, satellites = 1, callback = self._cb, interval = 30000000, partial = 0) self.active = True
def set_module(): modules = positioning.modules() positioning.select_module(modules[2]["id"]) print "Starting position feed again- withspecific module." print positioning.position(course=1, satellites=1, callback=cb, interval=1000000, partial=1)
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"
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)
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)
def get_position(): print "***position info***" t.add(u"\n\n***position info***") pos = positioning.position() print pos print "" t.add(unicode("\n\nposition: " + str(pos)))
def get_position(): print "***position info***" t.add(u"\n\n***position info***") pos = positioning.position() print pos print "" t.add( unicode( "\n\nposition: " + str(pos) ) )
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')
def get_position(): positioning.select_module(270526858) pos=positioning.position()['position'] ret="latitude=",pos['latitude'], "&longitude=", pos['longitude'] return ret
def get_current_position(): global pos global state state = "get_current_pos" long_pos = positioning.position() pos = long_pos['position'] pos_string = u"Lat: " + str(pos['latitude']) + "\n" + u"Long: " + str(pos['longitude']) appuifw.query(pos_string, "query") state = "have_position"
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')
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¢erx='+str(mylongitude)+'¢ery='+str(mylatitude) e32.start_exe(browserApp, ' "4 %s"' %url, 1) appuifw.app.set_exit()
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
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')
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 getmyposition(): result = positioning.position(course=1) #print 'all gps data: ', result coordinates=result["position"] mylatitude = coordinates["latitude"] mylongitude = coordinates["longitude"] course = result["course"] print course speed = course["speed"] heading = course["heading"] print 'mylatitude: ', mylatitude print 'mylongitude:', mylongitude print 'speed',speed print 'heading ',heading return mylatitude, mylongitude, speed, heading
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))
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'])
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=11¢erx=" + str(mylongitude) + "¢ery=" + str(mylatitude) ) e32.start_exe(browserApp, ' "4 %s"' % url, 1) appuifw.app.set_exit()
def getCurrentLocation(self): previous_time = time.clock() tempDict = positioning.position() currentTime = time.clock() self.current_location = {"lat":tempDict["position"]["latitude"], "lng":tempDict["position"]["longitude"], "timestamp":currentTime} # write to the log if necessary. if self.logmode: logtext = "GPS query completed in " + str(currentTime-previous_time) + " sec.\r" self.total_scan_time += currentTime-previous_time self.total_scans += 1 self.FILE.write(logtext) logtext = "New position is: " + str(self.current_location["lat"]) + ", " + str(self.current_location["lng"]) + "\r" self.FILE.write(logtext) self.GUI.current_position = self.current_location return self.current_location
def getmyposition(): print 'Reading GPS. Wait...' result = positioning.position() #print 'all gps data: ', result coordinates=result["position"] mylatitude = coordinates["latitude"] mylongitude = coordinates["longitude"] print 'mylatitude: ', mylatitude print 'mylongitude:', mylongitude s='<meta HTTP-EQUIV="REFRESH" content="0; url=http://mobil.gulesider.no/query?itype=nautical&what=mobaddr&map=1¢er='+str(mylongitude)+'%2C'+str(mylatitude)+'">' f=open('E:\\Activenotes\\goto.html','w') f.write(s) f.close() browserApp ='BrowserNG.exe' url = 'file:///E:/Activenotes/goto.html' e32.start_exe(browserApp, ' "4 %s"' %url, 1) appuifw.app.set_exit()
def getmyposition(): print 'Reading GPS. Wait...' result = positioning.position() #print 'all gps data: ', result coordinates=result["position"] mylatitude = coordinates["latitude"] mylongitude = coordinates["longitude"] print 'mylatitude: ', mylatitude print 'mylongitude:', mylongitude s='<meta HTTP-EQUIV="REFRESH" content="0; url=http://kansalaisen.karttapaikka.fi/kartanhaku/koordinaattihaku.html?srsName=EPSG%3A4258&showSRS=EPSG%3A4258&scale=16000&width=600&heigth=600&y=' + str(mylatitude) + '&x=' + str(mylongitude) + '">' f=open('E:\\Activenotes\\goto.html','w') f.write(s) f.close() browserApp ='BrowserNG.exe' url = 'file:///E:/Activenotes/goto.html' e32.start_exe(browserApp, ' "4 %s"' %url, 1) appuifw.app.set_exit()
def getmyposition(): print 'Reading GPS. Wait...' result = positioning.position() #print 'all gps data: ', result coordinates=result["position"] mylatitude = coordinates["latitude"] mylongitude = coordinates["longitude"] print 'mylatitude: ', mylatitude print 'mylongitude:', mylongitude f=open('E:/ais.html','w') f.write('<script type="text/javascript">\nwidth=400;\nheight=400;\nborder=0;\nnotation=false;\nshownames=false;\nzoom=10;\nmaptype=0;\ntrackvessel=0;\nfleet="";\nremember=false;\n') f.write('latitude=') f.write(str(mylatitude)) f.write('; \nlongitude=') f.write(str(mylongitude)) f.write(';\n</script>\n<script type="text/javascript" src="http://www.marinetraffic.com/ais/embed.js"></script>\n') f.close() browserApp ='BrowserNG.exe' url = 'file:///E:/ais.html' e32.start_exe(browserApp, ' "4 %s"' %url, 1) appuifw.app.set_exit()
def getmyposition(): print "Reading GPS. Wait..." result = positioning.position() # print 'all gps data: ', result coordinates = result["position"] mylatitude = coordinates["latitude"] mylongitude = coordinates["longitude"] print "mylatitude: ", mylatitude print "mylongitude:", mylongitude s = ( '<meta HTTP-EQUIV="REFRESH" content="0; url=http://mobil.gulesider.no/query?itype=nautical&what=mobaddr&map=1¢er=' + str(mylongitude) + "%2C" + str(mylatitude) + '">' ) f = open("E:\\goto.html", "w") f.write(s) f.close() browserApp = "BrowserNG.exe" url = "file:///E:/goto.html" e32.start_exe(browserApp, ' "4 %s"' % url, 1) appuifw.app.set_exit()
def startListening(self): positioning.position(course = 1, satellites = 1, callback = self.dataChanged)
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" }]) for iscan in range(NUMLOOP):
print "" # detailed information about the default positioning module print "***detailed module info***" print positioning.module_info(positioning.default_module()) print "" # set requestors. # at least one requestor must be set before requesting the position. # the last requestor must always be service requestor # (whether or not there are other requestors). positioning.set_requestors([{ "type": "service", "format": "application", "data": "test_app" }]) # get the position. # note that the first position()-call may take a long time # (because of gps technology). print "***position info***" print positioning.position() print "" # re-get the position. # this call should be much quicker. # ask also course and satellite information. print "***course and satellites***" print positioning.position(course=1, satellites=1) print ""
def startListening(self): positioning.position(course=1, satellites=1, callback=self.dataChanged)
def main(): gaeclient.name=appuifw.query(u"Your nick",'text') positioning.position(callback=gaeclient.positioning_callback,interval=poll_interval)
(u"1st wait", "number", startAfter), (u"Specials", "text", specials)] app_form = appuifw.Form(fields, flags=appuifw.FFormEditModeOnly) app_form.save_hook = form_save app_form.execute() if form_saved == True: phoneNumber = app_form[0][2] interval = app_form[1][2] startAfter = app_form[2][2] specials = map(int, app_form[3][2].split()) else: print "Please save the form data." quit(-1) sleeep(startAfter) pos = positioning.position()["position"] lat = pos["latitude"] lon = pos["longitude"] while(longitudes[0] < lon <= longitudes[80]): message = time.strftime(u"%x %X, ") nextUp = firstge(longitudes, lon) if nextUp == 58: if lat <= latitudes[57]: nextUp = 57 elif 60 < nextUp <= 63: if lat <= latitudes[61]: nextUp = 61 elif lat <= latitudes[62]: nextUp = 62 else: nextUp = 63
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'], e['position']['horizontal_accuracy'], time())) fp.close() print "Wrote gps info!" print "I think GPS is working, so trying to log the info..." positioning.position(callback=callback_fn, partial=0, interval=500000)
#Main Loop global gpson gpson = 0 loop_number = 0 old_lat = 0.0 print "Starting Tracker3 program" while True: if (gpson == 0): #initialize GPS initialize_gps() print "Getting GPS Position" gpsdata = positioning.position(course=1,satellites=1) if(gps_data['position']['latitude'] != 0.0): print gps_data['satellites']['used_satellites'], gps_data['position']['latitude'], gps_data['position']['longitude'], gps_data['course']['speed'] #stop GPS #stop_gps() old_lat = gps_data['position']['latitude'] #Get battery data battery = sysinfo.battery() #Get signal strength signal = sysinfo.signal_dbm() #Get time user_time = time.time() #Print data
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
print "---" print event print "---" def clean(): positioning.stop_position() print "Done." lock.signal() positioning.set_requestors([{ "type": "service", "format": "application", "data": "test_app" }]) print "Starting position feed." print positioning.position(course=1, satellites=1, callback=cb, interval=500000, partial=1) lock = e32.Ao_lock() appuifw.app.exit_key_handler = clean lock.wait() print "Testing last_position API..." print "Values displayed only if position data is cached" print positioning.last_position() print "Done."
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']
print "sending location to COS" post_data = urllib.urlencode({ "location_area_code" : location_area_code, "mobile_country_code" : mobile_country_code, "mobile_network_code" : mobile_network_code, "cell_id" : cell_id, "latitude" : str(event['position']['latitude']), "longitude" : str(event['position']['longitude'])}) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn = httplib.HTTPConnection("slushr.appspot.com") conn.request("POST", "/new", post_data, headers) response = conn.getresponse() data = response.read() if response: print "Data:"+ data else: print "Error sending data to slushd..." conn.close() else: print "no valid GPS position" # get a fixed access point apid = select_access_point() #Prompts you to select the access point apo = access_point(apid) #apo is the access point you selected set_default_access_point(apo) #Sets apo as the default access point # start positioning positioning.set_requestors([{"type":"service", "format":"application", "data":"test_app"}]) positioning.position(course=0, satellites=0, callback=cb, interval=10000000, partial=1)
try: snd = aud.Sound.open(media) #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"}]) for iscan in range(NUMLOOP): print '%sScan %d%s' % ('-'*12, iscan+1, '-'*12)