×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Incoming function

    I begin with this code:
    Code:
    import telephone, e32, appuifw, logs
    
    def quit():a.signal()
    appuifw.app.exit_key_handler=quit
    
    def handle_incoming_call(state):
         my_function()
    
    def cb(state):
    	if(state[0]==telephone.EStatusRinging):handle_incoming_call(state)
    
    telephone.call_state(cb)
    
    a=e32.Ao_lock()
    a.wait()
    Where "my_function()" has inside an infinite loop. The problems is that loop only is executed once. Any idea? Thanks

  2. #2
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Incoming function

    Any help? Please...

  3. #3
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Incoming function

    Could you post the code for my_function()?

  4. #4
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Incoming function

    Code:
    def detectar():
        print "Inicio bucle"
        while 1:
            print "Dentro del bucle"
            Script stop working here
            #Algoritmo de deteccion
            im = camera.take_photo('RGB', (160,120), position=1)
            nfotos += 1
            print nfotos
            box = Image.new((30,30), 'L')
            box.blit(im, (10,10,40,40))
            data = getdata(box, 8)
            pixdiff = 0
            for i in range(len(data)):
                if abs(ord(data[i])-ord(last1[i])) > 15:  # pix threshold 15/256
                    pixdiff += 1
                    if pixdiff > 90:    # img threshold 90/900
                        detec += 1
                        if detec >1:
                            #print nfotos
                            if (nfotos >inf) and (nfotos <sup):
                                segunda = 1
                                keypress.simulate_key(EKeyRightSoftkey,EKeyRightSoftkey)  
                                
                            if segunda == 1:
                                nfotos = sup
                                segunda = 0
                            else:
                                nfotos = 0
                            
                        break
            last1 = data
    If I run my script out of "def handle_incoming_call(state):" It works ok, but works all time I want only work during a call incoming.
    Thanks.
    Last edited by manugarrote; 2008-06-07 at 19:23.

  5. #5
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Incoming function

    Any idea?? tahnks

  6. #6
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Incoming function

    Hi manugarrote,
    I dont know the solution to your problem but don't you need to use unicode while executing print statement?

    Code:
    def detectar():
        print u"Inicio bucle"
        while 1:
            print u"Dentro del bucle"
    IDEAS is all they need but still they think only Genius can give them that.

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Incoming function

    Quote Originally Posted by shubhendra View Post
    Hi manugarrote,
    I dont know the solution to your problem but don't you need to use unicode while executing print statement?

    Code:
    def detectar():
        print u"Inicio bucle"
        while 1:
            print u"Dentro del bucle"
    Actually no. print shows the text on the default Shell background (the one with all that little green writing about copyright etc.). You only need to use unicode when setting the application's body to appuifw.Text() and writing to that. But in that case you would use the add statement, not print.
    Last edited by bogdan.galiceanu; 2008-06-10 at 06:28. Reason: typo

  8. #8
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Incoming function

    Oh ok thanks bogdan.galiceanu didn't knew about this fact.
    IDEAS is all they need but still they think only Genius can give them that.

  9. #9
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Incoming function

    Ok thank you. IF yo have any Idea to try with the code please contact me.

    PD: do you know other way to detect an incomming call?

  10. #10
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Incoming function

    Quote Originally Posted by manugarrote View Post
    PD: do you know other way to detect an incomming call?
    I know an improvised method that is inefficient and will drain your battery in a few hours. The idea is to check the log for the most recent "in" call, and then make a loop that keeps comparing the current value with that value until they are different (that means a new incoming call has occured). I don't have my phone with me right now so I can't test this, but I think it will work:
    Code:
    import logs
    
    a=logs.calls(mode='in')[0]
    while 1:
       a2=logs.calls(mode='in')[0]
       if(a<>a2): #This is when you do your thing
    Again, I don't recommend this at all as it's very inefficient, but I thought I'd share the idea anyway. Hope it helps .
    Last edited by bogdan.galiceanu; 2008-06-10 at 09:37. Reason: typo

  11. #11
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Re: Incoming function

    I would still suggest you to use the former method.

    Did you try having my_function() in other script file and executing that script file when you have an incoming call?

    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  12. #12
    Regular Contributor
    Join Date
    May 2007
    Posts
    56

    Re: Incoming function

    Quote Originally Posted by bogdan.galiceanu View Post
    I know an improvised method that is inefficient and will drain your battery in a few hours. The idea is to check the log for the most recent "in" call, and then make a loop that keeps comparing the current value with that value until they are different (that means a new incoming call has occured). I don't have my phone with me right now so I can't test this, but I think it will work:
    Code:
    import logs
    
    a=logs.calls(mode='in')[0]
    while 1:
       a2=logs.calls(mode='in')[0]
       if(a<>a2): #This is when you do your thing
    Again, I don't recommend this at all as it's very inefficient, but I thought I'd share the idea anyway. Hope it helps .
    I tried this code and dindn't work (App close).

    If any of you want to tri with the other way:
    Code:
    #################################################################
    # Developed by MANU [http://www.XXXXXX.com]
    # Inspirado en:   
    # v0.1
    #################################################################
    
    import telephone, e32, appuifw, graphics, logs
    from graphics import *
    
    
    appuifw.app.title = u"PRUEBA"
    
    #Variables auxiliares
    running = 1
    detec = 0
    nfotos = 0
    segunda=0
    
    #Testeando
    inf = appuifw.query(u"mínimo:", "number")
    sup = appuifw.query(u"máximo:", "number")
    nfotos = sup
    
    
    #Algoritmo de comparacion
    def getdata(im, bpp=24):
        import struct, zlib
        im.save('E:\\pixels.png',compression='no')
        f = open('E:\\pixels.png', 'rb')
        f.seek(8 +8+13+4)
        chunk = []
        while 1:
            n = struct.unpack('>L', f.read(4))[0]
            if n==0: break
            f.read(4)
            chunk.append(f.read(n))
            f.read(4)
        f.close()
        return zlib.decompress(''.join(chunk))
     
    last1 = '\x00' * 930
    
    def detectar():
        print "Inicio bucle"
        while 1:
            print "Dentro del bucle"
            #Algoritmo de deteccion
            im = camera.take_photo('RGB', (160,120), position=1)
            nfotos += 1
            print nfotos
            box = Image.new((30,30), 'L')
            box.blit(im, (10,10,40,40))
            data = getdata(box, 8)
            pixdiff = 0
            for i in range(len(data)):
                if abs(ord(data[i])-ord(last1[i])) > 15:  # pix threshold 15/256
                    pixdiff += 1
                    if pixdiff > 90:    # img threshold 90/900
                        detec += 1
                        if detec >1:
                            #print nfotos
                            if (nfotos >inf) and (nfotos <sup):
                                segunda = 1
                                keypress.simulate_key(EKeyRightSoftkey,EKeyRightSoftkey)  
                                
                            if segunda == 1:
                                nfotos = sup
                                segunda = 0
                            else:
                                nfotos = 0
                            
                        break
            last1 = data
    
    
    def quit():a.signal()
    appuifw.app.exit_key_handler=quit
    
    
    
    def handle_incoming_call(state):
        print "Detecto llamada"
        detectar()
    
    def cb(state):
    	if(state[0]==telephone.EStatusRinging):handle_incoming_call(state)
    
    telephone.call_state(cb)
    
    a=e32.Ao_lock()
    a.wait()
    Thank you

Similar Threads

  1. Call function error for incoming message
    By ninidotnet in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-01-15, 02:40
  2. Replies: 0
    Last Post: 2003-11-17, 01:55
  3. Cannot compile SDK's examples for 7650 platform...
    By midletsoft in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-08-12, 19:11
  4. Problem with Nokia D211 Linux Drivers
    By fiveam in forum Multimodecards
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×