def sendSysinfo(self, full): self.send(NUM_SYSINFO_REPLY_START) self.send(NUM_SYSINFO_REPLY_LINE, "program_version", VERSION) self.send(NUM_SYSINFO_REPLY_LINE, "battery", sysinfo.battery()) self.send(NUM_SYSINFO_REPLY_LINE, "active_profile", sysinfo.active_profile()) self.send(NUM_SYSINFO_REPLY_LINE, "free_ram", sysinfo.free_ram()) self.send(NUM_SYSINFO_REPLY_LINE, "pys60_version", e32.pys60_version) if sysinfo.active_profile() == u"offline": # Return an error code if the phone is in offline mode self.send(NUM_SYSINFO_REPLY_LINE, "signal_dbm", -1) self.send(NUM_SYSINFO_REPLY_LINE, "signal_bars", -1) else: self.send(NUM_SYSINFO_REPLY_LINE, "signal_dbm", sysinfo.signal_dbm()) self.send(NUM_SYSINFO_REPLY_LINE, "signal_bars", sysinfo.signal_bars()) for drive, free in sysinfo.free_drivespace().iteritems(): self.send(NUM_SYSINFO_REPLY_LINE, "free_drivespace", str(drive) + str(free)) if full: self.send(NUM_SYSINFO_REPLY_LINE, "display", str(sysinfo.display_pixels()[0]) + "x" + str(sysinfo.display_pixels()[1])) self.send(NUM_SYSINFO_REPLY_LINE, "imei", sysinfo.imei()) self.send(NUM_SYSINFO_REPLY_LINE, "model", sysinfo.sw_version()) self.send(NUM_SYSINFO_REPLY_LINE, "s60_version", e32.s60_version_info[0], e32.s60_version_info[1] ) self.send(NUM_SYSINFO_REPLY_LINE, "total_ram", sysinfo.total_ram()) self.send(NUM_SYSINFO_REPLY_LINE, "total_rom", sysinfo.total_rom()) self.send(NUM_SYSINFO_REPLY_END)
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
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
def measure(self, fname): fsize = 0 self.signal_bars = sysinfo.signal_bars() self.signal_dbm = sysinfo.signal_dbm() c1 = time.clock() (r1, fsize) = self.download(fname) c2 = time.clock() cdiff = c2 - c1 t2 = time.time() self.update_state(cdiff, t2, r1, fsize)
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(())
def sendSysinfo(self, full): self.send(NUM_SYSINFO_REPLY_START) self.send(NUM_SYSINFO_REPLY_LINE, "program_version", VERSION) self.send(NUM_SYSINFO_REPLY_LINE, "battery", sysinfo.battery()) self.send(NUM_SYSINFO_REPLY_LINE, "active_profile", sysinfo.active_profile()) self.send(NUM_SYSINFO_REPLY_LINE, "free_ram", sysinfo.free_ram()) self.send(NUM_SYSINFO_REPLY_LINE, "pys60_version", e32.pys60_version) if sysinfo.active_profile() == "offline": # Return an error code if the phone is in offline mode self.send(NUM_SYSINFO_REPLY_LINE, "signal_dbm", -1) self.send(NUM_SYSINFO_REPLY_LINE, "signal_bars", -1) else: self.send(NUM_SYSINFO_REPLY_LINE, "signal_dbm", sysinfo.signal_dbm()) self.send(NUM_SYSINFO_REPLY_LINE, "signal_bars", sysinfo.signal_bars()) for drive, free in sysinfo.free_drivespace().items(): self.send(NUM_SYSINFO_REPLY_LINE, "free_drivespace", str(drive) + str(free)) if full: self.send( NUM_SYSINFO_REPLY_LINE, "display", str(sysinfo.display_pixels()[0]) + "x" + str(sysinfo.display_pixels()[1]), ) self.send(NUM_SYSINFO_REPLY_LINE, "imei", sysinfo.imei()) self.send(NUM_SYSINFO_REPLY_LINE, "model", sysinfo.sw_version()) self.send( NUM_SYSINFO_REPLY_LINE, "s60_version", e32.s60_version_info[0], e32.s60_version_info[1], ) self.send(NUM_SYSINFO_REPLY_LINE, "total_ram", sysinfo.total_ram()) self.send(NUM_SYSINFO_REPLY_LINE, "total_rom", sysinfo.total_rom()) self.send(NUM_SYSINFO_REPLY_END)
def test_singal_dbm(self): sysinfo.signal_dbm()
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: gpspos = gpsdict['position'] # position gpssat = gpsdict['satellites'] # satellites #gpscrs = gpsdict['course'] # course sat_used = gpssat['used_satellites'] sat_view = gpssat['satellites'] gps = [ str(gpspos[x]) for x in ('latitude','longitude','altitude') ]
def pasek(): global screen global img global ekran global mp3 global ladow while 1: e32.Ao_timer().after(1) (rok, mies, dz, godz, min, sek, x, x, x) = time.localtime() godz = '%02d' % (godz) min = '%02d' % (min) sek = '%02d' % (sek) if (godz == ustaw[51:53]) and (min == ustaw[53:55]) and ( sek == '00') and (pb <> 'None'): e32.reset_inactivity() try: appuifw.e32.start_exe( u'c:\\sys\\bin\\' + unicode(pb) + u'.exe', '') except: try: appuifw.e32.start_exe( u'e:\\sys\\bin\\' + unicode(pb) + u'.exe', '') except: try: appuifw.e32.start_exe( u'z:\\sys\\bin\\' + unicode(pb) + u'.exe', '') except: pass try: if (int(ustaw[36:39]) <> 0) and (sysinfo.active_profile() <> u'silent'): if ((int(min) == 0) and (int(sek) == 0) or (int(sysinfo.battery()) == 100) and (ladow > 0)): if (int(sysinfo.battery()) == 100) and (ladow > 0): ladow = 0 if os.path.isdir(sciezkaplik): if (int(min) == 0) and (int(sek) == 0): mp3 = audio.Sound.open( unicode(sciezkaplik + '\\' + str(godz) + '.mp3')) else: mp3 = audio.Sound.open( unicode(sciezkaplik + '\\' + '24.mp3')) else: mp3 = audio.Sound.open(unicode(sciezkaplik)) if (int(ustaw[39:42]) < int(ustaw[42:45])) and ( int(godz) >= int(ustaw[39:42])) and ( int(godz) <= int(ustaw[42:45])): mp3.play() elif (int(ustaw[39:42]) > int(ustaw[42:45])) and ( (int(godz) >= int(ustaw[39:42])) or (int(godz) <= int(ustaw[42:45]))): mp3.play() elif int(godz) == int(ustaw[39:42]): mp3.play() audio.Sound.set_volume( mp3, int( audio.Sound.max_volume(mp3) * (float(int(ustaw[36:39])) / float(100)))) if audio.Sound.state(mp3) <> 2: mp3 = 0 if (int(min) == 0) and (int(sek) == 0): if (int(ustaw[39:42]) < int(ustaw[42:45])) and ( int(godz) >= int(ustaw[39:42])) and (int(godz) <= int( ustaw[42:45])): miso.vibrate(500, 100) elif (int(ustaw[39:42]) > int(ustaw[42:45])) and ( (int(godz) >= int(ustaw[39:42])) or (int(godz) <= int(ustaw[42:45]))): miso.vibrate(500, 100) elif int(godz) == int(ustaw[39:42]): miso.vibrate(500, 100) except: pass if int(ustaw[18:21]) == 888: img.blit(ima, ((0, 0), (int(ustaw[0:3]), int(ustaw[3:6])))) else: img.rectangle( [(0, 0), (int(ustaw[0:3]), int(ustaw[3:6]))], (int(ustaw[18:21]), int(ustaw[21:24]), int(ustaw[24:27])), fill=(int(ustaw[18:21]), int(ustaw[21:24]), int(ustaw[24:27]))) if pb <> 'None': img.line([(0, 0), (0, int(ustaw[3:6]))], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) img.line([(-1 + int(ustaw[0:3]), 0), (-1 + int(ustaw[0:3]), int(ustaw[3:6]))], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) if fpp[int(ustaw[56:57])] <> 'None': img.line([(0, 0), (0, 4)], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) img.line([(0, 0), (4, 0)], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) img.line([(-1 + int(ustaw[0:3]), 0), (-1 + int(ustaw[0:3]), 4)], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) img.line([(-1 + int(ustaw[0:3]), 0), (-1 - 4 + int(ustaw[0:3]), 0)], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) img.line([(-1 + int(ustaw[0:3]), -1 + int(ustaw[3:6])), (-1 - 4 + int(ustaw[0:3]), -1 + int(ustaw[3:6]))], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) img.line([(-1 + int(ustaw[0:3]), -1 + int(ustaw[3:6])), (-1 + int(ustaw[0:3]), -1 - 4 + int(ustaw[3:6]))], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) img.line([(0, -1 + int(ustaw[3:6])), (0, -1 - 4 + int(ustaw[3:6]))], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) img.line([(0, -1 + int(ustaw[3:6])), (4, -1 + int(ustaw[3:6]))], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) if ekran > 0: e32.reset_inactivity() img.line([(0, -1 + int(ustaw[3:6])), (int(ustaw[0:3]), -1 + int(ustaw[3:6]))], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) if ladow > 0: img.line([(0, 0), (int(ustaw[0:3]), 0)], (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) if int(ustaw[45:48]) / 10 > 0: if int(ustaw[45:48]) / 10 == 1: k = unicode(str(godz) + ':' + str(min) + ':' + str(sek)) elif int(ustaw[45:48]) / 10 == 2: k = unicode('%02i' % (dz) + '.' + '%02i' % (mies) + '.' + str(rok)) elif int(ustaw[45:48]) / 10 == 3: k = unicode('%06.3f' % (float(sysinfo.free_ram()) / float(1000000))) elif int(ustaw[45:48]) / 10 == 4: k = unicode('%03i' % (sysinfo.signal_dbm()) + ' dBm') elif int(ustaw[45:48]) / 10 == 5: k = unicode('%03i' % (sysinfo.battery()) + ' %') if int(ustaw[45:48]) % 10 == 1: q = (None, None, graphics.FONT_BOLD | graphics.FONT_ANTIALIAS) elif int(ustaw[45:48]) % 10 == 2: q = (None, None, graphics.FONT_ITALIC | graphics.FONT_ANTIALIAS) elif int(ustaw[45:48]) % 10 == 3: q = (None, None, graphics.FONT_BOLD | graphics.FONT_ITALIC | graphics.FONT_ANTIALIAS) else: q = (None, None, graphics.FONT_ANTIALIAS) img.text( (int(ustaw[12:15]), int(ustaw[15:18])), k, font=q, fill=(int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36]))) screen.background_color = 0xffffff else: screen.hide()
#initialize GPS initialize_gps() sats = gps_data['satellites']['used_satellites'] print sats, gpson, gps_data['position']['latitude'] if ((sats > 3) and (gps_data['position']['latitude'] != old_lat)): 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() count = count + 1 #Print data telem_string = "%d,%d,%f,%f,%.2f,%d,%d,%d" % (count, user_time, gps_data['position']['latitude'], gps_data['position']['longitude'], gps_data['course']['speed'], gps_data['course']['heading'], signal, battery) print telem_string messaging.sms_send('+447748628528', telem_string,'8bit',cb) #Reset loop number loop_number = 0
"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: gpspos = gpsdict['position'] # position gpssat = gpsdict['satellites'] # satellites #gpscrs = gpsdict['course'] # course sat_used = gpssat['used_satellites'] sat_view = gpssat['satellites']
import sysinfo, appuifw, e32 def cn(x): return x.decode("utf8") appuifw.app.body = t = appuifw.Text() t.focus = False appuifw.app.screen = "full" t.add(cn("情景模式:") + sysinfo.active_profile()) t.add(cn("\n电量:") + unicode(sysinfo.battery())) t.add(cn("\n屏幕分辨率:") + unicode(sysinfo.display_pixels())) t.add(cn("\n剩余空间:\n")) i = 0 drive = [u"C:", u"D:", u"E:"] while i < len(drive): t.add(drive[i] + unicode(sysinfo.free_drivespace()[drive[i]] / 1024) + u"kb\n") i += 1 t.add(cn("剩余运存:") + unicode(sysinfo.free_ram() / 1024) + u"kb") t.add(cn("\nIMEI:") + unicode(sysinfo.imei())) t.add(cn("\n系统版本:") + unicode(sysinfo.os_version())) t.add(cn("\n响铃方式:") + unicode(sysinfo.ring_type())) t.add(cn("\n手机版本:") + unicode(sysinfo.sw_version())) t.add(cn("\n缓存总大小:") + unicode(sysinfo.total_ram() / 1024) + u"kb") t.add(cn("\nZ盘总大小:") + unicode(sysinfo.total_rom() / 1024) + u"kb") t.add(cn("\n信号强度:") + unicode(sysinfo.signal_bars())) t.add(cn("\n信号强度:") + unicode(sysinfo.signal_dbm()) + u"dbm") e32.ao_sleep(3)
import sys import os import time import sysinfo import e32 sys.stdout.write("IMEI: %s\n" % sysinfo.imei()) sys.stdout.write("Battery strength: %s\n" % sysinfo.battery()) sys.stdout.write("Signal strength: %s\n" % sysinfo.signal_bars()) sys.stdout.write("Network signal strength in dBm: %s\n" % sysinfo.signal_dbm()) sys.stdout.write("SW version: %s\n" % sysinfo.sw_version()) sys.stdout.write("Display size:\n") print(sysinfo.display_pixels()) sys.stdout.write("Current profile: %s\n" % sysinfo.active_profile()) sys.stdout.write("Ringing type: %s\n" % sysinfo.ring_type()) sys.stdout.write("OS version:\n") print(sysinfo.os_version()) sys.stdout.write("Free/total RAM (MB): %.2f / %.2f\n" % (sysinfo.free_ram()/1024/1024,sysinfo.total_ram()/1024/1024)) sys.stdout.write("Total ROM (MB): %.2f \n" % (sysinfo.total_rom()/1024/1024)) sys.stdout.write("Free disk space C/E (MB): %.2f / %.2f\n" % (sysinfo.free_drivespace()['C:']/1024/1024,sysinfo.free_drivespace()['E:']/1024/1024))