Development

» Int 04: GPRS PRO interrupt

This example shows how to manage the GPRS PRO interrupt.

Required Materials

1 x Waspmote
1 x MiniUSB wire
1 x Battery
1 x GPRS_Pro module
1 x GPRS/3G antenna
1 x SIM card

Notes

- For generating the interruption, the GPRS PRO module has to be activated externally, e.g: making a call to the SIM card number.
- This example can be executed in Waspmote v12

Code

/*
 *  ------ [INT_4] GPRS_Pro PRO interrupt Example --------
 *
 *  Explanation: This example shows how to manage the GPRS PRO 
 *  interruption entering Waspmote and GPRS_Pro module in low
 *  power states until the GPRS module receives a external call.
 *
 *  Copyright (C) 2012 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:    Marcos Yarza
 */

#include <WaspGPRS_Pro.h>
#include <WaspGPRS_Proconstants.h>

void setup()
{

  // setup for Serial port over USB
  USB.ON();
  USB.println(F("INT_04 example"));

  ///////////////////////////////////////
  // 1. setup for GPRS serial port
  ///////////////////////////////////////
  GPRS_Pro.ON();
  USB.println(F("GPRS PRO module ready..."));

  ///////////////////////////////////////
  // 2. waiting while GPRS connects to the network
  ///////////////////////////////////////
  while(!GPRS_Pro.check());
  USB.println(F("GPRS PRO connected to the network"));

  Utils.blinkLEDs(200);

  // configure SMS and Incoming Calls
  if(GPRS_Pro.setInfoIncomingCall()) USB.println(F("Info Incoming Call OK"));
  if(GPRS_Pro.setInfoIncomingSMS()) USB.println(F("Info Incoming SMS OK"));
  if(GPRS_Pro.setTextModeSMS()) USB.println(F("Text Mode SMS OK"));
 
 
  ///////////////////////////////////////
  // 4. enabling interruptions
  ///////////////////////////////////////
  enableInterrupts(UART1_INT);

}

void loop()
{
  ///////////////////////////////////////
  // 3. set sleep mode to GPRS module
  ///////////////////////////////////////
  if(GPRS_Pro.setMode(GPRS_PRO_SLEEP) == 1)
  {
    USB.println(F("GPRS changed to sleep mode"));
  }
  else
  {
    USB.println(F("Error changing GPRS power mode"));
  }

  ///////////////////////////////////////
  // 5. enter sleep mode waiting for interruption
  ///////////////////////////////////////  
  USB.println(F("Waspmote goes into sleep mode until the GPRS causes an interrupt"));
  USB.println(F("A lost call or SMS will generate interrupt"));
  PWR.sleep(UART0_OFF|RTC_OFF|BAT_OFF);


  ///////////////////////////////////////
  // 6. check intFlag
  ///////////////////////////////////////
  if( intFlag & UART1_INT )
  {
    USB.println(F("\r\n------------------------------------------------"));
    USB.println(F("Waspmote wake up - GPRS interrupt detected!!"));
    USB.println(F("------------------------------------------------\r\n"));
    Utils.blinkLEDs(100);
    Utils.blinkLEDs(100);
    Utils.blinkLEDs(100);
    
    // 6.1. clear intFlag 
    intFlag &= ~(UART1_INT);

    // 6.2. disable interruptions in UART1
    disableInterrupts(UART1_INT);
  
    // 6.3. set operative mode to GPRS module
    if(GPRS_Pro.setMode(GPRS_PRO_FULL) == 1)
    {
      USB.println(F("GPRS mode changed to FULL operation succesfully"));
    }
    else
    {
      USB.println(F("Error changing GPRS power mode"));
    }

    // 6.4. wait for some seconds
    delay(5000);

    // 6.5. enable interruptions
    enableInterrupts(UART1_INT);
  
    
    // 6.6. check the GPRS module is connected to network
    while(!GPRS_Pro.check());
    USB.println(F("GPRS PRO connected to the network"));
  }
}


Output

E#
INT_04 example
GPRS PRO module ready...
GPRS PRO connected to the network
Info Incoming Call OK
Info Incoming SMS OK
Text Mode SMS OK
GPRS changed to sleep mode
Waspmote goes into sleep mode until the GPRS causes an interrupt
A lost call or SMS will generate interrupt

------------------------------------------------
Waspmote wake up - GPRS interrupt detected!!
------------------------------------------------

GPRS mode changed to FULL operation succesfully
GPRS PRO connected to the network
GPRS changed to sleep mode
Waspmote goes into sleep mode until the GPRS causes an interrupt
A lost call or SMS will generate interrupt

------------------------------------------------
Waspmote wake up - GPRS interrupt detected!!
------------------------------------------------

GPRS mode changed to FULL operation succesfully
GPRS PRO connected to the network
GPRS changed to sleep mode
Waspmote goes into sleep mode until the GPRS causes an interrupt
A lost call or SMS will generate interrupt

...

Quick Publish: