-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Conversation
Remove OTA demo specific conditional macros used in the demo. Remove dependency on network manager APIs. Remove dependency on aws_iot_demo_network.c Add MQTT disconnect reason logs in the disconnect callback. Update doxygen and other comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
demos/ota/aws_iot_ota_update_demo.c
Outdated
|
||
#define myappONE_SECOND_DELAY_IN_TICKS pdMS_TO_TICKS( 1000UL ) | ||
/** | ||
* @brief Timeout for MQTT connection, if the MQTT connection is not establihsed within |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling: established
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing this, Thank you for pointing it out.
demos/ota/aws_iot_ota_update_demo.c
Outdated
* @brief Timeout for MQTT connection, if the MQTT connection is not establihsed within | ||
* this time, the connect function returns #IOT_MQTT_TIMEOUT | ||
*/ | ||
#define OTA_DEMO_CONNECTION_TIMEOUT ( 2000UL ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What units is this in? If it is milliseconds, please rename to OTA_DEMO_CONNECTION_TIMEOUT_MS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must have the ms , changing it to OTA_DEMO_CONNECTION_TIMEOUT_MS
* by the MQTT 3.1.1 spec) is 23 characters. Add 1 to include the length of the NULL | ||
* terminator. | ||
*/ | ||
#define OTA_DEMO_CLIENT_IDENTIFIER_MAX_LENGTH ( 24 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be available in an MQTT header file somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not defined in MQTT library , the MQTT demo has its definition similar to what we are doing here.
demos/ota/aws_iot_ota_update_demo.c
Outdated
} | ||
|
||
static BaseType_t prxCreateNetworkConnection( void ) | ||
/** | ||
* @brief Delay before retrying network connection upto a maximum interval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling: up to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing this to up to , thanks.
demos/ota/aws_iot_ota_update_demo.c
Outdated
} | ||
} | ||
} while( ulRetriesLeft-- > 0 ); | ||
intervalTicks = pdMS_TO_TICKS( retryInterval * 1000 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would add some jitter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding jitter in commit 50e1814 using rand so devices will initiate reconnection anywhere within the interval window.
demos/ota/aws_iot_ota_update_demo.c
Outdated
if( xMqttInitStatus != IOT_MQTT_SUCCESS ) | ||
{ | ||
xRet = EXIT_FAILURE; | ||
while( ( ( eState = OTA_GetAgentState() ) != eOTA_AgentState_Stopped ) && networkConnected ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is networkConnected
set to pdFALSE
? I notice it's not declared volatile
. If some other task is setting it, some compilers might optimize this test away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_networkConnected is set false in disconnect callback, fixed in dec8c99
demos/ota/aws_iot_ota_update_demo.c
Outdated
* @brief The maximum time interval that is permitted to elapse between the point at | ||
* which the MQTT client finishes transmitting one control Packet and the point it starts | ||
* sending the next.In the absence of control packet a PINGREQ is sent. The broker must | ||
* disconnect a client that does not send a a message or a PINGREQ packet in one and a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correction send a message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks , fixing this.
demos/ota/aws_iot_ota_update_demo.c
Outdated
* @brief The delay used in the main OTA Demo task loop to periodically output the OTA | ||
* statistics like number of packets received, dropped, processed and queued per connection. | ||
*/ | ||
#define OTA_DEMO_ONE_SECOND_DELAY pdMS_TO_TICKS( 1000UL ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be made in seconds as well for easy configuration and understanding by user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this in 0ac73bd
Also renamed it to make sense if the value is changed from 1 sec.
demos/ota/aws_iot_ota_update_demo.c
Outdated
/* Connect to one of the network type.*/ | ||
xRet = xMqttDemoCreateNetworkConnection( &xConnection, otaDemoNETWORK_TYPES ); | ||
#endif | ||
configPRINTF( ( "Retrying network connection in %d Secs ", retryInterval ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest using IotLog for logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to IotLog in commit ea768f3
demos/ota/aws_iot_ota_update_demo.c
Outdated
( void ) awsIotMqttMode; | ||
( void ) pIdentifier; | ||
( void ) pNetworkServerInfo; | ||
retryInterval = OTA_DEMO_CONN_RETRY_BASE_INTERVAL_SECONDS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should retry interval be reset back to OTA_DEMO_CONN_RETRY_BASE_INTERVAL_SECONDS
once a successful connection is made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it can be reset to base time interval, making a change to address this.
demos/ota/aws_iot_ota_update_demo.c
Outdated
xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( clientcredentialIOT_THING_NAME ); | ||
xConnectInfo.pClientIdentifier = clientcredentialIOT_THING_NAME; | ||
/* Suspend OTA agent.*/ | ||
OTA_Suspend(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be called from main OTA demo for(;;)
loop before tearing down MQTT connection. Otherwise it can cause race condition if MQTT connection is deleted but OTA agent is still active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is moved in the OTA Demo loop in commit c567abe
demos/ota/aws_iot_ota_update_demo.c
Outdated
} | ||
|
||
/* Try to close the MQTT connection. */ | ||
if( ( mqttConnection != NULL ) && networkConnected ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Teardown mqtt connection resources in network disconnected case as well ? , by calling IotMqtt_Disconnect( mqttConnection, true);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit dec8c99
* Add E2E tests for OTA suspend and resume * Add doctring to OTA E2E test cases * Fix typos in the OTA E2E tests docstring
…ertos into prasad/OTA_Suspend_Resume
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small thing, see comments.
demos/ota/aws_iot_ota_update_demo.c
Outdated
{ | ||
/* Wait forever for OTA traffic but allow other tasks to run and output statistics only once per second. */ | ||
vTaskDelay( OTA_DEMO_ONE_SECOND_DELAY ); | ||
IotClock_SleepMs( OTA_DEMO_TASK_DELAY * 1000 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be named OTA_DEMO_TASK_DELAY_SECONDS
. If a #define
value is in units (time/distance/mass/etc.), include the unit in the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in 1815858
OTA Suspend and Resume Feature
Description
This is a draft pull request not for merging.
Checklist:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.