arduino GPS GSM

hello…i using arduino , GPS, and GSM s, i got every step to reply and receiving GPS data to my phone… but i wan the GSM continuously sending me the message after after i send a certain test to the GPS GSM device… could any tell the code so the GSM continously sending the message to my phone

but i wan the GSM continuously sending me the message

"The message"? "You are lost!" maybe?

i did success on my coding … but now yes…i am a bit lost on how to make the data keep sending jus like in the pic i sent…

I don't want to look at a picture. Post your TEXT here!

Put the code INSIDE the code tags.

help me identify … what should i change so i can get continuous result reply from the device…

Myduino.txt (17.7 KB)

for you code You need to send us appropriate library links where you downloaded

what should i change so i can get continuous result reply from the device..

Isn't that obvious. The code!

Quit dancing around like you need to piss, and tell us what you want to continuously send. Then, wise up and understand that distance, if that is what you are referring to, only changes as the GPS sends new data, which it does NOT do continuously.


#include <TimedAction.h>
#include <NewSoftSerial.h>
#include <TinyGPS.h>
#include <String.h>

#define CELL_RX_PIN 2
#define CELL_TX_PIN 3

#define GPSBAUD 4800

#define STX 0x02 // Start of text
#define ETX 0x03 // End of text
#define CR 0x0D // Carriage return
#define CTRL_Z 0x1A // Control-z

TimedAction CELL_NetConnectTimeoutTask = TimedAction( 20000, CELL_NetConnectTimeout );
TimedAction CELL_ReplyTimeoutTask = TimedAction( 5000, CELL_ReplyTimeout );

TinyGPS gps;

NewSoftSerial CELL_Serial = NewSoftSerial( CELL_RX_PIN, CELL_TX_PIN );

enum CellCmnd
{
Cmnd_None,
Cmnd_Connect,
Cmnd_SMS_Type,
Cmnd_SMS_Indication,
Cmnd_CallForwarding,
Cmnd_Location,
Cmnd_SendGPSMessage,
Cmnd_DeleteMsgs,
Cmnd_OK
} nextCellCmnd = Cmnd_Connect;

enum CellReply
{
Reply_None,
Reply_Connect,
Reply_SMS_Type,
Reply_SMS_Indication,
Reply_CallForwarding,
Reply_Location,
Reply_SendGPSMessage,
Reply_MessageText,
Reply_DeleteMsgs,
Reply_OK
} nextCellReply = Reply_Connect;
#define BUFFSIZE 100
char *privCellPhone = “+0101010101”; //GSM phone number

char cellMsgBuff[ BUFFSIZE ] = “”;
char cellCmndBuff[ BUFFSIZE ] = “”;
char cellPhoneNumber[ 30 ] = “+101010101”; // sender’s number
int cellMsgBuffIndex = 0;
char incomingChar = 0;
int connectRespCnt = 0;
bool cellConnected = false;
bool cellNetConnectTimeout = false;
bool cellReplyTimeout = false;

float latitude, longitude;
int year;
byte month, day, hour, minute, second, hundredths;
float x, y, km;
float destinationLat = 6.0333;
float destinationLon = 116.1228333;

void getgps(TinyGPS &gps);

void setup( )
{
Serial.begin( GPSBAUD );
CELL_Serial.begin( 9600 );
CELL_NetConnectTimeoutTask.enable( );
CELL_NetConnectTimeoutTask.reset( );
CELL_ReplyTimeoutTask.disable( );
#if defined DEBUG_CELL
Serial.println( “Debug enabled…” );
#define DEBUG
#endif
}

void loop( )
{

#ifndef DEBUG
GPS_Update( );
#endif
CELL_Update( );
CELL_Actions( );
CELL_NetConnectTimeoutTask.check( );
CELL_ReplyTimeoutTask.check( );
}

void GPS_Update( )
{
while( Serial.available( ) )
{
int c = Serial.read();
if(gps.encode(c))
{
getgps(gps);
}
}

}

void getgps(TinyGPS &gps)
{

gps.f_get_position(&latitude, &longitude);
gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);

hour = hour + 8;
if (hour >= 24) {
hour = hour - 24; }
else
{ hour = hour; }

x = 111.2057 * (destinationLat - latitude);
y = 85.2952 * (destinationLon - longitude);
km = sqrt((x * x) + (y * y));
}


``
void CELL_Update( )
{
while( CELL_Serial.available( ) )
{
incomingChar = CELL_Serial.read( );

#ifdef DEBUG_CELL
Serial.print( incomingChar );
#endif
if( nextCellCmnd == Cmnd_SendGPSMessage )
{
if( incomingChar == ‘>’ || cellReplyTimeout )
{
SendGPSMessage( );
cellMsgBuffIndex = 0;
cellMsgBuff[cellMsgBuffIndex] = ‘\0’;

CELL_ResetReplyTimeout( );
nextCellCmnd = Cmnd_None;
nextCellReply = Reply_SendGPSMessage;
}
}

else if( incomingChar == ‘\r’ )
{
if( cellMsgBuffIndex > 0 )
{
ProcessCellReply( );
}

cellMsgBuffIndex = 0;
cellMsgBuff[cellMsgBuffIndex] = ‘\0’;
}
else if( incomingChar > 0x1F && incomingChar < 0x7F )
{
cellMsgBuff[cellMsgBuffIndex] = incomingChar;
if( ++cellMsgBuffIndex >= BUFFSIZE )
cellMsgBuffIndex = 0;
cellMsgBuff[cellMsgBuffIndex] = ‘\0’;
}
}

if( cellReplyTimeout )
{
cellMsgBuffIndex = 0;
cellMsgBuff[cellMsgBuffIndex] = ‘\0’;
CELL_ResetReplyTimeout( );
nextCellCmnd = Cmnd_OK;
nextCellReply = Reply_None;
}
}

void ProcessCellReply( )
{

if( strncmp( cellMsgBuff, “+SIND: 1”, 10 ) == 0)
{
nextCellReply = Reply_Connect;
nextCellCmnd = Cmnd_Connect;
connectRespCnt = 0;
cellConnected = false;
CELL_NetConnectTimeoutTask.enable( );
CELL_NetConnectTimeoutTask.reset( );
return;
}

else if( cellConnected && ( strncmp( cellMsgBuff, “+CMT:”, 5 ) == 0 ) )
{
strncpy( cellPhoneNumber, &cellMsgBuff[7], 12 );
cellPhoneNumber[13] = ‘\0’;
nextCellReply = Reply_MessageText;
nextCellCmnd = Cmnd_None;
return;
}
switch( nextCellReply )
{
case Reply_Connect:
if( strncmp( cellMsgBuff, “+SIND: 4”, 10 ) == 0 )
connectRespCnt += 1;
else if( strncmp( cellMsgBuff, “+SIND: 11”, 10 ) == 0 )
connectRespCnt += 2;

if( connectRespCnt > 2 && !cellConnected )
{
cellConnected = true;
CELL_NetConnectTimeoutTask.disable( );
nextCellCmnd = Cmnd_CallForwarding;
nextCellReply = Reply_None;
}
CELL_NetConnectTimeoutTask.reset( );
break;

case Reply_CallForwarding:
if( ( strncmp( cellMsgBuff, “OK”, 2 ) == 0 ) || ( strncmp( cellMsgBuff, “+CME ERROR”, 10 ) == 0 ) )
{
CELL_ResetReplyTimeout( );
nextCellCmnd = Cmnd_SMS_Type;
nextCellReply = Reply_None;
}
break;

case Reply_SMS_Type:
if( ( strncmp( cellMsgBuff, “OK”, 2 ) == 0 ) || ( strncmp( cellMsgBuff, “+CME ERROR”, 10 ) == 0 ) )
{
CELL_ResetReplyTimeout( );
nextCellCmnd = Cmnd_SMS_Indication;
nextCellReply = Reply_None;
}
break;

case Reply_SMS_Indication:
if( ( strncmp( cellMsgBuff, “OK”, 2 ) == 0 ) || ( strncmp( cellMsgBuff, “+CME ERROR”, 10 ) == 0 ) )
{
CELL_ResetReplyTimeout( );
nextCellCmnd = Cmnd_DeleteMsgs;
nextCellReply = Reply_None;
}
break;

case Reply_Location:
if( ( strncmp( cellMsgBuff, “OK”, 2 ) == 0 ) || ( strncmp( cellMsgBuff, “+CME ERROR”, 10 ) == 0 ) )
{
CELL_ResetReplyTimeout( );
nextCellCmnd = Cmnd_None;
nextCellReply = Reply_None;
}
break;

case Reply_SendGPSMessage:
if( ( strncmp( cellMsgBuff, “OK”, 2 ) == 0 ) || ( strncmp( cellMsgBuff, “+CME ERROR”, 10 ) == 0 ) )
{
CELL_ResetReplyTimeout( );
nextCellCmnd = Cmnd_None;
nextCellReply = Reply_None;
}
break;

case Reply_MessageText:

nextCellCmnd = ( strncmp( cellMsgBuff, “Loc?”, 4 ) == 0 ) ? Cmnd_Location : Cmnd_OK;
nextCellReply = Reply_None;
break;

case Reply_DeleteMsgs:
if( ( strncmp( cellMsgBuff, “OK”, 2 ) == 0 ) || ( strncmp( cellMsgBuff, “+CME ERROR”, 10 ) == 0 ) )
{
CELL_ResetReplyTimeout( );
strcpy( cellPhoneNumber, privCellPhone );
nextCellCmnd = Cmnd_Location;
nextCellReply = Reply_None;
}
break;

case Reply_OK:
CELL_ResetReplyTimeout( );
nextCellCmnd = Cmnd_None;
nextCellReply = Reply_None;
break;

default:
nextCellCmnd = Cmnd_None;
nextCellReply = Reply_None;
break;
}
}

void CELL_Actions( )
{
switch( nextCellCmnd )
{
case Cmnd_Connect:
break;

case Cmnd_CallForwarding:
strcpy( cellCmndBuff, “AT+CCFC=0,3,”" );
strcat( cellCmndBuff, privCellPhone );
strcat( cellCmndBuff, “”,129" );
SendATCommand( cellCmndBuff );
nextCellReply = Reply_CallForwarding;
nextCellCmnd = Cmnd_None;
break;

case Cmnd_SMS_Type:
SendATCommand( “AT+CMGF=1” );
nextCellReply = Reply_SMS_Type;
nextCellCmnd = Cmnd_None;
break;

case Cmnd_SMS_Indication:
SendATCommand( “AT+CNMI=3,3” );
nextCellReply = Reply_SMS_Indication;
nextCellCmnd = Cmnd_None;
break;

case Cmnd_Location:
strcpy( cellCmndBuff, “AT+CMGS=+601"” );
strcat( cellCmndBuff, cellPhoneNumber );
strcat( cellCmndBuff, “”" );
SendATCommand( cellCmndBuff );
nextCellReply = Reply_None;
nextCellCmnd = Cmnd_SendGPSMessage;
break;

case Cmnd_DeleteMsgs:
SendATCommand( “AT+CMGD=1,4” );
nextCellReply = Reply_DeleteMsgs;
nextCellCmnd = Cmnd_None;
break;

case Cmnd_OK:
SendATCommand( “AT” );
nextCellReply = Reply_OK;
nextCellCmnd = Cmnd_None;
break;

default:
break;
}

#ifdef DEBUG_CELL
while( Serial.available( ) )
{
char incoming_char = Serial.read( );

if( incoming_char == ‘~’ )
incoming_char = CR;
else if( incoming_char == ‘^’ )
incoming_char = CTRL_Z;

CELL_Serial.print( incoming_char );
Serial.print( incoming_char );

if( incoming_char == CR || incoming_char == CTRL_Z )
{
Serial.println( );
break;
}
}
#endif
}

void SendATCommand( char *cmnd )
{
delay( 1000 );
CELL_Serial.println( cmnd );

CELL_StartReplyTimeout( );

#ifdef DEBUG_CELL
Serial.print( "\n>> " );
Serial.println( cmnd );
#endif
}

void SendGPSMessage( )
{

delay( 1000 );

CELL_Serial.print( "Lat/Long: " );
CELL_Serial.print( latitude, 5 );
CELL_Serial.print( “,” );
CELL_Serial.print( longitude, 5 );

if (latitude < 17.0350 && latitude > 3.0349 )
{

CELL_Serial.print( " Loc: what ever " );
}
else
{
// Location undefined
CELL_Serial.print( " Loc: Undefined " );
}

CELL_Serial.print( " Date: " );
CELL_Serial.print( month, DEC );
CELL_Serial.print( “/” );
CELL_Serial.print( day, DEC );
CELL_Serial.print( “/” );
CELL_Serial.print(year);
CELL_Serial.print( " Time: " );
CELL_Serial.print( hour, DEC );
CELL_Serial.print( “:” );
CELL_Serial.print( minute, DEC );
CELL_Serial.print( “:” );
CELL_Serial.print( second, DEC );
CELL_Serial.print( " Remain Distance: " );
CELL_Serial.print( km, 2 );
CELL_Serial.print( “km” );

CELL_Serial.print( " Speed(kmph): " );
CELL_Serial.print( gps.f_speed_kmph());

CELL_Serial.print( CTRL_Z, BYTE );

CELL_StartReplyTimeout( );

#ifdef DEBUG_CELL
Serial.println( “Sent location…” );
#endif
}

void CELL_ReplyTimeout( )
{
cellReplyTimeout = true;
CELL_ReplyTimeoutTask.disable( );

#ifdef DEBUG_CELL
Serial.println( “ReplyTimeout” );
#endif
}

void CELL_StartReplyTimeout( )
{

cellReplyTimeout = false;
CELL_ReplyTimeoutTask.enable( );
CELL_ReplyTimeoutTask.reset( );
}

void CELL_ResetReplyTimeout( )
{
cellReplyTimeout = false;
CELL_ReplyTimeoutTask.disable( );
}

void CELL_NetConnectTimeout( )
{
cellNetConnectTimeout = true;
CELL_NetConnectTimeoutTask.disable( );

#ifdef DEBUG_CELL
Serial.println( “NetConnectTimeout” );
#endif
}


This is the code i use… library i use NewSoftserial… because im using SIM5100b … what AT command should i use so i can get continuous reply from it…

NewSoftSerial12.zip (9.73 KB)

what AT command should i use so i can get continuous reply from it..

OK. Now we know what your code looks like, even though it was not properly posted.

Now, we can begin to understand the question. If you phrase it properly. You are using AT commands on the Arduino communicate with the cell modem. You need to explain what you mean by "get continuous reply from it".

Do NOT use the term it anywhere in your response. Use nouns. Explain what "it" is that is supposed to "continuously reply", and what is it be continuously replied, and under what circumstances.