Skip to content

Commit

Permalink
aws-iot-core-mqtt-file-streams-embedded-c: Port related cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Sheth committed Jul 18, 2024
1 parent c262c06 commit b9ca562
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 432 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ idf_component_register(

set_source_files_properties(
"${CMAKE_CURRENT_LIST_DIR}/aws-iot-core-mqtt-file-streams-embedded-c/source/MQTTFileDownloader.c"
PROPERTIES COMPILE_FLAGS -Wno-format)
PROPERTIES COMPILE_FLAGS -Wno-format)

if (NOT CONFIG_MQTT_STREAMS_USE_CUSTOM_CONFIG)
target_compile_definitions( ${COMPONENT_TARGET} PUBLIC MQTT_STREAMS_DO_NOT_USE_CUSTOM_CONFIG=1 )
endif()
67 changes: 8 additions & 59 deletions libraries/aws-iot-core-mqtt-file-streams-embedded-c/Kconfig
Original file line number Diff line number Diff line change
@@ -1,61 +1,4 @@
menu "AWS OTA"

config MAX_NUM_BLOCKS_REQUEST
int "The maximum number of data blocks requested from OTA streaming service."
default 1
range 1 4294967295
help
This configuration parameter is sent with data requests and represents the maximum number of
data blocks the service will send in response. The maximum limit for this must be calculated
from the maximum data response limit (128 KB from service) divided by the block size.
For example if block size is set as 1 KB then the maximum number of data blocks that we can
request is 128/1 = 128 blocks. Configure this parameter to this maximum limit or lower based on
how many data blocks response is expected for each data requests.

config MAX_NUM_OTA_DATA_BUFFERS
int "The number of data buffers reserved by the OTA agent."
default 2
range 1 4294967295
help
This configurations parameter sets the maximum number of static data buffers used by
the OTA agent for job and file data blocks received.

config ALLOW_DOWNGRADE
int "Allow OTA update to same or lower version."
default 0
range 0 1
help
Set this to 1 to allow downgrade or same version update. This configurations parameter
disables version check and allows update to a same or lower version. This is provided for
testing purpose and it is recommended to always update to higher version and keep this
configuration disabled.

config OTA_DATA_OVER_MQTT
bool "Enable data over MQTT"
default y

config OTA_DATA_OVER_HTTP
bool "Enable data over HTTP"
default n

choice OTA_PRIMARY_DATA_PROTOCOL
bool "Primary Data Protocol"
default OTA_DATA_OVER_MQTT_PRIMARY
help
Primary data protocol will be the protocol used for downloading file if more than
one protocol is selected while creating OTA job.
config OTA_DATA_OVER_MQTT_PRIMARY
bool "MQTT"
depends on OTA_DATA_OVER_MQTT
config OTA_DATA_OVER_HTTP_PRIMARY
bool "HTTP"
depends on OTA_DATA_OVER_HTTP
endchoice

config OTA_PRIMARY_DATA_PROTOCOL
int
default 1 if OTA_DATA_OVER_MQTT_PRIMARY
default 2 if OTA_DATA_OVER_HTTP_PRIMARY
menu "AWS MQTT File Streams"

menu "Logging"

Expand All @@ -77,4 +20,10 @@ menu "AWS OTA"

endmenu # AWS OTA Logging

endmenu # AWS OTA
config MQTT_STREAMS_USE_CUSTOM_CONFIG
bool "MQTT Streams use custom config"
default n
help
This configuration parameter allows you to provide custom configurations for OTA over MQTT.

endmenu # AWS OTA
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "sdkconfig.h"
#include "MQTTFileDownloader.h"
#include "MQTTFileDownloader_defaults.h"

#define OTA_DATA_BLOCK_SIZE ( mqttFileDownloader_CONFIG_BLOCK_SIZE )
#define JOB_DOC_SIZE ( 2048U )
Expand Down Expand Up @@ -101,139 +102,4 @@

/************ End of logging configuration ****************/

/**
* @brief Size of the file data block message (excluding the header).
*
*/
#define otaconfigFILE_BLOCK_SIZE ( 1UL << otaconfigLOG2_FILE_BLOCK_SIZE )

/**
* @brief Milliseconds to wait for the self test phase to succeed before we force reset.
*/
#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 60000U

/**
* @brief Milliseconds to wait before requesting data blocks from the OTA service if nothing is happening.
*
* The wait timer is reset whenever a data block is received from the OTA service so we will only send
* the request message after being idle for this amount of time.
*/
#define otaconfigFILE_REQUEST_WAIT_MS 10000U

/**
* @brief The maximum allowed length of the thing name used by the OTA agent.
*
* AWS IoT requires Thing names to be unique for each device that connects to the broker.
* Likewise, the OTA agent requires the developer to construct and pass in the Thing name when
* initializing the OTA agent. The agent uses this size to allocate static storage for the
* Thing name used in all OTA base topics. Namely $aws/things/<thingName>
*/
#define otaconfigMAX_THINGNAME_LEN 64U

/**
* @brief The maximum number of data blocks requested from OTA streaming service.
*
* This configuration parameter is sent with data requests and represents the maximum number of
* data blocks the service will send in response. The maximum limit for this must be calculated
* from the maximum data response limit (128 KB from service) divided by the block size.
* For example if block size is set as 1 KB then the maximum number of data blocks that we can
* request is 128/1 = 128 blocks. Configure this parameter to this maximum limit or lower based on
* how many data blocks response is expected for each data requests.
* @note This must be set larger than zero.
*
*/
#define otaconfigMAX_NUM_BLOCKS_REQUEST CONFIG_MAX_NUM_BLOCKS_REQUEST

/**
* @brief The maximum number of requests allowed to send without a response before we abort.
*
* This configuration parameter sets the maximum number of times the requests are made over
* the selected communication channel before aborting and returning error.
*
*/
#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U

/**
* @brief The number of data buffers reserved by the OTA agent.
*
* This configurations parameter sets the maximum number of static data buffers used by
* the OTA agent for job and file data blocks received.
*/
#define otaconfigMAX_NUM_OTA_DATA_BUFFERS CONFIG_MAX_NUM_OTA_DATA_BUFFERS

/**
* @brief How frequently the device will report its OTA progress to the cloud.
*
* Device will update the job status with the number of blocks it has received every certain
* number of blocks it receives. For example, 25 means device will update job status every 25 blocks
* it receives.
*/
#define otaconfigOTA_UPDATE_STATUS_FREQUENCY 25U

/**
* @brief Allow update to same or lower version.
*
* Set this to 1 to allow downgrade or same version update. This configurations parameter
* disables version check and allows update to a same or lower version. This is provided for
* testing purpose and it is recommended to always update to higher version and keep this
* configuration disabled.
*/
#define otaconfigAllowDowngrade CONFIG_ALLOW_DOWNGRADE

/**
* @brief The protocol selected for OTA control operations.
*
* This configurations parameter sets the default protocol for all the OTA control
* operations like requesting OTA job, updating the job status etc.
*
* Note - Only MQTT is supported at this time for control operations.
*/
#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT )

#define CONFIG_OTA_DATA_OVER_MQTT 1
#define CONFIG_OTA_PRIMARY_DATA_PROTOCOL 1

/**
* @brief The protocol selected for OTA data operations.
*
* This configurations parameter sets the protocols selected for the data operations
* like requesting file blocks from the service.
*
* Note - Both MQTT and HTTP is supported for data transfer. This configuration parameter
* can be set to following -
* Enable data over MQTT - ( OTA_DATA_OVER_MQTT )
* Enable data over HTTP - ( OTA_DATA_OVER_HTTP)
* Enable data over both MQTT & HTTP ( OTA_DATA_OVER_MQTT | OTA_DATA_OVER_HTTP )
*/

#if CONFIG_OTA_DATA_OVER_MQTT && CONFIG_OTA_DATA_OVER_HTTP
#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT | OTA_DATA_OVER_HTTP )
#elif CONFIG_OTA_DATA_OVER_HTTP
#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_HTTP )
#elif CONFIG_OTA_DATA_OVER_MQTT
#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT )
#else
#error "No protocol defined for OTA data operations."
#endif

/**
* @brief The preferred protocol selected for OTA data operations.
*
* Primary data protocol will be the protocol used for downloading file if more than
* one protocol is selected while creating OTA job. Default primary data protocol is MQTT
* and following update here to switch to HTTP as primary.
*
* Note - use OTA_DATA_OVER_HTTP for HTTP as primary data protocol.
*/

#if defined(CONFIG_OTA_PRIMARY_DATA_PROTOCOL)
#if CONFIG_OTA_PRIMARY_DATA_PROTOCOL == 1
#define configOTA_PRIMARY_DATA_PROTOCOL ( OTA_DATA_OVER_MQTT )
#elif CONFIG_OTA_PRIMARY_DATA_PROTOCOL == 2
#define configOTA_PRIMARY_DATA_PROTOCOL ( OTA_DATA_OVER_HTTP )
#endif
#else
#error "Primary data protocol for OTA data operations not defined."
#endif

#endif /* OTA_CONFIG_H_ */
Loading

0 comments on commit b9ca562

Please sign in to comment.