The word "OK" is display each time SMS is receive using GSM shield problem!!!


hi everyone,
i'm using gsm shield receive sms stored in array code working word ok display each time i'm receiving sms, can please me how solve this.
please refer attachment error i'm encountering.
thanks lot


code: [select]


/*
 sms receiver

 this sketch, arduino gsm shield, waits sms message
 and displays through serial port.

 circuit:
 * gsm shield attached , arduino
 * sim card can receive sms messages

 created 25 feb 2012
 by javier zorzano / td

 this example in public domain.

 http://arduino.cc/en/tutorial/gsmexamplesreceivesms

*/

// include gsm library
#include <gsm.h>

// pin number sim
#define pinnumber ""

// initialize library instances
gsm gsmaccess;
gsm_sms sms;

// array hold number sms retreived from
char sendernumber[20];
char newmessage[160];
bool newmessageavailable = false;


void setup()
{
  pinmode(5, output);
  // initialize serial communications , wait port open:
  serial.begin(9600);
  while (!serial) {
    ; // wait serial port connect. needed leonardo only
  }

  serial.println("sms messages receiver");

  // connection state
  boolean notconnected = true;

  // start gsm connection
  while (notconnected)
  {
    if (gsmaccess.begin(pinnumber) == gsm_ready)
      notconnected = false;
    else
    {
      serial.println("not connected");
      delay(1000);
    }
  }

  serial.println("gsm initialized");
  serial.println("waiting messages");
}

void loop()
{
  char c;
  byte smsindex = 0;

  // if there smss available()
  if (sms.available())

  {
   
    serial.println("message received from:");

    // remote number
    sms.remotenumber(sendernumber, 20);
    serial.println(sendernumber);

    // example of message disposal
    // messages starting # should discarded
    if (sms.peek() == '#')
    {
      serial.println("discarded sms");
      sms.flush();
    }

    // read message bytes , print them
    while (c = sms.read())
    {
      serial.print(c);
      newmessage[smsindex++] = c;
      newmessage[smsindex] = '\0'; // keep string null terminated
      newmessageavailable = true;
       } // use curly braces while statements!
       
      serial.println("\nmessage store in array");
      serial.print(newmessage);
      serial.println("\nend of message");

    // delete message modem memory
    sms.flush();
    serial.println("message deleted");
  }
   
     
 
  delay(1000);
 
}


quote
but word ok display each time i'm receiving sms, can please me how solve this.
every time send @ command, response if generated. since process asynchronous, must manage connect response command.

typically, done misusing asynchronous nature of communications, waiting response, doing nothing else until complete response received.

i don't see getting ok response problem solved. of course, if is, unplug device. no ok responses anymore.


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > The word "OK" is display each time SMS is receive using GSM shield problem!!!


arduino

Comments