Due to poor stabilty with mqtt libs over regular TCP connections i try to examine the use the internal mqqt stack of the SARA modem. This would be a VERY convenient way to do mqtt.
With the serial passtrough sketch and manual commands it works:
AT+UMQTT=0, "3527530xxxxxxx" // Define the client id (Use your IMEI, with characters it fails!)
AT+UMQTT=1, 1883 // Set the port
AT+UMQTT=2, "mqtt.broker.com" // Define the broker server name
AT+UMQTT=4, "username", "password" // Set username and password
AT+UMQTTC=1 // Open connection to the mqtt broker
AT+UMQTTC=2,0,0,"topic", "message: hello world"
So far so good.
Remarks :
- The connection persists over a sketch upload
- Useful commands :
AT+UMQTT? = Print the mqtt configuration
AT+UMQTTER = Print the last mqtt error (Error codes in the u-blox manual)
AT+CGPADDR = Print your own IP adress (To chek if you are online)
Questions:
I tried to rebuild the process with SerialSARA.println("AT commad"); and MODEM.sen("AT command"); but everything reacts very strange. To read the serial response i use for example:
SerialSARA.println("AT+UMQTT=1, 1883");
while (SerialSARA.available()) {
Serial.write(SerialSARA.read());
}
Now some commands go smooth:
09:26:51.742 -> AT+UMQTT=1, 1883
09:26:51.742 -> +UMQTT: 1,1
09:26:51.742 ->
09:26:51.742 -> OK
And the some commands don't even get trough, some have reaction times of over 30 sec etc.
while with manual commands everything goes fast and fine.
ERGO : i'm not able to code a sketch but i can do it with manual commands. Why?
Questions:
- What is wrong with my approach?
- Have someone ever tried this with success?
- Does someone knows of a library for the mqqt stack of the SARA 410
Thx for ideas, help or hints