@@ -151,14 +151,16 @@ namespace GSM
151
151
std::string send (const std::string &message, const std::string &answerKey, uint64_t timeout)
152
152
{
153
153
#ifdef ESP_PLATFORM
154
+ String temp = gsm.readString ();
155
+ data += temp.c_str ();
154
156
gsm.println ((message + " \r " ).c_str ());
155
157
156
158
std::cout << " [GSM] Sending request: " << message << " , " << answerKey << std::endl;
157
159
158
160
uint64_t lastChar = millis ();
159
161
std::string answer = " " ;
160
162
161
- while (lastChar + timeout > millis ()) // save none related messages to data.
163
+ /* while (lastChar + timeout > millis()) // save none related messages to data.
162
164
{
163
165
if (gsm.available())
164
166
{
@@ -172,7 +174,7 @@ namespace GSM
172
174
break;
173
175
}
174
176
}
175
- }
177
+ }*/
176
178
177
179
while (lastChar + timeout > millis () && (answer.find (" OK\r\n " ) == std::string::npos && answer.find (" ERROR\r\n " ) == std::string::npos))
178
180
{
@@ -192,6 +194,8 @@ namespace GSM
192
194
std::cout << "[GSM] Response: " << answer << std::endl;
193
195
}*/
194
196
197
+ delay (50 );
198
+
195
199
return answer;
196
200
#endif
197
201
@@ -793,9 +797,9 @@ namespace GSM
793
797
{
794
798
send (" AT+CMGF=0" , " AT+CMGF=0" , 100 );
795
799
796
- std::string input = send (" AT+CMGL=0" , " AT+ CMGL" , 5000 ); // read all messages
800
+ std::string input = send (" AT+CMGL=0" , " CMGL" , 5000 ); // read all messages
797
801
798
- std::cout << input << std::endl;
802
+ std::cout << " AT+CMGL=0 -----------------------------------------: " << input << std::endl;
799
803
800
804
std::vector<std::string> pdus;
801
805
@@ -891,6 +895,12 @@ namespace GSM
891
895
catch (const std::out_of_range& e) {
892
896
std::cerr << " Erreur : " << e.what () << std::endl;
893
897
}
898
+
899
+ if (pdu.length () > 0 )
900
+ {
901
+ if (ExternalEvents::onNewMessage)
902
+ ExternalEvents::onNewMessage ();
903
+ }
894
904
}
895
905
896
906
send (" AT+CMGD=1,1" , " AT+CMGD" , 1000 );
@@ -1232,7 +1242,12 @@ namespace GSM
1232
1242
1233
1243
// PaxOS_Delay(50000);
1234
1244
1235
- requests.push_back ({[](){ send (" AT+CNTP=\" time.google.com\" ,8" , " AT+CNTP" ); send (" AT+CNTP" ," AT+CNTP" , 1000 ); }, priority::high});
1245
+ requests.push_back ({[]()
1246
+ {
1247
+ send (" AT+CNTP=\" time.google.com\" ,4" , " AT+CNTP" ); // the number 4 is the time zone*4, so each 1 is 1 quarter hour (weird)
1248
+ send (" AT+CNTP" ," AT+CNTP" , 2000 );
1249
+ send (" AT+CNMI=2,1,0,0,0" , " AT+CNMI" );
1250
+ }, priority::high});
1236
1251
1237
1252
updateHour ();
1238
1253
getNetworkQuality ();
0 commit comments