HELP! Error after modifying the GSMShield Library

I am trying this code which I found from a tutorial where he used an Arduino UNO Clone. The code below is to turn on or off an LED on pin 7 after an SMS instruction is received.

In my project I want to use an Arduino Mega 2560 so I needed to modify some lines in the GSM Library for GSM Shield based on SIM900 which it got from "http://www.gsmlib.org/"

Unfortunately I ran into these error after compiling the sketch:

C:\Users\alexi\Downloads\arduino-1.6.7\libraries\GSMSHIELD\HWSerial.cpp: In member function 'size_t HWSerial::print(const __FlashStringHelper*)':

C:\Users\alexi\Downloads\arduino-1.6.7\libraries\GSMSHIELD\HWSerial.cpp:55:9: error: 'prog_char' does not name a type

const prog_char *p = (const prog_char *)ifsh;

^

In file included from C:\Users\alexi\Downloads\arduino-1.6.7\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,

from C:\Users\alexi\Downloads\arduino-1.6.7\libraries\GSMSHIELD\HWSerial.h:6,

from C:\Users\alexi\Downloads\arduino-1.6.7\libraries\GSMSHIELD\HWSerial.cpp:1:

C:\Users\alexi\Downloads\arduino-1.6.7\libraries\GSMSHIELD\HWSerial.cpp:58:37: error: 'p' was not declared in this scope

unsigned char c = pgm_read_byte(p++);

^

exit status 1
Error compiling.

Below is the sample sketch:

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
char number[]="ur cellphone number here";
char message[180];
char pos;
char *p;

void setup() //declaring inputs and outputs
{
Serial.begin(9600); //initiate gizduino witha baud rate of 9600
pinMode(13, OUTPUT); //output for turning LED ON or OFF

if (gsm.begin(9600)) //condition if gsm is initialized
Serial.println("\nstatus=READY"); //displays "ready" on the serial monitor if gsm is ready
else Serial.println("\nstatus=IDLE"); //otherwise displays "idle" on the serial monitor if gsm is not found
};

void loop() //looping of the program
{
pos=sms.IsSMSPresent(SMS_UNREAD); //save to variable if there is an SMS
Serial.println((int)pos); //display position number (a.k.a index) of the message
if((int)pos>0&&(int)pos<=20) //if message from 0-20 is found
{
Serial.print("Message Received, INBOX="); //display an output on the serial monitor
Serial.println((int)pos); //display the position/index of the message
message[0]='\0'; //display '0' if no messages found
sms.GetSMS((int)pos,number,message,180); //get position/index, number of sender, and text message
Serial.println(message); //display the text on serial monitor
if(strstr(message, "ON")) digitalWrite(13,HIGH); //if message 'ON' is received, LED is ON
if(strstr(message, "OFF")) digitalWrite(13,LOW); //if message 'OFF' is received, LED is OFF
sms.DeleteSMS((int)pos); //after reading, delete SMS
}
delay(5000); //delay of 5seconds per loop
};

Does not look like your error is in the sketch but in
C:\Users\alexi\Downloads\arduino-1.6.7\libraries\GSMSHIELD\HWSerial.cpp

I'm not familiar enough to pinpoint the issue, but maybe the library is outdated and contains 'stuff' (prog_char in this case) that worked with older compilers.

Where can I find an updated version of this library.

It is the most updated library I found on the site.

Or maybe I am thinking that the updated Arduino IDE does not comply with the Library I'm using?

If there is no newer library, you have to modify it.

Google for arduino ide prog_char

First hit might help: compile error since IDE 1.5.8

update #2:

  • i'm not using the official shield. i am using breakout board for sim900a i bought from online store.
  • so, i need to connect pins from gsm rx/tx to Serial1 on Arduino Mega.
  • i've checked the code. when I de-comment define MEGA in HWSerial.h and GSM.cpp, the program will now using HWSerial as communication for Arduino Mega and GSM SIM900A.
  • when i further check the code in HWSerial.cpp, it use Serial1 to communicate with GSM. So, pin configuration in GSM.cpp it not used.
  • hope this helps.

update #1:

original post:
same problem here. can't find update for HWSerial.cpp. Please help.

Hi, i was able to solve the issue. modify this line;
const prog_char *p = (const prog_char *)ifsh;
to
const char PROGMEM *p = (const char PROGMEM *)ifsh;