adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
566 stars 292 forks source link

Fix packet identifier #199

Closed fipwmaqzufheoxq92ebc closed 2 years ago

fipwmaqzufheoxq92ebc commented 2 years ago

The MQTT specification requires (Ref: MQTT-2.3.1-1) that

[...] Control Packets MUST contain a non-zero 16-bit Packet Identifier The current implementation uses a counter "packet_id_counter", which is set in the constructor to zero. That causes the first SUBSCRIBE, PUBLISH or UNSUBSCRIBE to cause a disconnect by the broker because of protocol violation. The packet_id_counter is not reset on reconnect, so after a reconnect everything works normally. This PR fixes the behavior to:

  • start by packet id "1"
  • in case of an overflow (i.e. packet id > 65535) to restart at 1
fipwmaqzufheoxq92ebc commented 2 years ago

Oops, there is already a PR open for that. Sorry

brentru commented 2 years ago

@fipwmaqzufheoxq92ebc Which PR addresses this? Thanks

fipwmaqzufheoxq92ebc commented 2 years ago

@brentru #190