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:
Overview
Properties
Methods
Signals
Enumerations
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:
- › 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:
- › Attributes:
Readonly
authenticationType
This property was introduced in InCore 2.3.
- › Type:
- › Default:
- › Signal:
authenticationTypeChanged()
- › Attributes:
Writable
authenticationTypeItem
This property holds an internal ConfigurationItem instance for the authenticationType property.
- › Type:
- › 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:
- › 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:
- › 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:
- › 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:
- › 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:
- › 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:
- › 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 |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State
This enumeration describes all possible states of the modem device represented by the object.
Name |
Value |
Description |
|---|---|---|
|
|
Could not find a modem device. |
|
|
The modem is unusable. |
|
|
The modem is in an unknown state. |
|
|
The modem is currently being initialized. |
|
|
The modem needs to be unlocked with a PIN. |
|
|
The modem is not enabled and is powered down. |
|
|
The modem is currently transitioning to the MobileNetworkInterface.StateDisabled state. |
|
|
The modem is currently transitioning to the MobileNetworkInterface.StateEnabled state. |
|
|
The modem is enabled and powered on but not registered with a network provider and not available for data connections. |
|
|
The modem is searching for a network provider to register with. |
|
|
The modem is registered with a network provider and data connections may be available for use. |
|
|
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. |
|
|
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. |
|
|
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))
}
}