コード例 #1
0
def do_tests():
    first_f = files_to_test[0]
    print "Fetching a file, the timing of which will be ignored..."
    measurement = Measurement()
    print u"File: " + first_f
    measurement.measure(first_f)
    print "Done."
    exceptions = 0
    iteration = 0
    while (1):
        iteration += 1
        print u"*********\nITERATION: " + str(iteration)
        for f in files_to_test:
            try:
                print unicode(time.ctime())
                print u'exceptions: ' + str(exceptions)
                print u'signal_bars():' + str(sysinfo.signal_bars())
                print u'signal_dbm():' + str(sysinfo.signal_dbm())
                print u'location:' + str(location.gsm_location())
                measurement = Measurement()
                print u"File: " + f
                measurement.measure(f)
                responseText = measurement.uploadToSensorBase(
                    project_id_str, g_table_name)
                print g_table_name + ":" + responseText
            except Exception, e:
                print e
                exceptions = exceptions + 1
コード例 #2
0
ファイル: andrewhome.py プロジェクト: nesl/gprstest
def do_tests():
    first_f = files_to_test[0]
    print "Fetching a file, the timing of which will be ignored..."
    measurement = Measurement()
    print  u"File: " + first_f
    measurement.measure(first_f)
    print "Done."
    exceptions = 0
    iteration = 0    
    while(1):
        iteration += 1
        print u"*********\nITERATION: " + str(iteration)
        for f in files_to_test:
            try:
                print unicode(time.ctime())
                print u'exceptions: ' + str(exceptions)
                print u'signal_bars():' + str(sysinfo.signal_bars())
                print u'signal_dbm():' + str(sysinfo.signal_dbm())
                print u'location:' + str(location.gsm_location())
                measurement = Measurement()
                print  u"File: " + f
                measurement.measure(f)
                responseText = measurement.uploadToSensorBase(project_id_str,
                                                              g_table_name)
                print g_table_name +":" + responseText
            except Exception, e:
                print e
                exceptions = exceptions + 1
コード例 #3
0
	def gsm_location(self) :
		self.noRefresh = self.noRefresh + 1;
		try:
			(self.mcc, self.mnc, self.lac, self.cellid) = location.gsm_location()
		except:
			self.mcc = 0
			self.mnc = 0
			self.lac = 0
			self.cellid = 0
		self.text = u"MCC: %s\nMNC: %s\nLAC: %s\nCell id: %s\nnoSamples: %i\n Azimuth: %i\n" % (self.mcc, self.mnc, self.lac, self.cellid, self.noRefresh, self.app2.getazimuth())
		return self.text
コード例 #4
0
 def sendLocation(self):
     loc = location.gsm_location()
     if loc is None:
         self.send(NUM_LOCATION_REPLY_NA)
     else:
         mcc, mnc, lac, cellid = loc
         self.send(
             NUM_LOCATION_REPLY,
             "%03d" % mcc,
             "%02d" % mnc,
             "%X" % lac,
             "%X" % cellid,
         )
コード例 #5
0
 def gsm_location(self):
     self.noRefresh = self.noRefresh + 1
     try:
         (self.mcc, self.mnc, self.lac,
          self.cellid) = location.gsm_location()
     except:
         self.mcc = 0
         self.mnc = 0
         self.lac = 0
         self.cellid = 0
     self.text = u"MCC: %s\nMNC: %s\nLAC: %s\nCell id: %s\nnoSamples: %i\n" % (
         self.mcc, self.mnc, self.lac, self.cellid, self.noRefresh)
     return self.text
コード例 #6
0
def cb(event):

    global counter
    counter = counter + 1

    t = int(time.time())
    sat = event["satellites"]
    tm = sat["time"]
    tot = sat["satellites"]
    used = sat["used_satellites"]
    pos = event["position"]
    lat = pos["latitude"]
    lng = pos["longitude"]
    alt = pos["altitude"]
    vdop = pos["vertical_accuracy"]
    hdop = pos["horizontal_accuracy"]
    crse = event["course"]
    hdg = crse["heading"]
    hdgacc = crse["heading_accuracy"]
    spd = crse["speed"]

    sdb = sysinfo.signal_dbm()
    loc = location.gsm_location()
    sloc = str(loc)
    sloc = sloc.replace(',', '/')

    global S
    sndtime = int(S.current_position() / 1000)

    s = "gps:" + str(t) + "," + str(sndtime) + ',' + str(tm) + "," + str(
        tot) + "," + str(used) + "," + str(lat) + "," + str(lng) + "," + str(
            alt)
    s = s + "," + str(vdop) + "," + str(hdop) + "," + str(hdg) + "," + str(
        hdgacc) + "," + str(spd) + "gsm:" + str(sloc) + "," + str(sdb)
    fncSavedata(s)

    pic = camera.take_photo('RGB', (320, 240), 0, 'none', 'auto', 'auto', 1)
    sp = "e:\\datalogger\\pic" + str(t) + '.jpg'
    pic.save(sp)

    img.clear()
    img.text((40, 34), u'Log ID: ' + str(counter), 0xff0000, font='normal')
    img.text((40, 64),
             u'Sats: ' + str(used) + "/" + str(tot),
             0xff0000,
             font='normal')
    img.text((40, 94), u'Spd: ' + str(int(spd)), 0xff0000, font='normal')
    img.text((40, 124), u'Snd: ' + str(sndtime), 0xff0000, font='normal')
    handle_redraw(())
コード例 #7
0
def net():
    (
        mcc,
        mnc,
        lac,
        cellid,
    ) = location.gsm_location()
    si = sysinfo.signal_bars()
    osama.add((u'\n\t...................\nMCC: ' + unicode(mcc)))
    osama.add((u'\nMNC: ' + unicode(mnc)))
    osama.add((u'\nLAC: ' + unicode(lac)))
    osama.add((u'\nCell id: ' + unicode(cellid)))
    osama.add(
        ((itq('\n\t...................\nSignal Strength is : \n') + str(si)) +
         itq('/7\n\t...................\n')))
コード例 #8
0
ファイル: gsm_locator.py プロジェクト: udit-gupta/socialmaps
def start():
  cache=location.gsm_location()
  if cache is None:
    print 'Can-not get the GSM Coordinates...'
    print 'Try Again or Contact : <*****@*****.**>'
    raw_input("Press any key to exit...")
    exit(0)
  else:
    send(cache)
  timer = e32.Ao_timer()
  while 1:
    values = get_details()
    if values is not None and values != cache:
      send(values)
      cache = values
    timer.after(3)
コード例 #9
0
ファイル: slushd60.py プロジェクト: sizzlelab/Ossi
def cb(event): 
  print "" 
  print "---" 
  # getting GSM info
  gsm_location = location.gsm_location()
  if gsm_location:
    mobile_country_code, mobile_network_code, location_area_code, cell_id = gsm_location
  else:
    print "ERROR in GSM location: "+str(gsm_location)
    return False
  print "GPS: "+str(event['position']['latitude'])+", "+str(event['position']['longitude'])
  print "MCC: "+str(mobile_country_code)
  print "MNC: "+str(mobile_network_code)
  print "LAC: "+str(location_area_code)
  print "CellID: "+str(cell_id)
  if str(event['position']['longitude']) != 'NaN' and str(event['position']['latitude']) != 'NaN':
    print "sending to slushd server..."
    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"
コード例 #10
0
ファイル: Scanner.py プロジェクト: sizzlelab/Ossi
 def get_gsm_data(self):
   l = location.gsm_location()
   if l is not None and len(l) == 4:
     return l
   else:
     return False
コード例 #11
0
# nokia-gsm-location-hacks, record GSM location information with Symbian 60 phones
# Copyright (C) 2009 Massimo Santini
#
# This file is part of nokia-gsm-location-hacks.
# 
# nokia-gsm-location-hacks is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# nokia-gsm-location-hacks is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with nokia-gsm-location-hacks.  If not, see <http://www.gnu.org/licenses/>.

import location, e32, time

while True:
		file = open( 'E:\\Python\\location_db.txt', 'a' ) # change the drive to suit your installation 
		file.write( str( time.time() ) + '\t' + str( location.gsm_location() ) + '\n' )
		file.close()
		e32.ao_sleep( 60 )
コード例 #12
0
 def gsm_data(self):
     try:
         import location as gsm
         return str(gsm.gsm_location())
     except ImportError:
         return "ERROR"
コード例 #13
0
ファイル: xloopscan.py プロジェクト: FomkaV/wifi-arsenal
    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)

    cellok = 1 # Cell info OK.
    celloc = loc.gsm_location()
    if (not isinstance(celloc, tuple)) or (not len(celloc) == 4):
        print 'Oops! GSM location FAILED!'
        cellok = 0
    else:
        celloc = [ str(x) for x in celloc ]
        cellrss = str(si.signal_dbm() - 127)
        print 'CellInfo:%s,%s,%s,%s,%s' % (celloc[0],celloc[1],celloc[2],celloc[3],cellrss)

    gpsok = 1 # GPS data OK.
    try:
        gpsdict = pos.position(satellites=True)
    except:
        print 'Oops! GPS failed!'
        gpsok = 0
    if gpsok:
コード例 #14
0
 def netInfo(self):
     import location
     par=[u'MCC', u'MNC', u'Area ID', u'Cell ID', u'Signal Strength']
     val=list(location.gsm_location())+[sysinfo.signal_bars()*100/7]
     nfo='\n'.join(['%s: %d' %(k, v) for k, v in zip(par, val)])
     return infopopup(nfo, u'Network Info', OKREmpty)
コード例 #15
0
ファイル: Social Maps.py プロジェクト: udit-gupta/socialmaps
def location_values():
	values = location.gsm_location()
	if values is not None:
		values = base64.b64encode(str(uid)+":"+str(values[0])+":"+str(values[1])+":"+str(values[2])+":"+str(values[3]))
	return values
コード例 #16
0
nbr1 = "03235348241" # change the mobile number here
#nbr2 = "234567" # change the mobile number here
timer = e32.Ao_timer()

while (1): 

    mylatitude = 0
    mylongitude = 0
    print 'getting position'
    mylatitude, mylongitude, speed, heading = getmyposition()
    mylatitude = '%.13f' % mylatitude
    mylongitude = '%.13f' % mylongitude
    speed = '%.13f' % speed
    heading = '%.13f' % heading
    loc = location.gsm_location()
    txt = u"test message  " + mylatitude + u" " + mylongitude + u" " +speed + u" " + heading + u" " + str(loc)


    #if appuifw.query(u"Send message to your 2 friends","query") == True:
       #txt = txt + mylatitude + u" " + mylongitude 
    messaging.sms_send(nbr1, txt)
        #messaging.sms_send(nbr2, txt)
    appuifw.note(u"Messages sent", "info")
    timer.after(60)
    #else:
    #    appuifw.note(u"Well, your Messages are not sent then", "info")
	
	
	
	
コード例 #17
0
 def test_gsm_location(self):
     # gms_location returns : [Mobile Country Code, Mobile Network Code,
     # Location Area Code, CellID]
     mcc, mnc, lac, cell_id = location.gsm_location()
     # Since cell_id changes very frequently it is omitted
     self.assertEqual([mcc, mnc, lac], [404, 45, 1627])
コード例 #18
0
def get_gsm():
    try:
        gsm = location.gsm_location()
    except:
        gsm = None
    return gsm
コード例 #19
0
ファイル: gsm_locator.py プロジェクト: udit-gupta/socialmaps
def get_details():
  details = location.gsm_location()
  return details
コード例 #20
0
    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)

    cellok = 1  # Cell info OK.
    celloc = loc.gsm_location()
    if (not isinstance(celloc, tuple)) or (not len(celloc) == 4):
        print 'Oops! GSM location FAILED!'
        cellok = 0
    else:
        celloc = [str(x) for x in celloc]
        cellrss = str(si.signal_dbm() - 127)
        print 'CellInfo:%s,%s,%s,%s,%s' % (celloc[0], celloc[1], celloc[2],
                                           celloc[3], cellrss)

    gpsok = 1  # GPS data OK.
    try:
        gpsdict = pos.position(satellites=True)
    except:
        print 'Oops! GPS failed!'
        gpsok = 0
コード例 #21
0
ファイル: 049-location.py プロジェクト: sudo-gera/c
import location
print location.gsm_location()