Step 7: End the Connection

Step 7: End the Connection

Last updated: December 3, 2008

This control program example is written to test a mobile station with both GSM and GPRS capability. The GSM capability of the mobile station is tested first, then the voice call is ended before a data connection is established. After GPRS testing, the GPRS data connection must be stopped. See the following for code examples:

Ending a GSM Call Connection

You can end the connection in one of two ways:

Ending the Connection from the Test Set

When you are ending the connection from the test set use the CALL:END command. The example below illustrates how you use the CALL:CONN:STAT? query for call synchronization. This query returns a "0" if the call ended successfully and a "1" if the call is not ended. It is not necessary for you to arm the change detector or set a change detector timeout when using the test set to terminate a call. The test set automatically arms the change detector and uses a default timeout in this situation.

 
2280  !  End the GSM call so a GPRS connection can be established.
2290  !
2300  OUTPUT Test_set;"CALL:END"
2310  OUTPUT Test_set;"CALL:CONN:STAT?"
2320  ENTER Test_set;Call_connected
2330  IF Call_connected THEN
2340    BEEP
2350    PRINT "Unable to complete BS termination. Program terminated."
2360    STOP
2370  END IF

Ending the Connection from the Mobile Station

When the connection is being ended from the mobile station, it is important to set a timeout value and arm the change detector. More information about using these commands to achieve call synchronization is available in Step 7: End Connection .

This code is not included in the control program available on-line for you to download. In that example, the connection is ended from the test set.

 
OUTPUT Test_set;"CALL:CONN:TIM 5" !Set timeout time to 5 seconds.
OUTPUT Test_set;"CALL:CONN:ARM"   !Arm the change detector.
OUTPUT Test_set;"CALL:CONN:STAT?" !Initiate call connect state query.
DISP "Terminate the call from the mobile station."
ENTER Test_set;Call_connected     !Program will hang here until state
                                  !change or timer expires.
IF Call_connected THEN            !Check if disconnect successful.
  OUTPUT Test_set;"CALL:END"
  PRINT "Call failed to end correctly.  Program terminated."
  STOP
END IF

Ending a GPRS Data Connection

Stopping the data connection

The CALL:FUNC:DATA:STOP command ends the data connection. Use the CALL:STAT:DATA? query to ensure the data connection has ended and the connection is in the "ATTached" state.

 
3160  OUTPUT Test_set;"CALL:FUNC:DATA:STOP"
3170  OUTPUT Test_set;"CALL:STAT:DATA?"
3180  ENTER Test_set;Conn_status$
3190  IF Conn_status$<>"ATT" THEN
3200    PRINT "Unable to terminate data connection correctly."
3210    PRINT "PROGRAM TERMINATED."
3220    STOP
3230  END IF

Initiating a GPRS Detach

The test set does not require you to perform a GPRS detach. No errors are generated if a GPRS detach is not performed. Therefore, you may choose to remove the tested phone after the data connection has ended.

There are two ways to initiate a GPRS Detach.

Initiating the GPRS Detach from the Test Set

The example below illustrates initiating a GPRS Detach from the Test Set.

 
3280  ! Initiate a GPRS detach from the test set.
3290  OUTPUT Test_set;"CALL:FUNC:DATA:DET"
3300  !
3310  Start_time=TIMEDATE
3320  LOOP
3330    OUTPUT Test_set;"CALL:DCON:ARM"
3340    OUTPUT Test_set;"CALL:ATT?"
3350    ENTER Test_set;Att_state
3360  EXIT IF NOT Att_state
3370    Current_time=TIMEDATE-Start_time
3380    IF Current_time>=Timer THEN
3390      DISP ""
3400      PRINT "GPRS detach did not occur.  Program terminated"
3410      STOP
3420    END IF
3430    IF Conn_state$="DET" THEN
3440      DISP "GPRS detach is in process."
3450    END IF
3460  END LOOP

Mobile Station initiated GPRS Detach

The example below illustrates initiating a GPRS Detach from the mobile station.

 
DISP "Initiate a GPRS Detach"
Start_time=TIMEDATE
LOOP
  OUTPUT Test_set;"CALL:STAT:DATA?"
  ENTER Test_set;Conn_state$
 EXIT IF Conn_state$="IDLE"
  Current_time=TIMEDATE-Start_time
  IF Current_time>=Timer THEN
    DISP ""
    PRINT "GPRS detach did not occur.  Program terminated"
    STOP
  END IF
  IF Conn_state$="DET" THEN
    DISP "GPRS detach is in process."
  END IF
END LOOP