Development

Communication / GPRS+GPS:

» GPRS SIM928A 22: Getting IMSI from SIM and IMEI

This example shows how to get IMSI form SIM card and IMEI from GPRS_SIM928A module

Required Materials

1 x Waspmote
1 x Battery
1 x GPRS_SIM928A module
1 x SIM card

Notes

GPRS_SIM928A module must be powered with a battery
When GPRS_SIM928A is in use, interrupts can't be used

Code

/*  
 *  ------ GPRS_SIM928A_22 - Getting IMSI from SIM and IMEI -------- 
 *  
 *  Explanation: This example shows how to get IMSI form SIM card, IMEI and 
 * 	firmware version from GPRS_Pro module and APN parameters
 *  
 *  Copyright (C) 2015 Libelium Comunicaciones Distribuidas S.L. 
 *  http://www.libelium.com 
 *  
 *  This program is free software: you can redistribute it and/or modify 
 *  it under the terms of the GNU General Public License as published by 
 *  the Free Software Foundation, either version 3 of the License, or 
 *  (at your option) any later version. 
 *  
 *  This program is distributed in the hope that it will be useful, 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 *  GNU General Public License for more details. 
 *  
 *  You should have received a copy of the GNU General Public License 
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 *  
 *  Version:           0.1 
 *  Design:            David Gascón 
 *  Implementation:    Alejandro Gállego 
 */

#include "WaspGPRS_SIM928A.h"

int answer;

void setup()
{
    // setup for Serial port over USB:
    USB.ON();
    USB.println(F("USB port started..."));

    // 1. activates the GPRS_SIM928A module:
    answer = GPRS_SIM928A.ON(); 
    if ((answer == 1) || (answer == -3))
    {
        USB.println(F("GPRS SIM928A module ready..."));

        // 2. gets IMSI:
        while (GPRS_SIM928A.getIMSI() != 1);
        USB.print(F("IMSI: "));
        USB.println(GPRS_SIM928A.buffer_GPRS);

        // 3. gets IMEI:
        while (GPRS_SIM928A.getIMEI() != 1);
        USB.print(F("IMEI: "));
        USB.println(GPRS_SIM928A.buffer_GPRS);

        // 4. shows firmware:
        while (GPRS_SIM928A.firmware_version() != 1);
        USB.print(F("Firmware version: "));
        USB.println(GPRS_SIM928A.buffer_GPRS);

        // 5. show operator parameters:
        GPRS_SIM928A.show_APN();

    }
    else
    {
        USB.println(F("GPRS SIM908 module not ready"));    
    }

    // 6. powers off the GPRS_SIM928A module
    GPRS_SIM928A.OFF(); 
}

void loop()
{

}

Output

E#
USB port started...
GPRS_SIM928A module ready...
IMSI: 214075540745112
IMEI: 861001000993307
Firmware version: 1137B03SIM908M64_ST_ENHANCE
APN: movistar.es
LOGIN: movistar
PASSWORD: movistar

Quick Publish: