I'm trying to write a C++ app, that is able to make some phone calls. For this, I ordered a USB GSM Module, and a SIM Card with a prepaid contract.
I tested the module in PuTTY and everything works as expected. I choose a COM Port and can send/receive messages. See example:
AT
OK
AT+CMEE=2
OK
But when I try sending these commands via my own application, SOME of them fail (e.g. AT+CMEE=2).
AT
OK
AT+CMEE=2
+CMEE ERROR: Syntax Error
Other commands, such as unlocking the SIM Card work fine as well. But e.g "ATD" doesn't work. Here is the code for writing to the serial port. Keep in mind this is just for testing purposes:
DWORD dummy;
// "buffer" is just an std::string
char* string = new char[buffer.length() + 3]; // "+3" because I append '\0' later when printing
strcpy(string, buffer.c_str());
string[buffer.length()] = ' ';
string[buffer.length() + 1] = '\r';
WriteFile(m_hCom,
string,
(buffer.length() + 2) * sizeof(char),
&dummy,
0
);
I tried several variations ('\0' at the end, no space in between, etc) but all of those led to no commands working at all. So this is the solution where at least some commands are working and responding.
Any more ideas what could be wrong here?