×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Alarm at specified cell id using PySymbian

From Nokia Developer Wiki
Jump to: navigation, search
shubhendra (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix underscores in categories)
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Category:Python]][[Category:Code Examples]][[Category:Location Based Services]]
+
[[Category:Location]][[Category:Code Snippet]][[Category:PySymbian]]
'''Problem Faced'''
+
__NOTOC__
 +
__NOEDITSECTION__
  
You are travelling in train and you know the "destination's cell id", but you want to sleep for while. Just enter the cell id of the destination and you will be woke up by the alarm.
 
  
----
+
{{ArticleMetaData <!-- v1.1 -->
 +
|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]]) -->
 +
|devices= N95, N96
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= S60
 +
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required (e.g. Location, NetworkServices. -->)
 +
|keywords= cellid, gsm ,audio
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080530
 +
|author= [[User:Shubhendra]]
 +
}}
 +
 
 +
 
 +
 
 +
==Overview==
 +
 
 +
Sometimes, it happens that you are traveling and you know the "destination's cell id", but want to sleep for while. Just enter the cell id of the destination and you will be woken up by the alarm.
 +
 
 +
==Preconditions==
 +
The user of this script should know the cellid of the destination place where the user wants to set the alarm.
 +
 
 +
 
 +
==Proposed Solution==
  
'''Solution by Shubhendra Singh'''
 
 
 
Just use this code, it will trigger alarm as soon as cell id of the location matches with the cell id you input,
 
Just use this code, it will trigger alarm as soon as cell id of the location matches with the cell id you input,
 +
 
<code python>
 
<code python>
import appuifw,e32,location
+
import appuifw
 +
import e32
 +
import location
 
from graphics import *
 
from graphics import *
 
from audio import *
 
from audio import *
abc=0
+
import globalui
f = 'Z:\\Nokia\\Sounds\\Digital\\Alarm.mid'  # Could be changed, this is what you will hear.
+
data=appuifw.query(u"enter the cell id","number")
+
  
while abc == 0:
 
xyz=location.gsm_location()
 
if(xyz[3] == data):
 
abc=1
 
s = Sound.open(f)
 
s.play(KMdaRepeatForever)    # Alarm will play until Network is available.
 
  
 +
 +
def run():
 +
        abc=0
 +
        f = "e:\\Python\\Alarm.mp3"  # Could be changed, this is what you will hear
 +
        data=appuifw.query(u"enter the cell id","number")
 +
       
 +
        while abc == 0:
 +
                xyz=location.gsm_location()
 +
                if(xyz[3] == data):
 +
                   
 +
                    abc = 1
 +
                    globalui.global_note(u"Alarm Activated please wake up",'wait')
 +
                    s = Sound.open(f)
 +
                    s.play(KMdaRepeatForever)    # Alarm will play until Network is available.
 +
 +
def loc():
 +
 +
        l = location.gsm_location()[3]
 +
        print l
 +
        globalui.global_msg_query(u""+str(l),u"your Cellid is:",7)
  
 
def quit():
 
def quit():
s.stop()
 
 
       app_lock.signal()
 
       app_lock.signal()
 
       appuifw.app.set_exit()
 
       appuifw.app.set_exit()
 
   
 
   
def handle_redraw(rect):
+
 
    canvas.blit(img)
+
+
+
canvas=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
+
appuifw.app.body=canvas
+
 
appuifw.app.title = u"location Mode"
 
appuifw.app.title = u"location Mode"
 +
appuifw.app.menu = [(u"Set Alarm",run),(u"Cellid",loc),(u"Back",quit)]
 
appuifw.app.exit_key_handler = quit        # Press "Quit" to quit application.
 
appuifw.app.exit_key_handler = quit        # Press "Quit" to quit application.
 
app_lock = e32.Ao_lock()
 
app_lock = e32.Ao_lock()
 
app_lock.wait()
 
app_lock.wait()
 +
 +
</code>
 +
 +
==Postconditions==
 +
 +
[[Image:Cellid1.jpg]] [[Image:Cellid2.jpg]] [[Image:Cellid3.jpg]]
 +
 +
 +
== Related Wiki Links ==
 +
 +
[[How to get info on cell location]]

Revision as of 09:23, 7 February 2012



Article Metadata
Tested with
Devices(s): N95, N96
Compatibility
Platform(s): S60
Platform Security
Capabilities: )
Article
Keywords: cellid, gsm ,audio
Created: shubhendra (30 May 2008)
Last edited: hamishwillee (07 Feb 2012)


Overview

Sometimes, it happens that you are traveling and you know the "destination's cell id", but want to sleep for while. Just enter the cell id of the destination and you will be woken up by the alarm.

Preconditions

The user of this script should know the cellid of the destination place where the user wants to set the alarm.


Proposed Solution

Just use this code, it will trigger alarm as soon as cell id of the location matches with the cell id you input,

import appuifw
import e32
import location
from graphics import *
from audio import *
import globalui
 
 
 
def run():
abc=0
f = "e:\\Python\\Alarm.mp3" # Could be changed, this is what you will hear
data=appuifw.query(u"enter the cell id","number")
 
while abc == 0:
xyz=location.gsm_location()
if(xyz[3] == data):
 
abc = 1
globalui.global_note(u"Alarm Activated please wake up",'wait')
s = Sound.open(f)
s.play(KMdaRepeatForever) # Alarm will play until Network is available.
 
def loc():
 
l = location.gsm_location()[3]
print l
globalui.global_msg_query(u""+str(l),u"your Cellid is:",7)
 
def quit():
app_lock.signal()
appuifw.app.set_exit()
 
 
appuifw.app.title = u"location Mode"
appuifw.app.menu = [(u"Set Alarm",run),(u"Cellid",loc),(u"Back",quit)]
appuifw.app.exit_key_handler = quit # Press "Quit" to quit application.
app_lock = e32.Ao_lock()
app_lock.wait()

Postconditions

Cellid1.jpg Cellid2.jpg Cellid3.jpg


Related Wiki Links

How to get info on cell location

68 page views in the last 30 days.
×