arduino-libraries / ArduinoMqttClient

ArduinoMqttClient Library for Arduino
GNU Lesser General Public License v2.1
187 stars 73 forks source link

MQTT acknowledgement for QoS 1 #23

Closed salvq closed 4 years ago

salvq commented 4 years ago

It is duplication to https://github.com/arduino/ArduinoCloudProviderExamples/issues/10 but I am not sure where is the right point to ask / point the issue to...

Hello,

I have been using https://github.com/VSChina/ESP32_AzureIoT_Arduino for connection for some time and it has one very important feature. Recently I switched over to MKR GSM and started using examples https://github.com/arduino/ArduinoCloudProviderExamples and would like to understand if there are routines for following features part of libraries that are used.

  1. Callback whether the message has been delivered / received to IOT HUB (MS AZURE) ? The main reason is to keep tracking and consistency whether all the messages from arduino has been received to MS azure. If there are, can you point me where it is so i will integrate to my routines.
  2. Device twin callback i.e. firmware update via MS AZURE ? Also, if so can you point me where to find this routines ?

Attaching example from callback from ESP32 routine (acknowledge)

static void SendConfirmationCallback(IOTHUB_CLIENT_CONFIRMATION_RESULT result)
{
  if (result == IOTHUB_CLIENT_CONFIRMATION_OK)
  {
    Serial.println("Send Confirmation Callback finished.");
  }
}

This was an output to serial monitor:

10:18:23.212 -> Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub.

10:18:23.521 -> Info: >>>Confirmation[2] received for message tracking id = 2 with result = IOTHUB_CLIENT_CONFIRMATION_OK

10:18:23.521 -> Send Confirmation Callback finished.

Attaching example from callback from ESP32 routine (devicetwin)

static void DeviceTwinCallback(DEVICE_TWIN_UPDATE_STATE updateState, const unsigned char *payLoad, int size)
{
  char *temp = (char *)malloc(size + 1);
  if (temp == NULL)
  {
    return;
  }
  memcpy(temp, payLoad, size);
  temp[size] = '\0';
  // Display Twin message.
  Serial.println(temp);
  free(temp);
}

Thank you

salvq commented 4 years ago

Hello, I did find out to use QoS set to level 1 or even 2 to ensure delivery.

Is there any notification about confirmation that message has been delivered or re-transmitted and so on ? I would like to start logging this type of data for further analysis.

Thanks

salvq commented 4 years ago

Using QoS1 helps to improve reliability