Weird error message about char*

Hi everyone! Can someone help me understanding this error message?
It is an Arduino+Sim800L project.

C:\Users\salve\Documents\Arduino\GSMSim_Module_Info\GSMSim_Module_Info.ino: In function 'void setup()':

C:\Users\salve\Documents\Arduino\GSMSim_Module_Info\GSMSim_Module_Info.ino:79:25: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

gsm.call("+39331xxxxxxx");

^

C:\Users\salve\Documents\Arduino\GSMSim_Module_Info\GSMSim_Module_Info.ino:86:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char* Number = "+39331xxxxxxx";

^~~~~~~~~~~~~~~

C:\Users\salve\Documents\Arduino\GSMSim_Module_Info\GSMSim_Module_Info.ino:87:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char* Message = "Message from Skynet";

^~~~~~~~~~~~~~~~~~~~~

Here is the code

#include <GSMSim.h>
#include <SoftwareSerial.h>

#define RX 7
#define TX 8
#define BAUD 9600

SoftwareSerial mySerial(7, 8);


GSMSim gsm(RX, TX);


void setup() {
  // put your setup code here, to run once:
  
  Serial.begin(9600);

  while(!Serial){}

  Serial.println("GSMSim Library - Module Information");
  Serial.println("");
  delay(1000);

  gsm.start();
  

  Serial.print("Manufacturer:\t\t");
  Serial.println(gsm.moduleManufacturer());
  delay(250);
  Serial.print("Model:\t\t\t");
  Serial.println(gsm.moduleModel());
  delay(250);
  Serial.print("Revision:\t\t");
  Serial.println(gsm.moduleRevision());
  delay(250);
  Serial.print("IMEI:\t\t\t");
  Serial.println(gsm.moduleIMEI());
  delay(250);
  Serial.print("IMSI:\t\t\t");
  Serial.println(gsm.moduleIMSI());
  delay(250);
  Serial.print("ICCID:\t\t\t");
  Serial.println(gsm.moduleICCID());
  delay(250);
  Serial.print("Is Connected?:\t\t");
  Serial.println(gsm.isRegistered());
  delay(250);
  Serial.print("Signal Quality:\t\t");
  Serial.println(gsm.signalQuality());
  delay(250);
  Serial.print("Operator:\t\t");
  Serial.println(gsm.operatorName());
  delay(250);
  Serial.print("Operator From Sim:\t");
  Serial.println(gsm.operatorNameFromSim());
  delay(250);


gsm.call("+393312646708");
delay(15000);
gsm.callHangoff();


gsm.start();
gsm.smsTextMode(true);
char* Number = "+39331xxxxxxx";
char* Message = "Message from Skynet";
gsm.smsSend(Number, Message);
  Serial.print("Message sent");

  
}

void loop() {
  // put your main code here, to run repeatedly:

}

Everything's working: the call is made, but the sms text is not sent.

Thank you!

Try instead
char Message[]= "Message from Skynet";

Ok, thanks, no error message with

char Number[] = "+39331xxxxxxx";
char Message[] = "Message from Skynet";

but the message is not sent.

So probably the problem is in

gsm.smsSend(Number, Message);

Any advice?

Does the gsm.send() function return a value that might indicate the status of the send or why it failed? If not, is there some kind of gsm.getStatus() function that might provide useful hints?

What happens when you run the library example for GSMSim_SMS?

cattledog:
What happens when you run the library example for GSMSim_SMS?

Thank you!

Running GSMSim_SMS this error is shown when compiling

cattledog:
What happens when you run the library example for GSMSim_SMS?

Thank you!

With GSMSim_SMS when compiling, this error is showing

C:\Users\salve\Documents\Arduino\GSMSim_SMS\GSMSim_SMS.ino: In function 'void setup()':

C:\Users\salve\Documents\Arduino\GSMSim_SMS\GSMSim_SMS.ino:32:18: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char* number = "+905123456789";

^~~~~~~~~~~~~~~

C:\Users\salve\Documents\Arduino\GSMSim_SMS\GSMSim_SMS.ino:33:19: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

char* message = "Hi my friend. How are you?"; // message lenght must be <= 160. Only english characters.

^~~~~~~~~~~~~~~~~~~~~~~~~~~~

C:\Users\salve\Documents\Arduino\libraries\GSMSim\GSMSim.cpp: In member function 'bool GSMSim::fmOpen(bool, uint8_t)':

C:\Users\salve\Documents\Arduino\libraries\GSMSim\GSMSim.cpp:1032:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]

uint8_t frekans = 875;

^~~

C:\Users\salve\Documents\Arduino\libraries\GSMSim\GSMSim.cpp:1034:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]

frekans = 875;

^~~

C:\Users\salve\Documents\Arduino\libraries\GSMSim\GSMSim.cpp:1037:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]

frekans = 1080;

^~~~

C:\Users\salve\Documents\Arduino\libraries\GSMSim\GSMSim.cpp: In member function 'bool GSMSim::fmSetFreq(uint8_t)':

C:\Users\salve\Documents\Arduino\libraries\GSMSim\GSMSim.cpp:1101:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]

uint8_t frekans = 875;

^~~

C:\Users\salve\Documents\Arduino\libraries\GSMSim\GSMSim.cpp:1103:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]

frekans = 875;

^~~

C:\Users\salve\Documents\Arduino\libraries\GSMSim\GSMSim.cpp:1106:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]

frekans = 1080;

^~~~

But the sketch is compiled.

But the sketch is compiled.

Because the error messages don't contain the word "error"?

TheMemberFormerlyKnownAsAWOL:
Because the error messages don't contain the word "error"?

Ok, I understand... so what's the problem? I mean, why is that message shown? It talks about ISO C++... So, if it's not a problem, why is it shown? And why the sms text is not sent?

What do your debug prints show?

johnwasser:
Does the gsm.send() function return a value that might indicate the status of the send or why it failed? If not, is there some kind of gsm.getStatus() function that might provide useful hints?

Thank you!

I really don't know...
The sms text is not sent, but the call works...
I mean, the sketch is compiled and it runs, even if there is that error... the call is dialed... I don't know what's the matter...

Anyway, using AT commands everything works... so there is some problem with GSMSim library... but I cannot understand which it is...

I mean, why is that message shown?

It's the same warning from before. Make the same correction as you did before with the char* changed to char[]

Thank you guys...
I don't know why but verything it's now working, both with char* and char []...
But with char [] the red message about ISO C++ etc. is not shown when compiling.
Probably a case of "turn it off and on again"... :o

salventre:
Thank you guys...
I don't know why but verything it's now working, both with char* and char []...
But with char [] the red message about ISO C++ etc. is not shown when compiling.
Probably a case of "turn it off and on again"... :o

If you copy and paste the error/warning message (excluded the file path and file line number) to your favorite search engine, you will most definitely find your answers.

Anyway, using AT commands everything works... so there is some problem with GSMSim library... but I cannot understand which it is...

Please post the AT commands which successfully sent the message. It should be straightforward to determine the difference to the library function

bool GSMSim::smsSend(char* number, char* message) {
	this->print(F("AT+CMGS=\""));  // command to send sms
	this->print(number);
	this->print(F("\"\r"));
	_buffer = _readSerial();
	this->print(message);
	this->print("\r");
	//change delay 100 to readserial
	_buffer += _readSerial();
	this->print((char)26);

	_buffer += _readSerial();
	//expect CMGS:xxx   , where xxx is a number,for the sending sms.
	/*
	return _buffer;
	*/
	if (((_buffer.indexOf("AT+CMGS")) != -1)) {
		return true;
	}
	else {
		return false;
	}
}

cattledog:
Please post the AT commands which successfully sent the message. It should be straightforward to determine the difference to the library function

Here it is

 mySerial.println("AT+CMGF=1");    
  delay(1000);  
  mySerial.println("AT+CMGS=\"+39331xxxxxxx\"\r"); 
  delay(1000);
  mySerial.println("This is a message from Skynet");// 
  delay(100);
  mySerial.println((char)26);
  delay(1000);

So, you wrote what is inside the library... so interesting... But I'm not keen at C++, so I don't know if I can understand the process...

mySerial.println("AT+CMGF=1") The library equivalent has a trailing "

mySerial.println("AT+CMGF=1");

This is the command which sets text mode. In your sketch, there is a library command which is supposed to do the same thing.

bool GSMSim::smsTextMode(bool textModeON) {
	if (textModeON == true) {
		this->print(F("AT+CMGF=1\r"));
	}

I have seen different syntax for this command, both with and without the \r terminator. It can depend on the specific manufacturer and model of the 800L. Maybe whether or not is is a clone or an actual SimCom module?

There may also be some small differences in the actual sending commands as the library pieces together the different bits of the AT+ CMGS command and I'm not entirely certain of the exact end result with all the escapes and quotation marks.

If you want to sort out the library issue, and whether or not it is the text mode command or and actual send command you can try to add the text mode line instead of the library line and see if the message is sent. If it doesn't go, then the issue is with the sms.send() and how is pieces together the multiple elements.

gsm.start();
//gsm.smsTextMode(true);
mySerial.println("AT+CMGF=1"); 
char* Number = "+39331xxxxxxx";
char* Message = "Message from Skynet";
gsm.smsSend(Number, Message);
  Serial.print("Message sent");

If you choose to drop this enquiry and just proceed with the AT commands which are known to work it would be a very reasonable approach.

Ok, I've checked again.
I should try the original examples of GSMSim library.
The errors are generated from the lines that I added to GSMSim_Module_Info.ino (I added the sms part to the original file); I should have used the original GSMSim_SMS.ino to send SMS and GSMSim_Call to make calls.
I'll try ASAP when I'm home.
Anyway, all this is so interesting... Thank you guys...