vshymanskyy / TinyGSM

A small Arduino library for GSM modules, that just works
GNU Lesser General Public License v3.0
1.91k stars 709 forks source link

Sending continuous AT commands from a code #667

Open reddy9698 opened 1 year ago

reddy9698 commented 1 year ago

I've been trying to connect to AWS using a ESP32 with SIM7000G Firmware : 1351B05SIM7000A

This is the code that I'm using in the void loop part.

` modem.sendAT("+SMCONN"); if (modem.waitResponse(1000L, res) == 1) { res.replace(GSM_NL "OK" GSM_NL, ""); Serial.println(res); Serial.println("connection!!!!"); }

res="";

modem.sendAT("+SMPUB = "BasicPubSub", 425,0,0");

if (modem.waitResponse(10000L, res) == 1) { res.replace(GSM_NL "OK" GSM_NL, ""); Serial.println(res); Serial.println("datssent"); res="";

SerialAT.print(jsonBuffer);

}
modem.sendAT("+SMDISC"); if(modem.waitResponse(1000L,res) == 1) { Serial.println(res); res=""; Serial.println("disconnectedf");

}   

res="";
} `

The expected output at the AWS topic should be just the jsonBuffer,

{"state": {"desired": {"device_id":"device001" } } }

But this is the message that arrives on the topic on AWS

=================================================== `AT+SMCONN AT+SMPUB = "BasicPubSub", 425,0,0 {"state":{"desired": {"device_id":"device001"}}} AT+SMDISC AT+SMCONN

AT+SMPUB = "BasicPubSub", 425,0,0 {"state":{"desired": {"device_id":"device001"}}}

AT+SMDISC

AT+SMCONN

AT+SMPUB = "BasicPubSub", 425,0,0 {"state":{"desired": {"device_id":"device001"}}}

AT+SMDISC

AT+SMCONN

AT+SMPUB = "BasicPubSub", 425,0,0

AT+SMDISC`

The payload just contains all the previous AT commands entered with the actual payload. What is the mistake that I am doing ? What changes should I be making to the code that after AT+SMPUB only the jsonBuffer payload is sent over to SIM7000 to publish to AWS?