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
The MQTT specification requires (Ref: MQTT-2.3.1-1) that