Skip to content

Commit

Permalink
Merge pull request #294 from embhorn/zd14059
Browse files Browse the repository at this point in the history
Fix SN disconnect with sleep should not use CB
  • Loading branch information
dgarske authored Dec 30, 2022
2 parents dce4697 + 6332b03 commit 2501a7e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3094,12 +3094,19 @@ static int SN_Client_HandlePacket(MqttClient* client, SN_MsgType packet_type,
}
case SN_MSG_TYPE_DISCONNECT:
{
SN_Disconnect disc_s, *disc = &disc_s;
if (packet_obj) {
disc = (SN_Disconnect*)packet_obj;
}
else {
XMEMSET(disc, 0, sizeof(SN_Disconnect));
}
/* Decode Disconnect */
rc = SN_Decode_Disconnect(client->rx_buf, client->packet.buf_len);

#ifdef WOLFMQTT_DISCONNECT_CB
/* Call disconnect callback to allow handling broker disconnect */
if (client->disconnect_cb) {
if ((client->disconnect_cb != NULL) && (disc->sleepTmr == 0)) {
client->disconnect_cb(client, rc, client->disconnect_ctx);
}
#endif
Expand Down

0 comments on commit 2501a7e

Please sign in to comment.