Archived:How to use your phone as a panic button using PySymbian
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot addition of Template:ArticleMetaData) |
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot update - Fix ArticleMetaData and RevieweApproval) |
||
| (3 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | {{ArticleMetaData | + | [[Category:PySymbian]][[Category:How To]][[Category:Code Snippet]][[Category:S60]][[Category:SMS]][[Category:Telephony]][[Category:Location]] |
| + | {{Abstract|This Python on Symbian code example acts as a panic button - sending by SMS your location (cell ID and LAC, and GPS if available) to predefined emergency numbers and recipients.}} | ||
| + | {{ArticleMetaData <!-- v1.1 --> | ||
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] --> | |sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] --> | ||
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | ||
| Line 6: | Line 8: | ||
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | |platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | ||
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | ||
| − | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> |
| − | |signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | + | |signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> |
| − | |capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> |
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | |keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | ||
|id= <!-- Article Id (Knowledge base articles only) --> | |id= <!-- Article Id (Knowledge base articles only) --> | ||
| − | |language=<!-- Language category code for non-English topics - e.g. Lang-Chinese --> | + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> |
| − | |review-by=<!-- After re-review: [[User:username]] --> | + | |translated-by= <!-- [[User:XXXX]] --> |
| − | |review-timestamp=<!-- After re-review: YYYYMMDD --> | + | |translated-from-title= <!-- Title only --> |
| − | |update-by=<!-- After significant update: [[User:username]]--> | + | |translated-from-id= <!-- Id of translated revision --> |
| − | |update-timestamp=<!-- After significant update: YYYYMMDD --> | + | |review-by= <!-- After re-review: [[User:username]] --> |
| − | |creationdate=20080829 | + | |review-timestamp= <!-- After re-review: YYYYMMDD --> |
| − | |author=[[User:Tommybreit]] | + | |update-by= <!-- After significant update: [[User:username]]--> |
| − | + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | |
| − | [[ | + | |creationdate= 20080829 |
| − | + | |author= [[User:Tommybreit]] | |
| − | + | }} | |
| + | == Overview == | ||
| + | The [[:Category:PySymbian|PySymbian]] code posted here will basically do the following when run: | ||
* Immediately transmit LAC and CellID to predefined recipients via SMS (this allows for a rough containment of where you are located in your emergency) | * Immediately transmit LAC and CellID to predefined recipients via SMS (this allows for a rough containment of where you are located in your emergency) | ||
* Call an predefined emergency number | * Call an predefined emergency number | ||
| Line 28: | Line 32: | ||
This sums up to a rather complete emergency package acting as some kind of panic button (place this as an .sis application on your today screen or similar...). If you ever get into an emergency immediately broadcast all relevant info to get help! | This sums up to a rather complete emergency package acting as some kind of panic button (place this as an .sis application on your today screen or similar...). If you ever get into an emergency immediately broadcast all relevant info to get help! | ||
| + | == Code == | ||
<code python> | <code python> | ||
| − | |||
import e32, appuifw, positioning, location, messaging, telephone | import e32, appuifw, positioning, location, messaging, telephone | ||
| Line 96: | Line 100: | ||
</code> | </code> | ||
| − | PS: Credits also go to the original contributor of the GPS code. Please keep in mind that you will need the "unsigned_testrange" edition | + | PS: Credits also go to the original contributor of the GPS code. Please keep in mind that you will need the "unsigned_testrange" edition PySymbian for location/position capabilities to function properly. |
Revision as of 06:42, 8 February 2012
This Python on Symbian code example acts as a panic button - sending by SMS your location (cell ID and LAC, and GPS if available) to predefined emergency numbers and recipients.
Article Metadata
Overview
The PySymbian code posted here will basically do the following when run:
- Immediately transmit LAC and CellID to predefined recipients via SMS (this allows for a rough containment of where you are located in your emergency)
- Call an predefined emergency number
- Try to get the GPS position of your phone and if it gets a signal transmit Latitude/Longitude and current speed every three minutes via SMS to predefined recipients
This sums up to a rather complete emergency package acting as some kind of panic button (place this as an .sis application on your today screen or similar...). If you ever get into an emergency immediately broadcast all relevant info to get help!
Code
import e32, appuifw, positioning, location, messaging, telephone
def gps_init():
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:
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=500000,partial=0)
e32.ao_sleep(3)
except:
appuifw.note(u'Problem with GPS','error')
def gps(event):
global gps_data
gps_data = event
def gps_stop():
#this function stops GPS
try:
positioning.stop_position()
except:
appuifw.note(u'Problem with GPS','error')
def gps_emerg():
gpessa = str( 'My GPS position is (Lat/Long/Geschwindigkeit): %s, %s, %i' % (pos_lat , pos_long, speed) )
print gpessa
messaging.sms_send('0123456789', gpessa) #PUT number of receipient you want to inform here
print 'GPS Position sent!'
print 'Recalling emergency phone number...'
telephone.dial('0123456789') #PUT some emergency number here
e32.ao_sleep(180)
ftrack = location.gsm_location()
messa = str( 'I have hit the panic button! My current cell information is LAC %s and Cell-ID %s. Trying to send my exact GPS position soon...' % (ftrack[2] , ftrack[3]) )
print messa
messaging.sms_send('0123456789', messa) #PUT number of receipient you want to inform here
print 'SMS sent!'
e32.ao_sleep(3)
print 'Calling emergency phone number...' #PUT some emergency number here
telephone.dial('0123456789')
gps_init()
count = 0
while True:
count = count + 1
sat = gps_data['satellites']['used_satellites']
pos_lat = gps_data['position']['latitude']
pos_long = gps_data['position']['longitude']
speed = gps_data['course']['speed']
if pos_lat > 0:
print 'Found GPS position, terminating call to free the line...'
telephone.hang_up()
e32.ao_sleep(1)
gps_emerg()
e32.ao_sleep(1)
PS: Credits also go to the original contributor of the GPS code. Please keep in mind that you will need the "unsigned_testrange" edition PySymbian for location/position capabilities to function properly.

