Mege OTA and greengrass demo together

embeddedx wrote on September 20, 2019:

Hello,

I’m trying to have OTA through greengrass core.
I have the greengrass demo works on a greengrass core setup on EC2 instance.
I have the OTA demo works OK.
I managed to merge both demos and as follows:
The greengrass seraches for a core, if it was found, the OTA task is created.
I thing the shadow and jobs urls used in the OTA demo have to be updated, but not sure.
This is a screenshot from the ESP32 logs
[https://imge.to/i/vIUUl6]
Edit:
The publish error is : IOT_MQTT_NETWORK_ERROR

Edited by: embeddedx on Sep 20, 2019 3:41 AM

embeddedx wrote on September 20, 2019:

Thanks for your reply
I get MQTT v2 client connection from mqttAgent after get the greengrass endpoint and credentials, and use it in the OTA task.

  • I’m using EC2 instance as greengrass, do I need to add any configurations for the OTA?
  • How to create the job? from the console like default OTA demo?

In the code belo, I use the AWS IOT End point for the greengrass to connect, if I use the autoget



/*
 * Amazon FreeRTOS V201906.00 Major
 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * http://aws.amazon.com/freertos
 * http://www.FreeRTOS.org
 */

/**
 * @file aws_greengrass_discovery_demo.c
 * @brief A simple Greengrass discovery example.
 *
 * A simple example that perform discovery of the greengrass core device.
 * The JSON file is retrieved.
 */


/* Standard includes. */
#include "iot_config.h"

/* MQTT include. */
#include "iot_mqtt.h"
#include "iot_mqtt_agent.h"

/* Demo includes. */
#include "aws_demo_config.h"


/* Standard includes. */
#include <stdio.h>
#include <string.h>

/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "platform/iot_network.h"

/* Greengrass includes. */
#include "aws_ggd_config.h"
#include "aws_ggd_config_defaults.h"
#include "aws_greengrass_discovery.h"

/* Demo network handling */
#include "aws_iot_demo_network.h"

/* Required to get the broker address and port. */
#include "aws_clientcredential.h"

/* Amazon FreeRTOS OTA agent includes. */
#include "aws_iot_ota_agent.h"

#include "iot_network_manager_private.h"

/* Required for demo task stack and priority */
#include "aws_demo_config.h"
#include "aws_application_version.h"

#define otaDemoCONN_TIMEOUT_MS            ( 2000UL )

#define otaDemoCONN_RETRY_INTERVAL_MS     ( 5000 )

#define otaDemoCONN_RETRY_LIMIT           ( 100 )

#define otaDemoKEEPALIVE_SECONDS          ( 1200 )

#define myappONE_SECOND_DELAY_IN_TICKS    pdMS_TO_TICKS( 10000UL )

#define otaDemoNETWORK_TYPES              ( AWSIOT_NETWORK_TYPE_ALL )


#define ggdDEMO_MAX_MQTT_MESSAGES      3
#define ggdDEMO_MAX_MQTT_MSG_SIZE      500
#define ggdDEMO_DISCOVERY_FILE_SIZE    2500
#define ggdDEMO_MQTT_MSG_TOPIC         "freertos/demos/ggd"
#define ggdDEMO_MQTT_MSG_DISCOVERY     "{\"message\":\"Hello #%lu from Amazon FreeRTOS to Greengrass Core.\"}"

/**
 * @brief Contains the user data for callback processing.
 */
typedef struct
{
    const char * pcExpectedString;      /**< Informs the MQTT callback of the next expected string. */
    BaseType_t xCallbackStatus;         /**< Used to communicate the success or failure of the callback function.
                                         * xCallbackStatus is set to pdFALSE before the callback is executed, and is
                                         * set to pdPASS inside the callback only if the callback receives the expected
                                         * data. */
    SemaphoreHandle_t xWakeUpSemaphore; /**< Handle of semaphore to wake up the task. */
    char * pcTopic;                     /**< Topic to subscribe and publish to. */
} GGDUserData_t;

/* The maximum time to wait for an MQTT operation to complete.  Needs to be
 * long enough for the TLS negotiation to complete. */
static const TickType_t xMaxCommandTime = pdMS_TO_TICKS( 20000UL );
static const TickType_t xTimeBetweenPublish = pdMS_TO_TICKS( 1200UL );
static char pcJSONFile[ ggdDEMO_DISCOVERY_FILE_SIZE ];

/*
 * The MQTT client used for all the publish and subscribes.
 */
static MQTTAgentHandle_t xMQTTClientHandle;
static BaseType_t prvMQTTConnect( GGD_HostAddressData_t * pxHostAddressData );
static void prvSendMessageToGGC( GGD_HostAddressData_t * pxHostAddressData );
static void prvDiscoverGreenGrassCore( void * pvParameters );
static IotNetworkError_t prvNetworkDisconnectCallback( void * pvContext );
/*-----------------------------------------------------------*/
static MqttConnectionContext_t xConnection =
{
    .pvNetworkConnection = NULL,
    .ulNetworkType       = AWSIOT_NETWORK_TYPE_NONE,
    .xNetworkInfo        = IOT_MQTT_NETWORK_INFO_INITIALIZER,
    .xMqttConnection     = IOT_MQTT_CONNECTION_INITIALIZER,
    .xDisconnectCallback = prvNetworkDisconnectCallback
};


static void App_OTACompleteCallback( OTA_JobEvent_t eEvent );
static void App_OTACompleteCallback( OTA_JobEvent_t eEvent )
{
    OTA_Err_t xErr = kOTA_Err_Uninitialized;


    /* OTA job is completed. so delete the MQTT and network connection. */
    if( eEvent == eOTA_JobEvent_Activate )
    {
        configPRINTF( ( "Received eOTA_JobEvent_Activate callback from OTA Agent.\r
" ) );
        IotMqtt_Disconnect( xConnection.xMqttConnection, 0 );
        #if defined( CONFIG_OTA_UPDATE_DEMO_ENABLED )
            vMqttDemoDeleteNetworkConnection( &xConnection );
        #endif
        OTA_ActivateNewImage();
    }
    else if( eEvent == eOTA_JobEvent_Fail )
    {
        configPRINTF( ( "Received eOTA_JobEvent_Fail callback from OTA Agent.\r
" ) );
        /* Nothing special to do. The OTA agent handles it. */
    }
    else if( eEvent == eOTA_JobEvent_StartTest )
    {
        /* This demo just accepts the image since it was a good OTA update and networking
         * and services are all working (or we wouldn't have made it this far). If this
         * were some custom device that wants to test other things before calling it OK,
         * this would be the place to kick off those tests before calling OTA_SetImageState()
         * with the final result of either accepted or rejected. */
        configPRINTF( ( "Received eOTA_JobEvent_StartTest callback from OTA Agent.\r
" ) );
        xErr = OTA_SetImageState( eOTA_ImageState_Accepted );

        if( xErr != kOTA_Err_None )
        {
            OTA_LOG_L1( " Error! Failed to set image state as accepted.\r
" );
        }
    }
}
static const char * pcStateStr[ eOTA_NumAgentStates ] =
{
    "Not Ready",
    "Ready",
    "Active",
    "Shutting down"
};
IotMqttConnection_t MQTT_AGENT_Getv2Connection( MQTTAgentHandle_t xMQTTHandle );

void OTA_Run( void * param )
{
   
    IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER;
    OTA_State_t eState;

    configPRINTF( ( "OTA demo version %u.%u.%u\r
",
                    xAppFirmwareVersion.u.x.ucMajor,
                    xAppFirmwareVersion.u.x.ucMinor,
                    xAppFirmwareVersion.u.x.usBuild ) );
    configPRINTF( ( "Creating MQTT Client...\r
" ) );

    /* Create the MQTT Client. */
    configPRINTF( ( "WAHDAN : vRunOTAUpdateDemo : Start \r
" ) );
    for( ; ; )
    {
          configPRINTF( ( "Connecting to broker...\r
" ) );
            memset( &xConnectInfo, 0, sizeof( xConnectInfo ) );

            if( xConnection.ulNetworkType == AWSIOT_NETWORK_TYPE_BLE )
            {
                xConnectInfo.awsIotMqttMode = false;
                xConnectInfo.keepAliveSeconds = 0;
            }
            else
            {
                configPRINTF( ( "WAHDAN : vRunOTAUpdateDemo : Set connection info \r
" ) );
                xConnectInfo.awsIotMqttMode = true;
                xConnectInfo.keepAliveSeconds = otaDemoKEEPALIVE_SECONDS;
            }

            xConnectInfo.cleanSession = true;
            xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( clientcredentialIOT_THING_NAME );
            xConnectInfo.pClientIdentifier = clientcredentialIOT_THING_NAME;

            /* Connect to the broker. */
            configPRINTF( ( "WAHDAN : vRunOTAUpdateDemo : IotMqtt_Connect() connecto to broker \r
" ) );
             configPRINTF( ( "WAHDAN : vRunOTAUpdateDemo : IotMqtt_Connect() connecto to broker \r
" ) );
                IotMqttConnection_t xMqttConnection = MQTT_AGENT_Getv2Connection( xMQTTClientHandle );
                OTA_AgentInit( xMqttConnection, ( const uint8_t * ) ( clientcredentialIOT_THING_NAME ), App_OTACompleteCallback, ( TickType_t ) ~0 );

                while( ( eState = OTA_GetAgentState() ) != eOTA_AgentState_NotReady )
                {
                    /* Wait forever for OTA traffic but allow other tasks to run and output statistics only once per second. */
                    configPRINTF( ( "WAHDAN : vRunOTAUpdateDemo : Inside the while loop   \r
" ) );
                    vTaskDelay( myappONE_SECOND_DELAY_IN_TICKS );
                    configPRINTF( ( "State: %s  Received: %u   Queued: %u   Processed: %u   Dropped: %u\r
", pcStateStr[ eState ],
                                    OTA_GetPacketsReceived(), OTA_GetPacketsQueued(), OTA_GetPacketsProcessed(), OTA_GetPacketsDropped() ) );
                }
                configPRINTF( ( "WAHDAN : vRunOTAUpdateDemo :IotMqtt_Disconnect  \r
" ) );
                IotMqtt_Disconnect( xMqttConnection, false );
        
    
}


}
static void prvSendMessageToGGC( GGD_HostAddressData_t * pxHostAddressData )
{
    const char * pcTopic = "/OTA/TEST";
    MQTTAgentPublishParams_t xPublishParams;
    MQTTAgentReturnCode_t xReturnCode;
    uint32_t ulMessageCounter = 0;
    char cBuffer[ ggdDEMO_MAX_MQTT_MSG_SIZE ];


    if( prvMQTTConnect( pxHostAddressData ) == pdPASS )
    {
        /* Publish to the topic to which this task is subscribed in order
         * to receive back the data that was published. */
        xPublishParams.xQoS = eMQTTQoS0;
        xPublishParams.pucTopic = ( const uint8_t * ) pcTopic;
        xPublishParams.usTopicLength = ( uint16_t ) ( strlen( pcTopic ) );
        ( void ) xTaskCreate( OTA_Run, "OTA", democonfigGREENGRASS_DISCOVERY_TASK_STACK_SIZE/2, NULL, democonfigDEMO_PRIORITY - 2, NULL );
        for( ; ; ulMessageCounter++ )
        {
            xPublishParams.ulDataLength = ( uint32_t ) sprintf( cBuffer, ggdDEMO_MQTT_MSG_DISCOVERY, ( long unsigned int ) ulMessageCounter ); /*lint !e586 sprintf can be used for specific demo. */
            xPublishParams.pvData = cBuffer;
            xReturnCode = MQTT_AGENT_Publish( xMQTTClientHandle,
                                              &xPublishParams,
                                              xMaxCommandTime );

            if( xReturnCode != eMQTTAgentSuccess )
            {
                configPRINTF( ( "mqtt_client - Failure to publish 
" ) );
            }
            else
            {
                configPRINTF( ( "mqtt_client -  publish 
" ) );
            }

            vTaskDelay( xTimeBetweenPublish );
        }

        configPRINTF( ( "Disconnecting from broker.\r
" ) );

        if( MQTT_AGENT_Disconnect( xMQTTClientHandle,
                                   xMaxCommandTime ) == eMQTTAgentSuccess )
        {
            configPRINTF( ( "Disconnected from the broker.\r
" ) );

            if( MQTT_AGENT_Delete( xMQTTClientHandle ) == eMQTTAgentSuccess )
            {
                configPRINTF( ( "Deleted Client.\r
" ) );
            }
            else
            {
                configPRINTF( ( "ERROR:  MQTT_AGENT_Delete() Failed.\r
" ) );
            }
        }
        else
        {
            configPRINTF( ( "ERROR:  Did not disconnected from the broker.\r
" ) );
        }
    }
}

/*-----------------------------------------------------------*/

static BaseType_t prvMQTTConnect( GGD_HostAddressData_t * pxHostAddressData )
{
    MQTTAgentConnectParams_t xConnectParams;
    BaseType_t xResult = pdPASS;

    /* Connect to the broker. */
    xConnectParams.pucClientId = ( const uint8_t * ) ( clientcredentialIOT_THING_NAME );
    xConnectParams.usClientIdLength = ( uint16_t ) ( strlen( clientcredentialIOT_THING_NAME ) );
    xConnectParams.pcURL = pxHostAddressData->pcHostAddress;
    xConnectParams.usPort = clientcredentialMQTT_BROKER_PORT;
    xConnectParams.xFlags = mqttagentREQUIRE_TLS | mqttagentURL_IS_IP_ADDRESS;
    xConnectParams.xURLIsIPAddress = pdTRUE; /* Deprecated. */
    xConnectParams.pcCertificate = pxHostAddressData->pcCertificate;
    xConnectParams.ulCertificateSize = pxHostAddressData->ulCertificateSize;
    xConnectParams.pvUserData = NULL;
    xConnectParams.pxCallback = NULL;
    xConnectParams.xSecuredConnection = pdTRUE; /* Deprecated. */

    if( MQTT_AGENT_Connect( xMQTTClientHandle,
                            &xConnectParams,
                            xMaxCommandTime ) != eMQTTAgentSuccess )
    {
        configPRINTF( ( "ERROR: Could not connect to the Broker.\r
" ) );
        xResult = pdFAIL;
    }

    return xResult;
}
static BaseType_t xNetworkConnected = pdFALSE;
static BaseType_t prxCreateNetworkConnection( void );
static IotNetworkError_t prvNetworkDisconnectCallback( void * pvContext );
static void prvNetworkStateChangeCallback( uint32_t ulNetworkType,
                                           AwsIotNetworkState_t xNetworkState,
                                           void * pvContext );
static IotNetworkError_t prvNetworkDisconnectCallback( void * pvContext )
{
    ( void ) pvContext;
    xNetworkConnected = pdFALSE;

    return IOT_NETWORK_SUCCESS;
}
/*-----------------------------------------------------------*/

static void prvDiscoverGreenGrassCore( void * pvParameters )
{
    GGD_HostAddressData_t xHostAddressData;

    ( void ) pvParameters;

    /* Create MQTT Client. */
    if( MQTT_AGENT_Create( &( xMQTTClientHandle ) ) == eMQTTAgentSuccess )
    {
        memset( &xHostAddressData, 0, sizeof( xHostAddressData ) );

        /* Demonstrate automated connection. */
        configPRINTF( ( "Attempting automated selection of Greengrass device\r
" ) );

 if( GGD_GetGGCIPandCertificate( pcJSONFile,
                                        ggdDEMO_DISCOVERY_FILE_SIZE,
                                        &xHostAddressData )
            == pdPASS )
        {
            configPRINTF( ( "Greengrass device discovered.\r
" ) );
            configPRINTF( ( "Establishing MQTT communication to Greengrass...\r
" ) );
            prvSendMessageToGGC( &xHostAddressData );

            /* Report on space efficiency of this demo task. */
            #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
                {
                    configPRINTF( ( "Heap low watermark: %u. Stack high watermark: %u.\r
",
                                    xPortGetMinimumEverFreeHeapSize(),
                                    uxTaskGetStackHighWaterMark( NULL ) ) );
                }
            #endif
        }
        else
        {
            configPRINTF( ( "Auto-connect: Failed to retrieve Greengrass address and certificate.\r
" ) );
        }
        
    }

    configPRINTF( ( "----Demo finished----\r
" ) );
    vTaskDelete( NULL );
}

/*-----------------------------------------------------------*/

int vStartGreenGrassDiscoveryTask( bool awsIotMqttMode,
                                   const char * pIdentifier,
                                   void * pNetworkServerInfo,
                                   void * pNetworkCredentialInfo,
                                   const IotNetworkInterface_t * pNetworkInterface )
{
    /* Unused parameters */
    ( void ) awsIotMqttMode;
    ( void ) pIdentifier;
    ( void ) pNetworkServerInfo;
    ( void ) pNetworkCredentialInfo;
    ( void ) pNetworkInterface;

    prvDiscoverGreenGrassCore( NULL );
    return 0;
}

Edited by: embeddedx on Sep 20, 2019 1:12 PM

Edited by: embeddedx on Sep 20, 2019 3:10 PM

Gaurav-Aggarwal-AWS wrote on September 21, 2019:

These are the logs which tell that the broker is closing the connection as soon as the client is publishing a message:


395 3224 [iot_thread] [DEBUG][MQTT][32240] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Scheduling retry 1 of 3 in 1000 ms.
403 3282 [IP-task] Socket 25012 -> 36bfdd83ip:8883 State eESTABLISHED->eLAST_ACK
404 3282 [NetRecv] [DEBUG][NET][32820] Network receive task terminating.
405 3322 [IP-task] Socket 25012 -> 36bfdd83ip:8883 State eLAST_ACK->eCLOSE_WAIT
406 3326 [Tmr Svc] [DEBUG][TASKPOOL][33260] Timer thread started for task pool 0x3ffc660c.

Would you please change your policy to “iot:*” for testing only:


{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iot:*"
      ],
      "Resource": [
        "*"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "greengrass:*"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

Also, enable the CloudWatch logs for AWS IoT for your account as mentioned here: https://docs.aws.amazon.com/iot/latest/developerguide/cloud-watch-logs.html

Share the above logs from CloudWatch as well.

Thanks.

Gaurav-Aggarwal-AWS wrote on September 21, 2019:

At this point we need to find out the cause of the NETWORK_ERROR. Would you please enable TCP and TLS logs and see if get some hint from there.

To enable TCP logs, change ipconfigHAS_DEBUG_PRINTF to 1 in amazon-freertos\vendors\espressif\boards\esp32\aws_demos\config_files\FreeRTOSIPConfig.h:


#define ipconfigHAS_DEBUG_PRINTF    1

To enable TLS logs, uncomment the following lines in amazon-freertos\libraries\3rdparty\mbedtls\include\mbedtls\config.h:


#define MBEDTLS_SSL_DEBUG_ALL
#define MBEDTLS_DEBUG_C

Also, update the log level to debug for all libraries in amazon-freertos\vendors\espressif\boards\esp32\aws_demos\config_files\iot_config.h:


#define IOT_LOG_LEVEL_GLOBAL                    IOT_LOG_DEBUG
#define IOT_LOG_LEVEL_DEMO                      IOT_LOG_DEBUG
#define IOT_LOG_LEVEL_PLATFORM                  IOT_LOG_DEBUG
#define IOT_LOG_LEVEL_NETWORK                   IOT_LOG_DEBUG
#define IOT_LOG_LEVEL_TASKPOOL                  IOT_LOG_DEBUG
#define IOT_LOG_LEVEL_MQTT                      IOT_LOG_DEBUG
#define AWS_IOT_LOG_LEVEL_SHADOW                IOT_LOG_DEBUG
#define AWS_IOT_LOG_LEVEL_DEFENDER              IOT_LOG_DEBUG
#define IOT_LOG_LEVEL_HTTPS                     IOT_LOG_DEBUG

Let see if that provides any useful log message. If not, would you be able to share your code which demonstrates this problem so that I can repro and debug at my end?

Thanks.

TJirsch wrote on September 22, 2019:

That is cool ! Could you point me to the documentation ?

Gaurav-Aggarwal-AWS wrote on September 20, 2019:

The Greengrass demo tries to find a Core and if found, retrieves credentials and endpoint of the Greengrass core. It then connects to the Greengrass core using these credentials and endpoint.

The OTA demo connects to the AWS IoT Broker. See the following function call sequence:


vRunOTAUpdateDemo --> prxCreateNetworkConnection --> xMqttDemoCreateNetworkConnection --> prxCreateNetworkConnection --> prxCreateSecureSocketConnection

The prxCreateSecureSocketConnection function calls AwsIotNetworkManager_GetConnectionParams and AwsIotNetworkManager_GetConnectionParams which make use of the following defines:


clientcredentialMQTT_BROKER_ENDPOINT
clientcredentialMQTT_BROKER_PORT 
keyCLIENT_CERTIFICATE_PEM
keyCLIENT_PRIVATE_KEY_PEM

You need to modify the OTA demo so that it does not connect to the AWS IoT Broker but instead connects to the Greengrass Core. The steps would roughly be:

  1. Retrieve credentials and endpoint of the Greengrass Core.
  2. Establish an MQTT connection the Greengrass core using the information retrieved in the step 1.
  3. Pass the MQTT connection handle from step 2 to the OTA_AgentInit API for the pvClient parameter.

You can try to use the MQTT connection handle created in the Greengrass demo to pass to the OTA_AgentInit API for the pvClient parameter.

Thanks.

Gaurav-Aggarwal-AWS wrote on September 20, 2019:

What is the policy attached to the certificate you created? From your logs Subscribe succeeds but Publish fails.

Yes, that remains the same.

Thanks.

embeddedx wrote on September 20, 2019:

Hi,
This is the policy attached to the thing


{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iot:Publish",
        "iot:Subscribe",
        "iot:Connect",
        "iot:Receive"
      ],
      "Resource": [
        "*"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "greengrass:*"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

Another thing, I’m subscribing from the IOT console to the topic greengrass demo publishes to, but I didn’t get any updates, any Ideas? Is this related to group subscribtions?

Edited by: embeddedx on Sep 20, 2019 4:09 PM

embeddedx wrote on September 21, 2019:

Hello,
This is the debug info


159 2975 [iot_thread] [DEBUG][THREAD][29750] Locking mutex 0x3ffc7dc0.
160 2976 [iot_thread] [DEBUG][THREAD][29750] Unlocking mutex 0x3ffc7dc0.
161 2976 [iot_thread] [INFO ][MQTT][29760] Establishing new MQTT connection.
162 2976 [iot_thread] [DEBUG][THREAD][29760] Creating new mutex 0x3ffdaca0.
163 2976 [iot_thread] [DEBUG][THREAD][29760] Creating new mutex 0x3ffdad14.
164 2976 [iot_thread] [DEBUG][MQTT][29760] MQTT PINGREQ packet:
165 2976 [iot_thread] c0 00
166 2976 [iot_thread] [DEBUG][MQTT][29760] (MQTT connection 0x3ffdac84) Creating new operation record.
167 2976 [iot_thread] [DEBUG][THREAD][29760] Locking mutex 0x3ffdaca0.
168 2976 [iot_thread] [DEBUG][MQTT][29760] (MQTT connection 0x3ffdac84) Reference count changed from 2 to 3.
169 2976 [iot_thread] [DEBUG][THREAD][29760] Unlocking mutex 0x3ffdaca0.
170 2976 [iot_thread] [DEBUG][THREAD][29760] Creating new semaphore 0x3fff15fc.
171 2976 [iot_thread] [DEBUG][THREAD][29760] Locking mutex 0x3ffdaca0.
172 2976 [iot_thread] [DEBUG][THREAD][29760] Unlocking mutex 0x3ffdaca0.
173 2976 [iot_thread] [INFO ][MQTT][29760] Anonymous metrics (SDK language, SDK version) will be provided to AWS IoT. Recompile with AWS_IOT_MQTT_
ENABLE_METRICS set to 0 to disable.
174 2976 [iot_thread] [DEBUG][MQTT][29760] MQTT CONNECT packet:
175 2976 [iot_thread] 10 85 01 00 04 4d 51 54 54 04 82 04 b0 00 14 48
176 2976 [iot_thread] 65 6c 6c 6f 57 6f 72 6c 64 5f 50 75 62 6c 69 73
177 2976 [iot_thread] 68 65 72 00 63 3f 53 44 4b 3d 41 6d 61 7a 6f 6e
178 2976 [iot_thread] 46 72 65 65 52 54 4f 53 26 56 65 72 73 69 6f 6e
179 2976 [iot_thread] 3d 34 2e 30 2e 30 26 50 6c 61 74 66 6f 72 6d 3d
180 2976 [iot_thread] 45 73 70 72 65 73 73 69 66 45 53 50 33 32 26 41
181 2976 [iot_thread] 46 52 44 65 76 49 44 3d 38 38 46 44 32 44 37 45
182 2976 [iot_thread] 45 39 31 42 45 46 46 43 46 43 35 35 42 41 39 35
183 2976 [iot_thread] 36 30 46 37 34 46 41 39
184 2976 [iot_thread] [DEBUG][THREAD][29760] Locking mutex 0x3ffc6724.
185 2976 [iot_thread] [DEBUG][THREAD][29760] Posting to semaphore 0x3ffc6640.
186 2976 [iot_thread] [DEBUG][THREAD][29760] Unlocking mutex 0x3ffc6724.
187 2976 [iot_thread] [DEBUG][THREAD][29760] Locking mutex 0x3ffdaca0.
188 2976 [iot_thread] [INFO ][MQTT][29760] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Waiting for operation completion.
189 2977 [iot_thread] [DEBUG][THREAD][29770] Unlocking mutex 0x3ffdaca0.
190 2977 [iot_thread] [DEBUG][THREAD][29770] Locking mutex 0x3ffc6724.
191 2977 [iot_thread] [DEBUG][THREAD][29770] Unlocking mutex 0x3ffc6724.
192 2977 [iot_thread] [DEBUG][MQTT][29770] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Sending MQTT packet.
193 2978 [iot_thread] [DEBUG][THREAD][29770] Locking mutex 0x3ffdaca0.
194 2978 [iot_thread] [DEBUG][MQTT][29780] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Job reference changed from 2 to 1.
195 2978 [iot_thread] [DEBUG][THREAD][29780] Unlocking mutex 0x3ffdaca0.
196 2978 [iot_thread] [DEBUG][THREAD][29780] Locking mutex 0x3ffdaca0.
200 3036 [NetRecv] [DEBUG][NET][30360] Successfully received 1 bytes.
201 3036 [NetRecv] [DEBUG][NET][30360] Successfully received 1 bytes.
202 3036 [NetRecv] [DEBUG][NET][30360] Successfully received 2 bytes.
203 3037 [NetRecv] [DEBUG][MQTT][30370] (MQTT connection 0x3ffdac84) CONNACK in data stream.
204 3038 [NetRecv] CONNACK session present bit not set.
205 3038 [NetRecv] Connection accepted.
206 3039 [NetRecv] [DEBUG][MQTT][30390] (MQTT connection 0x3ffdac84) Searching for operation CONNECT pending response.
207 3040 [NetRecv] [DEBUG][THREAD][30400] Locking mutex 0x3ffdaca0.
208 3040 [NetRecv] [DEBUG][MQTT][30400] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Job reference changed from 1 to 2.
209 3041 [NetRecv] [DEBUG][MQTT][30410] (MQTT connection 0x3ffdac84) Found operation CONNECT.
210 3042 [NetRecv] [DEBUG][THREAD][30420] Unlocking mutex 0x3ffdaca0.
211 3043 [NetRecv] [DEBUG][THREAD][30430] Locking mutex 0x3ffdaca0.
212 3044 [NetRecv] [DEBUG][MQTT][30430] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Job reference changed from 2 to 1.
213 3045 [NetRecv] [DEBUG][THREAD][30450] Unlocking mutex 0x3ffdaca0.
214 3045 [NetRecv] [DEBUG][MQTT][30450] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Waitable operation notified of completion.
215 3047 [NetRecv] [DEBUG][THREAD][30470] Posting to semaphore 0x3fff15fc.
216 3047 [iot_thread] [INFO ][MQTT][30470] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Wait complete with result SUCCESS.
217 3047 [iot_thread] [DEBUG][THREAD][30470] Locking mutex 0x3ffdaca0.
218 3047 [iot_thread] [DEBUG][MQTT][30470] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Job reference changed from 1 to 0.
219 3047 [iot_thread] [DEBUG][THREAD][30470] Unlocking mutex 0x3ffdaca0.
220 3047 [iot_thread] [DEBUG][MQTT][30470] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Destroying operation.
221 3047 [iot_thread] [DEBUG][THREAD][30470] Locking mutex 0x3ffdaca0.
222 3047 [iot_thread] [DEBUG][MQTT][30470] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Operation was not present in connection list
s.
223 3047 [iot_thread] [DEBUG][THREAD][30470] Unlocking mutex 0x3ffdaca0.
224 3047 [iot_thread] [DEBUG][MQTT][30470] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) MQTT packet freed.
225 3047 [iot_thread] [DEBUG][THREAD][30470] Destroying semaphore 0x3fff15fc.
226 3047 [iot_thread] [DEBUG][MQTT][30470] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Wait semaphore destroyed.
227 3047 [iot_thread] [DEBUG][MQTT][30470] (MQTT connection 0x3ffdac84, CONNECT operation 0x3fff15b4) Operation record destroyed.
228 3049 [iot_thread] [DEBUG][THREAD][30470] Locking mutex 0x3ffdaca0.
229 3049 [iot_thread] [DEBUG][MQTT][30490] (MQTT connection 0x3ffdac84) Reference count changed from 3 to 2.
230 3049 [iot_thread] [DEBUG][THREAD][30490] Unlocking mutex 0x3ffdaca0.
231 3049 [iot_thread] [DEBUG][MQTT][30490] Scheduling first MQTT keep-alive job.
232 3049 [iot_thread] [DEBUG][THREAD][30490] Locking mutex 0x3ffc6724.
233 3049 [iot_thread] [DEBUG][CLOCK][30490] Arming timer 0x3ffc66e8 with timeout 1200000 and period 95562786596.
234 3049 [iot_thread] [DEBUG][THREAD][30490] Unlocking mutex 0x3ffc6724.
235 3049 [iot_thread] [INFO ][MQTT][30490] New MQTT connection 0x3ffdc5ec established.
236 3065 [OTA] OTA demo version 0.9.2
237 3065 [OTA] Creating MQTT Client...
238 3065 [OTA] WAHDAN : vRunOTAUpdateDemo : Start
239 3066 [OTA] Connecting to broker...
240 3066 [OTA] WAHDAN : vRunOTAUpdateDemo : Set connection info
241 3067 [OTA] WAHDAN : vRunOTAUpdateDemo : IotMqtt_Connect() connecto to broker
242 3067 [OTA] WAHDAN : vRunOTAUpdateDemo : IotMqtt_Connect() connecto to broker
243 3068 [OTA Task] [DEBUG][MQTT][30680] (MQTT connection 0x3ffdac84) Creating new operation record.
244 3068 [OTA Task] [DEBUG][THREAD][30680] Locking mutex 0x3ffdaca0.
245 3068 [OTA Task] [DEBUG][MQTT][30680] (MQTT connection 0x3ffdac84) Reference count changed from 2 to 3.
246 3068 [OTA Task] [DEBUG][THREAD][30680] Unlocking mutex 0x3ffdaca0.
247 3068 [OTA Task] [DEBUG][THREAD][30680] Creating new semaphore 0x3ffb7b30.
248 3068 [OTA Task] [DEBUG][THREAD][30680] Locking mutex 0x3ffdaca0.
249 3068 [OTA Task] [DEBUG][THREAD][30680] Unlocking mutex 0x3ffdaca0.
250 3068 [OTA Task] [DEBUG][MQTT][30680] MQTT SUBSCRIBE packet:
251 3070 [OTA Task] 82 3d 00 01 00 38 24 61 77 73 2f 74 68 69 6e 67
252 3070 [OTA Task] 73 2f 48 65 6c 6c 6f 57 6f 72 6c 64 5f 50 75 62
253 3070 [OTA Task] 6c 69 73 68 65 72 2f 6a 6f 62 73 2f 24 6e 65 78
254 3070 [OTA Task] 74 2f 67 65 74 2f 61 63 63 65 70 74 65 64 01
255 3070 [OTA Task] [DEBUG][THREAD][30700] Locking mutex 0x3ffdad14.
256 3070 [OTA Task] [DEBUG][THREAD][30700] Unlocking mutex 0x3ffdad14.
257 3070 [OTA Task] [DEBUG][THREAD][30700] Locking mutex 0x3ffc6724.
258 3070 [OTA Task] [DEBUG][THREAD][30700] Posting to semaphore 0x3ffc6640.
259 3070 [OTA Task] [DEBUG][THREAD][30700] Unlocking mutex 0x3ffc6724.
260 3070 [OTA Task] [INFO ][MQTT][30700] (MQTT connection 0x3ffdac84) SUBSCRIBE operation scheduled.
261 3070 [OTA Task] [DEBUG][THREAD][30700] Locking mutex 0x3ffdaca0.
262 3070 [OTA Task] [INFO ][MQTT][30700] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Waiting for operation completion.
263 3070 [OTA Task] [DEBUG][THREAD][30700] Unlocking mutex 0x3ffdaca0.
264 3071 [iot_thread] [DEBUG][THREAD][30710] Locking mutex 0x3ffc6724.
265 3071 [iot_thread] [DEBUG][THREAD][30710] Unlocking mutex 0x3ffc6724.
266 3071 [iot_thread] [DEBUG][MQTT][30710] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Sending MQTT packet.
267 3071 [iot_thread] [DEBUG][THREAD][30710] Locking mutex 0x3ffdaca0.
268 3071 [iot_thread] [DEBUG][MQTT][30710] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Job reference changed from 2 to 1.
269 3071 [iot_thread] [DEBUG][THREAD][30710] Unlocking mutex 0x3ffdaca0.
270 3071 [iot_thread] [DEBUG][THREAD][30710] Locking mutex 0x3ffdaca0.
271 3071 [iot_thread] [DEBUG][THREAD][30710] Unlocking mutex 0x3ffdaca0.
272 3071 [iot_thread] [DEBUG][THREAD][30710] Locking mutex 0x3ffc6724.
273 3071 [iot_thread] [DEBUG][THREAD][30710] Unlocking mutex 0x3ffc6724.
274 3118 [NetRecv] [DEBUG][NET][31180] Successfully received 1 bytes.
275 3118 [NetRecv] [DEBUG][NET][31180] Successfully received 1 bytes.
276 3118 [NetRecv] [DEBUG][NET][31180] Successfully received 3 bytes.
277 3119 [NetRecv] [DEBUG][MQTT][31190] (MQTT connection 0x3ffdac84) SUBACK in data stream.
278 3120 [NetRecv] Packet identifier 1.
279 3120 [NetRecv] Topic filter 0 accepted, max QoS 0.
280 3120 [NetRecv] [DEBUG][MQTT][31200] (MQTT connection 0x3ffdac84) Searching for operation SUBSCRIBE pending response with packet identifier 1.
281 3122 [NetRecv] [DEBUG][THREAD][31220] Locking mutex 0x3ffdaca0.
282 3122 [NetRecv] [DEBUG][MQTT][31220] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Job reference changed from 1 to 2.
283 3124 [NetRecv] [DEBUG][MQTT][31240] (MQTT connection 0x3ffdac84) Found operation SUBSCRIBE.
284 3124 [NetRecv] [DEBUG][THREAD][31240] Unlocking mutex 0x3ffdaca0.
285 3125 [NetRecv] [DEBUG][THREAD][31250] Locking mutex 0x3ffdaca0.
286 3126 [NetRecv] [DEBUG][MQTT][31260] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Job reference changed from 2 to 1.
287 3127 [NetRecv] [DEBUG][THREAD][31270] Unlocking mutex 0x3ffdaca0.
288 3127 [NetRecv] [DEBUG][MQTT][31270] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Waitable operation notified of completion.
289 3129 [NetRecv] [DEBUG][THREAD][31290] Posting to semaphore 0x3ffb7b30.
290 3129 [OTA Task] [INFO ][MQTT][31290] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Wait complete with result SUCCESS.
291 3129 [OTA Task] [DEBUG][THREAD][31290] Locking mutex 0x3ffdaca0.
292 3129 [OTA Task] [DEBUG][MQTT][31290] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Job reference changed from 1 to 0.
293 3129 [OTA Task] [DEBUG][THREAD][31290] Unlocking mutex 0x3ffdaca0.
294 3129 [OTA Task] [DEBUG][MQTT][31290] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Destroying operation.
295 3129 [OTA Task] [DEBUG][THREAD][31290] Locking mutex 0x3ffdaca0.
296 3130 [OTA Task] [DEBUG][MQTT][31290] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Operation was not present in connection list
s.
297 3130 [OTA Task] [DEBUG][THREAD][31300] Unlocking mutex 0x3ffdaca0.
298 3130 [OTA Task] [DEBUG][MQTT][31300] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) MQTT packet freed.
299 3130 [OTA Task] [DEBUG][THREAD][31300] Destroying semaphore 0x3ffb7b30.
300 3130 [OTA Task] [DEBUG][MQTT][31300] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Wait semaphore destroyed.
301 3130 [OTA Task] [DEBUG][MQTT][31300] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3ffb7ae8) Operation record destroyed.
302 3130 [OTA Task] [DEBUG][THREAD][31300] Locking mutex 0x3ffdaca0.
303 3130 [OTA Task] [DEBUG][MQTT][31300] (MQTT connection 0x3ffdac84) Reference count changed from 3 to 2.
304 3130 [OTA Task] [DEBUG][THREAD][31300] Unlocking mutex 0x3ffdaca0.
305 3130 [OTA Task] [prvSubscribeToJobNotificationTopics] OK: $aws/things/HelloWorld_Publisher/jobs/$next/get/accepted
306 3130 [OTA Task] [DEBUG][MQTT][31300] (MQTT connection 0x3ffdac84) Creating new operation record.
307 3130 [OTA Task] [DEBUG][THREAD][31300] Locking mutex 0x3ffdaca0.
308 3130 [OTA Task] [DEBUG][MQTT][31300] (MQTT connection 0x3ffdac84) Reference count changed from 2 to 3.
309 3130 [OTA Task] [DEBUG][THREAD][31300] Unlocking mutex 0x3ffdaca0.
310 3130 [OTA Task] [DEBUG][THREAD][31300] Creating new semaphore 0x3fff37c8.
311 3130 [OTA Task] [DEBUG][THREAD][31300] Locking mutex 0x3ffdaca0.
312 3130 [OTA Task] [DEBUG][THREAD][31300] Unlocking mutex 0x3ffdaca0.
313 3130 [OTA Task] [DEBUG][MQTT][31300] MQTT SUBSCRIBE packet:
314 3130 [OTA Task] 82 36 00 03 00 31 24 61 77 73 2f 74 68 69 6e 67
315 3131 [OTA Task] 73 2f 48 65 6c 6c 6f 57 6f 72 6c 64 5f 50 75 62
316 3131 [OTA Task] 6c 69 73 68 65 72 2f 6a 6f 62 73 2f 6e 6f 74 69
317 3131 [OTA Task] 66 79 2d 6e 65 78 74 01
318 3131 [OTA Task] [DEBUG][THREAD][31310] Locking mutex 0x3ffdad14.
319 3131 [OTA Task] [DEBUG][THREAD][31310] Unlocking mutex 0x3ffdad14.
320 3131 [OTA Task] [DEBUG][THREAD][31310] Locking mutex 0x3ffc6724.
321 3131 [OTA Task] [DEBUG][THREAD][31310] Posting to semaphore 0x3ffc6640.
322 3131 [OTA Task] [DEBUG][THREAD][31310] Unlocking mutex 0x3ffc6724.
327 3132 [iot_thread] [DEBUG][THREAD][31320] Locking mutex 0x3ffc6724.
328 3132 [iot_thread] [DEBUG][THREAD][31320] Unlocking mutex 0x3ffc6724.
335 3133 [iot_thread] [DEBUG][THREAD][31320] Locking mutex 0x3ffc6724.
337 3210 [NetRecv] [DEBUG][NET][32100] Successfully received 1 bytes.
338 3210 [NetRecv] [DEBUG][NET][32100] Successfully received 1 bytes.
339 3210 [NetRecv] [DEBUG][NET][32100] Successfully received 3 bytes.
340 3211 [NetRecv] [DEBUG][MQTT][32110] (MQTT connection 0x3ffdac84) SUBACK in data stream.
341 3212 [NetRecv] Packet identifier 3.
342 3212 [NetRecv] Topic filter 0 accepted, max QoS 0.
343 3212 [NetRecv] [DEBUG][MQTT][32120] (MQTT connection 0x3ffdac84) Searching for operation SUBSCRIBE pending response with packet identifier 3.
344 3214 [NetRecv] [DEBUG][THREAD][32140] Locking mutex 0x3ffdaca0.
345 3214 [NetRecv] [DEBUG][MQTT][32140] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Job reference changed from 1 to 2.
346 3215 [NetRecv] [DEBUG][MQTT][32150] (MQTT connection 0x3ffdac84) Found operation SUBSCRIBE.
347 3216 [NetRecv] [DEBUG][THREAD][32160] Unlocking mutex 0x3ffdaca0.
348 3217 [NetRecv] [DEBUG][THREAD][32170] Locking mutex 0x3ffdaca0.
349 3218 [NetRecv] [DEBUG][MQTT][32180] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Job reference changed from 2 to 1.
350 3219 [NetRecv] [DEBUG][THREAD][32190] Unlocking mutex 0x3ffdaca0.
351 3219 [NetRecv] [DEBUG][MQTT][32190] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Waitable operation notified of completion.
352 3221 [NetRecv] [DEBUG][THREAD][32210] Posting to semaphore 0x3fff37c8.
353 3221 [OTA Task] [INFO ][MQTT][32210] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Wait complete with result SUCCESS.
354 3221 [OTA Task] [DEBUG][THREAD][32210] Locking mutex 0x3ffdaca0.
355 3221 [OTA Task] [DEBUG][MQTT][32210] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Job reference changed from 1 to 0.
356 3221 [OTA Task] [DEBUG][THREAD][32210] Unlocking mutex 0x3ffdaca0.
357 3221 [OTA Task] [DEBUG][MQTT][32210] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Destroying operation.
358 3221 [OTA Task] [DEBUG][THREAD][32210] Locking mutex 0x3ffdaca0.
359 3221 [OTA Task] [DEBUG][MQTT][32210] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Operation was not present in connection list
s.
360 3221 [OTA Task] [DEBUG][THREAD][32210] Unlocking mutex 0x3ffdaca0.
361 3223 [OTA Task] [DEBUG][MQTT][32210] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) MQTT packet freed.
362 3223 [OTA Task] [DEBUG][THREAD][32230] Destroying semaphore 0x3fff37c8.
363 3223 [OTA Task] [DEBUG][MQTT][32230] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Wait semaphore destroyed.
364 3223 [OTA Task] [DEBUG][MQTT][32230] (MQTT connection 0x3ffdac84, SUBSCRIBE operation 0x3fff3780) Operation record destroyed.
365 3223 [OTA Task] [DEBUG][THREAD][32230] Locking mutex 0x3ffdaca0.
366 3223 [OTA Task] [DEBUG][MQTT][32230] (MQTT connection 0x3ffdac84) Reference count changed from 3 to 2.
367 3223 [OTA Task] [DEBUG][THREAD][32230] Unlocking mutex 0x3ffdaca0.
368 3223 [OTA Task] [prvSubscribeToJobNotificationTopics] OK: $aws/things/HelloWorld_Publisher/jobs/notify-next
369 3223 [OTA Task] [OTA_CheckForUpdate] Request #0
370 3223 [OTA Task] [DEBUG][MQTT][32230] (MQTT connection 0x3ffdac84) Creating new operation record.
371 3223 [OTA Task] [DEBUG][THREAD][32230] Locking mutex 0x3ffdaca0.
372 3223 [OTA Task] [DEBUG][MQTT][32230] (MQTT connection 0x3ffdac84) Reference count changed from 2 to 3.
373 3223 [OTA Task] [DEBUG][THREAD][32230] Unlocking mutex 0x3ffdaca0.
374 3223 [OTA Task] [DEBUG][THREAD][32230] Creating new semaphore 0x3fff4010.
375 3223 [OTA Task] [DEBUG][THREAD][32230] Locking mutex 0x3ffdaca0.
376 3223 [OTA Task] [DEBUG][THREAD][32230] Unlocking mutex 0x3ffdaca0.
377 3223 [OTA Task] [DEBUG][MQTT][32230] MQTT PUBLISH packet:
378 3223 [OTA Task] 32 5b 00 2f 24 61 77 73 2f 74 68 69 6e 67 73 2f
379 3223 [OTA Task] 48 65 6c 6c 6f 57 6f 72 6c 64 5f 50 75 62 6c 69
380 3223 [OTA Task] 73 68 65 72 2f 6a 6f 62 73 2f 24 6e 65 78 74 2f
381 3223 [OTA Task] 67 65 74 00 05 7b 22 63 6c 69 65 6e 74 54 6f 6b
382 3223 [OTA Task] 65 6e 22 3a 22 30 3a 48 65 6c 6c 6f 57 6f 72 6c
383 3223 [OTA Task] 64 5f 50 75 62 6c 69 73 68 65 72 22 7d
384 3223 [OTA Task] [DEBUG][THREAD][32230] Locking mutex 0x3ffc6724.
385 3223 [OTA Task] [DEBUG][THREAD][32230] Posting to semaphore 0x3ffc6640.
391 3224 [iot_thread] [DEBUG][THREAD][32240] Locking mutex 0x3ffc6724.
395 3224 [iot_thread] [DEBUG][MQTT][32240] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Scheduling retry 1 of 3 in 1000 ms.
403 3282 [IP-task] Socket 25012 -> 36bfdd83ip:8883 State eESTABLISHED->eLAST_ACK
404 3282 [NetRecv] [DEBUG][NET][32820] Network receive task terminating.
405 3322 [IP-task] Socket 25012 -> 36bfdd83ip:8883 State eLAST_ACK->eCLOSE_WAIT
406 3326 [Tmr Svc] [DEBUG][TASKPOOL][33260] Timer thread started for task pool 0x3ffc660c.
407 3326 [Tmr Svc] [DEBUG][THREAD][33260] Locking mutex 0x3ffc6724.
408 3326 [Tmr Svc] [DEBUG][TASKPOOL][33260] Scheduling job from timer event.
409 3326 [Tmr Svc] [DEBUG][THREAD][33260] Posting to semaphore 0x3ffc6640.
410 3326 [Tmr Svc] [DEBUG][CLOCK][33260] Arming timer 0x3ffc66e8 with timeout 1197230 and period 4611474741469668876.
411 3326 [Tmr Svc] [DEBUG][THREAD][33260] Unlocking mutex 0x3ffc6724.
412 3327 [iot_thread] [DEBUG][THREAD][33270] Locking mutex 0x3ffc6724.
413 3327 [iot_thread] [DEBUG][THREAD][33270] Unlocking mutex 0x3ffc6724.
414 3327 [iot_thread] [DEBUG][MQTT][33270] Changing PUBLISH packet identifier 7 to 9.
415 3327 [iot_thread] [DEBUG][MQTT][33270] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Sending MQTT packet.
416 3327 [iot_thread] [DEBUG][THREAD][33270] Locking mutex 0x3ffdaca0.
417 3327 [iot_thread] [DEBUG][MQTT][33270] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Job reference changed from 2 to 1.
418 3327 [iot_thread] [DEBUG][THREAD][33270] Unlocking mutex 0x3ffdaca0.
419 3327 [iot_thread] [DEBUG][MQTT][33270] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Waitable operation notified of completion.
420 3327 [iot_thread] [DEBUG][THREAD][33270] Posting to semaphore 0x3fff4010.
421 3327 [iot_thread] [DEBUG][THREAD][33270] Locking mutex 0x3ffc6724.
422 3327 [iot_thread] [DEBUG][THREAD][33270] Unlocking mutex 0x3ffc6724.
423 3327 [OTA Task] [INFO ][MQTT][33270] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Wait complete with result NETWORK ERROR.
424 3327 [OTA Task] [DEBUG][THREAD][33270] Locking mutex 0x3ffdaca0.
425 3327 [OTA Task] [DEBUG][MQTT][33270] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Job reference changed from 1 to 0.
426 3328 [OTA Task] [DEBUG][THREAD][33280] Unlocking mutex 0x3ffdaca0.
427 3328 [OTA Task] [DEBUG][MQTT][33280] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Destroying operation.
428 3328 [OTA Task] [DEBUG][THREAD][33280] Locking mutex 0x3ffdaca0.
429 3328 [OTA Task] [DEBUG][MQTT][33280] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Removed operation from connection lists.
430 3328 [OTA Task] [DEBUG][THREAD][33280] Unlocking mutex 0x3ffdaca0.
431 3328 [OTA Task] [DEBUG][MQTT][33280] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) MQTT packet freed.
432 3328 [OTA Task] [DEBUG][THREAD][33280] Destroying semaphore 0x3fff4010.
433 3328 [OTA Task] [DEBUG][MQTT][33280] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Wait semaphore destroyed.
434 3328 [OTA Task] [DEBUG][MQTT][33280] (MQTT connection 0x3ffdac84, PUBLISH operation 0x3fff3fc8) Operation record destroyed.
435 3328 [OTA Task] [DEBUG][THREAD][33280] Locking mutex 0x3ffdaca0.
436 3328 [OTA Task] [DEBUG][MQTT][33280] (MQTT connection 0x3ffdac84) Reference count changed from 3 to 2.
437 3328 [OTA Task] [DEBUG][THREAD][33280] Unlocking mutex 0x3ffdaca0.
438 3328 [OTA Task] [OTA_CheckForUpdate] Failed to publish MQTT message.
439 3352 [OTA] [OTA_AgentInit_internal] Ready.
440 3352 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
441 4353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
442 4353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
443 5353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
444 5353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
445 6353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
446 6353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
447 7353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
448 7353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
449 8353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
450 8353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
451 9225 [iot_thread] [WARN ][THREAD][92250] Timeout waiting on semaphore 0x3ffc6640.
452 9225 [iot_thread] [DEBUG][THREAD][92250] Locking mutex 0x3ffc6724.
453 9225 [iot_thread] [DEBUG][THREAD][92250] Unlocking mutex 0x3ffc6724.
454 9327 [iot_thread] [WARN ][THREAD][93270] Timeout waiting on semaphore 0x3ffc6640.
455 9327 [iot_thread] [DEBUG][THREAD][93270] Locking mutex 0x3ffc6724.
456 9327 [iot_thread] [DEBUG][THREAD][93270] Unlocking mutex 0x3ffc6724.
457 9353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
458 9353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
459 10353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
460 10353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
461 11353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
462 11353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
463 12353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
464 12353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop
465 13353 [OTA] State: Ready  Received: 0   Queued: 0   Processed: 0   Dropped: 0
466 13353 [OTA] WAHDAN : vRunOTAUpdateDemo : Inside the while loop


TJirsch wrote on September 21, 2019:

I thought that you wanted to do OTA Updates via a MQTT Session connected to a Greengrass host.
This did not work for me, because the MQTT host of Greengrass does not support/offer QOS1, which is needed by the MQTT Session used by OTA, but only QOS1.

embeddedx wrote on September 21, 2019:

Hello,

This is the thing policy


{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iot:*",
        "greengrass:*"
      ],
      "Resource": [
        "*"
      ]
    }
  ]

For the greengrass group I have these subscriptions:


IoT Cloud                   HelloWorld_Publisher              TEST
HelloWorld_Publisher   IoT Cloud                              TEST

I’m not sure if this setup has sth to do witht OTA, but I don’t think so.
What I noticed I just got only on message from the greengrassdemo and one callback!

I stopped the subscription and the publishing of the greengrass demo, I used it for just fetching the greengrass endpoint and credentials, and this what I got from in the cloudwatch log


2019-09-21 08:56:01.966 TRACEID:886fc0b9-8612-c390-35c5-7813975d00ec PRINCIPALID:30388d8fc1290ef9cbc4caa641b343c67f447c1720f935fbbd50eeaab8218c9a [INFO] EVENT:MQTT Client Disconnect MESSAGE: IpAddress: 105.80.18.254 SourcePort: 60933

2019-09-21 08:47:35.917 TRACEID:fc6ab13e-e2b3-312c-d6dc-9837b26e691a PRINCIPALID:MyFirstGroup_Core-gci [INFO] EVENT:GetThingShadow THINGNAME:MyFirstGroup_Core-gci

2019-09-21 08:50:25.844 TRACEID:c710fe91-2037-77a5-1f1f-1f1838ebb40d PRINCIPALID:HelloWorld_Publisher [INFO] EVENT:GetThingShadow THINGNAME:HelloWorld_Publisher

2019-09-21 08:50:28.991 TRACEID:3c02cf43-1c04-450a-c6e1-6970788965c0 PRINCIPALID:713567411902 [INFO] EVENT:MQTT Client Connect MESSAGE:Connect Status: SUCCESS

2019-09-21 08:50:28.991 TRACEID:3c02cf43-1c04-450a-c6e1-6970788965c0 PRINCIPALID:713567411902 [INFO] EVENT:MQTT Client Connect MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001

2019-09-21 08:50:29.259 TRACEID:960477a0-2e8d-3018-f1da-7bcb608dd41f PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/things/HelloWorld_Publisher/shadow/update/rejected MESSAGE:Subscribe Status: SUCCESS
2019-09-21 08:50:29.259 TRACEID:5fe2e9dd-a328-554d-e7fe-5cf49164f289 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.259 TRACEID:960477a0-2e8d-3018-f1da-7bcb608dd41f PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.259 TRACEID:154921b6-233a-5545-ebd9-56e5d4d10a4c PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/things/HelloWorld_Publisher/shadow/delete/accepted MESSAGE:Subscribe Status: SUCCESS
2019-09-21 08:50:29.259 TRACEID:154921b6-233a-5545-ebd9-56e5d4d10a4c PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.259 TRACEID:5fe2e9dd-a328-554d-e7fe-5cf49164f289 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/things/HelloWorld_Publisher/shadow/update/accepted MESSAGE:Subscribe Status: SUCCESS
2019-09-21 08:50:29.264 TRACEID:4eb01bc7-956b-900f-88cb-a8c1f99e5665 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/things/HelloWorld_Publisher/shadow/delete/rejected MESSAGE:Subscribe Status: SUCCESS
2019-09-21 08:50:29.264 TRACEID:1304f6b5-3ca9-76db-49fc-fcfdaf1916ef PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.264 TRACEID:bfffbd1b-fca1-8a07-c8b0-7f4b35f7b4a8 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.264 TRACEID:bfffbd1b-fca1-8a07-c8b0-7f4b35f7b4a8 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/events/presence/disconnected/HelloWorld_Publisher MESSAGE:Subscribe Status: SUCCESS
2019-09-21 08:50:29.264 TRACEID:1304f6b5-3ca9-76db-49fc-fcfdaf1916ef PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/things/HelloWorld_Publisher/shadow/update/documents MESSAGE:Subscribe Status: SUCCESS
2019-09-21 08:50:29.267 TRACEID:0000a23a-5ba9-64bc-72d8-96b32cd2fa88 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/events/subscriptions/subscribed/HelloWorld_Publisher MESSAGE:Subscribe Status: SUCCESS
2019-09-21 08:50:29.267 TRACEID:0000a23a-5ba9-64bc-72d8-96b32cd2fa88 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.269 TRACEID:891df95c-4f45-5b5d-baa9-70894445ecdf PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/events/subscriptions/unsubscribed/HelloWorld_Publisher MESSAGE:Subscribe Status: SUCCESS
2019-09-21 08:50:29.307 TRACEID:7a7c8353-aa2a-d693-4a20-e045bb7f7b46 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/things/HelloWorld_Publisher/shadow/delete/accepted MESSAGE:Subscribe Status: SUCCESS

2019-09-21 08:50:29.264 TRACEID:4eb01bc7-956b-900f-88cb-a8c1f99e5665 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.269 TRACEID:891df95c-4f45-5b5d-baa9-70894445ecdf PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.307 TRACEID:7a7c8353-aa2a-d693-4a20-e045bb7f7b46 PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001
2019-09-21 08:50:29.348 TRACEID:b81ead84-95fb-1869-600a-9261b64cdcdc PRINCIPALID:713567411902 [INFO] EVENT:MQTTClient Subscribe TOPICNAME:$aws/events/presence/connected/HelloWorld_Publisher MESSAGE:Subscribe Status: SUCCESS

2019-09-21 08:56:01.966 TRACEID:886fc0b9-8612-c390-35c5-7813975d00ec PRINCIPALID:30388d8fc1290ef9cbc4caa641b343c67f447c1720f935fbbd50eeaab8218c9a [INFO] EVENT:MQTT Client Disconnect MESSAGE:Disconnect Status: SUCCESS

2019-09-21 08:56:25.803 TRACEID:870336e5-7631-8454-c498-66b69845688b PRINCIPALID:30388d8fc1290ef9cbc4caa641b343c67f447c1720f935fbbd50eeaab8218c9a [INFO] EVENT:MQTT Client Connect MESSAGE:Connect Status: SUCCESS

2019-09-21 08:51:07.360 TRACEID:5a83a76d-6cb0-9aa9-6572-48eef53c12b5 PRINCIPALID:HelloWorld_Publisher [INFO] EVENT:GetThingShadow THINGNAME:HelloWorld_Publisher
2019-09-21 08:56:25.803 TRACEID:870336e5-7631-8454-c498-66b69845688b PRINCIPALID:30388d8fc1290ef9cbc4caa641b343c67f447c1720f935fbbd50eeaab8218c9a [INFO] EVENT:MQTT Client Connect MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62198

2019-09-21 08:44:58.255 TRACEID:bf158382-f521-806d-85ea-aec8b414bf98 PRINCIPALID:MyFirstGroup_Core-gci [INFO] EVENT:GetThingShadow THINGNAME:MyFirstGroup_Core-gci
2019-09-21 09:01:16.100 TRACEID:a5340491-15b0-8bf8-c99c-8f0c774aab09 PRINCIPALID:30388d8fc1290ef9cbc4caa641b343c67f447c1720f935fbbd50eeaab8218c9a [INFO] EVENT:MQTT Client Disconnect MESSAGE:Disconnect Status: SUCCESS

2019-09-21 09:01:16.100 TRACEID:a5340491-15b0-8bf8-c99c-8f0c774aab09 PRINCIPALID:30388d8fc1290ef9cbc4caa641b343c67f447c1720f935fbbd50eeaab8218c9a [INFO] EVENT:MQTT Client Disconnect MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62198

2019-09-21 09:01:43.165 TRACEID:a5ad13b0-e543-97c4-45ae-104c70917986 PRINCIPALID:30388d8fc1290ef9cbc4caa641b343c67f447c1720f935fbbd50eeaab8218c9a [INFO] EVENT:MQTT Client Connect MESSAGE:Connect Status: SUCCESS
2019-09-21 09:01:43.165 TRACEID:a5ad13b0-e543-97c4-45ae-104c70917986 PRINCIPALID:30388d8fc1290ef9cbc4caa641b343c67f447c1720f935fbbd50eeaab8218c9a [INFO] EVENT:MQTT Client Connect MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62392
2019-09-21 09:02:00.737 TRACEID:29275edc-22af-d4d4-f419-3b458cd0f365 PRINCIPALID:713567411902 [INFO] EVENT:HTTP Client Disconnect MESSAGE: IpAddress: 105.80.18.254 SourcePort: 62001

2019-09-21 09:02:00.737 TRACEID:29275edc-22af-d4d4-f419-3b458cd0f365 PRINCIPALID:713567411902 [ERROR] EVENT:HTTP Client Disconnect MESSAGE:Disconnect Status: CLIENT_ERROR Failure reason:DUPLICATE_CLIENT_ID

The last message is kinda interesting.

This is the pcap log of the ESP32
[https://drive.google.com/file/d/1IYcZpBveEK7KO29uazPkFOGm7UAgE3aX/view?usp=sharing]

Edited by: embeddedx on Sep 21, 2019 2:35 AM

TJirsch wrote on September 21, 2019:

As far as I remember this did not work when I tried, because GG MQTT offers only QOS0 while the OTA Agent needs QOS1.
I tried to fiddle with the OTA code to make it use QOS0 but gave up on some point.
The other thing you will need to do is to figure out the GG subscriptions for the ota agent.
You can get them from the greengrass hosts logs as they are reported.
Wildcard subscriptions on the root do not work.

OTA over greengrass would be a really cool feature, because the need for the IoT Thing to connect to the Internet directly would be reduced.

embeddedx wrote on September 21, 2019:

Thanks for this information.

I don’t get this point, do you mean that the broker supports only QOS0 and will not respond to QOS1 requests?

You can get them from the greengrass hosts logs as they are reported.
Wildcard subscriptions on the root do not work.
Could you explain this more. I also have an issue with the greengrass logging (the log folder can’t be accessed with permission denied error) on EC2 instance!

Thank

embeddedx wrote on September 22, 2019:

Thanks for your reply.
I’m trying to do similar to what you did.
The problem is I can’t have two client one for the greengreass and one for IOT cloud, the TLS layer populate with error code -12 and -16 and I don’t find those two errors.
I went to the MQTT demo trying to have two client connection and I had the same error code -16


status = _establishMqttConnection( awsIotMqttMode,
                                           NULL,
                                           pNetworkServerInfo,
                                           pNetworkCredentialInfo,
                                           pNetworkInterface,
                                           &mqttConnection );
         if( status == EXIT_SUCCESS )
         {
             IotLogInfo("Sucess 1 \r
");
                 status = _establishMqttConnection( awsIotMqttMode,
                                           NULL,
                                           pNetworkServerInfo,
                                           pNetworkCredentialInfo,
                                           pNetworkInterface,
                                           &mqttConnection2 );

            if( status == EXIT_SUCCESS )
            {
                IotLogInfo("Sucess 2 \r
");                               
            } 
            else
            {
                    IotLogInfo("Fail 2 \r
");
            }
         }
         else
         {
             IotLogInfo("Fail 1 \r
");
         }

embeddedx wrote on September 23, 2019:

Hi,
I still have the TLS error.
I’m trying to have two separate client connection as I mentioned and creation of the second cliemt connection fails.

embeddedx wrote on September 22, 2019:

Yes that what I’m trying to do, but there is already documentation about OTA over greengrass, so how come the MQTT doesn’t support it?!

Thanks

Gaurav-Aggarwal-AWS wrote on September 23, 2019:

Were you able to resolve this TLS error?

Regarding the approach of sharing the same MQTT connection from Greengrass demo to perform OTA over greengrass, I was able to solve the NETWORK_ERROR during MQTT publish by changing MQTT Publishs to QoS0 instead of QoS1 in the OTA code. But I am still not able to get the OTA job notification and OTA data on the device.

Note that this is not something which is officially supported and I am trying this for the first time myself. I’ll try to get more information about this.

Thanks.

embeddedx wrote on September 22, 2019:

Sorry the document is about the core update not the devices connected to it.
However having two MQTT clients one for greengrass and the other for OTA over IOT core is failing!
Have you managed to have both demos working together?

TJirsch wrote on September 22, 2019:

I did that with an app completely separate from the demos, because in my opinion the demos are harder to adapt than to start from scratch.

I started building the app to connect to greengrass shadows properly and then integrated the ota functionality from the demos, example code and guessing.

It works with two mqtt connections. I also needed to connect to an existing onsite non AWS mqtt host and had to start tweaking mbedtls parameters to squeeze the tree connections in.
I ended up with a scheduled task scenario, that terminated the two mqtt connections, started ota, checked for update jobs and restarted the other “normal” mqtt connections.

The check does not take longer than one or two minutes and it was ok for this usecase to loose connections to the iot backend for that time.

aggarg wrote on September 24, 2019:

I am now able to get OTA via Greengrass working. There are some code changes needed:

  1. Use MQTT connection to Greengrass for OTA (basically similar to what you did already).
  2. Change MQTT Quality of Service to QoS0 from QoS1 in the OTA Agent - replace all IOT_MQTT_QOS_1 with IOT_MQTT_QOS_0 in libraries/freertos_plus/aws/ota/src/aws_iot_ota_agent.c.

After the above code changes, you need to establish the following Subscriptions for your Greengrass group (Replace greengrass_thing with your thing name):


Device to Cloud
$aws/things/greengrass_thing/jobs/$next/get
$aws/things/greengrass_thing/jobs/+/update
$aws/things/greengrass_thing/streams/+/get/cbor

Cloud to Device
$aws/things/greengrass_thing/jobs/$next/get/accepted
$aws/things/greengrass_thing/jobs/notify-next
$aws/things/greengrass_thing/streams/+/data/cbor

After the above changes, it works for me.

Thanks.