44 |
return str; |
return str; |
45 |
} |
} |
46 |
|
|
47 |
|
|
48 |
string GsmModem::Command(string command, string term) |
string GsmModem::Command(string command, string term) |
49 |
{ |
{ |
50 |
time_t start,now; |
time_t start,now; |
51 |
start = time(0); |
start = time(0); |
52 |
|
|
53 |
command.append("\r"); |
if (term != "> ") |
54 |
|
command.append("\r"); //Dont append CarriageReturn if sending SMS |
55 |
|
|
56 |
m_port.Write(command); |
m_port.Write(command); |
57 |
|
|
58 |
Util::Sleep(25); |
Util::Sleep(1); |
59 |
string response = GetResponse(); |
string response = GetResponse(); |
60 |
|
|
|
|
|
61 |
unsigned int tlen = term.length(); |
unsigned int tlen = term.length(); |
62 |
while ( 1 ) |
while ( 1 ) |
63 |
{ |
{ |
68 |
} |
} |
69 |
|
|
70 |
response += GetResponse(); |
response += GetResponse(); |
71 |
Util::Sleep(25); |
Util::Sleep(1); |
72 |
|
|
73 |
now = time(0); |
now = time(0); |
74 |
if ( (now-start) > 10 ) |
if ( (now-start) > 10 ) |
76 |
Common::instance()->logMessage( string("GsmModem::Command time out --") + command); |
Common::instance()->logMessage( string("GsmModem::Command time out --") + command); |
77 |
break; |
break; |
78 |
} |
} |
|
|
|
|
|
|
79 |
} |
} |
80 |
|
|
81 |
Util::Sleep(5); |
Util::Sleep(5); |
132 |
|
|
133 |
Command(line1,"> "); |
Command(line1,"> "); |
134 |
|
|
135 |
|
if (message.length() > 160) |
136 |
|
{ |
137 |
|
message = message.substr(0,160); |
138 |
|
Common::instance()->logMessage( "Trunkating message! "); |
139 |
|
} |
140 |
|
|
141 |
|
message.append("\032"); // \032 == Ctrl+Z |
142 |
|
|
143 |
|
Command( message ); //In textmode limit to 160 bytes |
144 |
|
|
|
message.append("\032\r"); // \032 == Ctrl+Z |
|
145 |
|
|
|
Command(message); |
|
146 |
Util::Sleep(50); //Give the modem some time to send the sms and be ready again |
Util::Sleep(50); //Give the modem some time to send the sms and be ready again |
147 |
|
Common::instance()->smsCounter.outgoing++; |
148 |
} |
} |
149 |
|
|
150 |
void GsmModem::DeleteSms(std::string smsIndex) |
void GsmModem::DeleteSms(std::string smsIndex) |