SIM800MQTT icon indicating copy to clipboard operation
SIM800MQTT copied to clipboard

is there a way to set QOS?

Open illidan1372 opened this issue 4 years ago • 2 comments

hi there! first off , thanks for publishing this amazing library!

I remember that I was using this library , months ago, using a STM32 nucleo + sim800l. I used hivemqtt's free broker to test everything. The library used to work OK. Now however I have noticed that sometimes I get the message that I publish and sometimes I don't(i am using a never-ending loop to keep sending the same message over and over again). Sometimes I get the messages for a short time then don't get them anymore. I think it has to do with the fact that hivemqtt's free version is not stable and I get disconnected soon after connecting but the library does not detect that, my sim800l keeps blinking fast and does not get reset by the library which means that it is still sending the message but the broker doesn't receive it.

Now in the code there is a part where if the connect function returns no errors then it sets the "connected" variable to 1 and then never checks if the connection is still ok ever again. I think the recent version subscribes to the same topic it publishes to and checks if the messages it's sending is being received. But why not just use a higher QOS instead of using extra traffic to check every message you publish? or am I misunderstanding how your code works? thank you very much in advance!

illidan1372 avatar Sep 28 '21 09:09 illidan1372

On the SIM800 side you actually have both publisher and subscriber. If you use QOS the broker will receive the message and for example the connection will be broken at this moment and he will not be able to send it back, he will just try to resend it to infinity, but the device (SIM800) will not know about it. In my implementation (https://github.com/leech001/SIM800MQTT/tree/MQTTCheck) if we do not get an echo reply to our packet we consider the connection lost and restore it again.

leech001 avatar Oct 02 '21 10:10 leech001

Thanks. So i read about how QOS works under the hood, turns out it does some kind of a "handshake" every time the client sends a message to the broker. I think your example program does the same thing? also it seems like in your library, there is an error for different situations?(like disconnected, error etc?)

illidan1372 avatar Oct 08 '21 20:10 illidan1372