256dpi / lwmqtt

a light weight MQTT implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UIPEthernet support

SomeshDaga opened this issue · comments

Hi,

I am attempting to use an Arduino Due with an ENC28J60 shield, to connect to an MQTT broker using the EthernetClient provided by the UIPEthernet library. I am having partial success, in that the client momentarily connects to the broker and then immediately disconnects. Based on some debugging, it's due to the decoding of the Connack packet failing (the error code was -8 i.e. LWMQTT_REMAINING_LENGTH_MISMATCH).

Commenting out the decoding of the packet in the lwmqtt code results in the client remaining connected. However, I am facing decoding errors with all other types of packets as well (e.g. subscribe). Commenting out the packet decoding for the subscribe function does allow it to subscribe to the messages sent on topics successfully. However, these are band-aid fixes just to get things working. Would appreciate any input on how I could get this working without commenting out the lwmqtt code.

It sounds like either the ethernet chip or the broker is corrupting the packets you're receiving. Without further details on the broker or the code you're using it's hard to give advice. One thing did you use lwmqtt directly or the arduino-mqtt library?

@256dpi I used it through the arduino-mqtt library, which I had been successfully using up to now with an arduino mega. I do not believe the issue is with the broker (shiftr.io), as I continue to use the same one I was using with the mega (and it also works fine on the Due + ENC28J60 shield with the PubSub client). The ethernet shields are quite different, so that's probably the source of the issue.

Is it possible that the modem is not properly set in a TCP pass through mode and somehow answers with AT commands or something similar?

Since this issue is most likely related to UIPEthernet not working correctly, I'm closing this issue for now. If you still encounter issues please open an issue at the arduino-mqtt repo since lwmqtt is just a low level library.