gsmSetNetworkType (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

4.10 / 1.00.00


This function selects the preferred service type from the cellular network (2G, 3G or 4G).

 

If a specific network service type is selected, then the device will not try to connect to other network services.

For example, if the 3G network is selected, then the connection will be lost when entering an area where an only 2G network is present.

 

To avoid this it is possible to specify the preferred search order (Not available on all devices).
The search order determines the order in which the device will try to connect to the different network types.

For example, setting the search order to '2G then 3G' will make the device try to connect to the 2G network if it is present. If the 2G network is not present or disappears, then the device will search for a 3G network.

 

Note:  
The selection made by calling this function will remain in effect (persistent through reset/power down) until changed explicitly by a new call to gsmSetNetworkType.
Not all service types are available on all devices. Please consult the data-sheet.

 

 

Input:

type : SINT (default: 0)

The network type to use.

0

Search order.

2

2G network

3

3G network

4

4G (LTE) network

 

order : SINT (default: 0)

The order used to search for network types. (Is only used when type is set to Search order)

0

Automatic

1

2G then 3G

2

3G then 2G

 
LTE capable devices only supports the "Automatic" mode and other values will return 1;

 

Returns: INT

0

Success.

1

Not supported.

2

GSM module is not powered on (see gsmPower()).

3

Illegal network type.

4

Illegal search order.

5

SIM card not present.

 

Declaration:

FUNCTION gsmSetNetworkType : INT;
VAR_INPUT
  type   : SINT := 0;
  order : SINT := 0;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
 
// Turn on power to the GSM module
gsmPower(power := TRUE);
 
BEGIN
  ...
  // Set search order to 2G first, then 3G
  gsmSetNetworkType(type := 0, order := 1);
  ...
END;
 
END_PROGRAM;