Prev: Telephony
Module gsm: GSM information
This module provides access to GSM (Global System for Mobile communication) related information. This includes identifiers and network information.
Please note that not all functions of this module are supported on all devices. Some functions may throw ErrNotSupported.
gsm.cid
• function cid() → Number
Permissions: ReadApp
Capabilities: extended
Gets the current CID (Cell Identity). Roughly speaking, a cell identifies the location of the phone: in a simplified view, each GSM cell corresponds to an antenna the phone is communicating with[18]. In cities, cells identify the location of the phone with a precision of a few hundred meters or even less. In remote locations, in particular on mountains, the distance to the antenna can be ten or more kilometers.
In practice, a specific location (e.g. an office) is typically covered by more than one cell, so the CID may change even if the phone doesn't move.
According to GSM specs, the CID is a number between 0 and 65535 for GSM cells, and a number greater than 65535 on UTMS cells.
gsm.net
• function net() → Array
Permissions: ReadApp
Capabilities: extended
Gets the current network as an array with the following keys:
| Key | Contents |
| mcc | Mobile Country Code (MCC) |
| mnc | Mobile Network Code (MNC) |
| short | Short Network Name |
| long | Long Network Name |
| lac | Location Area Code (LAC) |
| |
To identify the current provider, MCC and MNC should be used. MCC and MNC of the home network are identical to the first three and two digits of the IMSI (see gsm.imsi).
Short and long name come from a database stored in the phone, so they may differ between phones for the same network.
n=gsm.net();
print n
→ 228,1,Swisscom,Swisscom,1616]
print 100*n["mcc"]+n["mnc"]
→ 22801
print substr(gsm.imsi,0,5)
→ 22801
|
gsm.new
• function new(timeout=-1) → Boolean
Permissions: ReadApp
Capabilities: extended
Waits until the current location information (typically the cell) changes, or until timeout milliseconds passed, if timeout>=0.
Returns true if the location information changed, or false if the timeout expired.
Throws ExcValueOutOfRange if timeout exceeds 2147483 (35 minutes and 47.483 seconds).
The following code fragment waits ten seconds for a change in the location information, and prints the new cell if it changed.
if gsm.new(10000) then
print "In cell",gsm.cid()
end
|
gsm.signal
• function signal() → Number
Permissions: ReadApp
| | |
| Compatibility of function gsm.signal |
| Sony Ericsson UIQ3 phones do not support this API. | Call returns 0. |
|
Gets the strength of the signal in the current network. The meaning of the returned value is device dependent. It may be a number between 0 (no signal) and 100 (strongest), or it may correspond to the number of signal strength bars normally shown on the display.
gsm Constants
• const imei = phone identifier
This constant contains the IMEI (International Mobile Equipment Identity) for the device m is running on. The IMEI is a fifteen digit unique identifier assigned to each device (cellphone). This number can also be queried directly by dialing *#06# on the phone.
print gsm.imei
→ 355023001234567
|
• const imsi = subscriber identifier
Capabilities: extended
| | |
| Compatibility of constant imsi |
| Nokia 6600: the IMSI cannot be obtained. | imsi=000000000000000 |
|
This constant contains the the IMSI (International Mobile Subscriber Identity) for the SIM card of the device m is running on. The IMSI is an up to fifteen digit unique identifier assigned to each subscriber (SIM card).
print gsm.imsi
→ 228011234567890
|
• const number = own phone number
If set in the m properties, contains the own phone number. If undefined, or in standalone applications, contains a single plus sign ("+").
print gsm.number
→ +41791234567
|
Next: Module phone: Phone Calls© 2004-2011 airbit AG, CH-8008 Zürich
Document AB-M-LIB-888