peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
550 stars 117 forks source link

Broken compatibility to ESP32_Lobo #13

Closed kevinkk525 closed 5 years ago

kevinkk525 commented 5 years ago

In line 469 the network status is compared to "network.STAT_CONNECTING" but Loboris fork doesn't have this implemented, just like the pyboard.

peterhinch commented 5 years ago

Could you please check whether the Loboris port simply lacks the STAT_CONNECTING constant? The Pyboard returns values of 1 or 2 while connecting. Perhaps you could verify if the same check works for the Loboris fork?

The Loboris port seems dead but we might as well support it for a while.

FYI Regarding the Pyboard D this issue is pending review by Damien: the Pyboard D emits these two values with distinct meanings and he was undecided whether to lump them together as STAT_CONNECTING: this would maximise compatibility but lose information. This is one of the reasons that Pyboard D support is still provisional. The other reason is that I have identified circumstances where the Pyboard D fails to connect at all https://github.com/micropython/micropython/issues/4681.

kevinkk525 commented 5 years ago

Lobo port is lacking that constant. Lobo port is dead but people still use it and all other checks are implemented so it's probably good to keep the compatibility. Thanks for the insight about the Pyboard D progress. Looking forward to getting full support for it. Thanks for your testing.

peterhinch commented 5 years ago

I've pushed an update which also includes some minor changes to Pyboard D setup. There is also a small change to config.py and the test programs. Please could you verify that the Lobo change works. Thank you.

kevinkk525 commented 5 years ago

Thanks for the update. Sadly this doesn't work because sta_if.status() always returns None. Therefore polling sta_if.isconnected() needs to be used as a workaround, maybe with a timeout?

elif LOBO:
                i = 0
                while not s.isconnected():
                    await asyncio.sleep(1)
                    i+= 1
                    if i >= 10:
                        break

With that change the initial connection and reconnects work.

Also config.py line 17 should look like this: if platform == 'esp8266' or platform == 'esp32' or platform == 'esp32_LoBo':

peterhinch commented 5 years ago

Now pushed. Thank you for your help with this.

kevinkk525 commented 5 years ago

Thanks for the update. This should be fixed now.