Skip to content

Commit 4ea2d0e

Browse files
[v2.0.0] Fix MISRA Violations, Update Changelog, Update Version Numbers and add Migration Guide (aws#116)
* Resolve MISRA violations given by Coverity * Fix Formating * Update Changelog and version numbers in source files * Add Migrating Guide for versions >= 20.0.0 * Update the Migration Guide * Fix Formating * Update the upload-artifact version number in workflows
1 parent 6ddba19 commit 4ea2d0e

File tree

15 files changed

+104
-18
lines changed

15 files changed

+104
-18
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
ctest -E system --output-on-failure
9292
cd ..
9393
- name: Create artifact of ZIP
94-
uses: actions/upload-artifact@v2
94+
uses: actions/upload-artifact@v4
9595
with:
9696
name: Jobs-for-AWS-IoT-embedded-sdk-${{ github.event.inputs.version_number }}.zip
9797
path: zip-check/Jobs-for-AWS-IoT-embedded-sdk-${{ github.event.inputs.version_number }}.zip

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog for AWS IoT Jobs Library
22

3+
## v2.0.0
4+
- [#105](https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk/pull/105), [#109](https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk/pull/109) Change the `Jobs_UpdateMsg` API signature to include optional status parameters.
5+
- [#99](https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk/pull/99) Update CBMC version to 5.95.1
6+
- [#113](https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk/pull/113) Update links for coverity related information.
7+
- [#115](https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk/pull/115) Add support for optional job document fields
8+
39
## v1.5.1 (June 2024)
410
- Fix doxygen deployment on Github
511

MigrationGuide.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Migration guide for Jobs-for-AWS-IoT-embedded-sdk version $\geq$ v2.0.0
2+
3+
With Jobs-for-AWS-IoT-embedded-sdk versions $\geq$ v2.0.0, there are some breaking changes that need to be addressed when upgrading.
4+
5+
## Breaking Changes
6+
7+
The signature of the `Jobs_UpdateMsg` API has been changed from
8+
```c
9+
size_t Jobs_UpdateMsg( JobCurrentStatus_t status,
10+
const char * expectedVersion,
11+
size_t expectedVersionLength,
12+
char * buffer,
13+
size_t bufferSize )
14+
```
15+
to
16+
```c
17+
size_t Jobs_UpdateMsg( JobsUpdateRequest_t request,
18+
char * buffer,
19+
size_t bufferSize );
20+
```
21+
A new structure `JobsUpdateRequest_t` has been introduced. This struct is now passed as a parameter to the API to include values like `status`, `expectedVersion` and `expectedVersionLength` which were earlier direct input to the API. All values in the struct except `status` are now optional. Following is the definition of the `JobsUpdateRequest_t` struct.
22+
```c
23+
typedef struct
24+
{
25+
JobCurrentStatus_t status; /**< Status to update the job to. */
26+
const char * expectedVersion; /**< Expected version, optional. */
27+
size_t expectedVersionLength; /**< Expected version length, optional. */
28+
const char * statusDetails; /**< JSON key-value pair, optional. */
29+
size_t statusDetailsLength; /**< JSON key-value pair length, optional. */
30+
} JobsUpdateRequest_t;
31+
```
32+
### Old Code Snippet
33+
```c
34+
const char * expectedVersion = "2";
35+
size_t expectedVersionLength = ( sizeof(expectedVersion ) - 1U );
36+
JobCurrentStatus_t status = Succeeded;
37+
char messageBuffer[ UPDATE_JOB_MSG_LENGTH ] = {0};
38+
size_t messageLength = 0U;
39+
40+
messageLength = Jobs_UpdateMsg( status,
41+
expectedVersion,
42+
expectedVersionLength,
43+
messageBuffer,
44+
UPDATE_JOB_MSG_LENGTH );
45+
46+
if (messageLength > 0 )
47+
{
48+
// The message string of length, messageLength, has been
49+
// generated in the buffer, messageBuffer, for the UpdateJobExecution API
50+
// Publish this message to the topic generated by Jobs_Update using an
51+
// MQTT client of your choice.
52+
}
53+
```
54+
55+
### New Code Snippet
56+
```c
57+
const char * expectedVersion = "2";
58+
const chat * statusDetails = "{\"key\":\"value\"}"; // This can be any user defined JSON key value pair
59+
char messageBuffer[ UPDATE_JOB_MSG_LENGTH ] = {0};
60+
size_t messageLength = 0U;
61+
62+
JobsUpdateRequest_t request;
63+
request.status = Succeeded;
64+
request.expectedVersion = expectedVersion;
65+
request.expectedVersionLength = ( sizeof( expectedVersion ) - 1U );
66+
request.statusDetails = statusDetails;
67+
request.statusDetailsLength = ( sizeof( statusDetails ) - 1U );
68+
69+
messageLength = Jobs_UpdateMsg( request
70+
messageBuffer,
71+
UPDATE_JOB_MSG_LENGTH );
72+
73+
if (messageBufferLength > 0 )
74+
{
75+
// The message string of length, messageLength, has been
76+
// generated in the buffer, messageBuffer, for the UpdateJobExecution API
77+
// Publish this message to the topic generated by Jobs_Update using an
78+
// MQTT client of your choice.
79+
}
80+
```

docs/doxygen/config.doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = "AWS IoT Jobs"
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = v1.5.1
51+
PROJECT_NUMBER = v2.0.0
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name : "Jobs-for-AWS-IoT-embedded-sdk"
2-
version: "v1.5.1"
2+
version: "v2.0.0"
33
description: |
44
"Library for using the AWS IoT Jobs service on embedded devices.\n"
55
license: "MIT"

source/include/jobs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* AWS IoT Jobs v1.5.1
2+
* AWS IoT Jobs v2.0.0
33
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT
@@ -897,7 +897,7 @@ JobsStatus_t Jobs_Update( char * buffer,
897897
* messageBuffer,
898898
* UPDATE_JOB_MSG_LENGTH );
899899
*
900-
* if (messageBufferLength > 0 )
900+
* if (messageLength > 0 )
901901
* {
902902
* // The message string of length, messageLength, has been
903903
* // generated in the buffer, messageBuffer, for the UpdateJobExecution API

source/jobs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* AWS IoT Jobs v1.5.1
2+
* AWS IoT Jobs v2.0.0
33
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* SPDX-License-Identifier: MIT
@@ -839,7 +839,7 @@ static size_t getOptionalFieldsLength( JobsUpdateRequest_t request )
839839
minimumOptionalFieldsBufferSize += JOBS_API_EXPECTED_VERSION_LENGTH + request.expectedVersionLength;
840840
}
841841

842-
if( ( request.statusDetails != NULL ) && ( request.statusDetailsLength ) )
842+
if( ( request.statusDetails != NULL ) && ( request.statusDetailsLength > 0U ) )
843843
{
844844
minimumOptionalFieldsBufferSize += JOBS_API_STATUS_DETAILS_LENGTH + request.statusDetailsLength;
845845
}
@@ -871,9 +871,9 @@ static bool areOptionalFieldsValid( JobsUpdateRequest_t request )
871871
{
872872
bool optionalFieldsValid = true;
873873

874-
if( ( request.statusDetails != NULL ) && ( request.statusDetailsLength ) )
874+
if( ( request.statusDetails != NULL ) && ( request.statusDetailsLength > 0U ) )
875875
{
876-
optionalFieldsValid &= ( JSONSuccess == JSON_Validate( request.statusDetails, request.statusDetailsLength ) );
876+
optionalFieldsValid = ( JSONSuccess == JSON_Validate( request.statusDetails, request.statusDetailsLength ) );
877877
}
878878

879879
return optionalFieldsValid;
@@ -887,7 +887,7 @@ size_t Jobs_UpdateMsg( JobsUpdateRequest_t request,
887887

888888
size_t start = 0U;
889889
size_t minimumBufferSize = getRequiredFieldsLength( request ) + getOptionalFieldsLength( request );
890-
bool writeFailed = bufferSize < minimumBufferSize || !areOptionalFieldsValid( request );
890+
bool writeFailed = ( bufferSize < minimumBufferSize ) || !areOptionalFieldsValid( request );
891891

892892
if( !writeFailed )
893893
{

source/otaJobParser/include/job_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* AWS IoT Jobs v1.5.1
2+
* AWS IoT Jobs v2.0.0
33
* Copyright (C) 2023 Amazon.com, Inc. and its affiliates. All Rights Reserved.
44
* SPDX-License-Identifier: MIT
55
*

source/otaJobParser/include/ota_job_processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* AWS IoT Jobs v1.5.1
2+
* AWS IoT Jobs v2.0.0
33
* Copyright (C) 2023 Amazon.com, Inc. and its affiliates. All Rights Reserved.
44
* SPDX-License-Identifier: MIT
55
*

source/otaJobParser/job_parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* AWS IoT Jobs v1.5.1
2+
* AWS IoT Jobs v2.0.0
33
* Copyright (C) 2023 Amazon.com, Inc. and its affiliates. All Rights Reserved.
44
* SPDX-License-Identifier: MIT
55
*

0 commit comments

Comments
 (0)