gsmGetProviderList (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


This function block can be used to get a list of available GSM providers.

This function can be called during an active mobile network session.

 

It is possible to use the gsmSetProvider() function to select a different operator.

 

Note:

This operation can take a long time to execute - up to 2 minutes.

This function may fail if the GSM module is busy or the GSM coverage is reduced. In this case, it is recommended to wait a minimum of 30 seconds and retry the operation.

It is recommended not to call this function more frequently than every 5 minutes.

 

Input:

None.

 

Output:

status : INT (0..1)

0 - If list is available.

1 - If an error occurred while getting the list or during a GSM module power-off.

 

CurrentLAI : DINT

The GSM Public Land Mobile Network number (PLMN) of the current provider.

 

LAI : ARRAY[1..16] OF DINT

The GSM PLMN number of the provider "n".

 

Name : ARRAY[1..16] OF STRING

The name of the provider  "n".

 

State : ARRAY[1..16] OF SINT

The state of the provider "n": 0=unknown, 1=operator available,  2=current operator (registered), 3=forbidden operator.

 

Declaration:

FUNCTION_BLOCK gsmGetProviderList;
VAR_OUTPUT
  Status     : SINT;                   // 0 if successful, 1 if error
  CurrentLAI : DINT;                   // The current providers PLMN number
 
  // The following information is grouped, index 1 for all arrays is for the first provider etc.
  LAI       : ARRAY[1..16] OF DINT;   // Providers PLMN number
  Name       : ARRAY[1..16] OF STRING; // Name of provider
  State     : ARRAY[1..16] OF SINT;   // State: 0=unknown, 1=operator available,  2=current operator (registered), 3=forbidden operator
END_VAR;

 

 

Example:

//-----------------------------------------------------------------------------
// test.vpl, created 2003-02-26 12:13
//
//-----------------------------------------------------------------------------
INCLUDE rtcu.inc
 
VAR
  provider : gsmGetProviderList;
  i       : SINT;
END_VAR;
 
PROGRAM test;
 
// The next code will only be executed once after the program starts
gsmPower(power:=TRUE);
 
// Wait until GSM module registered on network
WHILE NOT gsmConnected() DO Sleep(delay:=1000); END_WHILE;
 
// Get list of GSM providers
provider();
 
DebugFmt(message:="Status=\1, Current provider =\4", v1:=provider.status, v4:=provider.CurrentLAI);
FOR i := 1 TO 16 DO
  IF provider.LAI[i] > 0 THEN
    DebugFmt(message:="Provider=\4, State=\1", v1:=provider.State[i], v4:=provider.LAI[i]);
    DebugMsg(message:=provider.Name[i]);
END_IF;  
END_FOR;
 
BEGIN
 
END;
 
END_PROGRAM;