Wie ichs mir dachte - @michael_x hats ja auch schon angepinnt... Die arbeiten da mit String und ich mit chararray...
Aber gut, bekommt man auch gelöst.
Und dann fallen einem solche Dinger auch noch in die Hände, die schon im Example drin stehen:
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/examples/GSMSim_SMS/GSMSim_SMS.ino: In function 'void setup()':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/examples/GSMSim_SMS/GSMSim_SMS.ino:100:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Serial.println(sms.send("xxxxxxxxxxxx", "Selam kardesim, naber?")); // only use ascii chars please
^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/examples/GSMSim_SMS/GSMSim_SMS.ino:100:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Und in der lib gibts auch einige Schnitzer:
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimFMRadio.cpp: In member function 'bool GSMSimFMRadio::fmSetVolume(uint8_t)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimFMRadio.cpp:178:13: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (volume < 0) {
~~~~~~~^~~
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimGPRS.cpp: In member function 'String GSMSimGPRS::getIP()':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimGPRS.cpp:127:23: warning: statement has no effect [-Wunused-value]
"ERROR:NO_IP_FETCH";
^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimGPRS.cpp:130:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp: In member function 'bool GSMSimSMS::initSMS()':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:48:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
if(setPreferredSMSStorage("ME", "ME", "ME")) {
^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:48:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:48:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:50:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
if(setCharset("IRA")) {
^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp: In member function 'String GSMSimSMS::read(unsigned int)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:259:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < mesaj.length(); i++) {
~~^~~~~~~~~~~~~~~~
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp: In member function 'String GSMSimSMS::read(unsigned int, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:338:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < mesaj.length(); i++) {
~~^~~~~~~~~~~~~~~~
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp: In member function 'String GSMSimHTTP::get(String, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp:193:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp: In member function 'String GSMSimHTTP::getWithSSL(String, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp:375:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp: In member function 'String GSMSimHTTP::post(String, String, String, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp:578:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp: In member function 'String GSMSimHTTP::postWithSSL(String, String, String, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp:793:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
Aber versuchs mal mit dem Code:
#include <GSMSimSMS.h>
// You can use any Serial interface. I recommended HardwareSerial. Please use the library with highiest baudrate.
// In examples, i used HardwareSerial. You can change it anymore.
#define RESET_PIN 10 // you can use any pin.
static volatile int num = 0;
GSMSimSMS sms(Serial1, RESET_PIN); // GSMSimSMS inherit from GSMSim. You can use GSMSim methods with it.
void setup()
{
Serial1.begin(115200); // If you dont change module baudrate, it comes with auto baudrate.
while (!Serial1)
{
; // wait for module for connect.
}
Serial.begin(115200); // Serial for debug...
// Init module...
sms.init(); // use for init module. Use it if you dont have any valid reason.
Serial.print(F("Set Phone Function... "));
Serial.println(sms.setPhoneFunc(1));
delay(1000);
Serial.print(F("is Module Registered to Network?... "));
Serial.println(sms.isRegistered());
delay(1000);
Serial.print(F("Signal Quality... "));
Serial.println(sms.signalQuality());
delay(1000);
Serial.print(F("Operator Name... "));
Serial.println(sms.operatorNameFromSim());
delay(1000);
Serial.print(F("Init SMS... "));
Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.
delay(1000);
Serial.print(F("List Unread SMS... "));
Serial.println(sms.list(true)); // Its optional but highly recommended. Some function work with this function.
delay(1000);
Serial.print(F("SMS to any number... "));
Serial.println(sms.send("+4915251927860", "Selam kardesim, naber?")); // only use ascii chars please
//delay(1000);
// For other methods please look at readme.txt file.
Serial.println(F("Begin to listen incoming messages..."));
}
void loop()
{
// Use your Serial interface...
if (Serial1.available())
{
String buffer = "";
buffer = Serial1.readString();
num = num + 1;
Serial.print(num);
Serial.print(". ");
//Serial.println(buffer);
/**/
// This example for how you catch incoming calls.
if (buffer.indexOf("+CMTI:") != -1)
{
Serial.print(F("SMS Index No... "));
int indexno = sms.indexFromSerial(buffer);
Serial.println(indexno);
Serial.print(F("Who send the message?..."));
Serial.println(sms.getSenderNo(indexno));
Serial.print(F("Read the message... "));
Serial.println(sms.readFromSerial(buffer));
Serial.print(F("Init SMS... "));
Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.
Serial.print(F("SMS to number: "));
String content = sms.getSenderNo(indexno);
Serial.print(content);
Serial.print(' ');
Serial.println(sms.send(content.c_str(), "MeinText")); // only use ascii chars please
}
else
{
Serial.println(buffer);
}
}
// put your main code here, to run repeatedly:
}