www.beck-ipc.com

GMLib - Initialization


Status / Initialization

Functions needed for initialization, status information, or mode changes

  • gmInit
  • gmInitExt
  • gmInitSimDetection
  • gmDeInit
  • gmEnableDTR
  • gmWriteBaudRate
  • gmSendAT
  • gmGetATLineWithTimeout
  • gmGetATLine
  • gmSimpleAT
  • gmLogon
  • gmReadRevision
  • gmReadIMEI
  • gmResetState
  • gmLibVersion


  • int gmInit(void)

    Initializes and opens the serial port of the IPC@CHIP. Reads port, pios, PIN and PUK from chip.ini for connecting to the GM0x. For CHIP.INI constants look at CHIP.INI entries and values.

    Return Value

    Return values are described here: Return values

    Comments

    You can alternatively use gmInitExt if you don't want to provide the parameters in CHIP.INI but use the parameters struct.

    Comment

    If there's no matching entry following values will be set by default on SC1x3/SC2x

    port          = FOSSIL_SER2 (2)
    IGNPio        = GM_DEFAULT_IGNPIO (0)
    ONPio         = GM_DEFAULT_ONPIO (0)
    DCDPio        = GM_DEFAULT_DCD_PIO (1)
    ResetPio      = GM_DEFAULT_RESET_PIO (17)
    PIN           = NULL
    PUK           = NULL
    
    If there's no matching entry following values will be set by default on SC2x3

    port          = FOSSIL_UART4 (3)
    IGNPio        = GM_DEFAULT_IGNPIO (31)
    ONPio         = GM_DEFAULT_ONPIO (31)
    DCDPio        = GM_DEFAULT_DCD_PIO (24)
    ResetPio      = GM_DEFAULT_RESET_PIO (28)
    PIN           = NULL
    PUK           = NULL
    
    If there's no matching entry following values will be set by default on SC1x5

    port          = 2000
    IGNPio        = GM_DEFAULT_IGNPIO (-2)       // ### TODO
    ONPio         = GM_DEFAULT_ONPIO (130)       // ### TODO
    DCDPio        = GM_DEFAULT_DCD_PIO (-1)      // ### TODO
    ResetPio      = GM_DEFAULT_RESET_PIO (-1)    // ### TODO
    PIN           = NULL
    PUK           = NULL
    

    Top
    Index page


    int gmInitExt(gmInitParameters * initParams)

    Initializes and opens the serial port of the IPC@CHIP with parameters provided in initParams.

    Parameters

    initParams

    Input parameter: Pointer to a gmInitParameters type data structure prepared by caller.

    Return Value

    Return values are described here: Return values

    Comments

    You can alternatively use gmInit if you want to provide the parameter in CHIP.INI.


    Top
    Index page


    int gmInitSimDetection(int mode)

    Modifies the SIM detection method. Must be called before gmInit() or gmInitExt().

    Parameters

    mode

    SIM detection method:
    -1: use modem specific default
    0: ignore SIMIN pin and simulate the status 'SIM Not Inserted'
    1: ignore SIMIN pin and simulate the status 'SIM Inserted'
    2: automatic SIM detection through SIMIN Pin

    Return Value

    Return values are described here: Return values


    Top
    Index page


    int gmDeInit(void)

    Turns off the modem, closes the serial port and terminates the SMS callback task, if provided in gmStartSMSTask(). With gmResetState() you can check if the modem is turned off.

    Return Value

    Return values are described here: Return values


    Top
    Index page


    void gmEnableDTR(int enable)

    Enables or disables the modem's DTR-line handling for switching from data mode into command mode. The DTR-line must be controlled by the application.

    Parameters

    enable

    0 - disable (default)
    !=0 - enable

    Comments

    When the DTR-line is enabled and data connection is established a rising edge switches the modem from data mode into command mode. To switch back to data mode the command ATO must be used.


    Top
    Index page


    int gmWriteBaudRate(unsigned long baudRate)

    Changes the baud rate of the GM0x and the gmPort of the IPC@CHIP. The default baud rate after startup is 115200.

    Parameters

    baudRate

    possible values for GM01/GM03:
        300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800

    possible values for GM02:
        300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600, 2900000, 3200000, 3686400, 4000000

    possible values for GM04:
        1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400

    possible values for GMLGA01/GMLGA02/GM05/GM06:
        300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600

    Return Value

    Return values are described here: Return values

    Comments

    V1.10 - Changed default baudrate from 57600 to 115200


    Top
    Index page


    int gmSendAT(const char * input)

    This function sends AT commands to the GM0x.

    Parameters

    input

    AT command to execute

    Return Value

    Return values are described here: Return values

    Comments

    Remember to read the output of the GM0x by calling gmGetATLine or gmGetATLineWithTimeout otherwise the output will be deleted on another call (see example). Before sending data you have to get the serial semaphore to avoid collisions with RTX_Reserve_Sem(gmSerialSemID,&tmp); The semaphore has to be released at the end of the function ( RTX_Release_Sem(gmSerialSemID);).

    Example

    send "AT" and receive answers

    long tmp=0L;
    
    RTX_Reserve_Sem(gmSerialSemID,&tmp);
    
    retval = gmSendAT("AT");
    if (retval == GM_EXIT_SUCCESS)
    {
      // receive echo of the command
      retval =  gmGetATLine(gmATLineBuf);
      if (retval == GM_EXIT_SUCCESS)
      {
        retval =  gmGetATLine(gmATLineBuf);
        if (retval == GM_EXIT_SUCCESS)
        {
          if (strcmp(gmATLineBuf, "OK") == 0)
          {
    	// command successful
    	retval = GM_EXIT_SUCCESS;
    	goto EXIT_FUNCTION;
          }
          // otherwise return error code
          retval = GM_CHIP_ERROR;
          goto EXIT_FUNCTION;
        }
      }
    }
    EXIT_FUNCTION:
    RTX_Release_Sem(gmSerialSemID);
    return retval;
    

    Top
    Index page


    int gmGetATLineWithTimeout(char * ATLine, const unsigned long timeout)

    This function returns the next line of the answer of the GM0x.

    Parameters

    ATLine

    Output parameter: array of char with size GM_MAX_LINE_LENGTH

    timeout

    Time to wait (in ms) for an output line before sending a GM_CONNECTION_TO_CHIP_ERROR.

    Return Value

    Return values are described here: Return values

    Comments

    see gmSendAT for example


    Top
    Index page


    int gmGetATLine(char * ATLine)

    This function returns the next line of the answer of the GM0x waiting for it for the default timeout time (GM_DEFAULT_TIMEOUT).

    Parameters

    ATLine

    Output parameter: array of char with size GM_MAX_LINE_LENGTH

    Return Value

    Return values are described here: Return values

    Comments

    see gmSendAT for example


    Top
    Index page


    int gmSimpleAT(void)

    This function sends a simple AT to the GM0x and expects an OK answer.

    Return Value

    Return values are described here: Return values


    Top
    Index page


    int gmLogon(void)

    If a SIM PIN is needed, gmLogon tries to logon the the network. gmLogon() also performs basic settings. You do not have to call gmLogon() because gmInit or gmInitExt automatically call gmLogon(). The logon to the GSM network may take several seconds, depending on the network and the availability.

    Return Value

    Return values are described here: Return values

    Comments

    You can alternatively use gmInit if you want to provide the parameter in CHIP.INI.


    Top
    Index page


    int gmReadRevision(char * deviceRev)

    This function reads the actual firmware version of the GM0x.

    Parameters

    deviceRev

    Output parameter: array of char, must have a length of 32

    Return Value

    Return values are described here: Return values


    Top
    Index page


    int gmReadIMEI(char * deviceIMEI)

    This function reads the IMEI identification number of the GM0x.

    Parameters

    deviceIMEI

    Output parameter: array of char, must have a length of 20

    Return Value

    Return values are described here: Return values


    Top
    Index page


    int gmResetState(void)

    This function checks the state of the reset PIO.

    Return Value

    Return value of reset PIO. If no reset PIO is defined the function will return GM_EXIT_FAILURE.


    Top
    Index page


    unsigned short gmLibVersion(void)

    This function returns the GMLib version number.

    Return Value

    Identifier for this version of the library. Library version 1.10, for example, will return value 0x0110.


    Top
    Index page


    End of document