Home Contact us


VSMS messages



//-----------------------------------------------------------------------------
// testvsms.vpl, created 2003-04-28 09:44
// 
// Test of VSMS messages sent over the RTCU GPRS Gateway. In order to run this 
// example, you need the following:
// 1. Install and configure the RTCU GPRS Gateway product
// 2. Insert a GPRS enabled SIM card in the RTCU unit
// 3. Configure the TCP/IP and Gateway settings in the RTCU, using the RTCU-IDE program
// 4. Download this project into the RTCU unit
//
// When running correctly the LED1 will turn on after a few seconds, and then LED2
// should turn on after approx 30..50 seconds signalling that the unit is now connected
// to the GPRS network (connected to the internet)
// The program will then send a VSMS message every 60 seconds to it self.
//-----------------------------------------------------------------------------
INCLUDE rtcu.inc
INCLUDE tcpip.inc

//  Output variables that can be configured via the configuration dialog (These are global)
VAR_OUTPUT
   gwOK   : BOOL| Monitors connection to the RTCU GPRS Gateway
   gprsOK : BOOL| Monitors connection to GPRS (The internet) connection
END_VAR;

PROGRAM testvsms;
VAR 
   rc        : INT;
   sms       : gsmIncomingSMS// Receives incoming VSMS messages
   ns        : DINT;   // Holds linsec time for next transmission
   sMyNodeID : STRING// Contains this units serialnumber (node ID) in the
                       // format of "@nnnn" where nnnn is the serialnumber
END_VAR;

// The next code will only be executed once after the program starts
gsmPower(power:=TRUE);

// Activate the GPRS support, and connect to the internet
DebugFmt(message:="gprsOpen=\1",v1:=gprsOpen());

// First VSMS will be sent in 60 seconds
ns:=clockNow()+60; 

// Construct our own nodeid in the form of "@nnnn"
sMyNodeID:=strConcat(str1:="@", str2:=dintToStr(v:=boardSerialNumber()));
DebugMsg(message:=sMyNodeID);

// Code from this point until END will be executed repeatedly
BEGIN
   sms();

   // If it's time to send another VSMS message (this message is destined for this unit)...
   if clockNow()>ns then
      DebugFmt(message:="gsmSendSMS()=\1", v1:=gsmSendSMS(phonenumber:=sMyNodeID, message:="Hello world"));
      ns:=clockNow()+60; // Next transmit is in 60 seconds
   end_if;
   
   // If any incoming VSMS messages, just show them
   if sms.status>0 then
      DebugMsg(message:="SMS received");
      DebugMsg(message:=sms.phonenumber); // In the case of VSMS messages, this will be "@nnnn" 
                                          // where nnnn is the nodenumber of the sending node
      DebugMsg(message:=sms.message);
   end_if;

   gprsOK:=gprsConnected();
   gwOK:=gwConnected();
END;

END_PROGRAM;