gsm location in python

859 views Asked by At

I have this script file in python running on S60:

import location

def current_location():
 gsm_loc = location.gsm_location()
 print gsm_loc

current_location()

instead of printing a tuple of mcc, mnc, lac and cellId it prints None.

on top of my python shell I see location between the capabilities included.

what can be the problem?

Development of the situation:

I thought maybe nevertheless, my problem is lack of capabilities. So I went to sign the PythonScriptShell file. I used OPDA website - I know they sign all the capabilities but three - which I don't use. I installed the signed PythonScriptShell file on my phone (N95). On the top the list of capabilities didn't change. tried to run the script again: same result - prints None.

If anyone can help me with this, it's really important.

thank you.

2

There are 2 answers

0
Day_Dreamer On BEST ANSWER

I think I can answer now one part of the problem:

the reason for printing None is because there needed another capability: ReadDeviceData which wasn't included in the capabilities list on top of python shell.

still, remaining the other part of the problem, why this capability wasn't included when I signed PythonScriptShell file? It is not one of the three restricted capabilities.

0
radioxoma On

I have same issue with all necessary scriptshell capabilities: 'PowerMgmnt', 'ReadDeviceData', 'WriteDeviceData', 'TrustedUI', 'ProtServ', 'SwEvent', 'Network services', 'LocalServices', 'ReadUserData', 'WriteUserData', 'Location', 'SurroundingsDD', 'UserEnviroment'.

Let's take a look at source code from PythonForS60/module-repo/dev-modules/location.py:

import e32
import _location

def gsm_location():
    if e32.s60_version_info>=(3,0):
        ret = _location.gsm_location()
        if ret[4]==1: # relevant information ?
            return (int(ret[0]),int(ret[1]),ret[2],ret[3])
        else:
            return None # information returned by _location.gsm_location() not relevant
    else:
        return _location.gsm_location()

On my Nokia E71 e32.s60_version_info == (3,1) and I get None value too.

I don't really know what means 'not relevant', but direct calling

>>> import _location
>>> _location.gsm_location()
(u'257', u'01', 555, 11, 0)

returns something close to my objective reality.