Skip to content

Commit

Permalink
Merge pull request #99 from ActoryOu/fixOtaDemo
Browse files Browse the repository at this point in the history
Move OTA max data buffer number to project configurations.
  • Loading branch information
ActoryOu authored Jul 29, 2024
2 parents 87cc57a + be24b76 commit ee2901e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
esp_idf_version: ${{ matrix.esp_idf_version }}
target: ${{ matrix.esp_target }}
path: './'
command: python -m pip install --upgrade idf-component-manager || idf.py build
command: python -m pip install --upgrade idf-component-manager && idf.py build
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/trans
# This gives MQTT_TEST_SOURCES, and MQTT_TEST_INCLUDE_DIRS
include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/mqtt_test.cmake)

# This gives OTA_PAL_TEST_SOURCES, and OTA_PAL_TEST_INCLUDE_DIRS
include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/ota_pal_test.cmake)

# This gives PKCS11_TEST_SOURCES, and PKCS11_TEST_INCLUDE_DIRS
include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/pkcs11_test.cmake)

Expand Down
16 changes: 8 additions & 8 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ menu "Featured FreeRTOS IoT Integration"
bool "Transport Interface Test."
default n

config GRI_OTA_PAL_TEST_ENABLED
bool "OTA PAL Test."
default n

config GRI_OTA_E2E_TEST_ENABLED
bool "OTA end-to-end Test."
default n

config GRI_CORE_PKCS11_TEST_ENABLED
bool "CorePKCS#11 Test."
default n
Expand Down Expand Up @@ -211,6 +203,10 @@ menu "Featured FreeRTOS IoT Integration"
int "OTA demo task stack size."
default 3072

config GRI_OTA_MAX_NUM_DATA_BUFFERS
int "OTA buffer number."
default 2

endmenu # OTA demo configurations
endmenu # Qualification Test Configurations

Expand Down Expand Up @@ -463,6 +459,10 @@ menu "Featured FreeRTOS IoT Integration"
int "Application version build."
default 0

config GRI_OTA_MAX_NUM_DATA_BUFFERS
int "OTA buffer number."
default 2

endmenu # OTA demo configurations

endmenu # Golden Reference Integration
Expand Down
7 changes: 3 additions & 4 deletions main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
#define MAX_THING_NAME_SIZE 128U

#define MAX_JOB_ID_LENGTH ( 64U )
#define MAX_NUM_OF_OTA_DATA_BUFFERS ( 2U )

/**
* @brief Used to clear bits in a task's notification value.
Expand Down Expand Up @@ -229,7 +228,7 @@ static uint8_t currentFileId = 0;
static uint32_t totalBytesReceived = 0;
char globalJobId[ MAX_JOB_ID_LENGTH ] = { 0 };

static OtaDataEvent_t dataBuffers[ otaconfigMAX_NUM_OTA_DATA_BUFFERS ] = { 0 };
static OtaDataEvent_t dataBuffers[ otademoconfigMAX_NUM_OTA_DATA_BUFFERS ] = { 0 };
static OtaJobEventData_t jobDocBuffer = { 0 };
static AfrOtaJobDocumentFields_t jobFields = { 0 };
static uint8_t OtaImageSignatureDecoded[ OTA_MAX_SIGNATURE_SIZE ] = { 0 };
Expand Down Expand Up @@ -898,7 +897,7 @@ static uint16_t getFreeOTABuffers( void )

if( xSemaphoreTake( bufferSemaphore, portMAX_DELAY ) == pdTRUE )
{
for( ulIndex = 0; ulIndex < MAX_NUM_OF_OTA_DATA_BUFFERS; ulIndex++ )
for( ulIndex = 0; ulIndex < otademoconfigMAX_NUM_OTA_DATA_BUFFERS; ulIndex++ )
{
if( dataBuffers[ ulIndex ].bufferUsed == false )
{
Expand Down Expand Up @@ -940,7 +939,7 @@ static OtaDataEvent_t * getOtaDataEventBuffer( void )

if( xSemaphoreTake( bufferSemaphore, portMAX_DELAY ) == pdTRUE )
{
for( ulIndex = 0; ulIndex < MAX_NUM_OF_OTA_DATA_BUFFERS; ulIndex++ )
for( ulIndex = 0; ulIndex < otademoconfigMAX_NUM_OTA_DATA_BUFFERS; ulIndex++ )
{
if( dataBuffers[ ulIndex ].bufferUsed == false )
{
Expand Down
29 changes: 17 additions & 12 deletions main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,61 +43,66 @@
/**
* @brief The thing name of the device.
*/
#define otademoconfigCLIENT_IDENTIFIER ( CONFIG_GRI_THING_NAME )
#define otademoconfigCLIENT_IDENTIFIER ( CONFIG_GRI_THING_NAME )

/**
* @brief The maximum size of the file paths used in the demo.
*/
#define otademoconfigMAX_FILE_PATH_SIZE ( CONFIG_GRI_OTA_DEMO_MAX_FILE_PATH_SIZE )
#define otademoconfigMAX_FILE_PATH_SIZE ( CONFIG_GRI_OTA_DEMO_MAX_FILE_PATH_SIZE )

/**
* @brief The maximum size of the stream name required for downloading update file
* from streaming service.
*/
#define otademoconfigMAX_STREAM_NAME_SIZE ( CONFIG_GRI_OTA_DEMO_MAX_STREAM_NAME_SIZE )
#define otademoconfigMAX_STREAM_NAME_SIZE ( CONFIG_GRI_OTA_DEMO_MAX_STREAM_NAME_SIZE )

/**
* @brief The delay used in the OTA demo task to periodically output the OTA
* statistics like number of packets received, dropped, processed and queued per connection.
*/
#define otademoconfigTASK_DELAY_MS ( CONFIG_GRI_OTA_DEMO_TASK_DELAY_MS )
#define otademoconfigTASK_DELAY_MS ( CONFIG_GRI_OTA_DEMO_TASK_DELAY_MS )

/**
* @brief The maximum time for which OTA demo waits for an MQTT operation to be complete.
* This involves receiving an acknowledgment for broker for SUBSCRIBE, UNSUBSCRIBE and non
* QOS0 publishes.
*/
#define otademoconfigMQTT_TIMEOUT_MS ( CONFIG_GRI_OTA_DEMO_MQTT_TIMEOUT_MS )
#define otademoconfigMQTT_TIMEOUT_MS ( CONFIG_GRI_OTA_DEMO_MQTT_TIMEOUT_MS )

/**
* @brief The task priority of OTA agent task.
*/
#define otademoconfigAGENT_TASK_PRIORITY ( CONFIG_GRI_OTA_DEMO_AGENT_TASK_PRIORITY )
#define otademoconfigAGENT_TASK_PRIORITY ( CONFIG_GRI_OTA_DEMO_AGENT_TASK_PRIORITY )

/**
* @brief The stack size of OTA agent task.
*/
#define otademoconfigAGENT_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_AGENT_TASK_STACK_SIZE )
#define otademoconfigAGENT_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_AGENT_TASK_STACK_SIZE )

/**
* @brief The task priority of the OTA demo task.
*/
#define otademoconfigDEMO_TASK_PRIORITY ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_PRIORITY )
#define otademoconfigDEMO_TASK_PRIORITY ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_PRIORITY )

/**
* @brief The task stack size of the OTA demo task.
*/
#define otademoconfigDEMO_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE )
#define otademoconfigDEMO_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE )

/**
* @brief The number of OTA data buffer.
*/
#define otademoconfigMAX_NUM_OTA_DATA_BUFFERS ( CONFIG_GRI_OTA_MAX_NUM_DATA_BUFFERS )

/**
* @brief The version for the firmware which is running. OTA agent uses this
* version number to perform anti-rollback validation. The firmware version for the
* download image should be higher than the current version, otherwise the new image is
* rejected in self test phase.
*/
#define APP_VERSION_MAJOR ( CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR )
#define APP_VERSION_MINOR ( CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR )
#define APP_VERSION_BUILD ( CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD )
#define APP_VERSION_MAJOR ( CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR )
#define APP_VERSION_MINOR ( CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR )
#define APP_VERSION_BUILD ( CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD )

/* *INDENT-OFF* */
#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CONFIG_LWIP_MAX_SOCKETS=8
# AWS OTA
CONFIG_LOG2_FILE_BLOCK_SIZE=12
CONFIG_MAX_NUM_BLOCKS_REQUEST=8
CONFIG_MAX_NUM_OTA_DATA_BUFFERS=8
CONFIG_GRI_OTA_MAX_NUM_DATA_BUFFERS=2
CONFIG_ALLOW_DOWNGRADE=0
CONFIG_OTA_DATA_OVER_MQTT=y
# CONFIG_OTA_DATA_OVER_HTTP is not set
Expand Down

0 comments on commit ee2901e

Please sign in to comment.