MobileNetworkInterface

Description

The MobileNetworkInterface object represents a mobile network interface (i.e. a modem device such as an LTE USB stick) and manages connections to a mobile (cellular) network. In order to start a connection, the apn, username and password need to be set. A connection will be established to available networks automatically. The current modem and connectivity state can always be read through the state property.

Important

A MobileNetworkInterface object always has to be a child of a NetworkConfiguration object in order to work properly. Otherwise the modem device will connect to the mobile network only without establishing a data connection.

› Inherits:NetworkInterface

Properties

allowRoaming

This property holds whether data connections are allowed during roaming. If disabled the device will be offline if the home network is not available.

› Type:Boolean
› Default:false
› Signal:allowRoamingChanged()
› Attributes:Writable

allowRoamingItem

This property holds an internal ConfigurationItem instance for the allowRoaming property.

› Type:ConfigurationItem
› Attributes:Readonly

apn

This property holds the access point name to use for the mobile connection.

› Type:String
› Signal:apnChanged()
› Attributes:Writable

apnItem

This property holds an internal ConfigurationItem instance for the apn property.

› Type:ConfigurationItem
› Attributes:Readonly

authenticationType

This property was introduced in InCore 2.3.

› Type:AuthenticationType
› Default:MobileNetworkInterface.UnknownAuthentication
› Signal:authenticationTypeChanged()
› Attributes:Writable

authenticationTypeItem

This property holds an internal ConfigurationItem instance for the authenticationType property.

› Type:ConfigurationItem
› Attributes:Readonly

deviceManufacturer

This property holds the manufacturer name of the modem device.

This property was introduced in InCore 2.3.

› Type:String
› Signal:deviceManufacturerChanged()
› Attributes:Readonly

deviceModel

This property holds the model name of the modem device.

› Type:String
› Signal:deviceModelChanged()
› Attributes:Readonly

establishIpConnection

This property holds whether to establish an IP-based data connection. When set to false, the modem will only register on the cellular network and remain in the MobileNetworkInterface.StateRegistered state. In this state it’s possible to send and receive text messages (SMS).

This property was introduced in InCore 2.4.

› Type:Boolean
› Default:true
› Signal:establishIpConnectionChanged()
› Attributes:Writable

establishIpConnectionItem

This property holds an internal ConfigurationItem instance for the establishIpConnection property.

› Type:ConfigurationItem
› Attributes:Readonly

iccid

This property holds the ICCID of the currently used SIM card.

› Type:String
› Signal:iccidChanged()
› Attributes:Readonly

imei

This property holds the IMEI of the modem device.

› Type:String
› Signal:imeiChanged()
› Attributes:Readonly

imsi

This property holds the IMSI of the currently used SIM card.

› Type:String
› Signal:imsiChanged()
› Attributes:Readonly

number

This property holds the telephone number to dial for establishing a data connection.

› Type:String
› Default:*99#
› Signal:numberChanged()
› Attributes:Writable

numberItem

This property holds an internal ConfigurationItem instance for the number property.

› Type:ConfigurationItem
› Attributes:Readonly

password

This property holds the password for authenticating with the mobile network.

› Type:String
› Signal:passwordChanged()
› Attributes:Writable

passwordItem

This property holds an internal ConfigurationItem instance for the password property.

› Type:ConfigurationItem
› Attributes:Readonly

pin

This property holds the PIN used to unlock the SIM card. It’s only required if the SIM card needs to be unlocked.

› Type:String
› Signal:pinChanged()
› Attributes:Writable

pinItem

This property holds an internal ConfigurationItem instance for the pin property.

› Type:ConfigurationItem
› Attributes:Readonly

signalQuality

This property holds the current signal quality in percent (0-100) of the dominant access technology the device is using to communicate with the network.

› Type:SignedInteger
› Signal:signalQualityChanged()
› Attributes:Readonly

state

This property holds the current state of the modem device and its connectivity.

› Type:State
› Signal:stateChanged()
› Attributes:Readonly

username

This property holds the username for authenticating with the mobile network.

› Type:String
› Signal:usernameChanged()
› Attributes:Writable

usernameItem

This property holds an internal ConfigurationItem instance for the username property.

› Type:ConfigurationItem
› Attributes:Readonly

Methods

sendMessage(String recipientNumbers, String text)

This method sends a text message (SMS) using the modem. The phone number(s) of the SMS recipient(s) have to be supplied in the recipientNumbers argument. To send more than one SMS separate the phone numbers with comma. Included spaces will be removed. If the message text in the text parameter contains non-ASCII characters the Unicode (UCS-2) encoding is used which requires 2 bytes per character. This may be relevant if the number of SMS that can be sent in a time period is limited.

It returns true if the send operation has been initiated successfully. Errors occurring while sending the SMS are signaled through the NetworkInterface.error property.

This method was introduced in InCore 2.3.

› Returns:Boolean

Signals

connected()

This signal is emitted when a data connection has been established, i.e. state changed to MobileNetworkInterface.StateConnected.

disconnected()

This signal is emitted when the connection to the mobile network has been closed, i.e. state is not MobileNetworkInterface.StateConnected yet/any longer.

messageReceived(String messageText, String messageId)

This signal is emitted when a text message (SMS) has been received. The message text is available trough the m̀essageText` argument. The internal ID of the received message is supplied in the messageId argument.

This signal was introduced in InCore 2.3.

messageSent(String messageId)

This signal is emitted when a text message (SMS) has been sent successfully. It’s not emitted if an error occurred while sending. The internal ID of the sent message is supplied in the messageId argument

This signal was introduced in InCore 2.3.

Enumerations

AuthenticationType

Name Value Description
MobileNetworkInterface.UnknownAuthentication 0
MobileNetworkInterface.NoAuthentication 1
MobileNetworkInterface.PAP 2
MobileNetworkInterface.CHAP 3
MobileNetworkInterface.MSCHAP 4
MobileNetworkInterface.MSCHAPv2 5
MobileNetworkInterface.EAP 6  

State

This enumeration describes all possible states of the modem device represented by the object.

Name Value Description
MobileNetworkInterface.StateNoDevice 0 Could not find a modem device.
MobileNetworkInterface.StateFailed 1 The modem is unusable.
MobileNetworkInterface.StateUnknown 2 The modem is in an unknown state.
MobileNetworkInterface.StateInitializing 3 The modem is currently being initialized.
MobileNetworkInterface.StateLocked 4 The modem needs to be unlocked with a PIN.
MobileNetworkInterface.StateDisabled 5 The modem is not enabled and is powered down.
MobileNetworkInterface.StateDisabling 6 The modem is currently transitioning to the MobileNetworkInterface.StateDisabled state.
MobileNetworkInterface.StateEnabling 7 The modem is currently transitioning to the MobileNetworkInterface.StateEnabled state.
MobileNetworkInterface.StateEnabled 8 The modem is enabled and powered on but not registered with a network provider and not available for data connections.
MobileNetworkInterface.StateSearching 9 The modem is searching for a network provider to register with.
MobileNetworkInterface.StateRegistered 10 The modem is registered with a network provider and data connections may be available for use.
MobileNetworkInterface.StateDisconnecting 11 The modem is disconnecting and deactivating the last active packet data bearer. This state will not be entered if more than one packet data bearer is active and one of the active bearers is deactivated.
MobileNetworkInterface.StateConnecting 12 The modem is activating and connecting the first packet data bearer. Subsequent bearer activations when another bearer is already active do not cause this state to be entered.
MobileNetworkInterface.StateConnected 13 One or more packet data bearers is active and connected, i.e. the device is online.

Example

import InCore.Foundation 2.5

Application {
    NetworkConfiguration {
        MobileNetworkInterface {
            id: wwan0

            // configure connection parameters
            apn: "internet.myprovider.de"
            username: "inhub"
            password: "MyS3cr3tP4ssw0rd"
            // print basic information when completed
            onCompleted: {
                console.log("Device model:", deviceModel)
                console.log("IMEI:", imei)
                console.log("IMSI:", imsi)
            }
            // continuously print signal quality
            onSignalQualityChanged: {
                console.log("Signal quality:", signalQuality)
            }
            // print state information
            onConnected: console.log("I'm online :-)")
            onDisconnected: console.log("I'm offline :-(")
            onStateChanged: console.log("Modem state", state)

            onMessageReceived: console.log(("SMS received: \"%1\"").arg(messageText))
        }
    }

    Counter {
        id: smsCounter
        interval: 30000
        onValueChanged: wwan0.sendMessage("+49123456789, +49135798642", ("Hello world! This is SMS number %1.").arg(value))
    }
}