Giter VIP home page Giter VIP logo

Comments (3)

hirotakaster avatar hirotakaster commented on August 16, 2024

Hi Lahorde,
I recommend you implement re-connect method or connect to the mqtt-server when you need. In my case, when keeping connect mqtt client with server suddenly disconnect or tcp connection is fail. That's reason is not based mqtt client library, I think photon firmware bug or wifi connection problem.
And FYI, as you know mqtt use tcp connection on wifi, keeping the tcp connection is high power consumption in my test on photon. so I recommend you would be better connect to mqtt server when you need only.

from mqtt.

Lahorde avatar Lahorde commented on August 16, 2024

Hi hirotakaster,
As you can see I already reconnect to mqtt when connection drops (loop() code :
https://github.com/OpHaCo/roomba_wifi/blob/master/roomba-control.ino
I lost some packets because of frequents connection drops. But before discovering it I tried to modify qos and saw problem descibed in this issue. No I have no more disconnections and performed some tests checking no packets are lost.

By investigating given issue, I saw :

mqttClient.connect("roomba_photon", NULL,  MQTTQOS2, 0, NULL); 
mqttClient.subscribe(topic, MQTTQOS1);

won't have any effect on qos, in MQTT.h are defined qos levels

#define MQTTQOS0        (0 << 1)
#define MQTTQOS1        (1 << 1)
#define MQTTQOS2        (2 << 1)

If I take connection methods, on underlying implementation, qos must be set at bit pos 3-4 in CONNECT frame buffer byte 10(refer http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html#connect),
In code it is done with :

if (willTopic) {
            v = 0x06|(willQos<<3)|(willRetain<<5);

But if I give MQTTQOS1 as parameter qos position won't be correct as it will be shifted by 1 once again. Maybe you can move MQTTQOSx definitions in source and add another enum/define for QOS to be provided to public MQTT methods.

Issue with

mqttClient.subscribe(topic, MQTTQOS1);

is quite similar, first check done in this method :

    if (qos < 0 || qos > 1)
        return false;

if I give MQTTQOS1 It will never subscribe anything!

I can send you a pull request with modifications if you want.

from mqtt.

hirotakaster avatar hirotakaster commented on August 16, 2024

oh, I see. please send a pull request and contribute your commit.
thank you.

from mqtt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.