Skip to main content

imp.net.getcellinfo(callback)

Retrieve cellular connection state information

Availability

Device (from impOS™ 40)

Parameters

Name Type Description
callback Function A function to be called when the cellular connection data has been gathered

Returns

Nothing

Description

This method requests current connection state information from the cellular modem integrated into imps that feature cellular interfaces. It takes as its argument a function which will be called when this information has been retrieved. Gathering this data can take a significant period of time, so imp.net.getcellinfo() operates asynchronously to prevent your application from being blocked while the information is collated. The information is only available once the imp’s cellular modem is powered on.

The cellular connection information is provided in a string — for example, "4G,6300,20,10,10,FDD,262,02,BF75,0345103,350,90,-94,-7,CONN" — and so the callback function should include a single parameter, cellinfo, which will receive the string. For more information on the data contained in the string, which varies according to the connected network type (2G, 3G, 4G, etc), please see ‘The Cinterion ELS61-E AT Command Set’, section 8.11.2.

Important

In early releases of impOS™ 39, an internal-only version of the OS, the cellular connection information described above was provided by the imp API method imp.net.info() via the key cellinfo within the cellular-specific table included in the returned data’s interface array. From impOS 40, imp.net.info() will not include cellinfo key nor the other state-specific keys rssi and voltage.

This is a breaking change for application code written for earlier versions of impOS than release 40. Customers making use of imp.net.info() to retrieve cellinfo, rssi and/or voltage values should update their application Squirrel accordingly. In release 40, accessing these keys via imp.net.info() will cause an exception to be thrown.

Example

// Request cellular connection info
imp.net.getcellinfo(function(cellinfo) {
    // Parse string 'cellinfo' - comma-separated values
    local cellData = split(cellinfo, ",");

    // Log the network type
    local ACT = cellData[0];
    server.log("Connected to a " + ACT + " network");

    if (ACT == "4G") {
        // Log the cell ID
        server.log("Global Cell ID: " + cellData[9]);
    }
});