This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to fix MQTT PUBACK EVENT not present ?

Hi, I have been modifying the MQTT Publish example for a product and found that the PUBACK message does not produce an event. The problem is in components/iot/mqtt/mqtt_transport.c. There is no handler for this event, it just falls into the default: which does nothing. I have added this code that does produce the event, in the routine mqtt_handle_rx_data(). If you need other MQTT events this is where and how to add them.

   // Add code to handle an MQTT PUBACK message

case MQTT_PKT_TYPE_PUBACK:
    {
	MQTT_TRC("[MQTT]: Received PUBACK\r\n");
	// Set event
	evt.id        = MQTT_EVT_PUBLISH_ACK;
	evt.result    = NRF_SUCCESS;
	evt_cb        = p_client->evt_cb;
	err_code    = NRF_SUCCESS;
}
break;
Related