@@ -124,8 +124,18 @@ void LiveObjectsCellular::connectNetwork()
124124 if (m_Protocol != SMS) while ((m_GPRSAcces.attachGPRS (SECRET_APN.c_str (), SECRET_APN_USER.c_str (), SECRET_APN_PASS.c_str ()) != GPRS_READY)) outputDebug (TXT, " ." );
125125 outputDebug ();
126126 #endif
127+ if (m_Encoding==BINARY) MODEM.send (" AT+CMGF=0" );
128+ delay (200 );
127129 outputDebug (INFO," You're connected to the network" );
128130 }
131+ else
132+ {
133+ if (m_Protocol==MQTT) while ((m_GPRSAcces.attachGPRS (SECRET_APN.c_str (), SECRET_APN_USER.c_str (), SECRET_APN_PASS.c_str ()) != GPRS_READY)) outputDebug (TXT, " ." );
134+ delay (100 );// outputDebug(INFO, "Sending atcmgf");
135+ if (m_Encoding==BINARY) MODEM.send (" AT+CMGF=0" );
136+ else MODEM.send (" AT+CMGF=1" );
137+ delay (200 );
138+ }
129139 if (m_nPort==8883 ){
130140 if (!m_bCertLoaded) {
131141 outputDebug (INFO," Loading DigiCert Root CA certificate" );
@@ -143,9 +153,6 @@ void LiveObjectsCellular::connectNetwork()
143153 }
144154 }
145155 }
146- if (m_Encoding==BINARY) MODEM.send (" AT+CMGF=0" );
147- else MODEM.send (" AT+CMGF=1" );
148- delay (200 );
149156}
150157
151158
@@ -265,6 +272,7 @@ void LiveObjectsCellular::sendData()
265272 if (m_Sms.beginSMS (SECRET_SERVER_MSISDN.c_str ())!=1 ) outputDebug (ERR," Error occured while sending SMS" );
266273 m_Sms.print (m_sPayload);
267274 if (m_Sms.endSMS ()!=1 ) outputDebug (ERR," Error occured while sending SMS" );
275+ outputDebug (INFO, " Nie tutaj" );
268276 }
269277 else
270278 {
@@ -279,7 +287,7 @@ void LiveObjectsCellular::sendData()
279287 msg+=to7bit (m_sPayload);
280288 int msgSize = (msg.length ()-2 )/2 ;
281289 msg+=' \x1A ' ;
282- outputDebug (INFO," MEssage len: " ,msgSize);
290+ outputDebug (INFO," Message len: " ,msgSize);
283291 outputDebug (INFO," Publishing message: " , msg);
284292 MODEM.sendf (" AT+CMGS=%d\r " , msgSize);
285293 delay (100 );
0 commit comments