├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── ci.yml │ ├── tag-and-zip.yml │ ├── update-submodules.yml │ ├── upload-release.yml │ └── version-updater.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── MISRA.md ├── README.md ├── SECURITY.md ├── demos ├── CMakeLists.txt ├── certificates │ └── .gitignore ├── defender │ └── defender_demo_json │ │ ├── CMakeLists.txt │ │ ├── core_mqtt_config.h │ │ ├── defender_config.h │ │ ├── defender_demo.c │ │ ├── demo_config.h │ │ ├── metrics_collector.c │ │ ├── metrics_collector.h │ │ ├── mqtt_operations.c │ │ ├── mqtt_operations.h │ │ ├── report_builder.c │ │ └── report_builder.h ├── http │ ├── common │ │ ├── include │ │ │ └── http_demo_utils.h │ │ └── src │ │ │ ├── README.md │ │ │ ├── http_demo_utils.c │ │ │ └── presigned_urls_gen.py │ ├── http_demo_basic_tls │ │ ├── CMakeLists.txt │ │ ├── core_http_config.h │ │ ├── demo_config.h │ │ └── http_demo_basic_tls.c │ ├── http_demo_mutual_auth │ │ ├── CMakeLists.txt │ │ ├── core_http_config.h │ │ ├── demo_config.h │ │ └── http_demo_mutual_auth.c │ ├── http_demo_plaintext │ │ ├── CMakeLists.txt │ │ ├── core_http_config.h │ │ ├── demo_config.h │ │ └── http_demo_plaintext.c │ ├── http_demo_s3_download │ │ ├── CMakeLists.txt │ │ ├── core_http_config.h │ │ ├── demo_config.h │ │ └── http_demo_s3_download.c │ ├── http_demo_s3_download_multithreaded │ │ ├── CMakeLists.txt │ │ ├── core_http_config.h │ │ ├── demo_config.h │ │ └── http_demo_s3_download_multithreaded.c │ └── http_demo_s3_upload │ │ ├── CMakeLists.txt │ │ ├── core_http_config.h │ │ ├── demo_config.h │ │ └── http_demo_s3_upload.c ├── jobs │ └── jobs_demo_mosquitto │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── Makefile │ │ ├── README.md │ │ ├── demo_config.h │ │ └── jobs_demo_mosquitto.c ├── lexicon.txt ├── logging-stack │ ├── logging.cmake │ ├── logging_levels.h │ └── logging_stack.h ├── mqtt │ ├── mqtt_demo_basic_tls │ │ ├── CMakeLists.txt │ │ ├── core_mqtt_config.h │ │ ├── demo_config.h │ │ └── mqtt_demo_basic_tls.c │ ├── mqtt_demo_mutual_auth │ │ ├── CMakeLists.txt │ │ ├── core_mqtt_config.h │ │ ├── demo_config.h │ │ └── mqtt_demo_mutual_auth.c │ ├── mqtt_demo_plaintext │ │ ├── CMakeLists.txt │ │ ├── core_mqtt_config.h │ │ ├── demo_config.h │ │ └── mqtt_demo_plaintext.c │ ├── mqtt_demo_serializer │ │ ├── CMakeLists.txt │ │ ├── core_mqtt_config.h │ │ ├── demo_config.h │ │ └── mqtt_demo_serializer.c │ └── mqtt_demo_subscription_manager │ │ ├── CMakeLists.txt │ │ ├── core_mqtt_config.h │ │ ├── demo_config.h │ │ ├── mqtt_demo_subscription_manager.c │ │ └── subscription-manager │ │ ├── CMakeLists.txt │ │ ├── mqtt_subscription_manager.c │ │ └── mqtt_subscription_manager.h ├── ota │ ├── common │ │ ├── include │ │ │ ├── http_demo_utils.h │ │ │ └── mqtt_subscription_manager.h │ │ └── src │ │ │ ├── http_demo_utils.c │ │ │ └── mqtt_subscription_manager.c │ ├── ota_demo_core_http │ │ ├── CMakeLists.txt │ │ ├── core_http_config.h │ │ ├── core_mqtt_config.h │ │ ├── demo_config.h │ │ ├── ota_config.h │ │ └── ota_demo_core_http.c │ └── ota_demo_core_mqtt │ │ ├── CMakeLists.txt │ │ ├── core_mqtt_config.h │ │ ├── demo_config.h │ │ ├── ota_config.h │ │ └── ota_demo_core_mqtt.c ├── pkcs11 │ ├── common │ │ ├── include │ │ │ ├── core_pkcs11_config.h │ │ │ ├── demo_helpers.h │ │ │ └── mbedtls_config.h │ │ └── src │ │ │ └── demo_helpers.c │ ├── pkcs11_demo_management_and_rng │ │ ├── CMakeLists.txt │ │ └── pkcs11_demo_management_and_rng.c │ ├── pkcs11_demo_mechanisms_and_digests │ │ ├── CMakeLists.txt │ │ └── pkcs11_demo_mechanisms_and_digests.c │ ├── pkcs11_demo_objects │ │ ├── CMakeLists.txt │ │ └── pkcs11_demo_objects.c │ └── pkcs11_demo_sign_and_verify │ │ ├── CMakeLists.txt │ │ └── pkcs11_demo_sign_and_verify.c └── shadow │ └── shadow_demo_main │ ├── CMakeLists.txt │ ├── core_mqtt_config.h │ ├── demo_config.h │ ├── shadow_config.h │ ├── shadow_demo_helpers.c │ ├── shadow_demo_helpers.h │ └── shadow_demo_main.c ├── doc ├── architecture.png ├── architecture.txt ├── config │ ├── common │ ├── html │ │ ├── footer.html │ │ ├── header.html │ │ └── style.css │ ├── layout_library.xml │ ├── layout_main.xml │ ├── main │ └── mqtt └── lib │ └── mqtt.txt ├── docs ├── doxygen │ ├── building.dox │ ├── config.doxyfile │ ├── demos │ │ ├── defender_demo.dox │ │ ├── demos_main.dox │ │ ├── http_demo.dox │ │ ├── jobs_demo.dox │ │ ├── mqtt_demo.dox │ │ ├── ota_demo.dox │ │ ├── pkcs11_demo.dox │ │ └── shadow_demo.dox │ ├── developer │ │ ├── developer.dox │ │ └── style.dox │ ├── images │ │ ├── defender_demo.png │ │ ├── defender_demo.pu │ │ ├── http_demo_basic_tls.png │ │ ├── http_demo_basic_tls.pu │ │ ├── http_demo_mutual_auth.png │ │ ├── http_demo_mutual_auth.pu │ │ ├── http_demo_plaintext.png │ │ ├── http_demo_plaintext.pu │ │ ├── http_demo_s3_download.png │ │ ├── http_demo_s3_download.pu │ │ ├── http_demo_s3_download_multithreaded.png │ │ ├── http_demo_s3_download_multithreaded.pu │ │ ├── http_demo_s3_upload.png │ │ ├── http_demo_s3_upload.pu │ │ ├── jobs_demo.png │ │ ├── jobs_demo.pu │ │ ├── logging_architecture.png │ │ ├── logging_architecture.xml │ │ ├── mqtt_basic_tls.png │ │ ├── mqtt_demo_diagrams.xml │ │ ├── mqtt_mutual_auth.png │ │ ├── mqtt_plaintext.png │ │ ├── mqtt_serializer.png │ │ ├── mqtt_subscription_manager.png │ │ ├── ota_demo_core_http.pu │ │ ├── ota_demo_core_http.svg │ │ ├── ota_demo_core_mqtt.pu │ │ ├── ota_demo_core_mqtt.svg │ │ ├── pkcs11_digest.png │ │ ├── pkcs11_object_generate.png │ │ ├── pkcs11_object_import.png │ │ ├── pkcs11_rng.png │ │ ├── pkcs11_sign_verify.png │ │ ├── retry_utils_flow.png │ │ ├── retry_utils_flow.pu │ │ ├── shadow_demo_main.png │ │ └── shadow_demo_main.pu │ ├── layout.xml │ ├── logging.dox │ ├── migration │ │ ├── jobs.dox │ │ ├── migration.dox │ │ ├── mqtt.dox │ │ └── shadow.dox │ ├── pages.dox │ ├── plantuml │ │ ├── pkcs11_digest.pu │ │ ├── pkcs11_object_generate.pu │ │ ├── pkcs11_object_import.pu │ │ ├── pkcs11_rng.pu │ │ └── pkcs11_sign_verify.pu │ └── style.css ├── doxygen_guide.md ├── doxygen_templates │ ├── config.doxyfile │ ├── layout.xml │ ├── pages.dox │ └── style.css ├── lexicon.txt └── utest_guide.md ├── integration-test ├── CMakeLists.txt ├── certificates │ └── .gitignore ├── http │ ├── CMakeLists.txt │ ├── core_http_config.h │ ├── http_system_test.c │ └── test_config.h ├── lexicon.txt ├── mqtt │ ├── CMakeLists.txt │ ├── core_mqtt_config.h │ ├── mqtt_system_test.c │ └── test_config.h └── shadow │ ├── CMakeLists.txt │ ├── core_mqtt_config.h │ ├── shadow_config.h │ ├── shadow_system_test.c │ └── test_config.h ├── libraries ├── 3rdparty │ └── CMakeLists.txt └── CMakeLists.txt ├── manifest.yml ├── platform ├── CMakeLists.txt ├── include │ └── clock.h ├── lexicon.txt └── posix │ ├── CMakeLists.txt │ ├── clock_posix.c │ ├── ota_pal │ ├── CMakeLists.txt │ ├── source │ │ ├── include │ │ │ └── ota_pal_posix.h │ │ └── ota_pal_posix.c │ └── utest │ │ ├── CMakeLists.txt │ │ ├── mocks │ │ ├── openssl_api.h │ │ ├── stdio_api.h │ │ └── unistd_api.h │ │ ├── ota_config.h │ │ └── ota_pal_posix_utest.c │ ├── posixFilePaths.cmake │ ├── transport │ ├── CMakeLists.txt │ ├── include │ │ ├── openssl_posix.h │ │ ├── plaintext_posix.h │ │ └── sockets_posix.h │ ├── src │ │ ├── openssl_posix.c │ │ ├── plaintext_posix.c │ │ └── sockets_posix.c │ └── utest │ │ ├── CMakeLists.txt │ │ ├── mocks │ │ ├── openssl_api.h │ │ ├── select_api.h │ │ ├── stdio_api.h │ │ └── unistd_api.h │ │ ├── openssl_utest.c │ │ ├── plaintext_utest.c │ │ └── sockets_utest.c │ └── utest │ ├── CMakeLists.txt │ ├── clock_utest.c │ └── mocks │ └── time_api.h └── tools ├── cmake ├── install.cmake └── utility.cmake ├── cmock ├── cmock_dependencies.cmake ├── coverage.cmake ├── create_test.cmake ├── ota.yml ├── project.yml └── transport.yml ├── coverity └── misra.config ├── doxygen ├── README.md └── generate_docs.py ├── link-verifier ├── README.md ├── allowlist.txt ├── requirements.txt └── verify-links.py ├── release ├── README.md ├── release-verify.py └── requirements.txt ├── spell ├── README.md ├── ablexicon ├── extract-comments └── find-unknown-comment-words └── uncrustify.cfg /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license. 7 | -------------------------------------------------------------------------------- /.github/workflows/update-submodules.yml: -------------------------------------------------------------------------------- 1 | name: Update Library Submodules 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | branch: 7 | description: 'Target branch for raising PR' 8 | required: true 9 | default: main 10 | allowed: 11 | description: 'Optional regex pattern passed to `grep` to update only the specified library submodules, e.g. "ota\|jobs" updates only libraries with "ota" or "jobs" in the name.' 12 | required: false 13 | default: .* 14 | 15 | jobs: 16 | update-submodules: 17 | name: Update submodules 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout code 21 | uses: actions/checkout@v2 22 | with: 23 | submodules: true 24 | - name: Configure Git identity 25 | run: | 26 | git config --global user.name "Submodule Updater" 27 | - name: Update the submodules 28 | run: | 29 | libs=$(find libraries/standard libraries/aws -maxdepth 1 -mindepth 1 | grep "${{ github.event.inputs.allowed }}") 30 | git submodule update --remote $libs 31 | - name: Commit changes and Push to remote 32 | run: | 33 | now="$(date +'%d-%m-%Y')" 34 | branch="updater-job/submodules-$now" 35 | git checkout -b $branch 36 | git commit -am 'Updating library submodules to the latest.' 37 | git push --set-upstream origin $branch 38 | - name: Raise a Pull-Request 39 | env: 40 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 41 | run: | 42 | gh pr create --base ${{ github.event.inputs.branch }} --title 'Update library submodules to the latest' --body 'Update library submodules to the latest' 43 | -------------------------------------------------------------------------------- /.github/workflows/upload-release.yml: -------------------------------------------------------------------------------- 1 | name: Create Release for Existing Tag 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | workflow_name: 7 | description: 'Name of workflow (file name) to obtain ZIP from' 8 | default: tag-and-zip 9 | required: false 10 | workflow_id: 11 | description: 'Workflow Run ID to obtain ZIP from' 12 | required: true 13 | version_number: 14 | description: 'Tag Version Number (Eg, 202012.00) to release' 15 | required: true 16 | 17 | jobs: 18 | create-release: 19 | name: Create Release and Upload Release Asset 20 | runs-on: ubuntu-18.04 21 | steps: 22 | - name: Create Release 23 | id: create_release 24 | uses: actions/create-release@v1 25 | env: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | with: 28 | tag_name: ${{ github.event.inputs.version_number }} 29 | release_name: ${{ github.event.inputs.version_number }} 30 | body: Release version ${{ github.event.inputs.version_number }} of the AWS IoT Device SDK for Embedded C. 31 | draft: false 32 | prerelease: false 33 | - name: Download ZIP artifact 34 | uses: dawidd6/action-download-artifact@v2 35 | with: 36 | github_token: ${{secrets.GITHUB_TOKEN}} 37 | # Required, workflow file name or ID 38 | workflow: ${{ github.event.inputs.workflow_name }}.yml 39 | run_id: ${{ github.event.inputs.run_id }} 40 | name: aws-iot-device-sdk-embedded-C-${{ github.event.inputs.version_number }}.zip 41 | - name: Upload Release Asset 42 | id: upload-release-asset 43 | uses: actions/upload-release-asset@v1 44 | env: 45 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 46 | with: 47 | upload_url: ${{ steps.create_release.outputs.upload_url }} 48 | asset_path: ./aws-iot-device-sdk-embedded-C-${{ github.event.inputs.version_number }}.zip 49 | asset_name: aws-iot-device-sdk-embedded-C-${{ github.event.inputs.version_number }}.zip 50 | asset_content_type: application/zip 51 | -------------------------------------------------------------------------------- /.github/workflows/version-updater.yml: -------------------------------------------------------------------------------- 1 | name: Source File Version Updater 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | branch: 7 | description: 'Target branch for raising PR' 8 | required: true 9 | new_version_number: 10 | description: 'New version Number (Eg, v1.1.0)' 11 | required: true 12 | old_version_number: 13 | description: 'Old version Number (Eg, v1.0.0)' 14 | required: true 15 | 16 | jobs: 17 | update-version: 18 | name: Update Version in source files 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Checkout code 22 | uses: actions/checkout@v2 23 | with: 24 | ref: ${{ github.event.inputs.branch }} 25 | - name: Configure git identity 26 | run: | 27 | git config --global user.name "Version Updater" 28 | - name: Update source files with new version 29 | run: | 30 | grep -ilr ${{ github.event.inputs.old_version_number }} . | grep -Ev ".git|CHANGELOG.md|README.md|CONTRIBUTING.md" | xargs sed -i s/${{ github.event.inputs.old_version_number }}/${{ github.event.inputs.new_version_number }}/g 31 | - name: Commit changes and Push to remote 32 | run: | 33 | git checkout -b updater-job/update-to-${{ github.event.inputs.new_version_number }} 34 | git commit -am 'Update versioning in file from ${{ github.event.inputs.old_version_number }} to ${{ github.event.inputs.new_version_number }}' 35 | git push --set-upstream origin updater-job/update-to-${{ github.event.inputs.new_version_number }} 36 | - name: Raise a Pull-Request 37 | env: 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 39 | run: | 40 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 41 | sudo apt-add-repository https://cli.github.com/packages 42 | sudo apt update 43 | sudo apt-get install gh 44 | gh pr create --base ${{ github.event.inputs.branch }} --title 'Update source file versioning to ${{ github.event.inputs.new_version_number }}' --body 'Updater-Job: PR to update versioning in source files from ${{ github.event.inputs.old_version_numver }} to ${{ github.event.inputs.new_version_number }}' 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore documentation output. 2 | **/docs/**/output/* 3 | 4 | # Ignore CMake build directory. 5 | build/ 6 | 7 | # Ignore build artifacts 8 | *.o 9 | 10 | # Ignore code coverage artifacts 11 | *.gcda 12 | *.gcno 13 | *.gcov 14 | 15 | # Ignore certificate files 16 | *.pem 17 | *.crt 18 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libraries/3rdparty/CMock"] 2 | path = libraries/3rdparty/CMock 3 | url = https://github.com/ThrowTheSwitch/CMock 4 | [submodule "libraries/standard/coreMQTT"] 5 | path = libraries/standard/coreMQTT 6 | branch = main 7 | url = https://github.com/FreeRTOS/coreMQTT.git 8 | [submodule "libraries/standard/coreHTTP"] 9 | path = libraries/standard/coreHTTP 10 | branch = main 11 | url = https://github.com/FreeRTOS/coreHTTP.git 12 | [submodule "libraries/standard/coreJSON"] 13 | path = libraries/standard/coreJSON 14 | branch = main 15 | url = https://github.com/FreeRTOS/coreJSON.git 16 | [submodule "libraries/aws/device-shadow-for-aws-iot-embedded-sdk"] 17 | path = libraries/aws/device-shadow-for-aws-iot-embedded-sdk 18 | branch = main 19 | url = https://github.com/aws/device-shadow-for-aws-iot-embedded-sdk.git 20 | [submodule "libraries/aws/jobs-for-aws-iot-embedded-sdk"] 21 | path = libraries/aws/jobs-for-aws-iot-embedded-sdk 22 | branch = main 23 | url = https://github.com/aws/jobs-for-aws-iot-embedded-sdk.git 24 | [submodule "libraries/aws/device-defender-for-aws-iot-embedded-sdk"] 25 | path = libraries/aws/device-defender-for-aws-iot-embedded-sdk 26 | branch = main 27 | url = https://github.com/aws/device-defender-for-aws-iot-embedded-sdk.git 28 | [submodule "libraries/standard/corePKCS11"] 29 | path = libraries/standard/corePKCS11 30 | branch = main 31 | url = https://github.com/FreeRTOS/corePKCS11.git 32 | [submodule "libraries/standard/backoffAlgorithm"] 33 | path = libraries/standard/backoffAlgorithm 34 | branch = main 35 | url = https://github.com/FreeRTOS/backoffAlgorithm.git 36 | [submodule "libraries/aws/ota-for-aws-iot-embedded-sdk"] 37 | path = libraries/aws/ota-for-aws-iot-embedded-sdk 38 | branch = main 39 | url = https://github.com/aws/ota-for-aws-iot-embedded-sdk.git 40 | [submodule "demos/jobs/jobs_demo_mosquitto/libmosquitto"] 41 | path = demos/jobs/jobs_demo_mosquitto/libmosquitto 42 | url = https://github.com/eclipse/mosquitto.git 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | ## Reporting a Vulnerability 2 | 3 | If you discover a potential security issue in this project, we ask that you notify AWS/Amazon Security 4 | via our [vulnerability reporting page](https://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. 5 | Please do **not** create a public github issue. -------------------------------------------------------------------------------- /demos/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Set the platform named based on the host OS if not defined. 2 | if( NOT DEFINED PLATFORM_NAME ) 3 | if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" ) 4 | set( PLATFORM_NAME "posix" CACHE STRING "Port to use for building the SDK." ) 5 | else() 6 | message( FATAL_ERROR "${CMAKE_SYSTEM_NAME} is not a supported platform." ) 7 | endif() 8 | endif() 9 | 10 | # Include each subdirectory that has a CMakeLists.txt file in it 11 | file(GLOB demo_dirs "${DEMOS_DIR}/*/*") 12 | foreach(demo_dir IN LISTS demo_dirs) 13 | if(IS_DIRECTORY "${demo_dir}" AND EXISTS "${demo_dir}/CMakeLists.txt") 14 | add_subdirectory(${demo_dir}) 15 | endif() 16 | endforeach() 17 | 18 | # Filter demos based on what packages or library exist. 19 | if(${LIB_RT} STREQUAL "LIB_RT-NOTFOUND") 20 | set(librt_demos 21 | "http_demo_s3_download_multithreaded" 22 | "ota_demo_core_http" 23 | "ota_demo_core_mqtt" 24 | ) 25 | message( WARNING "rt library could not be found. Demos that use it will be excluded from the default target." ) 26 | foreach(demo_name ${librt_demos}) 27 | set_target_properties(${demo_name} PROPERTIES EXCLUDE_FROM_ALL true) 28 | endforeach() 29 | endif() 30 | if(NOT ${OpenSSL_FOUND}) 31 | set(openssl_demos 32 | "defender_demo" 33 | "http_demo_basic_tls" 34 | "http_demo_mutual_auth" 35 | "http_demo_s3_download" 36 | "http_demo_s3_download_multithreaded" 37 | "http_demo_s3_upload" 38 | "mqtt_demo_basic_tls" 39 | "mqtt_demo_mutual_auth" 40 | "mqtt_demo_subscription_manager" 41 | "ota_demo_core_http" 42 | "ota_demo_core_mqtt" 43 | "shadow_demo_main" 44 | ) 45 | message( WARNING "OpenSSL library could not be found. Demos that use it will be excluded from the default target." ) 46 | foreach(demo_name ${openssl_demos}) 47 | set_target_properties(${demo_name} PROPERTIES EXCLUDE_FROM_ALL true) 48 | endforeach() 49 | endif() 50 | if(NOT ${Threads_FOUND}) 51 | set(thread_demos 52 | "ota_demo_core_http" 53 | "ota_demo_core_mqtt" 54 | ) 55 | message( WARNING "Threads library could not be found. Demos that use it will be excluded from the default target." ) 56 | foreach(demo_name ${thread_demos}) 57 | set_target_properties(${demo_name} PROPERTIES EXCLUDE_FROM_ALL true) 58 | endforeach() 59 | endif() 60 | -------------------------------------------------------------------------------- /demos/certificates/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /demos/defender/defender_demo_json/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "defender_demo" ) 2 | 3 | # Include MQTT library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Include JSON library's source and header path variables. 10 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreJSON/jsonFilePaths.cmake ) 11 | 12 | # Include Defender library's source and header path variables. 13 | include( ${CMAKE_SOURCE_DIR}/libraries/aws/device-defender-for-aws-iot-embedded-sdk/defenderFilePaths.cmake ) 14 | 15 | # Demo target. 16 | add_executable( ${DEMO_NAME} 17 | "defender_demo.c" 18 | "metrics_collector.c" 19 | "mqtt_operations.c" 20 | "report_builder.c" 21 | ${MQTT_SOURCES} 22 | ${MQTT_SERIALIZER_SOURCES} 23 | ${BACKOFF_ALGORITHM_SOURCES} 24 | ${JSON_SOURCES} 25 | ${DEFENDER_SOURCES} ) 26 | 27 | target_link_libraries( ${DEMO_NAME} PRIVATE 28 | clock_posix 29 | openssl_posix ) 30 | 31 | target_include_directories( ${DEMO_NAME} PUBLIC 32 | ${LOGGING_INCLUDE_DIRS} 33 | ${MQTT_INCLUDE_PUBLIC_DIRS} 34 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 35 | ${JSON_INCLUDE_PUBLIC_DIRS} 36 | ${DEFENDER_INCLUDE_PUBLIC_DIRS} 37 | ${CMAKE_CURRENT_LIST_DIR} ) 38 | 39 | set_macro_definitions(TARGETS ${DEMO_NAME} 40 | REQUIRED 41 | "AWS_IOT_ENDPOINT" 42 | "ROOT_CA_CERT_PATH" 43 | "CLIENT_CERT_PATH" 44 | "CLIENT_PRIVATE_KEY_PATH" 45 | "CLIENT_IDENTIFIER" 46 | "THING_NAME" 47 | OPTIONAL 48 | "CLIENT_USERNAME" 49 | "CLIENT_PASSWORD" 50 | "OS_NAME" 51 | "OS_VERSION" 52 | "HARDWARE_PLATFORM_NAME") 53 | -------------------------------------------------------------------------------- /demos/defender/defender_demo_json/defender_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef DEFENDER_CONFIG_H_ 24 | #define DEFENDER_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros. 33 | * 3. Include the header file "logging_stack.h". 34 | */ 35 | 36 | #include "logging_levels.h" 37 | 38 | /* Logging configuration for the Defender library. */ 39 | #ifndef LIBRARY_LOG_NAME 40 | #define LIBRARY_LOG_NAME "Defender" 41 | #endif 42 | 43 | #ifndef LIBRARY_LOG_LEVEL 44 | #define LIBRARY_LOG_LEVEL LOG_NONE 45 | #endif 46 | 47 | #include "logging_stack.h" 48 | 49 | /************ End of logging configuration ****************/ 50 | 51 | #endif /* ifndef DEFENDER_CONFIG_H_ */ 52 | -------------------------------------------------------------------------------- /demos/http/common/src/README.md: -------------------------------------------------------------------------------- 1 | # Presigned S3 URLs Generator 2 | 3 | `presigned_url_gen.py` generates pre-signed URLs for S3 HTTP GET and PUT request access. 4 | 5 | ### Dependencies 6 | 7 | * Python 3+ 8 | * boto3 9 | * argparse 10 | 11 | ### Prerequisites 12 | 13 | 1. Install the dependencies. 14 | ```sh 15 | pip install boto3 argparse 16 | ``` 17 | 18 | 1. You will need an AWS Account with S3 access before beginning. You must install and configure the AWS CLI in order to 19 | use this script. 20 | For information on AWS S3 please see: https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html 21 | For AWS CLI installation information please see: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html 22 | For AWS CLI configuration information please see: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html 23 | 24 | ```sh 25 | aws configure 26 | ``` 27 | 28 | ### Usage 29 | 30 | 1. Run `presigned_url_gen.py` with your s3 bucket name and s3 object key. 31 | ```sh 32 | ./presigned_urls_gen.py --bucket --key 33 | ``` 34 | An example expected output: 35 | ``` 36 | #define S3_PRESIGNED_GET_URL "https://aws-s3-endpoint/object-key.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ABABABABABABABABABAB%2F20201027%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20201027T194726Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=SomeHash12345UrlABcdEFgfIjK" 37 | #define S3_PRESIGNED_PUT_URL "https://aws-s3-endpoint/object-key.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ABABABABABABABABABAB%2F20201027%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20201027T194726Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=SomeHash12345UrlLMnmOPqrStUvW" 38 | ``` 39 | 1. Copy and paste the output to `demo_config.h` for macros `S3_PRESIGNED_GET_URL` and `S3_PRESIGNED_PUT_URL`. 40 | ```c 41 | #define S3_PRESIGNED_GET_URL "https://aws-s3-endpoint/object-key.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ABABABABABABABABABAB%2F20201027%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20201027T194726Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=SomeHash12345UrlABcdEFgfIjK" 42 | #define S3_PRESIGNED_PUT_URL "https://aws-s3-endpoint/object-key.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ABABABABABABABABABAB%2F20201027%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20201027T194726Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=SomeHash12345UrlLMnmOPqrStUvW" 43 | ``` 44 | 45 | ### Parameters 46 | 47 | #### --bucket 48 | The name of the S3 bucket from which the demo will download or upload. 49 | 50 | #### --key 51 | The name of the existing object you wish to download (GET), 52 | or the name of the object you wish to upload (PUT). 53 | 54 | #### --region 55 | Optional parameter for the AWS region in which the bucket is located. 56 | 57 | -------------------------------------------------------------------------------- /demos/http/common/src/presigned_urls_gen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import boto3 4 | from botocore.client import Config 5 | import argparse 6 | 7 | 8 | def get_presigned_urls(bucket_name, key_name, region_name) -> None: 9 | """ 10 | Prints the presigned GET and PUT URLs assigned to the demo specific C 11 | macros, for the given object key in the given S3 bucket. If the region 12 | parameter is not defined, boto3 will use the one configured using AWS CLI. 13 | The URLs are presigned with AWS's Signature Version 4. 14 | Args: 15 | bucket_name (str): S3 bucket 16 | key_name (str): S3 object key 17 | region_name (str): S3 bucket's region 18 | """ 19 | 20 | # Get the service client. 21 | # SigV2 is being deprecated. If the boto3 installation in the current Python environment has an older version of 22 | # the package, then this configuration forces the use of SigV4. 23 | s3 = boto3.client("s3", config=Config(signature_version="s3v4", region_name=region_name)) 24 | 25 | client_method_dict = {"GET": "get_object", "PUT": "put_object"} 26 | 27 | # Generate the URL to get 'key-name' from 'bucket-name' 28 | for method in client_method_dict.keys(): 29 | url = s3.generate_presigned_url( 30 | ClientMethod=client_method_dict[method], 31 | Params={"Bucket": bucket_name, "Key": key_name}, 32 | ) 33 | print("#define S3_PRESIGNED_" + method + "_URL" + " " + '"' + url + '"\n') 34 | 35 | 36 | def main(): 37 | """ 38 | Generate demo C macro strings, on the console, for the input S3 bucket and object key. 39 | """ 40 | parser = argparse.ArgumentParser(description="S3 Presigned URL Generator. See README.md") 41 | parser.add_argument( 42 | "--bucket", 43 | action="store", 44 | required=True, 45 | dest="bucket_name", 46 | help="The name of the S3 bucket of interest.", 47 | ) 48 | parser.add_argument( 49 | "--key", 50 | action="store", 51 | required=True, 52 | dest="key_name", 53 | help="The name of the S3 Object in the bucket. This is referred to as a 'key'", 54 | ) 55 | parser.add_argument( 56 | "--region", 57 | action="store", 58 | required=False, 59 | dest="region_name", 60 | help="The region in which the S3 bucket of interest is created.", 61 | ) 62 | args = parser.parse_args() 63 | 64 | get_presigned_urls(args.bucket_name, args.key_name, args.region_name) 65 | 66 | 67 | if __name__ == "__main__": # pragma: no cover 68 | main() 69 | -------------------------------------------------------------------------------- /demos/http/http_demo_basic_tls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "http_demo_basic_tls" ) 2 | 3 | # Include HTTP library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreHTTP/httpFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | "${DEMOS_DIR}/http/common/src/http_demo_utils.c" 14 | ${HTTP_SOURCES} 15 | ${HTTP_THIRD_PARTY_SOURCES} 16 | ${BACKOFF_ALGORITHM_SOURCES} 17 | ) 18 | 19 | target_link_libraries( 20 | ${DEMO_NAME} 21 | PRIVATE 22 | clock_posix 23 | openssl_posix 24 | ) 25 | 26 | target_include_directories( 27 | ${DEMO_NAME} 28 | PUBLIC 29 | "${DEMOS_DIR}/http/common/include" 30 | ${HTTP_INCLUDE_PUBLIC_DIRS} 31 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 32 | ${CMAKE_CURRENT_LIST_DIR} 33 | ${LOGGING_INCLUDE_DIRS} 34 | ) 35 | 36 | set_macro_definitions(TARGETS ${DEMO_NAME} 37 | REQUIRED 38 | "SERVER_HOST" 39 | "HTTPS_PORT" 40 | "ROOT_CA_CERT_PATH") 41 | -------------------------------------------------------------------------------- /demos/http/http_demo_basic_tls/core_http_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_HTTP_CONFIG_H_ 24 | #define CORE_HTTP_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Logging config definition and header files inclusion are required in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for HTTP. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for HTTP. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the HTTP library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "HTTP" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | /************ End of logging configuration ****************/ 51 | 52 | #endif /* ifndef CORE_HTTP_CONFIG_H_ */ 53 | -------------------------------------------------------------------------------- /demos/http/http_demo_mutual_auth/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "http_demo_mutual_auth" ) 2 | 3 | # Include HTTP library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreHTTP/httpFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | "${DEMOS_DIR}/http/common/src/http_demo_utils.c" 14 | ${HTTP_SOURCES} 15 | ${HTTP_THIRD_PARTY_SOURCES} 16 | ${BACKOFF_ALGORITHM_SOURCES} 17 | ) 18 | 19 | target_link_libraries( 20 | ${DEMO_NAME} 21 | PRIVATE 22 | clock_posix 23 | openssl_posix 24 | ) 25 | 26 | target_include_directories( 27 | ${DEMO_NAME} 28 | PUBLIC 29 | "${DEMOS_DIR}/http/common/include" 30 | ${HTTP_INCLUDE_PUBLIC_DIRS} 31 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 32 | ${CMAKE_CURRENT_LIST_DIR} 33 | ${LOGGING_INCLUDE_DIRS} 34 | ) 35 | 36 | if(ROOT_CA_CERT_PATH) 37 | target_compile_definitions( 38 | ${DEMO_NAME} PRIVATE 39 | ROOT_CA_CERT_PATH="${ROOT_CA_CERT_PATH}" 40 | ) 41 | endif() 42 | if(AWS_HTTPS_PORT) 43 | target_compile_definitions( 44 | ${DEMO_NAME} PRIVATE 45 | AWS_HTTPS_PORT=${AWS_HTTPS_PORT} 46 | ) 47 | endif() 48 | set_macro_definitions(TARGETS ${DEMO_NAME} 49 | REQUIRED 50 | "SERVER_HOST" 51 | "AWS_HTTPS_PORT" 52 | "ROOT_CA_CERT_PATH") 53 | set_macro_definitions(TARGETS ${DEMO_NAME} 54 | REQUIRED 55 | "AWS_IOT_ENDPOINT" 56 | "CLIENT_CERT_PATH" 57 | "CLIENT_PRIVATE_KEY_PATH" 58 | "ROOT_CA_CERT_PATH") 59 | -------------------------------------------------------------------------------- /demos/http/http_demo_mutual_auth/core_http_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_HTTP_CONFIG_H_ 24 | #define CORE_HTTP_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Logging config definition and header files inclusion are required in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for HTTP. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for HTTP. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the HTTP library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "HTTP" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | 51 | /************ End of logging configuration ****************/ 52 | 53 | #endif /* ifndef CORE_HTTP_CONFIG_H_ */ 54 | -------------------------------------------------------------------------------- /demos/http/http_demo_plaintext/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "http_demo_plaintext" ) 2 | 3 | # Include HTTP library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreHTTP/httpFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | "${DEMOS_DIR}/http/common/src/http_demo_utils.c" 14 | ${HTTP_SOURCES} 15 | ${HTTP_THIRD_PARTY_SOURCES} 16 | ${BACKOFF_ALGORITHM_SOURCES} 17 | ) 18 | 19 | target_link_libraries( 20 | ${DEMO_NAME} 21 | PRIVATE 22 | clock_posix 23 | plaintext_posix 24 | ) 25 | 26 | target_include_directories( 27 | ${DEMO_NAME} 28 | PUBLIC 29 | "${DEMOS_DIR}/http/common/include" 30 | ${HTTP_INCLUDE_PUBLIC_DIRS} 31 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 32 | ${CMAKE_CURRENT_LIST_DIR} 33 | ${LOGGING_INCLUDE_DIRS} 34 | ) 35 | 36 | set_macro_definitions(TARGETS ${DEMO_NAME} 37 | OPTIONAL 38 | "SERVER_HOST" 39 | "HTTP_PORT") 40 | -------------------------------------------------------------------------------- /demos/http/http_demo_plaintext/core_http_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_HTTP_CONFIG_H_ 24 | #define CORE_HTTP_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for HTTP. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for HTTP. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the HTTP library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "HTTP" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | 51 | /************ End of logging configuration ****************/ 52 | 53 | #endif /* ifndef CORE_HTTP_CONFIG_H_ */ 54 | -------------------------------------------------------------------------------- /demos/http/http_demo_s3_download/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "http_demo_s3_download" ) 2 | 3 | # Include HTTP library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreHTTP/httpFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | "${DEMOS_DIR}/http/common/src/http_demo_utils.c" 14 | ${HTTP_SOURCES} 15 | ${HTTP_THIRD_PARTY_SOURCES} 16 | ${BACKOFF_ALGORITHM_SOURCES} 17 | ) 18 | 19 | target_link_libraries( 20 | ${DEMO_NAME} 21 | PRIVATE 22 | clock_posix 23 | openssl_posix 24 | ) 25 | 26 | target_include_directories( 27 | ${DEMO_NAME} 28 | PUBLIC 29 | "${DEMOS_DIR}/http/common/include" 30 | ${HTTP_INCLUDE_PUBLIC_DIRS} 31 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 32 | ${HTTP_INCLUDE_THIRD_PARTY_DIRS} 33 | ${HTTP_INCLUDE_PRIVATE_DIRS} 34 | ${CMAKE_CURRENT_LIST_DIR} 35 | ${LOGGING_INCLUDE_DIRS} 36 | ) 37 | 38 | set_macro_definitions(TARGETS ${DEMO_NAME} 39 | REQUIRED 40 | "S3_PRESIGNED_GET_URL" 41 | "HTTPS_PORT" 42 | "ROOT_CA_CERT_PATH") 43 | -------------------------------------------------------------------------------- /demos/http/http_demo_s3_download/core_http_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_HTTP_CONFIG_H_ 24 | #define CORE_HTTP_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for HTTP. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for HTTP. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the HTTP library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "HTTP" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | 51 | /************ End of logging configuration ****************/ 52 | 53 | #endif /* ifndef CORE_HTTP_CONFIG_H_ */ 54 | -------------------------------------------------------------------------------- /demos/http/http_demo_s3_download_multithreaded/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "http_demo_s3_download_multithreaded" ) 2 | 3 | # Include HTTP library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreHTTP/httpFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | "${DEMOS_DIR}/http/common/src/http_demo_utils.c" 14 | ${HTTP_SOURCES} 15 | ${HTTP_THIRD_PARTY_SOURCES} 16 | ${BACKOFF_ALGORITHM_SOURCES} 17 | ) 18 | 19 | target_link_libraries( 20 | ${DEMO_NAME} 21 | PRIVATE 22 | clock_posix 23 | openssl_posix 24 | rt 25 | ) 26 | 27 | target_include_directories( 28 | ${DEMO_NAME} 29 | PUBLIC 30 | "${DEMOS_DIR}/http/common/include" 31 | ${HTTP_INCLUDE_PUBLIC_DIRS} 32 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 33 | ${HTTP_INCLUDE_THIRD_PARTY_DIRS} 34 | ${HTTP_INCLUDE_PRIVATE_DIRS} 35 | ${CMAKE_CURRENT_LIST_DIR} 36 | ${LOGGING_INCLUDE_DIRS} 37 | ) 38 | 39 | set_macro_definitions(TARGETS ${DEMO_NAME} 40 | REQUIRED 41 | "S3_PRESIGNED_GET_URL" 42 | "HTTPS_PORT" 43 | "ROOT_CA_CERT_PATH") 44 | -------------------------------------------------------------------------------- /demos/http/http_demo_s3_download_multithreaded/core_http_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_HTTP_CONFIG_H_ 24 | #define CORE_HTTP_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for HTTP. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for HTTP. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the HTTP library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "HTTP" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | 51 | /************ End of logging configuration ****************/ 52 | 53 | #endif /* ifndef CORE_HTTP_CONFIG_H_ */ 54 | -------------------------------------------------------------------------------- /demos/http/http_demo_s3_upload/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "http_demo_s3_upload" ) 2 | 3 | # Include HTTP library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreHTTP/httpFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | "${DEMOS_DIR}/http/common/src/http_demo_utils.c" 14 | ${HTTP_SOURCES} 15 | ${HTTP_THIRD_PARTY_SOURCES} 16 | ${BACKOFF_ALGORITHM_SOURCES} 17 | ) 18 | 19 | target_link_libraries( 20 | ${DEMO_NAME} 21 | PRIVATE 22 | clock_posix 23 | openssl_posix 24 | ) 25 | 26 | target_include_directories( 27 | ${DEMO_NAME} 28 | PUBLIC 29 | "${DEMOS_DIR}/http/common/include" 30 | ${HTTP_INCLUDE_PUBLIC_DIRS} 31 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 32 | ${HTTP_INCLUDE_THIRD_PARTY_DIRS} 33 | ${HTTP_INCLUDE_PRIVATE_DIRS} 34 | ${CMAKE_CURRENT_LIST_DIR} 35 | ${LOGGING_INCLUDE_DIRS} 36 | ) 37 | 38 | set_macro_definitions(TARGETS ${DEMO_NAME} 39 | REQUIRED 40 | "S3_PRESIGNED_PUT_URL" 41 | "S3_PRESIGNED_GET_URL" 42 | "HTTPS_PORT" 43 | "ROOT_CA_CERT_PATH") 44 | -------------------------------------------------------------------------------- /demos/http/http_demo_s3_upload/core_http_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_HTTP_CONFIG_H_ 24 | #define CORE_HTTP_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for HTTP. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for HTTP. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the HTTP library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "HTTP" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | 51 | /************ End of logging configuration ****************/ 52 | 53 | #endif /* ifndef CORE_HTTP_CONFIG_H_ */ 54 | -------------------------------------------------------------------------------- /demos/jobs/jobs_demo_mosquitto/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | jobs_demo_mosquitto 3 | -------------------------------------------------------------------------------- /demos/jobs/jobs_demo_mosquitto/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "jobs_demo_mosquitto" ) 2 | 3 | # The callbacks for libmosquitto have parameters that are not used. 4 | set_source_files_properties( "${DEMO_NAME}.c" PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter" ) 5 | 6 | # Include library source and header path variables. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreJSON/jsonFilePaths.cmake ) 8 | include( ${CMAKE_SOURCE_DIR}/libraries/aws/jobs-for-aws-iot-embedded-sdk/jobsFilePaths.cmake ) 9 | 10 | # Demo target. 11 | add_executable( 12 | ${DEMO_NAME} 13 | "${DEMO_NAME}.c" 14 | ${JOBS_SOURCES} 15 | ${JSON_SOURCES} 16 | ) 17 | 18 | find_library(LIB_MOSQUITTO mosquitto) 19 | if(${LIB_MOSQUITTO} STREQUAL "LIB_MOSQUITTO-NOTFOUND") 20 | message( "Mosquitto was not installed. It will be built from source to run ${DEMO_NAME}." ) 21 | # Build Mosquitto Client Library from source if it is not installed. 22 | add_subdirectory( libmosquitto ) 23 | target_link_libraries( 24 | ${DEMO_NAME} 25 | PUBLIC 26 | libmosquitto 27 | ) 28 | # Exclude extraneous mosquitto targets. 29 | set_target_properties(mosquittopp PROPERTIES EXCLUDE_FROM_ALL true) 30 | set_target_properties(mosquitto_rr PROPERTIES EXCLUDE_FROM_ALL true) 31 | set_target_properties(mosquitto_sub PROPERTIES EXCLUDE_FROM_ALL true) 32 | set_target_properties(mosquitto_pub PROPERTIES EXCLUDE_FROM_ALL true) 33 | set_target_properties(mosquitto_passwd PROPERTIES EXCLUDE_FROM_ALL true) 34 | set_target_properties(mosquitto PROPERTIES EXCLUDE_FROM_ALL true) 35 | 36 | target_include_directories( 37 | ${DEMO_NAME} 38 | SYSTEM PUBLIC 39 | ${CMAKE_CURRENT_LIST_DIR}/libmosquitto/lib 40 | ) 41 | else() 42 | target_link_libraries( 43 | ${DEMO_NAME} 44 | PUBLIC 45 | mosquitto 46 | ) 47 | endif() 48 | 49 | target_include_directories( 50 | ${DEMO_NAME} 51 | PUBLIC 52 | ${JOBS_INCLUDE_PUBLIC_DIRS} 53 | ${JSON_INCLUDE_PUBLIC_DIRS} 54 | ) 55 | 56 | if(AWS_IOT_ENDPOINT) 57 | target_compile_definitions( 58 | ${DEMO_NAME} PRIVATE 59 | AWS_IOT_ENDPOINT="${AWS_IOT_ENDPOINT}" 60 | ) 61 | endif() 62 | if(ROOT_CA_CERT_PATH) 63 | target_compile_definitions( 64 | ${DEMO_NAME} PRIVATE 65 | ROOT_CA_CERT_PATH="${ROOT_CA_CERT_PATH}" 66 | ) 67 | endif() 68 | if(CLIENT_CERT_PATH) 69 | target_compile_definitions( 70 | ${DEMO_NAME} PRIVATE 71 | CLIENT_CERT_PATH="${CLIENT_CERT_PATH}" 72 | ) 73 | endif() 74 | if(CLIENT_PRIVATE_KEY_PATH) 75 | target_compile_definitions( 76 | ${DEMO_NAME} PRIVATE 77 | CLIENT_PRIVATE_KEY_PATH="${CLIENT_PRIVATE_KEY_PATH}" 78 | ) 79 | endif() 80 | set_macro_definitions(TARGETS ${DEMO_NAME} 81 | REQUIRED 82 | "AWS_IOT_ENDPOINT" 83 | "ROOT_CA_CERT_PATH" 84 | "CLIENT_CERT_PATH" 85 | "CLIENT_PRIVATE_KEY_PATH" 86 | ) 87 | -------------------------------------------------------------------------------- /demos/jobs/jobs_demo_mosquitto/Makefile: -------------------------------------------------------------------------------- 1 | DEMO := jobs_demo_mosquitto 2 | JOBS_DIR := ../../../libraries/aws/jobs-for-aws-iot-embedded-sdk/source 3 | JSON_DIR := ../../../libraries/standard/coreJSON/source 4 | INCLUDES := -I. -I$(JOBS_DIR)/include -I$(JSON_DIR)/include 5 | CFLAGS := -Wall -Wextra -Wpedantic -Wno-unused-parameter $(INCLUDES) 6 | LDLIBS := -lmosquitto 7 | CC := gcc 8 | 9 | $(DEMO): $(DEMO).o jobs.o core_json.o 10 | 11 | jobs.o: $(JOBS_DIR)/jobs.c 12 | $(CC) $(CFLAGS) $< -c -o $@ 13 | 14 | core_json.o: $(JSON_DIR)/core_json.c 15 | $(CC) $(CFLAGS) $< -c -o $@ 16 | 17 | clean: 18 | rm -fr $(DEMO) *.o 19 | 20 | .PHONY: clean 21 | -------------------------------------------------------------------------------- /demos/jobs/jobs_demo_mosquitto/README.md: -------------------------------------------------------------------------------- 1 | This demonstration downloads files from URLs received via AWS IoT Jobs. 2 | Details are available in the usage function at the top of jobs_demo.c. 3 | 4 | This demo is intended for Linux platforms with the GCC toolchain, 5 | curl, and libmosquitto installed. To build this demo, run make. 6 | 7 | To install curl and libmosquitto on a Debian or Ubuntu host, run: 8 | 9 | apt install curl libmosquitto-dev 10 | 11 | libmosquitto 1.4.10 or any later version of the first major release is required to run this demo. 12 | For ALPN support, build the latest version of the first major release of libmosquitto (1.6.12). 13 | To do this, go to the libmosquitto directory, 14 | and follow the instructions in compiling.txt within the submodule. 15 | -------------------------------------------------------------------------------- /demos/jobs/jobs_demo_mosquitto/demo_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef DEMO_CONFIG_H 24 | #define DEMO_CONFIG_H 25 | 26 | /** 27 | * @brief The client must send a control packet at least 28 | * this often in seconds, or the broker will close the connection. 29 | */ 30 | #define MQTT_KEEP_ALIVE ( 120U ) 31 | 32 | /** 33 | * @brief Require acknowledgements of MQTT publish operations. 34 | */ 35 | #define MQTT_QOS ( 1 ) 36 | 37 | /** 38 | * @brief Give up after this many calls to mqtt_loop without progress, 39 | * used only for connect and subscribe. 40 | */ 41 | #define MAX_LOOPS ( 50U ) 42 | 43 | /** 44 | * @brief Maximum duration in milliseconds of one mqtt_loop, 45 | * used only for connect and subscribe. 46 | */ 47 | #define MQTT_SHORT_WAIT_TIME ( 500U ) 48 | 49 | /** 50 | * @brief Maximum duration in milliseconds of one mqtt_loop, 51 | * used after subscribe. 52 | */ 53 | #define MQTT_WAIT_TIME ( 10U * 1000U ) 54 | 55 | /** 56 | * @brief Maximum interval in seconds for pollinv and updateinv command line arguments. 57 | * (arbitrarily chosen to be a week; must be less than LONG_MAX) 58 | */ 59 | #define INTERVAL_MAX ( 60U * 60U * 24U * 7U ) 60 | 61 | /** 62 | * @brief Parent directory to contain download directories and files. 63 | */ 64 | #define DESTINATION_PREFIX "/tmp" 65 | 66 | /** 67 | * @brief How to invoke the download program, i.e., curl. 68 | * 69 | * As written, this curl command limits the download rate 70 | * to 10 KB per second. The slow rate provides an opportunity 71 | * to observe updates, and test job cancellation. 72 | */ 73 | #define CURL( url ) \ 74 | execl( "/usr/bin/curl", "curl", "-OLsSN", "--limit-rate", "10k", url, NULL ) 75 | 76 | #endif /* ifndef DEMO_CONFIG_H */ 77 | -------------------------------------------------------------------------------- /demos/logging-stack/logging.cmake: -------------------------------------------------------------------------------- 1 | # Configuration for logging. 2 | set( LOGGING_INCLUDE_DIRS 3 | ${CMAKE_CURRENT_LIST_DIR} ) -------------------------------------------------------------------------------- /demos/mqtt/mqtt_demo_basic_tls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "mqtt_demo_basic_tls" ) 2 | 3 | # Include MQTT library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | ${MQTT_SOURCES} 14 | ${MQTT_SERIALIZER_SOURCES} 15 | ${BACKOFF_ALGORITHM_SOURCES} 16 | ) 17 | 18 | target_link_libraries( 19 | ${DEMO_NAME} 20 | PRIVATE 21 | clock_posix 22 | openssl_posix 23 | ) 24 | 25 | target_include_directories( 26 | ${DEMO_NAME} 27 | PUBLIC 28 | ${MQTT_INCLUDE_PUBLIC_DIRS} 29 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 30 | ${CMAKE_CURRENT_LIST_DIR} 31 | ${LOGGING_INCLUDE_DIRS} 32 | ) 33 | 34 | set_macro_definitions(TARGETS ${DEMO_NAME} 35 | REQUIRED 36 | "ROOT_CA_CERT_PATH" 37 | "BROKER_ENDPOINT" 38 | "CLIENT_IDENTIFIER" 39 | "BROKER_PORT") 40 | -------------------------------------------------------------------------------- /demos/mqtt/mqtt_demo_mutual_auth/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "mqtt_demo_mutual_auth" ) 2 | 3 | # Include MQTT library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | ${MQTT_SOURCES} 14 | ${MQTT_SERIALIZER_SOURCES} 15 | ${BACKOFF_ALGORITHM_SOURCES} 16 | ) 17 | 18 | target_link_libraries( 19 | ${DEMO_NAME} 20 | PRIVATE 21 | clock_posix 22 | openssl_posix 23 | ) 24 | 25 | target_include_directories( 26 | ${DEMO_NAME} 27 | PUBLIC 28 | ${MQTT_INCLUDE_PUBLIC_DIRS} 29 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 30 | ${CMAKE_CURRENT_LIST_DIR} 31 | ${LOGGING_INCLUDE_DIRS} 32 | ) 33 | 34 | set_macro_definitions(TARGETS ${DEMO_NAME} 35 | REQUIRED 36 | "AWS_IOT_ENDPOINT" 37 | "ROOT_CA_CERT_PATH" 38 | "CLIENT_CERT_PATH" 39 | "CLIENT_PRIVATE_KEY_PATH" 40 | "CLIENT_IDENTIFIER" 41 | OPTIONAL 42 | "CLIENT_USERNAME" 43 | "CLIENT_PASSWORD" 44 | "OS_NAME" 45 | "OS_VERSION" 46 | "HARDWARE_PLATFORM_NAME") 47 | -------------------------------------------------------------------------------- /demos/mqtt/mqtt_demo_plaintext/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "mqtt_demo_plaintext" ) 2 | 3 | # Include MQTT library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | ${MQTT_SOURCES} 14 | ${MQTT_SERIALIZER_SOURCES} 15 | ${BACKOFF_ALGORITHM_SOURCES} 16 | ) 17 | 18 | target_link_libraries( 19 | ${DEMO_NAME} 20 | PRIVATE 21 | clock_posix 22 | plaintext_posix 23 | ) 24 | 25 | target_include_directories( 26 | ${DEMO_NAME} 27 | PUBLIC 28 | ${MQTT_INCLUDE_PUBLIC_DIRS} 29 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 30 | ${CMAKE_CURRENT_LIST_DIR} 31 | ${LOGGING_INCLUDE_DIRS} 32 | ) 33 | 34 | set_macro_definitions(TARGETS ${DEMO_NAME} 35 | REQUIRED 36 | "BROKER_ENDPOINT" 37 | "BROKER_PORT" 38 | "CLIENT_IDENTIFIER") 39 | -------------------------------------------------------------------------------- /demos/mqtt/mqtt_demo_serializer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "mqtt_demo_serializer" ) 2 | 3 | # Include MQTT library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Demo target. 10 | add_executable( 11 | ${DEMO_NAME} 12 | "${DEMO_NAME}.c" 13 | ${MQTT_SERIALIZER_SOURCES} 14 | ${BACKOFF_ALGORITHM_SOURCES} 15 | ) 16 | 17 | target_link_libraries( 18 | ${DEMO_NAME} 19 | PRIVATE 20 | clock_posix 21 | plaintext_posix 22 | ) 23 | 24 | target_include_directories( 25 | ${DEMO_NAME} 26 | PUBLIC 27 | ${MQTT_INCLUDE_PUBLIC_DIRS} 28 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 29 | ${CMAKE_CURRENT_LIST_DIR} 30 | ${LOGGING_INCLUDE_DIRS} 31 | ) 32 | 33 | set_macro_definitions(TARGETS ${DEMO_NAME} 34 | REQUIRED 35 | "BROKER_ENDPOINT" 36 | "BROKER_PORT" 37 | "CLIENT_IDENTIFIER") 38 | -------------------------------------------------------------------------------- /demos/mqtt/mqtt_demo_serializer/core_mqtt_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_MQTT_CONFIG_H_ 24 | #define CORE_MQTT_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for MQTT. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for MQTT. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the MQTT library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "MQTT" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | /************ End of logging configuration ****************/ 51 | 52 | #endif /* ifndef CORE_MQTT_CONFIG_H_ */ 53 | -------------------------------------------------------------------------------- /demos/mqtt/mqtt_demo_subscription_manager/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Include CMake configuration for subscriptipn manager library. 2 | add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/subscription-manager ) 3 | 4 | # Include MQTT library's source and header path variables. 5 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 6 | 7 | # Include backoffAlgorithm library file path configuration. 8 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 9 | 10 | set( DEMO_NAME "mqtt_demo_subscription_manager" ) 11 | 12 | # Demo target. 13 | add_executable( 14 | ${DEMO_NAME} 15 | "${DEMO_NAME}.c" 16 | ${MQTT_SOURCES} 17 | ${MQTT_SERIALIZER_SOURCES} 18 | ${BACKOFF_ALGORITHM_SOURCES} 19 | ) 20 | 21 | target_link_libraries( 22 | ${DEMO_NAME} 23 | PRIVATE 24 | mqtt_subscription_manager 25 | clock_posix 26 | openssl_posix 27 | ) 28 | 29 | target_include_directories( 30 | mqtt_subscription_manager 31 | PUBLIC 32 | ${CMAKE_CURRENT_LIST_DIR} 33 | ) 34 | 35 | target_include_directories( 36 | ${DEMO_NAME} 37 | PUBLIC 38 | ${CMAKE_CURRENT_LIST_DIR}/subscription-manager 39 | ${MQTT_INCLUDE_PUBLIC_DIRS} 40 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 41 | ${CMAKE_CURRENT_LIST_DIR} 42 | ${LOGGING_INCLUDE_DIRS} 43 | ) 44 | 45 | set_macro_definitions(TARGETS ${DEMO_NAME} 46 | REQUIRED 47 | "ROOT_CA_CERT_PATH" 48 | "BROKER_ENDPOINT" 49 | "BROKER_PORT" 50 | "CLIENT_IDENTIFIER") 51 | -------------------------------------------------------------------------------- /demos/mqtt/mqtt_demo_subscription_manager/subscription-manager/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Include MQTT library's source and header path variables. 2 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 3 | 4 | # Include backoffAlgorithm library file path configuration. 5 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 6 | 7 | set( LIBRARY_NAME "mqtt_subscription_manager" ) 8 | # Library target. 9 | add_library( ${LIBRARY_NAME} 10 | "${LIBRARY_NAME}.c" ) 11 | 12 | target_include_directories( 13 | ${LIBRARY_NAME} 14 | PUBLIC 15 | ${CMAKE_CURRENT_LIST_DIR} 16 | ${LOGGING_INCLUDE_DIRS} 17 | ${MQTT_INCLUDE_PUBLIC_DIRS} 18 | ) 19 | -------------------------------------------------------------------------------- /demos/ota/ota_demo_core_http/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "ota_demo_core_http" ) 2 | 3 | # Include required library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/aws/ota-for-aws-iot-embedded-sdk/otaFilePaths.cmake ) 5 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 6 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreHTTP/httpFilePaths.cmake ) 7 | 8 | # Include backoffAlgorithm library file path configuration. 9 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 10 | 11 | # Demo target. 12 | add_executable( 13 | ${DEMO_NAME} 14 | "${DEMO_NAME}.c" 15 | "${DEMOS_DIR}/ota/common/src/mqtt_subscription_manager.c" 16 | "${DEMOS_DIR}/ota/common/src/http_demo_utils.c" 17 | ${OTA_SOURCES} 18 | ${OTA_OS_POSIX_SOURCES} 19 | ${OTA_MQTT_SOURCES} 20 | ${OTA_HTTP_SOURCES} 21 | ${MQTT_SOURCES} 22 | ${MQTT_SERIALIZER_SOURCES} 23 | ${HTTP_SOURCES} 24 | ${BACKOFF_ALGORITHM_SOURCES} 25 | ) 26 | 27 | target_link_libraries( 28 | ${DEMO_NAME} 29 | PRIVATE 30 | ${LIB_RT} 31 | ota_pal 32 | pthread 33 | clock_posix 34 | openssl_posix 35 | ) 36 | 37 | target_include_directories( 38 | ${DEMO_NAME} 39 | PUBLIC 40 | "${DEMOS_DIR}/ota/common/include" 41 | "${CMAKE_CURRENT_LIST_DIR}" 42 | "${LOGGING_INCLUDE_DIRS}" 43 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 44 | ${OTA_INCLUDE_PUBLIC_DIRS} 45 | ${OTA_INCLUDE_PRIVATE_DIRS} 46 | ${OTA_INCLUDE_OS_POSIX_DIRS} 47 | ${MQTT_INCLUDE_PUBLIC_DIRS} 48 | ${HTTP_INCLUDE_PUBLIC_DIRS} 49 | ) 50 | 51 | set_macro_definitions(TARGETS ${DEMO_NAME} 52 | REQUIRED 53 | "AWS_IOT_ENDPOINT" 54 | "ROOT_CA_CERT_PATH" 55 | "ROOT_CA_CERT_PATH_HTTP" 56 | "CLIENT_CERT_PATH" 57 | "CLIENT_PRIVATE_KEY_PATH" 58 | "CLIENT_IDENTIFIER" 59 | OPTIONAL 60 | "CLIENT_USERNAME" 61 | "CLIENT_PASSWORD" 62 | "OS_NAME" 63 | "OS_VERSION" 64 | "HARDWARE_PLATFORM_NAME") 65 | -------------------------------------------------------------------------------- /demos/ota/ota_demo_core_http/core_http_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_HTTP_CONFIG_H_ 24 | #define CORE_HTTP_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for HTTP. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for HTTP. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the HTTP library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "HTTP" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | 51 | /************ End of logging configuration ****************/ 52 | 53 | #endif /* ifndef CORE_HTTP_CONFIG_H_ */ 54 | -------------------------------------------------------------------------------- /demos/ota/ota_demo_core_mqtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "ota_demo_core_mqtt" ) 2 | 3 | # Include required library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/aws/ota-for-aws-iot-embedded-sdk/otaFilePaths.cmake ) 5 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 6 | 7 | # Include backoffAlgorithm library file path configuration. 8 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 9 | 10 | # Demo target. 11 | add_executable( 12 | ${DEMO_NAME} 13 | "${DEMO_NAME}.c" 14 | "${DEMOS_DIR}/ota/common/src/mqtt_subscription_manager.c" 15 | ${OTA_SOURCES} 16 | ${OTA_OS_POSIX_SOURCES} 17 | ${OTA_MQTT_SOURCES} 18 | ${MQTT_SOURCES} 19 | ${MQTT_SERIALIZER_SOURCES} 20 | ${BACKOFF_ALGORITHM_SOURCES} 21 | ) 22 | 23 | target_link_libraries( 24 | ${DEMO_NAME} 25 | PRIVATE 26 | ${LIB_RT} 27 | ota_pal 28 | pthread 29 | clock_posix 30 | openssl_posix 31 | ) 32 | 33 | target_include_directories( 34 | ${DEMO_NAME} 35 | PUBLIC 36 | "${DEMOS_DIR}/ota/common/include" 37 | "${CMAKE_CURRENT_LIST_DIR}" 38 | "${LOGGING_INCLUDE_DIRS}" 39 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 40 | ${OTA_INCLUDE_PUBLIC_DIRS} 41 | ${OTA_INCLUDE_PRIVATE_DIRS} 42 | ${OTA_INCLUDE_OS_POSIX_DIRS} 43 | ${MQTT_INCLUDE_PUBLIC_DIRS} 44 | ) 45 | 46 | set_macro_definitions(TARGETS ${DEMO_NAME} 47 | REQUIRED 48 | "AWS_IOT_ENDPOINT" 49 | "ROOT_CA_CERT_PATH" 50 | "CLIENT_CERT_PATH" 51 | "CLIENT_PRIVATE_KEY_PATH" 52 | "CLIENT_IDENTIFIER" 53 | OPTIONAL 54 | "CLIENT_USERNAME" 55 | "CLIENT_PASSWORD" 56 | "OS_NAME" 57 | "OS_VERSION" 58 | "HARDWARE_PLATFORM_NAME") 59 | -------------------------------------------------------------------------------- /demos/pkcs11/pkcs11_demo_management_and_rng/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "pkcs11_demo_management_and_rng" ) 2 | 3 | # Set path to corePKCS11 and it's third party libraries. 4 | set(COREPKCS11_LOCATION "${CMAKE_SOURCE_DIR}/libraries/standard/corePKCS11") 5 | set(CORE_PKCS11_3RDPARTY_LOCATION "${COREPKCS11_LOCATION}/source/dependency/3rdparty") 6 | 7 | # Include PKCS #11 library's source and header path variables. 8 | include( ${COREPKCS11_LOCATION}/pkcsFilePaths.cmake ) 9 | 10 | file(GLOB MBEDTLS_FILES CONFIGURE_DEPENDS "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls/library/*.c") 11 | set_source_files_properties( 12 | ${MBEDTLS_FILES} 13 | PROPERTIES COMPILE_FLAGS 14 | "-Wno-pedantic" 15 | ) 16 | 17 | list(APPEND PKCS_SOURCES 18 | "${MBEDTLS_FILES}" 19 | "${COREPKCS11_LOCATION}/source/portable/posix/core_pkcs11_pal.c" 20 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils/mbedtls_utils.c" 21 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils/mbedtls_error.c" 22 | ) 23 | 24 | # Demo target. 25 | add_executable( 26 | ${DEMO_NAME} 27 | "${DEMO_NAME}.c" 28 | ${PKCS_SOURCES} 29 | ) 30 | 31 | target_compile_definitions( 32 | ${DEMO_NAME} 33 | PUBLIC 34 | -DMBEDTLS_CONFIG_FILE="mbedtls_config.h" 35 | ) 36 | 37 | 38 | target_include_directories( 39 | ${DEMO_NAME} 40 | PUBLIC 41 | "${DEMOS_DIR}/pkcs11/common/include" 42 | ${PKCS_INCLUDE_PUBLIC_DIRS} 43 | ${CMAKE_CURRENT_LIST_DIR} 44 | ${LOGGING_INCLUDE_DIRS} 45 | ${CORE_PKCS11_3RDPARTY_LOCATION}/pkcs11 46 | ${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls/include 47 | PRIVATE 48 | ${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils 49 | ) 50 | -------------------------------------------------------------------------------- /demos/pkcs11/pkcs11_demo_mechanisms_and_digests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "pkcs11_demo_mechanisms_and_digests" ) 2 | 3 | # Set path to corePKCS11 and its third party libraries. 4 | set(COREPKCS11_LOCATION "${CMAKE_SOURCE_DIR}/libraries/standard/corePKCS11") 5 | set(CORE_PKCS11_3RDPARTY_LOCATION "${COREPKCS11_LOCATION}/source/dependency/3rdparty") 6 | 7 | # Include PKCS #11 library's source and header path variables. 8 | include( ${COREPKCS11_LOCATION}/pkcsFilePaths.cmake ) 9 | 10 | file(GLOB MBEDTLS_FILES CONFIGURE_DEPENDS "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls/library/*.c") 11 | set_source_files_properties( 12 | ${MBEDTLS_FILES} 13 | PROPERTIES COMPILE_FLAGS 14 | "-Wno-pedantic" 15 | ) 16 | 17 | list(APPEND PKCS_SOURCES 18 | "${MBEDTLS_FILES}" 19 | "${DEMOS_DIR}/pkcs11/common/src/demo_helpers.c" 20 | "${COREPKCS11_LOCATION}/source/portable/posix/core_pkcs11_pal.c" 21 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils/mbedtls_utils.c" 22 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils/mbedtls_error.c" 23 | ) 24 | 25 | # Demo target. 26 | add_executable( 27 | ${DEMO_NAME} 28 | "${DEMO_NAME}.c" 29 | ${PKCS_SOURCES} 30 | ) 31 | 32 | target_compile_definitions( 33 | ${DEMO_NAME} 34 | PUBLIC 35 | -DMBEDTLS_CONFIG_FILE="mbedtls_config.h" 36 | ) 37 | 38 | 39 | target_include_directories( 40 | ${DEMO_NAME} 41 | PUBLIC 42 | "${DEMOS_DIR}/pkcs11/common/include" 43 | ${PKCS_INCLUDE_PUBLIC_DIRS} 44 | ${CMAKE_CURRENT_LIST_DIR} 45 | ${LOGGING_INCLUDE_DIRS} 46 | "${CORE_PKCS11_3RDPARTY_LOCATION}/pkcs11" 47 | PRIVATE 48 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls/include" 49 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils" 50 | ) 51 | -------------------------------------------------------------------------------- /demos/pkcs11/pkcs11_demo_objects/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "pkcs11_demo_objects" ) 2 | 3 | # Set path to corePKCS11 and it's third party libraries. 4 | set(COREPKCS11_LOCATION "${CMAKE_SOURCE_DIR}/libraries/standard/corePKCS11") 5 | set(3RDPARTY_LOCATION "${CMAKE_SOURCE_DIR}/libraries/source/dependency/3rdparty") 6 | set(CORE_PKCS11_3RDPARTY_LOCATION "${COREPKCS11_LOCATION}/source/dependency/3rdparty") 7 | 8 | # Include PKCS #11 library's source and header path variables. 9 | include( ${COREPKCS11_LOCATION}/pkcsFilePaths.cmake ) 10 | 11 | file(GLOB MBEDTLS_FILES CONFIGURE_DEPENDS "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls/library/*.c") 12 | set_source_files_properties( 13 | ${MBEDTLS_FILES} 14 | PROPERTIES COMPILE_FLAGS 15 | "-Wno-pedantic" 16 | ) 17 | 18 | list(APPEND PKCS_SOURCES 19 | "${MBEDTLS_FILES}" 20 | "../common/src/demo_helpers.c" 21 | "${COREPKCS11_LOCATION}/source/portable/posix/core_pkcs11_pal.c" 22 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils/mbedtls_utils.c" 23 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils/mbedtls_error.c" 24 | ) 25 | 26 | # Demo target. 27 | add_executable( 28 | ${DEMO_NAME} 29 | "${DEMO_NAME}.c" 30 | ${PKCS_SOURCES} 31 | ) 32 | 33 | target_compile_definitions( 34 | ${DEMO_NAME} 35 | PUBLIC 36 | -DMBEDTLS_CONFIG_FILE="mbedtls_config.h" 37 | ) 38 | 39 | 40 | target_include_directories( 41 | ${DEMO_NAME} 42 | PUBLIC 43 | "${DEMOS_DIR}/pkcs11/common/include" 44 | ${PKCS_INCLUDE_PUBLIC_DIRS} 45 | ${CMAKE_CURRENT_LIST_DIR} 46 | ${LOGGING_INCLUDE_DIRS} 47 | "${CORE_PKCS11_3RDPARTY_LOCATION}/pkcs11" 48 | PRIVATE 49 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls/include" 50 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils" 51 | ) 52 | 53 | -------------------------------------------------------------------------------- /demos/pkcs11/pkcs11_demo_sign_and_verify/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "pkcs11_demo_sign_and_verify" ) 2 | 3 | # Set path to corePKCS11 and it's third party libraries. 4 | set(COREPKCS11_LOCATION "${CMAKE_SOURCE_DIR}/libraries/standard/corePKCS11") 5 | set(3RDPARTY_LOCATION "${CMAKE_SOURCE_DIR}/libraries/source/dependency/3rdparty") 6 | set(CORE_PKCS11_3RDPARTY_LOCATION "${COREPKCS11_LOCATION}/source/dependency/3rdparty") 7 | 8 | # Include PKCS #11 library's source and header path variables. 9 | include( ${COREPKCS11_LOCATION}/pkcsFilePaths.cmake ) 10 | 11 | file(GLOB MBEDTLS_FILES CONFIGURE_DEPENDS "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls/library/*.c") 12 | set_source_files_properties( 13 | ${MBEDTLS_FILES} 14 | PROPERTIES COMPILE_FLAGS 15 | "-Wno-pedantic" 16 | ) 17 | 18 | list(APPEND PKCS_SOURCES 19 | "${MBEDTLS_FILES}" 20 | "${DEMOS_DIR}/pkcs11/common/src/demo_helpers.c" 21 | "${COREPKCS11_LOCATION}/source/portable/posix/core_pkcs11_pal.c" 22 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils/mbedtls_utils.c" 23 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils/mbedtls_error.c" 24 | ) 25 | 26 | # Demo target. 27 | add_executable( 28 | ${DEMO_NAME} 29 | "${DEMO_NAME}.c" 30 | ${PKCS_SOURCES} 31 | ) 32 | 33 | target_compile_definitions( 34 | ${DEMO_NAME} 35 | PUBLIC 36 | -DMBEDTLS_CONFIG_FILE="mbedtls_config.h" 37 | ) 38 | 39 | target_include_directories( 40 | ${DEMO_NAME} 41 | PUBLIC 42 | "${DEMOS_DIR}/pkcs11/common/include" 43 | ${PKCS_INCLUDE_PUBLIC_DIRS} 44 | ${CMAKE_CURRENT_LIST_DIR} 45 | ${LOGGING_INCLUDE_DIRS} 46 | "${CORE_PKCS11_3RDPARTY_LOCATION}/pkcs11" 47 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls/include" 48 | PRIVATE 49 | "${CORE_PKCS11_3RDPARTY_LOCATION}/mbedtls_utils" 50 | ) 51 | -------------------------------------------------------------------------------- /demos/shadow/shadow_demo_main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( DEMO_NAME "shadow_demo_main" ) 2 | 3 | # Include MQTT library's source and header path variables. 4 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake ) 5 | 6 | # Include backoffAlgorithm library file path configuration. 7 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/backoffAlgorithm/backoffAlgorithmFilePaths.cmake ) 8 | 9 | # Include Shadow library's source and header path variables. 10 | include( ${CMAKE_SOURCE_DIR}/libraries/aws/device-shadow-for-aws-iot-embedded-sdk/shadowFilePaths.cmake ) 11 | 12 | # Include JSON library's source and header path variables. 13 | include( ${CMAKE_SOURCE_DIR}/libraries/standard/coreJSON/jsonFilePaths.cmake ) 14 | 15 | # Demo target. 16 | add_executable( 17 | ${DEMO_NAME} 18 | "${DEMO_NAME}.c" 19 | "shadow_demo_helpers.c" 20 | ${MQTT_SOURCES} 21 | ${MQTT_SERIALIZER_SOURCES} 22 | ${BACKOFF_ALGORITHM_SOURCES} 23 | ${SHADOW_SOURCES} 24 | ${JSON_SOURCES} 25 | ) 26 | 27 | target_link_libraries( 28 | ${DEMO_NAME} 29 | PRIVATE 30 | clock_posix 31 | openssl_posix 32 | ) 33 | 34 | target_include_directories( 35 | ${DEMO_NAME} 36 | PUBLIC 37 | ${LOGGING_INCLUDE_DIRS} 38 | ${MQTT_INCLUDE_PUBLIC_DIRS} 39 | ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} 40 | ${SHADOW_INCLUDE_PUBLIC_DIRS} 41 | ${CMAKE_CURRENT_LIST_DIR} 42 | ${JSON_INCLUDE_PUBLIC_DIRS} 43 | ) 44 | 45 | set_macro_definitions(TARGETS ${DEMO_NAME} 46 | REQUIRED 47 | "AWS_IOT_ENDPOINT" 48 | "ROOT_CA_CERT_PATH" 49 | "CLIENT_CERT_PATH" 50 | "CLIENT_PRIVATE_KEY_PATH" 51 | "CLIENT_IDENTIFIER" 52 | OPTIONAL 53 | "CLIENT_USERNAME" 54 | "CLIENT_PASSWORD" 55 | "OS_NAME" 56 | "OS_VERSION" 57 | "HARDWARE_PLATFORM_NAME") 58 | -------------------------------------------------------------------------------- /demos/shadow/shadow_demo_main/shadow_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef SHADOW_CONFIG_H_ 24 | #define SHADOW_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Logging related header files are required to be included in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL. 33 | * 3. Include the header file "logging_stack.h". 34 | */ 35 | 36 | /* Include header that defines log levels. */ 37 | #include "logging_levels.h" 38 | 39 | /* Configure name and log level for the Shadow library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "SHADOW" 42 | #endif 43 | #ifndef LIBRARY_LOG_LEVEL 44 | #define LIBRARY_LOG_LEVEL LOG_INFO 45 | #endif 46 | 47 | #include "logging_stack.h" 48 | 49 | /************ End of logging configuration ****************/ 50 | 51 | #endif /* ifndef SHADOW_CONFIG_H_ */ 52 | -------------------------------------------------------------------------------- /doc/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/doc/architecture.png -------------------------------------------------------------------------------- /doc/architecture.txt: -------------------------------------------------------------------------------- 1 | /** 2 | @page architecture SDK Architecture and Design 3 | @brief This page documents the architecture and design goals of this SDK. 4 | 5 | The Embedded C SDK has a layered architecture. It is currently based on the MQTT protocol, but may support protocols like HTTP in the future. 6 | 7 | This SDK is primarily targeted for resource-constrained devices. 8 | 9 | @section architecture_considerations Considerations during design 10 | - Low memory footprint (around 6k of code size without TLS library for the MQTT layer) 11 | - Flexibility in picking and choosing functionality 12 | - Static memory only (no malloc) 13 | - Configurable resource usage (JSON tokens, MQTT subscription handlers, etc.) 14 | - Portability across RTOSes 15 | 16 | @section architecture_diagram Layered architecture 17 | @brief There are primarily 3 layers in the SDK as shown in the diagram below. 18 | 19 | @image html architecture.png 20 | 21 | @subsection architecture_tls TLS layer 22 | 23 | This SDK uses TLS sockets to talk to the server. We provide wrappers around mbed TLS (ARM) that allow the libraries to connect with AWS IoT Platform. 24 | 25 | @subsection architecture_mqtt AWS IoT MQTT client 26 | 27 | The MQTT library included in this SDK is a modification of the [Paho C MQTT client](https://www.eclipse.org/paho/clients/c/). MQTT is a standardized publish subscribe protocol popular on embedded devices. AWS IoT supports the MQTT protocol for communication with devices. This MQTT library can be used standalone or with other AWS IoT services such as Thing Shadows or Jobs. 28 | 29 | @subsection architecture_shadow Thing Shadow 30 | 31 | This SDK provides a client implementation for [AWS IoT Thing Shadows](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html). A device's Shadow is a JSON document that is used to store and retrieve its current state information in the cloud regardless of whether it is connected to the Internet. 32 | */ 33 | -------------------------------------------------------------------------------- /doc/config/html/footer.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 21 | 22 | 23 | 24 | 25 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/config/html/header.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | $projectname: $title 17 | 18 | 19 | 20 | 21 | $title 22 | 23 | 24 | 25 | 26 | 27 | $search 28 | $mathjax 29 | 30 | $extrastylesheet 31 | 32 | 33 | 34 |
35 | 36 | 37 |
38 | 39 | 40 | 41 | 42 | 45 | 46 | 47 | 58 | 59 | 60 | 61 | 66 | 67 | 68 | 69 | 70 | 73 | 74 | 75 | 76 | 77 | 80 | 81 | 82 |
48 |
49 | AWS IoT Device SDK C: 50 | $projectname 51 |
52 | 53 |
54 | $projectbrief 55 |
56 | 57 |
62 |
63 | $projectbrief 64 |
65 |
71 | $searchbox 72 |
78 | Return to main page ↑ 79 |
83 |
84 | 85 | $treeview 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /doc/config/html/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Stylesheet for Doxygen HTML output. 3 | * 4 | * This file defines styles for custom elements in the header/footer and 5 | * overrides some of the default Doxygen styles. 6 | * 7 | * Styles in this file do not affect the treeview sidebar. 8 | */ 9 | 10 | /* Set the margins to place a small amount of whitespace on the left and right 11 | * side of the page. */ 12 | div.contents { 13 | margin-left:4em; 14 | margin-right:4em; 15 | } 16 | 17 | /* Justify text in paragraphs. */ 18 | p { 19 | text-align: justify; 20 | } 21 | 22 | /* Style of section headings. */ 23 | h1 { 24 | border-bottom: 1px solid #879ECB; 25 | color: #354C7B; 26 | font-size: 160%; 27 | font-weight: normal; 28 | padding-bottom: 4px; 29 | padding-top: 8px; 30 | } 31 | 32 | /* Style of subsection headings. */ 33 | h2:not(.memtitle):not(.groupheader) { 34 | font-size: 125%; 35 | margin-bottom: 0px; 36 | margin-top: 16px; 37 | padding: 0px; 38 | } 39 | 40 | /* Style of paragraphs immediately after subsection headings. */ 41 | h2 + p { 42 | margin: 0px; 43 | padding: 0px; 44 | } 45 | 46 | /* Style of subsubsection headings. */ 47 | h3 { 48 | font-size: 100%; 49 | margin-bottom: 0px; 50 | } 51 | 52 | /* Style of paragraphs immediately after subsubsection headings. */ 53 | h3 + p { 54 | margin-top: 0px; 55 | } 56 | 57 | /* Style of the prefix "AWS IoT Device SDK C" that appears in the header. */ 58 | #csdkprefix { 59 | color: #757575; 60 | } 61 | 62 | /* Style of the "Return to main page" link that appears in the header. */ 63 | #returntomain { 64 | padding: 0.5em; 65 | } 66 | 67 | /* Style of the dividers on Configuration Settings pages. */ 68 | div.configpagedivider { 69 | margin-left: 0px !important; 70 | margin-right: 0px !important; 71 | margin-top: 20px !important; 72 | } 73 | 74 | /* Style of configuration setting names. */ 75 | dl.section.user ~ h1 { 76 | border-bottom: none; 77 | color: #000000; 78 | font-family: monospace, fixed; 79 | font-size: 16px; 80 | margin-bottom: 0px; 81 | margin-left: 2em; 82 | margin-top: 1.5em; 83 | } 84 | 85 | /* Style of paragraphs on a configuration settings page. */ 86 | dl.section.user ~ * { 87 | margin-bottom: 10px; 88 | margin-left: 4em; 89 | margin-right: 4em; 90 | margin-top: 0px; 91 | } 92 | 93 | /* Hide the configuration setting marker. */ 94 | dl.section.user { 95 | display: none; 96 | } 97 | 98 | /* Overrides for code fragments and lines. */ 99 | div.fragment { 100 | background: #ffffff; 101 | border: none; 102 | padding: 5px; 103 | } 104 | 105 | div.line { 106 | color: #3a3a3a; 107 | } 108 | 109 | /* Overrides for code syntax highlighting colors. */ 110 | span.comment { 111 | color: #008000; 112 | } 113 | 114 | span.keyword, span.keywordtype, span.keywordflow { 115 | color: #0000ff; 116 | } 117 | 118 | span.preprocessor { 119 | color: #50015a; 120 | } 121 | 122 | span.stringliteral, span.charliteral { 123 | color: #800c0c; 124 | } 125 | 126 | a.code, a.code:visited, a.line, a.line:visited { 127 | color: #496194; 128 | } 129 | -------------------------------------------------------------------------------- /doc/config/main: -------------------------------------------------------------------------------- 1 | # Include common configuration options. 2 | @INCLUDE_PATH = doc/config 3 | @INCLUDE = common 4 | 5 | # Basic project information. 6 | PROJECT_NAME = "Main" 7 | 8 | # Library documentation output directory. 9 | HTML_OUTPUT = main 10 | 11 | # Generate Doxygen tag file for this library. 12 | GENERATE_TAGFILE = doc/tag/main.tag 13 | 14 | # Files to show on the main page. 15 | INPUT = README.md \ 16 | CHANGELOG.md \ 17 | PortingGuide.md \ 18 | doc/architecture.txt 19 | 20 | # Path to architecture image. 21 | IMAGE_PATH += doc/ 22 | 23 | # Use repository README as main page. 24 | USE_MDFILE_AS_MAINPAGE = README.md 25 | 26 | # Don't automatically link to library symbols. 27 | AUTOLINK_SUPPORT = NO 28 | 29 | # Use the Main page layout file 30 | LAYOUT_FILE = doc/config/layout_main.xml 31 | -------------------------------------------------------------------------------- /doc/config/mqtt: -------------------------------------------------------------------------------- 1 | # Include common configuration options. 2 | @INCLUDE_PATH = doc/config 3 | @INCLUDE = common 4 | 5 | # Basic project information. 6 | PROJECT_NAME = "MQTT" 7 | PROJECT_BRIEF = "MQTT v3.1.1 client library" 8 | 9 | # Library documentation output directory. 10 | HTML_OUTPUT = mqtt 11 | 12 | # Generate Doxygen tag file for this library. 13 | GENERATE_TAGFILE = doc/tag/mqtt.tag 14 | 15 | # Directories containing library source code. 16 | INPUT = doc/lib \ 17 | include/ \ 18 | src/ 19 | 20 | # Library file names. 21 | FILE_PATTERNS = *mqtt*.c *mqtt*.h *mqtt*.txt 22 | -------------------------------------------------------------------------------- /docs/doxygen/demos/defender_demo.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page defender_demo AWS IoT Device Defender 3 | @brief This demo demonstrates usage of the AWS IoT Device Defender Client library. 4 | 5 | @section defender_demo_main AWS IoT Device Defender Demo 6 | @brief This demo application uses the AWS IoT Device Defender Client library, 7 | MQTT Client library, and JSON library to interact with the [AWS IoT Device 8 | Defender service](https://aws.amazon.com/iot-device-defender/). 9 | 10 | The demo reports the following metrics to the AWS IoT Device Defender Service: 11 | - Network statistics [Packets (Ethernet Frames) and Bytes sent and received over wire] 12 | - List of open TCP ports 13 | - List of open UDP ports 14 | - List of established connections 15 | - System CPU usage statistics (as a custom metric of number-list type) 16 | - System memory statistics (as a custom metric of string-list type) 17 | 18 | The demo gets the above metrics by reading `/proc/net/dev`, `/proc/net/tcp`, 19 | `/proc/net/udp`, `/proc/uptime`, and `/proc/meminfo`. It then constructs a JSON report in the format as expected by 20 | the AWS IoT Device Defender service. The constructed JSON report is then 21 | published on the device defender MQTT topic reserved for publishing JSON 22 | reports. The demo then waits for a report accepted response, and ensures that 23 | the response contains the same report Id as was sent in the request. 24 | 25 | For the AWS IoT Device Defender service to make use of the custom metrics reported by the demo, you need to 26 | define the custom metrics in your account. You can use either the AWS console or CLI to create 27 | custom metrics in your account. For more information, please refer to [Custom Metrics AWS documentation](https://docs.aws.amazon.com/iot/latest/developerguide/dd-detect-custom-metrics.html). 28 | 29 |
30 | AWS IoT Device Defender Demo Workflow 31 |
32 | @image html defender_demo.png width=100% 33 | */ 34 | -------------------------------------------------------------------------------- /docs/doxygen/demos/demos_main.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page demos_main Demos 3 | @brief These demos demonstrate usage of the AWS IoT Device SDK for Embedded C libraries. 4 | 5 | Demos for the following libraries are provided: 6 | - @subpage mqtt_demo 7 | - @subpage http_demo 8 | - @subpage pkcs11_demo 9 | - @subpage shadow_demo 10 | - @subpage jobs_demo 11 | - @subpage defender_demo 12 | - @subpage ota_demos 13 | */ 14 | -------------------------------------------------------------------------------- /docs/doxygen/demos/ota_demo.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page ota_demos AWS IoT Over-the-air Update 3 | @brief These demos demonstrate usage of the AWS IoT Over-the-air Update library. 4 | 5 | @section ota_demo_core_mqtt OTA over MQTT Demo 6 | @brief A demo of OTA library to perform a firmware update using coreMQTT for data operations. 7 | 8 |

9 | This example demonstrates the use of OTA library to perform a device firmware update. The Linux application acts as an OTA client and AWS Services(AWS IoT, S3, Jobs etc.) are used to 10 | send an update to the client. The demo uses the coreMQTT library to establish a connection to AWS IoT , then subscribes to OTA specific MQTT topics to receive a job. 11 | After a user schedules a job, the client begins the download using coreMQTT to request, ingest, and store the data blocks, with the help of tinyCBOR to encode the data stream. 12 | Once the image is downloaded, the file key signature, version, and image is verified to reset and display a successful update. Workflow for the demo is as follows: 13 | - User builds initial application with version 0.9.2. 14 | - User runs the application, establishes a connection to AWS IoT, and awaits a job. 15 | - User increases the application version to 0.9.3, and rebuilds the executable. 16 | - User schedules an OTA Update Job with the newer executable. 17 | - OTA client receives the job document and verifies all the parameters. 18 | - The new firmware is downloaded using coreMQTT and tinyCBOR. This is then verified by the OTA client. 19 | - User runs the downloaded executable to notify AWS IoT of a successful update and display it on the console and device logs. 20 | 21 |

22 | 23 |
24 | OTA over coreMQTT Demo Workflow 25 |
26 | @image html ota_demo_core_mqtt.svg width=100% 27 | 28 | @section ota_demo_core_http OTA over HTTP Demo 29 | @brief A demo of OTA library to perform a firmware update using coreHTTP for data operations. 30 | 31 |

32 | This example is a modification of the above demo to securely send a firmware image to the device by using coreHTTP for data plane operations. 33 | While it still uses MQTT for control operations like pending job notifications and updating job status, this demo uses HTTP instead of 34 | MQTT to download the file. 35 |

36 | 37 |
38 | OTA over coreHTTP Demo Workflow 39 |
40 | @image html ota_demo_core_http.svg width=100% 41 | 42 | */ 43 | -------------------------------------------------------------------------------- /docs/doxygen/demos/pkcs11_demo.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page pkcs11_demo corePKCS11 3 | @brief Demos used to illustrate various functionalities of the corePKCS11 library. 4 | 5 | @section pkcs11_demo_rng PKCS #11 Random Number Generation Demo 6 | @brief Demo of using the PKCS #11 interface to generate a random number. 7 | 8 | 9 | This demo will introduce the basics of PKCS #11. It will step you through the data types as well as give 10 | an overview of the functions used to manage the PKCS #11 library's state. 11 | 12 | Finally, it will demonstrate how to fill a buffer with random bytes using PKCS #11. 13 | 14 | @image html pkcs11_rng.png width=100% 15 | 16 | 17 | @section pkcs11_demo_digest PKCS #11 Mechanisms and Digest Demo 18 | @brief Demo of using the PKCS #11 interface to select a mechanism and create a digest (hash) with it. 19 | 20 | This demo details what PKCS #11 mechanisms are and how to query a slot's support for them. 21 | It will then use those mechanisms to generate a hash of a buffer. 22 | 23 | @image html pkcs11_digest.png width=100% 24 | 25 | 26 | @section pkcs11_demo_object PKCS #11 Objects Demo 27 | @brief Demo of using the PKCS #11 interface to create an EC key pair and import an RSA certificate. 28 | This will first import an RSA certificate into the PKCS #11 module, allowing it to be accessed through a label. 29 | It will then create a unique EC based key pair that can be accessed through a label, and will be used in the 30 | sign and verify demo. 31 | @image html pkcs11_object_import.png width=100% 32 | @image html pkcs11_object_generate.png width=100% 33 | 34 | @section pkcs11_demo_sign_verify PKCS #11 Sign and Verify Demo 35 | @brief Demo of using the PKCS #11 interface to sign and verify a hash using an EC key pair. 36 | @warning This demo requires the objects created by the PKCS #11 Objects Demo! 37 | This demo will use the key pair created in the @ref pkcs11_demo_object to sign a hash @ref pkcs11_demo_digest and then 38 | show how the public key can be used to verify that the signature originated from the private key that created it. 39 | @image html pkcs11_sign_verify.png width=100% 40 | */ 41 | -------------------------------------------------------------------------------- /docs/doxygen/demos/shadow_demo.dox: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | @page shadow_demo AWS IoT Device Shadow 4 | @brief This demo demonstrates usage of the AWS IoT Device Shadow library. 5 | 6 | @section shadow_demo_main AWS IoT Device Shadow Demo 7 | @brief Demo application that uses the AWS IoT Device Shadow library, MQTT Client library, 8 | and JSON library to interact with the AWS IoT Device Shadow service. 9 | 10 | AWS IoT Device Shadow service supports 2 types of shadows for a Thing; a classic 11 | shadow and multiple named shadows. This demo works with either a classic shadow or 12 | a named shadow depending on the value of demo config SHADOW_NAME. The demo 13 | can be configured as listed below. 14 | 1. Classic shadow - Demo config SHADOW_NAME can be defined as 15 | #SHADOW_NAME_CLASSIC to use classic shadow in the demo. This is the default 16 | configuration for the demo. 17 | 2. Named shadow - Demo config SHADOW_NAME can be defined as a non empty 18 | C string. This configuration value will be used as the name of the shadow in 19 | the demo. 20 | 21 | In this demo, the device is assumed to have the powerOn state, which can be 1 or 0 22 | depending on whether or not the device is powered on. This state is maintained in 23 | the device's classic shadow or a named shadow depending on the demo configuration 24 | SHADOW_NAME. The demo does the following operations: 25 | 26 | - Establish an MQTT connection. ( step 1. ) 27 | - Attempt to delete the shadow if it exists already. (step 6 ~ step 23) 28 | - Assemble MQTT topic strings for device shadow operations using macros defined 29 | by the Device Shadow library. ( step 24. ) 30 | - Subscribe to the MQTT topics for shadow update operations. ( step 26. ) 31 | - Publish a desired powerOn state. This causes a device shadow update delta 32 | message to be sent to the device. ( step 29 ~ step 31. ) 33 | - Handle the incoming MQTT message in the MQTT event callback and determine 34 | whether the message is related to the device shadow using @ref Shadow_MatchTopicString. 35 | If the message is a device shadow update delta message, set a flag for the 36 | main function to know. The main function will then publish a second message to 37 | update the reported powerOn state. ( step 34 ~ step 39. ) 38 | - Handle the incoming MQTT message again in the MQTT event callback and 39 | determine whether the message is related to the device shadow. If the message 40 | is a device shadow update accepted message, verify that it is for the update 41 | operation initiated previously by ensuring that it contains the same 42 | clientToken as sent in the update operation. ( step 34 ~ step 39. ) 43 | 44 | @image html shadow_demo_main.png width=100% 45 | */ 46 | -------------------------------------------------------------------------------- /docs/doxygen/developer/developer.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page guide_developer Developer's Guide 3 | @brief Guide for maintaining and contributing code to this project. 4 | 5 | This guide contains the following pages. All pages assume the reader has intermediate familiarity with this SDK. 6 | - @subpage guide_developer_styleguide
7 | @copybrief guide_developer_styleguide 8 | */ 9 | -------------------------------------------------------------------------------- /docs/doxygen/images/defender_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/defender_demo.png -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_basic_tls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/http_demo_basic_tls.png -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_basic_tls.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam dpi 300 3 | skinparam classFontSize 8 4 | skinparam classFontName Helvetica 5 | autonumber 6 | 7 | box "Application" #LightGreen 8 | participant "Application" as application 9 | end box 10 | 11 | box "Libraries" #LightBlue 12 | participant "HTTP Client" as http 13 | end box 14 | 15 | box "HTTP Server" #Yellow 16 | participant "HTTP Server" as server 17 | end box 18 | 19 | activate application 20 | loop until session established or all attempts exhausted 21 | application -> server : Establish TLS session (client verifies server's certificate) 22 | server -> application : Session established (no client authentication) 23 | end 24 | 25 | application -> application: Set request info parameters 26 | application -> http: Initialize request headers (HTTPClient_InitializeRequestHeaders) 27 | activate http 28 | http -> application : Write request headers to user-provided buffer 29 | deactivate http 30 | 31 | application -> http: Send HTTP GET request (HTTPClient_Send) 32 | activate http 33 | http -> server: Send payload of request through transport interface 34 | http -> application : Write response to user-provided buffer 35 | application -> application: Log response from contents of buffer 36 | deactivate http 37 | 38 | application -> http: Send HTTP HEAD request (HTTPClient_Send) 39 | activate http 40 | http -> server: Send payload of request through transport interface 41 | http -> application : Write response to user-provided buffer 42 | application -> application: Log response from contents of buffer 43 | deactivate http 44 | 45 | application -> http: Send HTTP PUT request (HTTPClient_Send) 46 | activate http 47 | http -> server: Send payload of request through transport interface 48 | http -> application : Write response to user-provided buffer 49 | application -> application: Log response from contents of buffer 50 | deactivate http 51 | 52 | application -> http: Send HTTP POST request (HTTPClient_Send) 53 | activate http 54 | http -> server: Send payload of request through transport interface 55 | http -> application : Write response to user-provided buffer 56 | application -> application: Log response from contents of buffer 57 | deactivate http 58 | 59 | application -> server: End TLS session and disconnect from server 60 | 61 | deactivate application 62 | 63 | @enduml 64 | -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_mutual_auth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/http_demo_mutual_auth.png -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_mutual_auth.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam dpi 300 3 | skinparam classFontSize 8 4 | skinparam classFontName Helvetica 5 | autonumber 6 | 7 | box "Application" #LightGreen 8 | participant "Application" as application 9 | end box 10 | 11 | box "Libraries" #LightBlue 12 | participant "HTTP Client" as http 13 | end box 14 | 15 | box "HTTP Server" #Yellow 16 | participant "HTTP Server" as server 17 | end box 18 | 19 | activate application 20 | loop until session established or all attempts exhausted 21 | application -> server : Start TLS session establishment (client verifies server's certificate) 22 | server -> application : Establish TLS session (server verifies client's certificate) 23 | end 24 | 25 | application -> application: Set request info parameters 26 | application -> http: Initialize request headers (HTTPClient_InitializeRequestHeaders) 27 | activate http 28 | http -> application : Write request headers to user-provided buffer 29 | deactivate http 30 | 31 | application -> http: Send HTTP POST request to publish a message to AWS IoT Core (HTTPClient_Send) 32 | activate http 33 | http -> server: Send payload of request through transport interface 34 | http -> application : Write response to user-provided buffer 35 | application -> application: Log response from contents of buffer 36 | deactivate http 37 | 38 | application -> server: End TLS session and disconnect from server 39 | 40 | deactivate application 41 | 42 | @enduml 43 | -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_plaintext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/http_demo_plaintext.png -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_plaintext.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam dpi 300 3 | skinparam classFontSize 8 4 | skinparam classFontName Helvetica 5 | autonumber 6 | 7 | box "Application" #LightGreen 8 | participant "Application" as application 9 | end box 10 | 11 | box "Libraries" #LightBlue 12 | participant "HTTP Client" as http 13 | end box 14 | 15 | box "HTTP Server" #Yellow 16 | participant "HTTP Server" as server 17 | end box 18 | 19 | activate application 20 | loop until session established or all attempts exhausted 21 | application -> server : Establish TCP session 22 | server -> application : Session established 23 | end 24 | 25 | application -> application: Set request info parameters 26 | application -> http: Initialize request headers (HTTPClient_InitializeRequestHeaders) 27 | activate http 28 | http -> application : Write request headers to user-provided buffer 29 | deactivate http 30 | 31 | application -> http: Send HTTP GET request (HTTPClient_Send) 32 | activate http 33 | http -> server: Send payload of request through transport interface 34 | http -> application : Write response to user-provided buffer 35 | application -> application: Log response from contents of buffer 36 | deactivate http 37 | 38 | application -> http: Send HTTP HEAD request (HTTPClient_Send) 39 | activate http 40 | http -> server: Send payload of request through transport interface 41 | http -> application : Write response to user-provided buffer 42 | application -> application: Log response from contents of buffer 43 | deactivate http 44 | 45 | application -> http: Send HTTP PUT request (HTTPClient_Send) 46 | activate http 47 | http -> server: Send payload of request through transport interface 48 | http -> application : Write response to user-provided buffer 49 | application -> application: Log response from contents of buffer 50 | deactivate http 51 | 52 | application -> http: Send HTTP POST request (HTTPClient_Send) 53 | activate http 54 | http -> server: Send payload of request through transport interface 55 | http -> application : Write response to user-provided buffer 56 | application -> application: Log response from contents of buffer 57 | deactivate http 58 | 59 | application -> server: End TCP session and disconnect from server 60 | 61 | deactivate application 62 | 63 | @enduml 64 | -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_s3_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/http_demo_s3_download.png -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_s3_download.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam dpi 300 3 | skinparam classFontSize 8 4 | skinparam classFontName Helvetica 5 | autonumber 6 | 7 | box "Application" #LightGreen 8 | participant "Application" as application 9 | end box 10 | 11 | box "Third-party \n Library" #LightPink 12 | participant "http-parser" as parser 13 | end box 14 | 15 | box "Libraries" #LightBlue 16 | participant "HTTP Client" as http 17 | end box 18 | 19 | box "HTTP Server" #Yellow 20 | participant "HTTP Server" as server 21 | end box 22 | 23 | activate application 24 | 25 | application -> parser : Parse configured pre-signed GET URL to extract\n S3 host address 26 | activate parser 27 | parser -> application : Return server host address 28 | deactivate parser 29 | 30 | loop until session established or all attempts exhausted 31 | application -> server : Establish TLS session\n (client verifies server's certificate) 32 | server -> application : Session established (no client authentication) 33 | end 34 | 35 | application -> parser : Parse configured pre-signed GET URL to extract\n URL path 36 | activate parser 37 | parser -> application : Return path string with request-URI 38 | deactivate parser 39 | 40 | application -> application: Set request info parameters 41 | application -> http: Initialize request headers\n (HTTPClient_InitializeRequestHeaders) 42 | activate http 43 | http -> application : Write request headers to user-provided buffer 44 | deactivate http 45 | 46 | application -> http : Send HTTP GET request (HTTPClient_Send) 47 | activate http 48 | http -> server: Send payload of request through transport interface 49 | http -> application : Write response to user-provided buffer 50 | deactivate http 51 | application -> application: Parse content-range header from response\n to obtain file size 52 | 53 | loop until entire file is downloaded 54 | application -> http: Initialize request headers\n (HTTPClient_InitializeRequestHeaders) 55 | activate http 56 | http -> application : Write request headers to user-provided buffer 57 | deactivate http 58 | application -> http: Add range header\n (HTTPClient_AddRangeHeader) 59 | activate http 60 | http -> application : Add range header to user-provided buffer 61 | deactivate http 62 | application -> http : Send HTTP GET request (HTTPClient_Send)\n to download requested bytes of the file 63 | activate http 64 | http -> server: Send payload of request through transport interface 65 | http -> application : Write response to user-provided buffer 66 | deactivate http 67 | application -> application: Log response from contents of buffer 68 | end 69 | 70 | application -> server: End TLS session and disconnect from server 71 | 72 | deactivate application 73 | @enduml 74 | -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_s3_download_multithreaded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/http_demo_s3_download_multithreaded.png -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_s3_download_multithreaded.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam dpi 300 3 | skinparam classFontSize 8 4 | skinparam classFontName Helvetica 5 | autonumber 6 | 7 | box "Application" #LightGreen 8 | participant "Main Thread" as application 9 | participant "HTTP Thread" as httpthread 10 | end box 11 | 12 | box "Queues" #Orange 13 | participant "Request queue" as requestqueue 14 | participant "Response queue" as responsequeue 15 | end box 16 | 17 | box "HTTP Server" #Yellow 18 | participant "S3" as server 19 | end box 20 | 21 | activate application 22 | loop until session established or all attempts exhausted 23 | application -> server: Establish TLS session (client verifies server's certificate) 24 | server -> application: Session established (no client authentication) 25 | end 26 | 27 | application -> httpthread: Start HTTP thread 28 | activate httpthread 29 | 30 | application -> application: Set request info parameters 31 | 32 | application -> application: Initialize request headers (HTTPClient_InitializeRequestHeaders) 33 | application -> application: Add range header (HTTPClient_AddRangeHeader) 34 | application -> requestqueue: Enqueue request 35 | 36 | requestqueue -> httpthread: Dequeue request 37 | httpthread -> server: Send HTTP GET request (HTTPClient_Send) 38 | activate server 39 | 40 | application -> application: Initialize request headers (HTTPClient_InitializeRequestHeaders) 41 | application -> application: Add range header (HTTPClient_AddRangeHeader) 42 | application -> requestqueue: Enqueue request 43 | 44 | server -> httpthread: Recieve HTTP response 45 | deactivate server 46 | httpthread -> responsequeue: Enqueue response 47 | requestqueue -> httpthread: Dequeue request 48 | httpthread -> server: Send HTTP GET request (HTTPClient_Send) 49 | activate server 50 | 51 | responsequeue -> application: Dequeue response 52 | application -> application: Log response from contents of buffer 53 | 54 | application -> application: Initialize request headers (HTTPClient_InitializeRequestHeaders) 55 | application -> application: Add range header (HTTPClient_AddRangeHeader) 56 | application -> requestqueue: Enqueue request 57 | 58 | server -> httpthread: Recieve HTTP response 59 | deactivate server 60 | httpthread -> responsequeue: Enqueue response 61 | 62 | requestqueue -> httpthread: Dequeue request 63 | httpthread -> server: Send HTTP GET request (HTTPClient_Send) 64 | activate server 65 | 66 | responsequeue -> application: Dequeue response 67 | application -> application: Log response from contents of buffer 68 | 69 | server -> httpthread: Recieve HTTP response 70 | deactivate server 71 | httpthread -> responsequeue: Enqueue response 72 | 73 | responsequeue -> application: Dequeue response 74 | application -> application: Log response from contents of buffer 75 | 76 | application -> server: End TLS session and disconnect from server 77 | 78 | deactivate application 79 | deactivate httpthread 80 | 81 | @enduml 82 | -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_s3_upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/http_demo_s3_upload.png -------------------------------------------------------------------------------- /docs/doxygen/images/http_demo_s3_upload.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam dpi 300 3 | skinparam classFontSize 8 4 | skinparam classFontName Helvetica 5 | autonumber 6 | 7 | box "Application" #LightGreen 8 | participant "Application" as application 9 | end box 10 | 11 | box "Third-party \n Library" #LightPink 12 | participant "http-parser" as parser 13 | end box 14 | 15 | box "Libraries" #LightBlue 16 | participant "HTTP Client" as http 17 | end box 18 | 19 | box "HTTP Server" #Yellow 20 | participant "HTTP Server" as server 21 | end box 22 | 23 | activate application 24 | 25 | application -> parser : Parse configured pre-signed PUT URL to extract\n host address 26 | activate parser 27 | parser -> application : Return server host address 28 | deactivate parser 29 | 30 | loop until session established or all attempts exhausted 31 | application -> server : Establish TLS session\n (client verifies server's certificate) 32 | server -> application : Session established (no client authentication) 33 | end 34 | 35 | application -> parser : Parse configured pre-signed PUT URL to extract\n URL path 36 | activate parser 37 | parser -> application : Return path string with request-URI 38 | deactivate parser 39 | 40 | application -> application: Set request info parameters 41 | application -> http: Initialize request headers\n (HTTPClient_InitializeRequestHeaders) 42 | activate http 43 | http -> application : Write request headers to user-provided buffer 44 | deactivate http 45 | 46 | application -> http: Send HTTP PUT request (HTTPClient_Send)\n to upload file to S3 object 47 | activate http 48 | http -> server: Send payload of request through transport interface 49 | http -> application : Write response to user-provided buffer 50 | deactivate http 51 | application -> application: Log response from contents of buffer 52 | 53 | application -> parser : Parse configured pre-signed GET URL to extract\n URL path 54 | activate parser 55 | parser -> application : Return path string with request-URI 56 | deactivate parser 57 | 58 | application -> http: Send HTTP GET request (HTTPClient_Send) 59 | activate http 60 | http -> server: Send payload of request through transport interface 61 | http -> application : Write response to user-provided buffer 62 | deactivate http 63 | application -> application: Parse content-range header from response\n to obtain file size 64 | 65 | application -> application : Verify that the file size obtained from S3 is\n equivalent to the file size uploaded 66 | 67 | application -> server: End TLS session and disconnect from server 68 | 69 | deactivate application 70 | @enduml 71 | -------------------------------------------------------------------------------- /docs/doxygen/images/jobs_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/jobs_demo.png -------------------------------------------------------------------------------- /docs/doxygen/images/logging_architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/logging_architecture.png -------------------------------------------------------------------------------- /docs/doxygen/images/logging_architecture.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/doxygen/images/mqtt_basic_tls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/mqtt_basic_tls.png -------------------------------------------------------------------------------- /docs/doxygen/images/mqtt_mutual_auth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/mqtt_mutual_auth.png -------------------------------------------------------------------------------- /docs/doxygen/images/mqtt_plaintext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/mqtt_plaintext.png -------------------------------------------------------------------------------- /docs/doxygen/images/mqtt_serializer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/mqtt_serializer.png -------------------------------------------------------------------------------- /docs/doxygen/images/mqtt_subscription_manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/mqtt_subscription_manager.png -------------------------------------------------------------------------------- /docs/doxygen/images/pkcs11_digest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/pkcs11_digest.png -------------------------------------------------------------------------------- /docs/doxygen/images/pkcs11_object_generate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/pkcs11_object_generate.png -------------------------------------------------------------------------------- /docs/doxygen/images/pkcs11_object_import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/pkcs11_object_import.png -------------------------------------------------------------------------------- /docs/doxygen/images/pkcs11_rng.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/pkcs11_rng.png -------------------------------------------------------------------------------- /docs/doxygen/images/pkcs11_sign_verify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/pkcs11_sign_verify.png -------------------------------------------------------------------------------- /docs/doxygen/images/retry_utils_flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/retry_utils_flow.png -------------------------------------------------------------------------------- /docs/doxygen/images/retry_utils_flow.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | skinparam dpi 300 4 | skinparam ArrowFontSize 18 5 | 6 | start 7 | : **RetryUtils_ParamsReset()**; 8 | note: Initializes parameters 9 | repeat 10 | : Attempt communication with Server; 11 | if (Success) then (no) 12 | : **RetryUtils_BackoffAndSleep()**; 13 | note: Performs backoff calculation and delay 14 | else (yes) 15 | endif 16 | repeat while (Server communication failed &&\nRetries not exhausted) is (yes) 17 | -> no; 18 | stop 19 | 20 | @enduml 21 | -------------------------------------------------------------------------------- /docs/doxygen/images/shadow_demo_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/aws-iot-device-sdk-embedded-C/59ecfed9fc03076984506d6218256718ab1d4ed7/docs/doxygen/images/shadow_demo_main.png -------------------------------------------------------------------------------- /docs/doxygen/migration/jobs.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page jobs_migration AWS IoT Jobs 3 | @brief How to migrate an application using AWS IoT Jobs from v3 to 202009.00 and subsequent releases. 4 | 5 | The AWS IoT Jobs client library has been refactored for this release. 6 | The refactored library has the following differences as compared to the jobs client library in v3 of the AWS IoT Device SDK for Embedded C: 7 | 8 | - The refactored library provides simple convenience macros and functions for handling MQTT topic strings as defined by the AWS IoT Jobs Service. 9 | - The refactored library is completely decoupled from the underlying MQTT implementation, permitting any MQTT client library to be used. 10 | - The refactored library does not construct JSON message bodies, permitting any JSON library to be used. 11 | 12 | The v3 jobs client library, on the other hand, is tightly coupled to the MQTT implementation present in v3 of the AWS IoT Device SDK for Embedded C. 13 | It consists of a heavyweight set of APIs with multiple dependencies. 14 | JSON parsing, for example, is built in to the API implementation. 15 | 16 | Note: The AWS IoT Device SDK for Embedded C now offers the coreMQTT library and the coreJSON library as supported alternatives. 17 | 18 | To migrate an existing application 19 | - change the setup code to establish a connection with AWS IoT core 20 | - add a subscription step to the setup code 21 | - use Jobs_GetTopic() to populate a buffer with the desired subscription topic 22 | - use the MQTT client library to subscribe to the topic 23 | - in your MQTT receive callback, add a handler that calls Jobs_MatchTopic() 24 | - based on the response, react to a succeeded or failed API request 25 | - if a jobs document is present, parse it for details and launch the job 26 | - replace each existing API request call with a set of steps 27 | - call the new API to populate a buffer with the desired topic 28 | - optionally add a JSON body for the MQTT message 29 | - use the MQTT client library to publish the request 30 | - periodically send a status update when a job is running 31 | 32 | A complete example using libmosquitto and coreJSON is available 33 | here. 34 | 35 | */ 36 | -------------------------------------------------------------------------------- /docs/doxygen/migration/migration.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page migration_guide Migration Guide 3 | @brief Migration guide for v3 libraries to 202009.00 and subsequent releases. 4 | 5 | - @subpage mqtt_migration
6 | @copybrief mqtt_migration 7 | 8 | - @subpage shadow_migration
9 | @copybrief shadow_migration 10 | 11 | - @subpage jobs_migration
12 | @copybrief jobs_migration 13 | */ 14 | -------------------------------------------------------------------------------- /docs/doxygen/migration/shadow.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page shadow_migration AWS IoT Device Shadow 3 | @brief How to migrate a AWS IoT Device Shadow application from v3 to 202009.00 and subsequent releases. 4 | 5 | The Device Shadow library has been redesigned in this release. The new design has the following differences as compared to the Device Shadow library in v3 of the AWS IoT Device SDK for Embedded C. 6 | 7 | - The new Device Shadow library is completely decoupled from the underlying MQTT Client library. The v3 Device Shadow library, on the other hand, depended on the MQTT Client library present in the v3 of AWS IoT Device SDK for Embedded C.
8 | - The new Device Shadow library does not have any code for constructing JSON files. The v3 Device Shadow library, on the other hand, contained code for constructing JSON files in the format expected by the AWS IoT Device Shadow Service.
9 | - The new Device Shadow library provides simple convenience macros and functions for handling MQTT topic strings as defined by AWS IoT Device Shadow Service. The v3 Device Shadow library, on the other hand, provided a complete set of APIs for interacting with the AWS IoT Device Shadow Service by using a MQTT Client library.
10 | 11 | The application can use the new Device Shadow library with their choice of MQTT Client library by following the call sequence diagram in the [Design document](@ref shadow_design). 12 | 13 | See the Device Shadow demo application for sample code. 14 | 15 | */ 16 | -------------------------------------------------------------------------------- /docs/doxygen/pages.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @mainpage Overview 3 | @brief The AWS IoT Device SDK for Embedded C provides demonstration code and integration tests for a collection of libraries. 4 | 5 | @section libraries_section Libraries 6 | The following libraries (along with their source repositories) are part of this SDK: 7 | - [MQTT client](@ref mqtt) - [coreMQTT](https://github.com/FreeRTOS/coreMQTT) 8 | - [HTTP client](@ref http) - [coreHTTP](https://github.com/FreeRTOS/coreHTTP) 9 | - [JSON parser](@ref json) - [coreJSON](https://github.com/FreeRTOS/coreJSON) 10 | - [PKCS #11 implementation](@ref core_pkcs11) - [corePKCS11](https://github.com/FreeRTOS/corePKCS11) 11 | - [AWS IoT Device Shadow client](@ref shadow) - [device-shadow-for-aws-iot-embedded-sdk](https://github.com/aws/device-shadow-for-aws-iot-embedded-sdk) 12 | - [AWS IoT Device Defender client](@ref defender) - [device-defender-for-aws-iot-embedded-sdk](https://github.com/aws/device-defender-for-aws-iot-embedded-sdk) 13 | - [AWS IoT Jobs client](@ref jobs) - [jobs-for-aws-iot-embedded-sdk](https://github.com/aws/jobs-for-aws-iot-embedded-sdk) 14 | - [AWS IoT Over-the-air Update Library](@ref ota) - [ota-for-aws-iot-embedded-sdk](https://github.com/aws/ota-for-aws-iot-embedded-sdk) 15 | */ 16 | -------------------------------------------------------------------------------- /docs/doxygen/plantuml/pkcs11_digest.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam classFontSize 8 3 | skinparam classFontName Helvetica 4 | skinparam dpi 300 5 | autonumber 6 | 7 | participant "Application" as app 8 | participant "PKCS #11" as pkcs 9 | 10 | box "PKCS #11 - Creating A Message Digest" #LightBlue 11 | participant app 12 | participant pkcs 13 | end box 14 | 15 | app -> pkcs: Acquire function list with C_GetFunctionList 16 | pkcs -> app: Return CK_FUNCTION_LIST_PTR with supported functions 17 | 18 | app -> pkcs: Initialize with C_Initialize 19 | 20 | app -> pkcs: Query for a slot with C_GetSlotList 21 | pkcs -> app: Return an array of CK_SLOT_IDs 22 | 23 | app -> pkcs: Open a new session with a slot using C_OpenSession 24 | pkcs -> app: Return a CK_SESSION_HANDLE 25 | 26 | app -> pkcs: Log in to current session with C_Login 27 | 28 | app -> pkcs: Query for supported mechanisms with C_GetMechanismInfo 29 | pkcs -> app: Return CK_MECHANISM_INFO 30 | 31 | app -> pkcs: Start a digest operation using SHA-256 by passing CKM_SHA256 to C_DigestInit 32 | app -> pkcs: Pass bytes buffer of message to C_DigestUpdate 33 | app -> pkcs: Pass bytes buffer for storing the digest to C_DigestFinal 34 | pkcs -> app: Fill buffer with digest bytes 35 | 36 | app -> pkcs: Close session with C_CloseSession 37 | app -> pkcs: Uninitialize with C_Finalize 38 | 39 | @enduml 40 | -------------------------------------------------------------------------------- /docs/doxygen/plantuml/pkcs11_object_generate.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam classFontSize 8 3 | skinparam classFontName Helvetica 4 | skinparam dpi 300 5 | autonumber 6 | 7 | participant "Application" as app 8 | participant "PKCS #11" as pkcs 9 | 10 | box "PKCS #11 - Generating A Key Pair" #LightBlue 11 | participant app 12 | participant pkcs 13 | end box 14 | 15 | app -> pkcs: Acquire function list with C_GetFunctionList 16 | pkcs -> app: Return CK_FUNCTION_LIST_PTR with supported functions 17 | 18 | app -> pkcs: Initialize with C_Initialize 19 | 20 | app -> pkcs: Query for a slot with C_GetSlotList 21 | pkcs -> app: Return an array of CK_SLOT_IDs 22 | 23 | app -> pkcs: Open a new session with a slot using C_OpenSession 24 | pkcs -> app: Return a CK_SESSION_HANDLE 25 | 26 | app -> pkcs: Log in to current session with C_Login 27 | 28 | app -> pkcs: Pass CK_ATTRIBUTEs template to C_CreateKeyPair 29 | pkcs -> app: Return CK_OBJECT_HANDLE for public key and for private key 30 | 31 | app -> pkcs: Close session with C_CloseSession 32 | app -> pkcs: Uninitialize with C_Finalize 33 | 34 | @endumlf 35 | -------------------------------------------------------------------------------- /docs/doxygen/plantuml/pkcs11_object_import.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam classFontSize 8 3 | skinparam classFontName Helvetica 4 | skinparam dpi 300 5 | autonumber 6 | 7 | participant "Application" as app 8 | participant "PKCS #11" as pkcs 9 | 10 | box "PKCS #11 - Importing A Crypto Object" #LightBlue 11 | participant app 12 | participant pkcs 13 | end box 14 | 15 | app -> pkcs: Acquire function list with C_GetFunctionList 16 | pkcs -> app: Return CK_FUNCTION_LIST_PTR with supported functions 17 | 18 | app -> pkcs: Initialize with C_Initialize 19 | 20 | app -> pkcs: Query for a slot with C_GetSlotList 21 | pkcs -> app: Return an array of CK_SLOT_IDs 22 | 23 | app -> pkcs: Open a new session with a slot using C_OpenSession 24 | pkcs -> app: Return a CK_SESSION_HANDLE 25 | 26 | app -> pkcs: Log in to current session with C_Login 27 | 28 | app -> pkcs: Pass Attribute template to C_CreateObject 29 | pkcs -> app: Return CK_OBJECT_HANDLE associated with the new object 30 | 31 | app -> pkcs: Close session with C_CloseSession 32 | app -> pkcs: Uninitialize with C_Finalize 33 | 34 | @enduml 35 | -------------------------------------------------------------------------------- /docs/doxygen/plantuml/pkcs11_rng.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam classFontSize 8 3 | skinparam classFontName Helvetica 4 | skinparam dpi 300 5 | autonumber 6 | 7 | participant "Application" as app 8 | participant "PKCS #11" as pkcs 9 | 10 | box "PKCS #11 - Generating A Random Number" #LightBlue 11 | participant app 12 | participant pkcs 13 | end box 14 | 15 | app -> pkcs: Acquire function list with C_GetFunctionList 16 | pkcs -> app: Return CK_FUNCTION_LIST_PTR with supported functions 17 | 18 | app -> pkcs: Initialize with C_Initialize 19 | 20 | app -> pkcs: Query for a slot with C_GetSlotList 21 | pkcs -> app: Return an array of CK_SLOT_IDs 22 | 23 | app -> pkcs: Open a new session with a slot using C_OpenSession 24 | pkcs -> app: Return a CK_SESSION_HANDLE 25 | 26 | app -> pkcs: Log in to current session with C_Login 27 | 28 | app -> pkcs: Request an array of random bytes with C_GenerateRandom 29 | pkcs -> app: Return an array of random bytes 30 | 31 | app -> pkcs: Close session with C_CloseSession 32 | app -> pkcs: Uninitialize with C_Finalize 33 | 34 | @enduml 35 | -------------------------------------------------------------------------------- /docs/doxygen/plantuml/pkcs11_sign_verify.pu: -------------------------------------------------------------------------------- 1 | @startuml 2 | skinparam classFontSize 8 3 | skinparam classFontName Helvetica 4 | skinparam dpi 300 5 | autonumber 6 | 7 | participant "Application" as app 8 | participant "PKCS #11" as pkcs 9 | 10 | box "PKCS #11 - Signing And Verifying A Signature" #LightBlue 11 | participant app 12 | participant pkcs 13 | end box 14 | 15 | app -> pkcs: Acquire function list with C_GetFunctionList 16 | pkcs -> app: Return CK_FUNCTION_LIST_PTR with supported functions 17 | 18 | app -> pkcs: Initialize with C_Initialize 19 | 20 | app -> pkcs: Query for a slot with C_GetSlotList 21 | pkcs -> app: Return an array of CK_SLOT_IDs 22 | 23 | app -> pkcs: Open a new session with a slot using C_OpenSession 24 | pkcs -> app: Return a CK_SESSION_HANDLE 25 | 26 | app -> pkcs: Log in to current session with C_Login 27 | 28 | app -> pkcs: Initiate a find operation by passing a CK_ATTRIBUTEs template to C_FindObjectsInit 29 | app -> pkcs: Request a CK_OBJECT_HANDLE 30 | pkcs -> app: Return CK_OBJECT_HANDLE for the appropriate object 31 | app -> pkcs: Clean up find operation with C_FindObjectsFinal 32 | 33 | app -> pkcs: Start a digest operation using SHA-256 by passing CKM_SHA256 C_DigestInit 34 | app -> pkcs: Provide bytes buffer of message to hash with C_DigestUpdate 35 | app -> pkcs: Provide bytes buffer to store digest in with C_DigestFinal 36 | pkcs -> app: Fill buffer with digest bytes 37 | 38 | app -> pkcs: Start a sign operation by passing the signature mechanism and private key handle to C_SignInit 39 | app -> pkcs: Provide bytes buffer of message hash and bytes buffer to store the signature to C_Sign 40 | pkcs -> app: Fill signature buffer with signature bytes of hash buffer 41 | 42 | app -> pkcs: Start a verify operation by passing the verify mechanism and public key handle to C_VerifyInit 43 | app -> pkcs: Provide bytes buffer of message hash and bytes buffer of the signature to C_Verify 44 | pkcs -> app: Return OK if public key could verify signature 45 | 46 | app -> pkcs: Close session with C_CloseSession 47 | app -> pkcs: Uninitialize with C_Finalize 48 | 49 | @endumla 50 | 51 | -------------------------------------------------------------------------------- /docs/doxygen/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Stylesheet for Doxygen HTML output. 3 | * 4 | * This file defines styles for custom elements in the header/footer and 5 | * overrides some of the default Doxygen styles. 6 | * 7 | * Styles in this file do not affect the treeview sidebar. 8 | */ 9 | 10 | /* Set the margins to place a small amount of whitespace on the left and right 11 | * side of the page. */ 12 | div.contents { 13 | margin-left:4em; 14 | margin-right:4em; 15 | } 16 | 17 | /* Justify text in paragraphs. */ 18 | p { 19 | text-align: justify; 20 | } 21 | 22 | /* Style of section headings. */ 23 | h1 { 24 | border-bottom: 1px solid #879ECB; 25 | color: #354C7B; 26 | font-size: 160%; 27 | font-weight: normal; 28 | padding-bottom: 4px; 29 | padding-top: 8px; 30 | } 31 | 32 | /* Style of subsection headings. */ 33 | h2:not(.memtitle):not(.groupheader) { 34 | font-size: 125%; 35 | margin-bottom: 0px; 36 | margin-top: 16px; 37 | padding: 0px; 38 | } 39 | 40 | /* Style of paragraphs immediately after subsection headings. */ 41 | h2 + p { 42 | margin: 0px; 43 | padding: 0px; 44 | } 45 | 46 | /* Style of subsection headings. */ 47 | h3 { 48 | font-size: 100%; 49 | margin-bottom: 0px; 50 | margin-left: 2em; 51 | margin-right: 2em; 52 | } 53 | 54 | /* Style of paragraphs immediately after subsubsection headings. */ 55 | h3 + p { 56 | margin-top: 0px; 57 | margin-left: 2em; 58 | margin-right: 2em; 59 | } 60 | 61 | /* Style of the prefix "AWS IoT Device SDK C" that appears in the header. */ 62 | #csdkprefix { 63 | color: #757575; 64 | } 65 | 66 | /* Style of the "Return to main page" link that appears in the header. */ 67 | #returntomain { 68 | padding: 0.5em; 69 | } 70 | 71 | /* Style of the dividers on Configuration Settings pages. */ 72 | div.configpagedivider { 73 | margin-left: 0px !important; 74 | margin-right: 0px !important; 75 | margin-top: 20px !important; 76 | } 77 | 78 | /* Style of configuration setting names. */ 79 | dl.section.user ~ h1 { 80 | border-bottom: none; 81 | color: #000000; 82 | font-family: monospace, fixed; 83 | font-size: 16px; 84 | margin-bottom: 0px; 85 | margin-left: 2em; 86 | margin-top: 1.5em; 87 | } 88 | 89 | /* Style of paragraphs on a configuration settings page. */ 90 | dl.section.user ~ * { 91 | margin-bottom: 10px; 92 | margin-left: 4em; 93 | margin-right: 4em; 94 | margin-top: 0px; 95 | } 96 | 97 | /* Hide the configuration setting marker. */ 98 | dl.section.user { 99 | display: none; 100 | } 101 | 102 | /* Overrides for code fragments and lines. */ 103 | div.fragment { 104 | background: #ffffff; 105 | border: none; 106 | padding: 5px; 107 | } 108 | 109 | div.line { 110 | color: #3a3a3a; 111 | } 112 | 113 | /* Overrides for code syntax highlighting colors. */ 114 | span.comment { 115 | color: #008000; 116 | } 117 | 118 | span.keyword, span.keywordtype, span.keywordflow { 119 | color: #0000ff; 120 | } 121 | 122 | span.preprocessor { 123 | color: #50015a; 124 | } 125 | 126 | span.stringliteral, span.charliteral { 127 | color: #800c0c; 128 | } 129 | 130 | a.code, a.code:visited, a.line, a.line:visited { 131 | color: #496194; 132 | } 133 | -------------------------------------------------------------------------------- /docs/doxygen_templates/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Stylesheet for Doxygen HTML output. 3 | * 4 | * This file defines styles for custom elements in the header/footer and 5 | * overrides some of the default Doxygen styles. 6 | * 7 | * Styles in this file do not affect the treeview sidebar. 8 | */ 9 | 10 | /* Set the margins to place a small amount of whitespace on the left and right 11 | * side of the page. */ 12 | div.contents { 13 | margin-left:4em; 14 | margin-right:4em; 15 | } 16 | 17 | /* Justify text in paragraphs. */ 18 | p { 19 | text-align: justify; 20 | } 21 | 22 | /* Style of section headings. */ 23 | h1 { 24 | border-bottom: 1px solid #879ECB; 25 | color: #354C7B; 26 | font-size: 160%; 27 | font-weight: normal; 28 | padding-bottom: 4px; 29 | padding-top: 8px; 30 | } 31 | 32 | /* Style of subsection headings. */ 33 | h2:not(.memtitle):not(.groupheader) { 34 | font-size: 125%; 35 | margin-bottom: 0px; 36 | margin-top: 16px; 37 | padding: 0px; 38 | } 39 | 40 | /* Style of paragraphs immediately after subsection headings. */ 41 | h2 + p { 42 | margin: 0px; 43 | padding: 0px; 44 | } 45 | 46 | /* Style of subsection headings. */ 47 | h3 { 48 | font-size: 100%; 49 | margin-bottom: 0px; 50 | margin-left: 2em; 51 | margin-right: 2em; 52 | } 53 | 54 | /* Style of paragraphs immediately after subsubsection headings. */ 55 | h3 + p { 56 | margin-top: 0px; 57 | margin-left: 2em; 58 | margin-right: 2em; 59 | } 60 | 61 | /* Style of the prefix "AWS IoT Device SDK C" that appears in the header. */ 62 | #csdkprefix { 63 | color: #757575; 64 | } 65 | 66 | /* Style of the "Return to main page" link that appears in the header. */ 67 | #returntomain { 68 | padding: 0.5em; 69 | } 70 | 71 | /* Style of the dividers on Configuration Settings pages. */ 72 | div.configpagedivider { 73 | margin-left: 0px !important; 74 | margin-right: 0px !important; 75 | margin-top: 20px !important; 76 | } 77 | 78 | /* Style of configuration setting names. */ 79 | dl.section.user ~ h1 { 80 | border-bottom: none; 81 | color: #000000; 82 | font-family: monospace, fixed; 83 | font-size: 16px; 84 | margin-bottom: 0px; 85 | margin-left: 2em; 86 | margin-top: 1.5em; 87 | } 88 | 89 | /* Style of paragraphs on a configuration settings page. */ 90 | dl.section.user ~ * { 91 | margin-bottom: 10px; 92 | margin-left: 4em; 93 | margin-right: 4em; 94 | margin-top: 0px; 95 | } 96 | 97 | /* Hide the configuration setting marker. */ 98 | dl.section.user { 99 | display: none; 100 | } 101 | 102 | /* Overrides for code fragments and lines. */ 103 | div.fragment { 104 | background: #ffffff; 105 | border: none; 106 | padding: 5px; 107 | } 108 | 109 | div.line { 110 | color: #3a3a3a; 111 | } 112 | 113 | /* Overrides for code syntax highlighting colors. */ 114 | span.comment { 115 | color: #008000; 116 | } 117 | 118 | span.keyword, span.keywordtype, span.keywordflow { 119 | color: #0000ff; 120 | } 121 | 122 | span.preprocessor { 123 | color: #50015a; 124 | } 125 | 126 | span.stringliteral, span.charliteral { 127 | color: #800c0c; 128 | } 129 | 130 | a.code, a.code:visited, a.line, a.line:visited { 131 | color: #496194; 132 | } 133 | -------------------------------------------------------------------------------- /docs/lexicon.txt: -------------------------------------------------------------------------------- 1 | abababababababababab 2 | abcdefg 3 | alpn 4 | amazonaws 5 | amz 6 | amzn 7 | ansi 8 | api 9 | apis 10 | app 11 | applicationfunction 12 | argparse 13 | args 14 | argumentlength 15 | arn 16 | ats 17 | auth 18 | aws 19 | backoff 20 | bbaf 21 | bool 22 | boto 23 | br 24 | ca 25 | cacreateserial 26 | cafile 27 | cakey 28 | capath 29 | cc 30 | cd 31 | cdn 32 | cert 33 | certfile 34 | certs 35 | ci 36 | cli 37 | clienttoken 38 | cmake 39 | codingstyle 40 | colspan 41 | com 42 | commmandline 43 | conf 44 | config 45 | configpagestyle 46 | connack 47 | continuators 48 | copybrief 49 | copydoc 50 | corehttp 51 | corejson 52 | coremqtt 53 | corepkcs 54 | cpu 55 | crontab 56 | crt 57 | csr 58 | css 59 | da 60 | datatypes 61 | daws 62 | dclient 63 | dd 64 | debian 65 | defgroup 66 | dev 67 | devel 68 | developerguide 69 | dir 70 | div 71 | droot 72 | ds 73 | ec 74 | ecdsa 75 | eg 76 | en 77 | endcode 78 | enum 79 | esp 80 | ethernet 81 | faws 82 | fixme 83 | freertos 84 | fs 85 | fssl 86 | fus 87 | gcc 88 | gen 89 | generalguidelines 90 | gettopic 91 | github 92 | hmac 93 | href 94 | html 95 | http 96 | https 97 | iam 98 | init 99 | int 100 | iot 101 | json 102 | keyfile 103 | keyout 104 | li 105 | libmosquitto 106 | libssl 107 | linux 108 | localhost 109 | logdebug 110 | logerror 111 | loginfo 112 | logwarn 113 | lowercamelcase 114 | lowercamelcased 115 | mainpage 116 | matchtopic 117 | meminfo 118 | metadata 119 | misra 120 | mkdir 121 | mosquitto 122 | mqtt 123 | mqttconnectinfo 124 | mqttcontext 125 | mqtteventcallback 126 | mqttpublishinfo 127 | mqttqos 128 | mqttsuccess 129 | multithreaded 130 | mv 131 | newkey 132 | ol 133 | openssl 134 | org 135 | os 136 | ota 137 | papplicationhandler 138 | params 139 | pargument 140 | pem 141 | pkcs 142 | plaintext 143 | png 144 | posix 145 | poweron 146 | pre 147 | prereqs 148 | presigned 149 | printf 150 | proc 151 | processloop 152 | pwd 153 | py 154 | qos 155 | receivedbytes 156 | receiveloop 157 | refactored 158 | relaunch 159 | repo 160 | req 161 | resubscribe 162 | rm 163 | rng 164 | rsa 165 | sdk 166 | sha 167 | signedheaders 168 | signin 169 | signup 170 | sigterm 171 | somehash 172 | src 173 | ssl 174 | stdint 175 | struct 176 | structs 177 | styleguide 178 | suback 179 | sudo 180 | svg 181 | tcp 182 | td 183 | testclient 184 | tinycbor 185 | tls 186 | tlsv 187 | tmp 188 | toolchain 189 | tr 190 | txt 191 | ubuntu 192 | udp 193 | uppercamelcase 194 | uppercamelcased 195 | url 196 | urlabcdefgfijk 197 | urllmnmopqrstuvw 198 | urls 199 | userguide 200 | wikipedia 201 | www 202 | xz -------------------------------------------------------------------------------- /integration-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Add each subdirectory in the current directory with a CMakeLists.txt file in it 2 | file(GLOB_RECURSE test_modules "${CMAKE_CURRENT_LIST_DIR}/*/CMakeLists.txt") 3 | foreach(module IN LISTS test_modules) 4 | get_filename_component(DIR_PATH "${module}" DIRECTORY) 5 | add_subdirectory(${DIR_PATH}) 6 | endforeach() 7 | 8 | # Filter demos based on what packages or library exist. 9 | if(NOT ${OpenSSL_FOUND}) 10 | set( openssl_tests 11 | "http_system_test" 12 | "mqtt_system_test" 13 | "shadow_system_test" 14 | ) 15 | message( WARNING "OpenSSL library could not be found. Tests that use it will be excluded from the default target." ) 16 | foreach(test_name ${openssl_tests}) 17 | set_target_properties(${test_name} PROPERTIES EXCLUDE_FROM_ALL true) 18 | endforeach() 19 | endif() 20 | -------------------------------------------------------------------------------- /integration-test/certificates/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /integration-test/http/core_http_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_HTTP_CONFIG_H_ 24 | #define CORE_HTTP_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Logging config definition and header files inclusion are required in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for HTTP. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for HTTP. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the HTTP library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "HTTP" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | /************ End of logging configuration ****************/ 51 | 52 | #endif /* ifndef CORE_HTTP_CONFIG_H_ */ 53 | -------------------------------------------------------------------------------- /integration-test/mqtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project ("mqtt system test") 2 | cmake_minimum_required (VERSION 3.2.0) 3 | 4 | # Include MQTT library's source and header path variables. 5 | include("${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake") 6 | 7 | # ==================== Define your project name (edit) ======================== 8 | set(project_name "mqtt_system") 9 | 10 | # ================= Create the library under test here (edit) ================== 11 | 12 | # list the files you would like to test here 13 | list(APPEND real_source_files 14 | ${MQTT_SOURCES} 15 | ${MQTT_SERIALIZER_SOURCES} 16 | ) 17 | # list the directories the module under test includes 18 | list(APPEND real_include_directories 19 | . 20 | ${MQTT_INCLUDE_PUBLIC_DIRS} 21 | ${LOGGING_INCLUDE_DIRS} 22 | ) 23 | 24 | # ===================== Create UnitTest Code here (edit) ===================== 25 | 26 | # list the directories your test needs to include 27 | list(APPEND test_include_directories 28 | . 29 | ${MQTT_INCLUDE_PUBLIC_DIRS} 30 | ${LOGGING_INCLUDE_DIRS} 31 | ) 32 | 33 | # ============================= (end edit) =================================== 34 | set(real_name "${project_name}_real") 35 | 36 | create_real_library(${real_name} 37 | "${real_source_files}" 38 | "${real_include_directories}" 39 | # Empty mock name as create_real_library needs the 4th argument. 40 | "" 41 | ) 42 | 43 | list(APPEND stest_link_list 44 | lib${real_name}.a 45 | ) 46 | 47 | list(APPEND stest_dep_list 48 | ${real_name} 49 | clock_posix 50 | openssl_posix 51 | ) 52 | 53 | set(stest_name "${project_name}_test") 54 | set(stest_source "${project_name}_test.c") 55 | create_test(${stest_name} 56 | ${stest_source} 57 | "${stest_link_list}" 58 | "${stest_dep_list}" 59 | "${test_include_directories}" 60 | ) 61 | 62 | set_macro_definitions(TARGETS ${stest_name} 63 | REQUIRED 64 | "ROOT_CA_CERT_PATH" 65 | "CLIENT_CERT_PATH" 66 | "CLIENT_PRIVATE_KEY_PATH" 67 | "CLIENT_IDENTIFIER" 68 | "BROKER_ENDPOINT" 69 | "BROKER_PORT" 70 | FILES_TO_CHECK 71 | "test_config.h") 72 | -------------------------------------------------------------------------------- /integration-test/mqtt/core_mqtt_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_MQTT_CONFIG_H_ 24 | #define CORE_MQTT_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for MQTT. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for MQTT. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the MQTT library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "MQTT" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | /************ End of logging configuration ****************/ 51 | 52 | /** 53 | * @brief The maximum number of MQTT PUBLISH messages that may be pending 54 | * acknowledgement at any time. 55 | * 56 | * QoS 1 and 2 MQTT PUBLISHes require acknowledgement from the server before 57 | * they can be completed. While they are awaiting the acknowledgement, the 58 | * client must maintain information about their state. The value of this 59 | * macro sets the limit on how many simultaneous PUBLISH states an MQTT 60 | * context maintains. 61 | */ 62 | #define MQTT_STATE_ARRAY_MAX_COUNT ( 10U ) 63 | 64 | /** 65 | * @brief Number of milliseconds to wait for a ping response to a ping 66 | * request as part of the keep-alive mechanism. 67 | * 68 | * If a ping response is not received before this timeout, then 69 | * #MQTT_ProcessLoop will return #MQTTKeepAliveTimeout. 70 | */ 71 | #define MQTT_PINGRESP_TIMEOUT_MS ( 5000U ) 72 | 73 | #endif /* ifndef CORE_MQTT_CONFIG_H_ */ 74 | -------------------------------------------------------------------------------- /integration-test/shadow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project ("shadow system test") 2 | cmake_minimum_required (VERSION 3.2.0) 3 | 4 | # Include MQTT library's source and header path variables. 5 | include("${CMAKE_SOURCE_DIR}/libraries/standard/coreMQTT/mqttFilePaths.cmake") 6 | 7 | include("${CMAKE_SOURCE_DIR}/libraries/aws/device-shadow-for-aws-iot-embedded-sdk/shadowFilePaths.cmake") 8 | 9 | # ==================== Define your project name (edit) ======================== 10 | set(project_name "shadow_system") 11 | 12 | # ================= Create the library under test here (edit) ================== 13 | 14 | # list the files you would like to test here 15 | list(APPEND real_source_files 16 | ${SHADOW_SOURCES} 17 | ${MQTT_SOURCES} 18 | ${MQTT_SERIALIZER_SOURCES} 19 | ) 20 | # list the directories the module under test includes 21 | list(APPEND real_include_directories 22 | . 23 | ${SHADOW_INCLUDE_PUBLIC_DIRS} 24 | ${MQTT_INCLUDE_PUBLIC_DIRS} 25 | ${LOGGING_INCLUDE_DIRS} 26 | ${CMAKE_CURRENT_LIST_DIR} 27 | ) 28 | 29 | # ===================== Create UnitTest Code here (edit) ===================== 30 | 31 | # list the directories your test needs to include 32 | list(APPEND test_include_directories 33 | . 34 | ${SHADOW_INCLUDE_PUBLIC_DIRS} 35 | ${MQTT_INCLUDE_PUBLIC_DIRS} 36 | ${LOGGING_INCLUDE_DIRS} 37 | ) 38 | 39 | # ============================= (end edit) =================================== 40 | set(real_name "${project_name}_real") 41 | 42 | create_real_library(${real_name} 43 | "${real_source_files}" 44 | "${real_include_directories}" 45 | # Empty mock name as create_real_library needs the 4th argument. 46 | "" 47 | ) 48 | 49 | list(APPEND stest_link_list 50 | lib${real_name}.a 51 | ) 52 | 53 | list(APPEND stest_dep_list 54 | ${real_name} 55 | clock_posix 56 | openssl_posix 57 | ) 58 | 59 | set(stest_name "${project_name}_test") 60 | set(stest_source "${project_name}_test.c") 61 | create_test(${stest_name} 62 | ${stest_source} 63 | "${stest_link_list}" 64 | "${stest_dep_list}" 65 | "${test_include_directories}" 66 | ) 67 | 68 | # Set preprocessor defines for test if configured in build. 69 | if(BROKER_ENDPOINT) 70 | target_compile_definitions( 71 | ${stest_name} PRIVATE 72 | AWS_IOT_ENDPOINT="${BROKER_ENDPOINT}" 73 | ) 74 | endif() 75 | if(ROOT_CA_CERT_PATH) 76 | target_compile_definitions( 77 | ${stest_name} PRIVATE 78 | ROOT_CA_CERT_PATH="${ROOT_CA_CERT_PATH}" 79 | ) 80 | endif() 81 | if(CLIENT_CERT_PATH) 82 | target_compile_definitions( 83 | ${stest_name} PRIVATE 84 | CLIENT_CERT_PATH="${CLIENT_CERT_PATH}" 85 | ) 86 | endif() 87 | if(CLIENT_PRIVATE_KEY_PATH) 88 | target_compile_definitions( 89 | ${stest_name} PRIVATE 90 | CLIENT_PRIVATE_KEY_PATH="${CLIENT_PRIVATE_KEY_PATH}" 91 | ) 92 | endif() 93 | -------------------------------------------------------------------------------- /integration-test/shadow/core_mqtt_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef CORE_MQTT_CONFIG_H_ 24 | #define CORE_MQTT_CONFIG_H_ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Include logging header files and define logging macros in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on 33 | * the logging configuration for MQTT. 34 | * 3. Include the header file "logging_stack.h", if logging is enabled for MQTT. 35 | */ 36 | 37 | #include "logging_levels.h" 38 | 39 | /* Logging configuration for the MQTT library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "MQTT" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | /************ End of logging configuration ****************/ 51 | 52 | /** 53 | * @brief The maximum number of MQTT PUBLISH messages that may be pending 54 | * acknowledgement at any time. 55 | * 56 | * QoS 1 and 2 MQTT PUBLISHes require acknowledgement from the server before 57 | * they can be completed. While they are awaiting the acknowledgement, the 58 | * client must maintain information about their state. The value of this 59 | * macro sets the limit on how many simultaneous PUBLISH states an MQTT 60 | * context maintains. 61 | */ 62 | #define MQTT_STATE_ARRAY_MAX_COUNT ( 10U ) 63 | 64 | /** 65 | * @brief Number of milliseconds to wait for a ping response to a ping 66 | * request as part of the keep-alive mechanism. 67 | * 68 | * If a ping response is not received before this timeout, then 69 | * #MQTT_ProcessLoop will return #MQTTKeepAliveTimeout. 70 | */ 71 | #define MQTT_PINGRESP_TIMEOUT_MS ( 5000U ) 72 | 73 | #endif /* ifndef CORE_MQTT_CONFIG_H_ */ 74 | -------------------------------------------------------------------------------- /integration-test/shadow/shadow_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef SHADOW_CONFIG_H__ 24 | #define SHADOW_CONFIG_H__ 25 | 26 | /**************************************************/ 27 | /******* DO NOT CHANGE the following order ********/ 28 | /**************************************************/ 29 | 30 | /* Logging related header files are required to be included in the following order: 31 | * 1. Include the header file "logging_levels.h". 32 | * 2. Define LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL. 33 | * 3. Include the header file "logging_stack.h". 34 | */ 35 | 36 | /* Include header that defines log levels. */ 37 | #include "logging_levels.h" 38 | 39 | /* Logging configurations for the Shadow library. */ 40 | #ifndef LIBRARY_LOG_NAME 41 | #define LIBRARY_LOG_NAME "SHADOW" 42 | #endif 43 | 44 | #ifndef LIBRARY_LOG_LEVEL 45 | #define LIBRARY_LOG_LEVEL LOG_INFO 46 | #endif 47 | 48 | #include "logging_stack.h" 49 | 50 | /************ End of logging configuration ****************/ 51 | 52 | #endif /* ifndef SHADOW_CONFIG_H__ */ 53 | -------------------------------------------------------------------------------- /libraries/3rdparty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${BUILD_TESTS}) 2 | add_library(cmock STATIC 3 | "${ROOT_DIR}/libraries/3rdparty/CMock/src/cmock.c" 4 | ) 5 | 6 | set_target_properties(cmock PROPERTIES 7 | ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib 8 | POSITION_INDEPENDENT_CODE ON 9 | COMPILE_FLAGS "-Og" 10 | ) 11 | 12 | add_library(unity STATIC 13 | "${3RDPARTY_DIR}/CMock/vendor/unity/src/unity.c" 14 | "${3RDPARTY_DIR}/CMock/vendor/unity/extras/fixture/src/unity_fixture.c" 15 | "${3RDPARTY_DIR}/CMock/vendor/unity/extras/memory/src/unity_memory.c" 16 | ) 17 | set_target_properties(unity PROPERTIES 18 | ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib 19 | POSITION_INDEPENDENT_CODE ON 20 | ) 21 | 22 | target_include_directories(cmock PUBLIC 23 | ${ROOT_DIR}/libraries/3rdparty/CMock/src 24 | ${ROOT_DIR}/libraries/3rdparty/CMock/vendor/unity/src/ 25 | ${ROOT_DIR}/libraries/3rdparty/CMock/examples 26 | ) 27 | 28 | target_link_libraries(cmock unity) 29 | endif() 30 | -------------------------------------------------------------------------------- /libraries/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Macro utility to clone a library and source-related submodules. 2 | macro( clone_path path ) 3 | # Attempt to clone submodules. 4 | if( ${BUILD_CLONE_SUBMODULES} ) 5 | find_package( Git REQUIRED ) 6 | execute_process( COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive ${ARGV1} -- ${path} 7 | WORKING_DIRECTORY ${ROOT_DIR} 8 | RESULT_VARIABLE LIB_CLONE_RESULT ) 9 | if( NOT ${LIB_CLONE_RESULT} STREQUAL "0" ) 10 | message( FATAL_ERROR "Failed to clone submodules." ) 11 | endif() 12 | endif() 13 | endmacro() 14 | 15 | # Clone the submodules only if this is a Git repo. 16 | if( EXISTS ${ROOT_DIR}/.git ) 17 | clone_path( ${MODULES_DIR} ) 18 | clone_path( ${MODULES_DIR}/standard/corePKCS11 "--checkout" ) 19 | endif() 20 | 21 | # Add build configuration for all 3rd party modules. 22 | add_subdirectory(${3RDPARTY_DIR}) 23 | -------------------------------------------------------------------------------- /manifest.yml: -------------------------------------------------------------------------------- 1 | name : "AWS_IoT_Device_SDK_for_Embedded_C" 2 | version: "202103.00" 3 | description: |- 4 | "The AWS IoT Device SDK for Embedded C is a collection of C source 5 | files that can be used in embedded applications to securely connect 6 | to AWS IoT Core and interact with other AWS IoT services on AWS Cloud.\n 7 | \n 8 | See dependencies for included libraries." 9 | dependencies: 10 | - name: "coreMQTT" 11 | version: "v1.1.1" 12 | repository: 13 | type: "git" 14 | url: "https://github.com/FreeRTOS/coreMQTT" 15 | - name: "coreJSON" 16 | version: "v3.0.1" 17 | repository: 18 | type: "git" 19 | url: "https://github.com/FreeRTOS/coreJSON" 20 | - name: "Device-Shadow-for-AWS-IoT-embedded-sdk" 21 | version: "v1.1.0" 22 | repository: 23 | type: "git" 24 | url: "https://github.com/aws/Device-Shadow-for-AWS-IoT-embedded-sdk" 25 | - name: "coreHTTP" 26 | version: "v2.0.1" 27 | repository: 28 | type: "git" 29 | url: "https://github.com/FreeRTOS/coreHTTP" 30 | - name: "Device-Defender-for-AWS-IoT-embedded-sdk" 31 | version: "v1.1.0" 32 | repository: 33 | type: "git" 34 | url: "https://github.com/aws/Device-Defender-for-AWS-IoT-embedded-sdk" 35 | - name: "Jobs-for-AWS-IoT-embedded-sdk" 36 | version: "v1.1.0" 37 | repository: 38 | type: "git" 39 | url: "https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk" 40 | - name: "OTA-for-AWS-IoT-embedded-sdk" 41 | version: "v3.0.0" 42 | repository: 43 | type: "git" 44 | url: "https://github.com/aws/ota-for-aws-iot-embedded-sdk" 45 | - name: "backoffAlgorithm" 46 | version: "v1.0.1" 47 | repository: 48 | type: "git" 49 | url: "https://github.com/FreeRTOS/backoffAlgorithm" 50 | - name: "corePKCS11" 51 | version: "v3.0.1" 52 | repository: 53 | type: "git" 54 | url: "https://github.com/FreeRTOS/corePKCS11" 55 | license: "MIT" 56 | -------------------------------------------------------------------------------- /platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For static library builds, link against static library of OpenSSL 2 | if(NOT BUILD_SHARED_LIBS) 3 | set( OPENSSL_USE_STATIC_LIBS TRUE ) 4 | endif() 5 | find_package(OpenSSL) 6 | # Verify the minimum OpenSSL version required 7 | if( ${OPENSSL_FOUND} AND ( OPENSSL_VERSION MATCHES "0.9$" OR OPENSSL_VERSION MATCHES "1.0$" ) ) 8 | message( WARNING "OpenSSL 1.1.0 or later required: OpenSSL ${OPENSSL_VERSION} found." ) 9 | endif() 10 | 11 | set(THREADS_PREFER_PTHREAD_FLAG ON) 12 | find_package(Threads) 13 | 14 | set(OpenSSL_FOUND ${OpenSSL_FOUND} CACHE INTERNAL "Indicates whether OpenSSL library was found.") 15 | set(Threads_FOUND ${Threads_FOUND} CACHE INTERNAL "Indicates whether Threads library was found.") 16 | 17 | find_library(LIB_RT rt) 18 | 19 | 20 | # Add the posix targets 21 | add_subdirectory( ${PLATFORM_DIR}/posix ) 22 | 23 | # Add ota porting targets 24 | add_subdirectory( ${PLATFORM_DIR}/posix/ota_pal ) 25 | -------------------------------------------------------------------------------- /platform/include/clock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | /** 24 | * @file clock.h 25 | * @brief Time-related functions used by demos and tests in this SDK. 26 | */ 27 | 28 | #ifndef CLOCK_H_ 29 | #define CLOCK_H_ 30 | 31 | /* Standard includes. */ 32 | #include 33 | 34 | /** 35 | * @brief The timer query function. 36 | * 37 | * This function returns the elapsed time. 38 | * 39 | * @return Time in milliseconds. 40 | */ 41 | uint32_t Clock_GetTimeMs( void ); 42 | 43 | /** 44 | * @brief Millisecond sleep function. 45 | * 46 | * @param[in] sleepTimeMs milliseconds to sleep. 47 | */ 48 | void Clock_SleepMs( uint32_t sleepTimeMs ); 49 | 50 | #endif /* ifndef CLOCK_H_ */ 51 | -------------------------------------------------------------------------------- /platform/posix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Include filepaths for source and include. 2 | include(posixFilePaths.cmake) 3 | 4 | # Create target for POSIX implementation of reconnect logic. 5 | add_library( clock_posix 6 | "clock_posix.c" ) 7 | 8 | target_include_directories( clock_posix 9 | PRIVATE 10 | ${PLATFORM_DIR}/include ) 11 | 12 | # Install clock abstraction as library. 13 | if(INSTALL_PLATFORM_ABSTRACTIONS) 14 | install(TARGETS 15 | clock_posix 16 | LIBRARY DESTINATION "${CSDK_LIB_INSTALL_PATH}") 17 | endif() 18 | 19 | if(BUILD_TESTS) 20 | add_subdirectory(utest) 21 | endif() 22 | 23 | # Add the transport targets 24 | add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/transport ) 25 | -------------------------------------------------------------------------------- /platform/posix/clock_posix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | /** 24 | * @file clock_posix.c 25 | * @brief Implementation of the functions in clock.h for POSIX systems. 26 | */ 27 | 28 | /* POSIX include. Allow the default POSIX header to be overridden. */ 29 | #ifdef POSIX_TIME_HEADER 30 | #include POSIX_TIME_HEADER 31 | #else 32 | #include 33 | #endif 34 | 35 | /* Platform clock include. */ 36 | #include "clock.h" 37 | 38 | /* 39 | * Time conversion constants. 40 | */ 41 | #define NANOSECONDS_PER_MILLISECOND ( 1000000L ) /**< @brief Nanoseconds per millisecond. */ 42 | #define MILLISECONDS_PER_SECOND ( 1000L ) /**< @brief Milliseconds per second. */ 43 | 44 | /*-----------------------------------------------------------*/ 45 | 46 | uint32_t Clock_GetTimeMs( void ) 47 | { 48 | int64_t timeMs; 49 | struct timespec timeSpec; 50 | 51 | /* Get the MONOTONIC time. */ 52 | ( void ) clock_gettime( CLOCK_MONOTONIC, &timeSpec ); 53 | 54 | /* Calculate the milliseconds from timespec. */ 55 | timeMs = ( timeSpec.tv_sec * MILLISECONDS_PER_SECOND ) 56 | + ( timeSpec.tv_nsec / NANOSECONDS_PER_MILLISECOND ); 57 | 58 | /* Libraries need only the lower 32 bits of the time in milliseconds, since 59 | * this function is used only for calculating the time difference. 60 | * Also, the possible overflows of this time value are handled by the 61 | * libraries. */ 62 | return ( uint32_t ) timeMs; 63 | } 64 | 65 | /*-----------------------------------------------------------*/ 66 | 67 | void Clock_SleepMs( uint32_t sleepTimeMs ) 68 | { 69 | /* Convert parameter to timespec. */ 70 | struct timespec sleepTime = { 0 }; 71 | 72 | sleepTime.tv_sec = ( ( time_t ) sleepTimeMs / ( time_t ) MILLISECONDS_PER_SECOND ); 73 | sleepTime.tv_nsec = ( ( int64_t ) sleepTimeMs % MILLISECONDS_PER_SECOND ) * NANOSECONDS_PER_MILLISECOND; 74 | 75 | /* High resolution sleep. */ 76 | ( void ) nanosleep( &sleepTime, NULL ); 77 | } 78 | -------------------------------------------------------------------------------- /platform/posix/ota_pal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(ota_pal INTERFACE) 2 | target_sources(ota_pal 3 | INTERFACE 4 | "${CMAKE_CURRENT_SOURCE_DIR}/source/ota_pal_posix.c" 5 | ) 6 | 7 | target_include_directories( ota_pal 8 | INTERFACE 9 | ${CMAKE_CURRENT_LIST_DIR}/source/include 10 | ${LOGGING_INCLUDE_DIRS} 11 | ) 12 | 13 | target_link_libraries( ota_pal 14 | INTERFACE ${OPENSSL_CRYPTO_LIBRARY} 15 | ) 16 | 17 | if(${BUILD_TESTS}) 18 | add_subdirectory(utest) 19 | endif() 20 | -------------------------------------------------------------------------------- /platform/posix/ota_pal/utest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project( "ota_pal unit test" ) 2 | cmake_minimum_required( VERSION 3.2.0 ) 3 | 4 | #== ================== Define your project name (edit) ======================== 5 | set( project_name "ota_pal" ) 6 | 7 | #== =================== Create your mock here (edit) ======================== 8 | 9 | #list the files to mock here 10 | list( APPEND mock_list 11 | ${CMAKE_CURRENT_LIST_DIR}/mocks/stdio_api.h 12 | ${CMAKE_CURRENT_LIST_DIR}/mocks/openssl_api.h 13 | ${CMAKE_CURRENT_LIST_DIR}/mocks/unistd_api.h 14 | ) 15 | #list the directories your mocks need 16 | list( APPEND mock_include_list 17 | ${LOGGING_INCLUDE_DIRS} 18 | ${PLATFORM_DIR}/include 19 | ) 20 | #list the definitions of your mocks to control what to be included 21 | list( APPEND mock_define_list 22 | "" 23 | ) 24 | 25 | #== =============== Create the library under test here (edit) ================== 26 | 27 | #list the files you would like to test here 28 | list( APPEND real_source_files 29 | "${PLATFORM_DIR}/posix/ota_pal/source/ota_pal_posix.c" 30 | ) 31 | 32 | #list the directories the module under test includes 33 | list( APPEND real_include_directories 34 | "${MODULES_DIR}/aws/ota-for-aws-iot-embedded-sdk/source/include" 35 | "${PLATFORM_DIR}/posix/ota_pal/source/include" 36 | ${OPENSSL_INCLUDE_DIR} 37 | ${CMAKE_CURRENT_LIST_DIR} 38 | ${CMAKE_CURRENT_LIST_DIR}/mocks 39 | ) 40 | 41 | #== =================== Create UnitTest Code here (edit) ===================== 42 | 43 | #list the directories your test needs to include 44 | list ( APPEND test_include_directories 45 | ${CMAKE_CURRENT_BINARY_DIR}/include 46 | ${CMAKE_CURRENT_LIST_DIR} 47 | ${MODULES_DIR}/aws/ota-for-aws-iot-embedded-sdk/source/include 48 | /usr/include/x86_64-linux-gnu/sys 49 | mocks 50 | ) 51 | 52 | #== =========================== (end edit) =================================== 53 | set ( mock_name "ota_pal_mocks" ) 54 | set ( real_name "ota_pal_real" ) 55 | 56 | create_mock_list(${mock_name} 57 | "${mock_list}" 58 | "${ROOT_DIR}/tools/cmock/ota.yml" 59 | "${mock_include_list}" 60 | "${mock_define_list}" 61 | ) 62 | 63 | create_real_library ( ${real_name} 64 | "${real_source_files}" 65 | "${real_include_directories}" 66 | "${mock_name}" 67 | ) 68 | 69 | list(APPEND utest_link_list 70 | lib${real_name}.a 71 | ) 72 | 73 | list ( APPEND utest_dep_list 74 | ${real_name} 75 | ) 76 | 77 | set ( utest_name "ota_pal_posix_utest" ) 78 | set ( utest_source "ota_pal_posix_utest.c" ) 79 | create_test ( ${utest_name} 80 | ${utest_source} 81 | "${utest_link_list}" 82 | "${utest_dep_list}" 83 | "${test_include_directories}" 84 | ) 85 | -------------------------------------------------------------------------------- /platform/posix/ota_pal/utest/mocks/unistd_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OTA PAL V2.0.1 for POSIX 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef UNISTD_API_H 24 | #define UNISTD_API_H 25 | 26 | extern char * getcwd( char * buf, 27 | size_t size ); 28 | 29 | #endif /* ifndef UNISTD_API_H */ 30 | -------------------------------------------------------------------------------- /platform/posix/posixFilePaths.cmake: -------------------------------------------------------------------------------- 1 | # This file is to add source files and include directories 2 | # into variables so that it can be reused from different repositories 3 | # in their Cmake based build system by including this file. 4 | # 5 | # Files specific to the repository such as test runner, platform tests 6 | # are not added to the variables. 7 | 8 | # Sockets utility source files. 9 | set( SOCKETS_SOURCES 10 | ${CMAKE_CURRENT_LIST_DIR}/transport/src/sockets_posix.c ) 11 | 12 | # Plaintext transport source files. 13 | set( PLAINTEXT_TRANSPORT_SOURCES 14 | ${CMAKE_CURRENT_LIST_DIR}/transport/src/plaintext_posix.c ) 15 | 16 | # OpenSSL transport source files. 17 | set( OPENSSL_TRANSPORT_SOURCES 18 | ${CMAKE_CURRENT_LIST_DIR}/transport/src/openssl_posix.c ) 19 | 20 | # Transport Public Include directories. 21 | set( COMMON_TRANSPORT_INCLUDE_PUBLIC_DIRS 22 | ${CMAKE_CURRENT_LIST_DIR}/transport/include 23 | ${PLATFORM_DIR}/include ) 24 | -------------------------------------------------------------------------------- /platform/posix/transport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Include filepaths for source and include. 2 | include( ${PLATFORM_DIR}/posix/posixFilePaths.cmake ) 3 | 4 | set( TRANSPORT_INTERFACE_INCLUDE_DIR 5 | ${MODULES_DIR}/standard/coreMQTT/source/interface ) 6 | 7 | # Create target for sockets utility. 8 | add_library( sockets_posix 9 | ${SOCKETS_SOURCES} ) 10 | 11 | target_include_directories( sockets_posix 12 | PUBLIC 13 | ${COMMON_TRANSPORT_INCLUDE_PUBLIC_DIRS} 14 | ${LOGGING_INCLUDE_DIRS} 15 | ${TRANSPORT_INTERFACE_INCLUDE_DIR} ) 16 | 17 | # Create target for plaintext transport. 18 | add_library( plaintext_posix 19 | ${PLAINTEXT_TRANSPORT_SOURCES} ) 20 | 21 | target_link_libraries( plaintext_posix 22 | PUBLIC 23 | sockets_posix ) 24 | 25 | # Create target for POSIX implementation of OpenSSL. 26 | add_library( openssl_posix 27 | ${OPENSSL_TRANSPORT_SOURCES} ) 28 | 29 | target_link_libraries( openssl_posix 30 | PUBLIC 31 | sockets_posix 32 | PRIVATE 33 | # This variable is set by the built-in FindOpenSSL.cmake 34 | # and contains the path to the actual library. 35 | ${OPENSSL_LIBRARIES} 36 | # SSL uses Threads and on some platforms require 37 | # explicit linking. 38 | Threads::Threads 39 | # SSL uses Dynamic Loading and on some platforms 40 | # requires explicit linking. 41 | ${CMAKE_DL_LIBS} ) 42 | 43 | # Install transport implementations as libraries. 44 | if(INSTALL_PLATFORM_ABSTRACTIONS) 45 | install(TARGETS 46 | openssl_posix 47 | plaintext_posix 48 | sockets_posix 49 | LIBRARY DESTINATION "${CSDK_LIB_INSTALL_PATH}") 50 | endif() 51 | 52 | if( BUILD_TESTS ) 53 | add_subdirectory( utest ) 54 | endif() 55 | -------------------------------------------------------------------------------- /platform/posix/transport/utest/mocks/select_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | /** 24 | * @file select_api.h 25 | * @brief This file is used to generate mocks for functions used from . 26 | * Mocking select.h itself causes several errors from parsing its macros. 27 | */ 28 | 29 | #ifndef SELECT_API_H_ 30 | #define SELECT_API_H_ 31 | 32 | #include 33 | 34 | extern int select( int nfds, 35 | fd_set * readfds, 36 | fd_set * writefds, 37 | fd_set * exceptfds, 38 | struct timeval * timeout ); 39 | 40 | #endif /* ifndef SELECT_API_H_ */ 41 | -------------------------------------------------------------------------------- /platform/posix/transport/utest/mocks/stdio_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef STDIO_API_H_ 24 | #define STDIO_API_H_ 25 | 26 | #include 27 | 28 | #if defined( __FILE_defined ) 29 | #define _STDIO_FILE_TYPE __FILE 30 | #else 31 | #define _STDIO_FILE_TYPE _IO_FILE 32 | #endif 33 | 34 | /** 35 | * @file stdio_api.h 36 | * @brief This file is used to generate mocks for functions used from . 37 | * Mocking stdio.h itself causes several errors from parsing its macros. 38 | */ 39 | 40 | /* Open a file and create a new stream for it. */ 41 | extern _STDIO_FILE_TYPE * fopen( const char * __filename, 42 | const char * __modes ); 43 | 44 | /* Close STREAM. */ 45 | extern int fclose( _STDIO_FILE_TYPE * __stream ); 46 | 47 | #endif /* ifndef STDIO_API_H_ */ 48 | -------------------------------------------------------------------------------- /platform/posix/transport/utest/mocks/unistd_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef UNISTD_API_H_ 24 | #define UNISTD_API_H_ 25 | 26 | /** 27 | * @file unistd_api.h 28 | * @brief This file is used to generate a mock for any functions from 29 | * unistd.h since mocking unistd.h causes several compilation errors from 30 | * parsing its macros. 31 | */ 32 | 33 | /* Close the file descriptor FD. 34 | * 35 | * This function is a cancellation point and therefore not marked with 36 | * __THROW. */ 37 | extern int close( int __fd ); 38 | 39 | /* Get the pathname of the current working directory, 40 | * and put it in SIZE bytes of BUF. Returns NULL if the 41 | * directory couldn't be determined or SIZE was too small. 42 | * If successful, returns BUF. In GNU, if BUF is NULL, 43 | * an array is allocated with `malloc'; the array is SIZE 44 | * bytes long, unless SIZE == 0, in which case it is as 45 | * big as necessary. */ 46 | extern char * getcwd( char * __buf, 47 | size_t __size ); 48 | 49 | #endif /* ifndef UNISTD_API_H_ */ 50 | -------------------------------------------------------------------------------- /platform/posix/utest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project ("posix unit test") 2 | cmake_minimum_required (VERSION 3.2.0) 3 | 4 | # ==================== Define your project name (edit) ======================== 5 | set(project_name "posix") 6 | 7 | # ===================== Create your mock here (edit) ======================== 8 | 9 | # list the files to mock here 10 | list(APPEND mock_list 11 | ${CMAKE_CURRENT_LIST_DIR}/mocks/time_api.h 12 | ) 13 | # list the directories your mocks need 14 | list(APPEND mock_include_list 15 | ${PLATFORM_DIR}/include 16 | ) 17 | #list the definitions of your mocks to control what to be included 18 | list(APPEND mock_define_list 19 | "" 20 | ) 21 | 22 | # ================= Create the library under test here (edit) ================== 23 | 24 | # list the files you would like to test here 25 | list(APPEND real_source_files 26 | ${PLATFORM_DIR}/posix/retry_utils_posix.c 27 | ) 28 | # list the directories the module under test includes 29 | list(APPEND real_include_directories 30 | ${PLATFORM_DIR}/include 31 | ) 32 | 33 | # ===================== Create UnitTest Code here (edit) ===================== 34 | 35 | # list the directories your test needs to include 36 | list(APPEND test_include_directories 37 | ${PLATFORM_DIR}/include 38 | /usr/include 39 | mocks 40 | ) 41 | 42 | # ============================= (end edit) =================================== 43 | 44 | # Create the target for unit testing the clock 45 | set(real_name "clock_real") 46 | set(mock_name "clock_mock") 47 | 48 | create_mock_list(${mock_name} 49 | "${mock_list}" 50 | "${ROOT_DIR}/tools/cmock/project.yml" 51 | "${mock_include_list}" 52 | "${mock_define_list}" 53 | ) 54 | 55 | set(real_source_files 56 | ${PLATFORM_DIR}/posix/clock_posix.c 57 | ) 58 | 59 | create_real_library(${real_name} 60 | "${real_source_files}" 61 | "${real_include_directories}" 62 | "${mock_name}" 63 | ) 64 | 65 | set(utest_link_list 66 | lib${real_name}.a 67 | -l${mock_name} 68 | ) 69 | 70 | set(utest_dep_list 71 | ${real_name} 72 | ) 73 | 74 | set(utest_name "clock_utest") 75 | set(utest_source "clock_utest.c") 76 | create_test(${utest_name} 77 | ${utest_source} 78 | "${utest_link_list}" 79 | "${utest_dep_list}" 80 | "${test_include_directories}" 81 | ) 82 | -------------------------------------------------------------------------------- /platform/posix/utest/mocks/time_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AWS IoT Device SDK for Embedded C 202103.00 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | /** 24 | * @file time_api.h 25 | * @brief This file is used to generate a mock for any functions from 26 | * time.h since mocking time.h causes several compilation errors from 27 | * parsing its macros. 28 | */ 29 | 30 | #ifndef TIME_API_H_ 31 | #define TIME_API_H_ 32 | 33 | #include 34 | 35 | /* Make the process sleep for SECONDS seconds, or until a signal arrives 36 | * and is not ignored. The function returns the number of seconds less 37 | * than SECONDS which it actually slept (thus zero if it slept the full time). 38 | * If a signal handler does a `longjmp' or modifies the handling of the 39 | * SIGALRM signal while inside `sleep' call, the handling of the SIGALRM 40 | * signal afterwards is undefined. There is no return value to indicate 41 | * error, but if `sleep' returns SECONDS, it probably didn't work. 42 | * 43 | * This function is a cancellation point and therefore not marked with 44 | * __THROW. */ 45 | extern unsigned int sleep( unsigned int seconds ); 46 | 47 | /* Get current value of clock CLOCK_ID and store it in the timespec. */ 48 | extern int clock_gettime( clockid_t clock_id, 49 | struct timespec * time_point ); 50 | 51 | /* Pause execution for a number of nanoseconds. 52 | * 53 | * This function is a cancellation point and therefore not marked with 54 | * __THROW. */ 55 | extern int nanosleep( const struct timespec * requested_time, 56 | struct timespec * remaining ); 57 | 58 | #endif /* ifndef TIME_API_ */ 59 | -------------------------------------------------------------------------------- /tools/cmock/cmock_dependencies.cmake: -------------------------------------------------------------------------------- 1 | # Check if the CMock source directory exists. 2 | if( NOT EXISTS ${3RDPARTY_DIR}/CMock/src ) 3 | # Attempt to clone CMock. 4 | if( ${BUILD_CLONE_SUBMODULES} ) 5 | find_package( Git REQUIRED ) 6 | 7 | message( "Cloning submodule CMock." ) 8 | execute_process( COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive libraries/3rdparty/CMock 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 10 | RESULT_VARIABLE CMOCK_CLONE_RESULT ) 11 | 12 | if( NOT ${CMOCK_CLONE_RESULT} STREQUAL "0" ) 13 | message( FATAL_ERROR "Failed to clone CMock submodule." ) 14 | endif() 15 | else() 16 | message( FATAL_ERROR "The required submodule CMock does not exist. Either clone it manually, or set BUILD_CLONE_SUBMODULES to 1 to automatically clone it during build." ) 17 | endif() 18 | endif() 19 | 20 | include("${ROOT_DIR}/tools/cmock/create_test.cmake") 21 | 22 | include_directories("${3RDPARTY_DIR}/CMock/vendor/unity/src/" 23 | "${3RDPARTY_DIR}/CMock/vendor/unity/extras/fixture/src" 24 | "${3RDPARTY_DIR}/CMock/vendor/unity/extras/memory/src" 25 | "${3RDPARTY_DIR}/CMock/src" 26 | ) 27 | link_directories("${CMAKE_BINARY_DIR}/lib" 28 | ) 29 | -------------------------------------------------------------------------------- /tools/cmock/ota.yml: -------------------------------------------------------------------------------- 1 | :cmock: 2 | :mock_prefix: mock_ 3 | :when_no_prototypes: :warn 4 | :enforce_strict_ordering: true 5 | # fclose is called after program terminates, so this will avoid a segfault. 6 | :fail_on_unexpected_calls: false 7 | :plugins: 8 | - :ignore 9 | - :ignore_arg 10 | - :expect_any_args 11 | - :array 12 | - :callback 13 | - :return_thru_ptr 14 | :callback_include_count: true # include a count arg when calling the callback 15 | :callback_after_arg_check: false # check arguments before calling the callback 16 | :treat_as: 17 | uint8: HEX8 18 | uint16: HEX16 19 | uint32: UINT32 20 | int8: INT8 21 | bool: UINT8 22 | :includes: # This will add these includes to each mock. 23 | - 24 | - 25 | :treat_externs: :include # Now the extern-ed functions will be mocked. 26 | :weak: __attribute__((weak)) 27 | :verbosity: 3 28 | :strippables: 29 | # These keywords are found in many POSIX APIs but is stripped as it cannot be parsed by CMock. 30 | - __restrict 31 | - \s__THROW 32 | - __owur 33 | - __attribute__((__warn_unused_result__)) 34 | -------------------------------------------------------------------------------- /tools/cmock/project.yml: -------------------------------------------------------------------------------- 1 | # Taken from amazon-freertos repository 2 | :cmock: 3 | :mock_prefix: mock_ 4 | :when_no_prototypes: :warn 5 | :enforce_strict_ordering: TRUE 6 | :plugins: 7 | - :ignore 8 | - :ignore_arg 9 | - :expect_any_args 10 | - :array 11 | - :callback 12 | - :return_thru_ptr 13 | :callback_include_count: true # include a count arg when calling the callback 14 | :callback_after_arg_check: false # check arguments before calling the callback 15 | :treat_as: 16 | uint8: HEX8 17 | uint16: HEX16 18 | uint32: UINT32 19 | int8: INT8 20 | bool: UINT8 21 | :includes: # This will add these includes to each mock. 22 | - 23 | - 24 | :treat_externs: :include # Now the extern-ed functions will be mocked. 25 | :weak: __attribute__((weak)) 26 | :verbosity: 3 27 | :attributes: 28 | - PRIVILEGED_FUNCTION 29 | :strippables: 30 | - PRIVILEGED_FUNCTION 31 | - portDONT_DISCARD 32 | # These keywords are found in many POSIX APIs but is stripped as it cannot be parsed by CMock. 33 | - __restrict 34 | - \s__THROW 35 | -------------------------------------------------------------------------------- /tools/cmock/transport.yml: -------------------------------------------------------------------------------- 1 | :cmock: 2 | :mock_prefix: mock_ 3 | :when_no_prototypes: :warn 4 | :enforce_strict_ordering: true 5 | # fclose is called after program terminates, so this will avoid a segfault. 6 | :fail_on_unexpected_calls: false 7 | :plugins: 8 | - :ignore 9 | - :ignore_arg 10 | - :expect_any_args 11 | - :array 12 | - :callback 13 | - :return_thru_ptr 14 | :callback_include_count: true # include a count arg when calling the callback 15 | :callback_after_arg_check: false # check arguments before calling the callback 16 | :treat_as: 17 | uint8: HEX8 18 | uint16: HEX16 19 | uint32: UINT32 20 | int8: INT8 21 | bool: UINT8 22 | :includes: # This will add these includes to each mock. 23 | - 24 | - 25 | :treat_externs: :include # Now the extern-ed functions will be mocked. 26 | :weak: __attribute__((weak)) 27 | :verbosity: 3 28 | :attributes: 29 | - PRIVILEGED_FUNCTION 30 | :strippables: 31 | - PRIVILEGED_FUNCTION 32 | - portDONT_DISCARD 33 | # These keywords are found in many POSIX APIs but is stripped as it cannot be parsed by CMock. 34 | - __restrict 35 | - \s__THROW 36 | # These functions in socket.h cannot be parsed correctly by CMock, so we won't mock them. 37 | - (.*)sendmsg((.|\n|\r)+?\;) 38 | - (.*)sendmmsg((.|\n|\r)+?\;) 39 | - (.*)recvmsg((.|\n|\r)+?\;) 40 | - (.*)recvmmsg((.|\n|\r)+?\;) 41 | # These functions in netdb.h cannot be parsed correctly by CMock, so we won't mock them. 42 | - (.*)getaddrinfo_a((.|\n|\r)+?\;) 43 | - (.*)gai_((.|\n|\r)+?\;) 44 | -------------------------------------------------------------------------------- /tools/coverity/misra.config: -------------------------------------------------------------------------------- 1 | // MISRA C-2012 Rules 2 | 3 | { 4 | version : "2.0", 5 | standard : "c2012", 6 | title: "Coverity MISRA Configuration", 7 | deviations : [ 8 | // Disable the following rules. 9 | { 10 | deviation: "Directive 4.5", 11 | reason: "Allow names that MISRA considers ambiguous (such as enum IOT_MQTT_CONNECT and function IotMqtt_Connect)." 12 | }, 13 | { 14 | deviation: "Directive 4.8", 15 | reason: "Allow inclusion of unused types. Header files for a specific port, which are needed by all files, may define types that are not used by a specific file." 16 | }, 17 | { 18 | deviation: "Directive 4.9", 19 | reason: "Allow inclusion of function like macros. Logging is done using function like macros." 20 | }, 21 | { 22 | deviation: "Rule 2.3", 23 | reason: "Allow unused types. Library headers may define types intended for the application's use, but not used within the library files." 24 | }, 25 | { 26 | deviation: "Rule 2.4", 27 | reason: "Allow unused tags. Some compilers warn if types are not tagged." 28 | }, 29 | { 30 | deviation: "Rule 2.5", 31 | reason: "Allow unused macros. Library headers may define macros intended for the application's use, but not used by a specific file." 32 | }, 33 | { 34 | deviation: "Rule 3.1", 35 | reason: "Allow nested comments. Documentation blocks contain comments for example code." 36 | }, 37 | { 38 | deviation: "Rule 11.5", 39 | reason: "Allow casts from void *. Contexts are passed as void * and must be cast to the correct data type before use." 40 | }, 41 | { 42 | deviation: "Rule 21.1", 43 | reason: "Allow use of all names." 44 | }, 45 | { 46 | deviation: "Rule 21.2", 47 | reason: "Allow use of all names." 48 | } 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /tools/doxygen/README.md: -------------------------------------------------------------------------------- 1 | # Generate all Doxygen 2 | 3 | ## Prerequisites 4 | 5 | - [Git](https://git-scm.com/downloads/) 6 | - [Python 3+](https://www.python.org/downloads/) 7 | 8 | ## Output 9 | 10 | This script generates all of the Doxygen documentation for the CSDK and its 11 | library spoke repos. 12 | Any Doxygen warnings from generation will print out to the console. 13 | Optionally, one can also choose to zip up the generated Doxygen documentation. 14 | 15 | ## Usage 16 | 17 | ### Preliminary 18 | 19 | Ensure that all of the library spoke repositories are cloned before running this script. 20 | 21 | ```console 22 | cd aws-iot-device-sdk-embedded-C 23 | git submodule update --init --checkout libraries/standard libraries/aws 24 | ``` 25 | 26 | ### Generate Doxygen 27 | 28 | You can run this script from anywhere with the path to the CSDK repo root. 29 | 30 | ```console 31 | python3 generate_docs.py --root 32 | ``` 33 | 34 | If the `--root` option is not given, then the script assumes the current working 35 | directory is the CSDK repo root. 36 | 37 | ```console 38 | python3 tools/doxygen/generate_docs.py 39 | ``` 40 | 41 | ### Generate Doxygen Zipfile 42 | 43 | Pass the `--zip` or `-z` option to create a zip file named "**doxygen.zip**" in the 44 | current working directory. 45 | 46 | ```console 47 | python3 tools/doxygen/generate_docs.py --zip 48 | ``` 49 | -------------------------------------------------------------------------------- /tools/link-verifier/README.md: -------------------------------------------------------------------------------- 1 | # Link Verification Script 2 | 3 | ## Pre-Requisites 4 | 5 | - Unix/Linux system 6 | - Python3 7 | - [pandoc](https://github.com/jgm/pandoc). Used to convert Markdown files to HTML, which are then searched. 8 | - [GitHub CLI](https://github.com/cli/cli). Optional, but recommended to speed up the testing of links involving GitHub issues and pull requests. 9 | - See [requirements.txt](requirements.txt) for versions of Python packages. This script uses beautfulsoup4, requests, and termcolor. 10 | 11 | ## Usage 12 | 13 | ```bash 14 | python3 tools/link-verifier/verify-links.py -F [MARKDOWN_FILE_LIST] -L [URL_LIST] 15 | ``` 16 | The script will print URLs that were not accessible. For Markdown files, it will also test relative paths to files, and anchors within the same document. 17 | 18 | ### Allowlist 19 | 20 | [allowlist.txt](allowlist.txt) contains a list of non-existant URLs used as placeholder examples in this repository. The script does not use it, but it can be used to filter out URLs before passing them in. 21 | 22 | ### Example 23 | 1. From the root of the repository, generate a list of Markdown files to test and store them in an array. Filter out files from third party repositories, and convert newlines to spaces. 24 | 25 | ```bash 26 | FILES=($(find . -type f -name '*.md' | \ 27 | grep -E -i -v 'cbmc|cmock|third-party|3rdparty|libmosquitto' | \ 28 | tr '\n' ' ')) 29 | ``` 30 | 2. Extract URLs from the other files to test. Since Markdown files are tested separately, only search for `.c`, `.h`, and `.dox` files, and exclude directories from third party repositories. The URLs are sorted so that the allowlist can be used to filter them further. 31 | 32 | ```bash 33 | LINKS=($(grep -e 'https\?://' . -RIa --include='*.c' --include='*.h' --include='*.dox' \ 34 | --exclude-dir=.git --exclude-dir=cbmc --exclude-dir=CMock \ 35 | --exclude-dir=third-party --exclude-dir=3rdparty --exclude-dir=libmosquitto | \ 36 | grep -IoE '\b(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]' | \ 37 | sort | uniq | grep -Fxvf tools/link-verifier/allowlist.txt | tr '\n' ' ')) 38 | ``` 39 | 3. Run the script with the files and links. Optionally increase verbosity to print all links. 40 | 41 | ```bash 42 | ./tools/link-verifier/verify-links.py -F ${FILES[@]} -L ${LINKS[@]} -v 43 | ``` 44 | 45 | ## Command Line Options 46 | 47 | | Option | Argument | Description | 48 | | --- | --- | --- | 49 | | `-F`, `--files` | 1 or more space-separated filepaths | Filepaths to GitHub-flavored Markdown files for which to verify links. Filepaths may be absolute or relative. | 50 | | `-L`, `--links` | 1 or more space-separated URLs | List of URLs to test. URLs should be separated by spaces. | 51 | | `-n`, `--num-processes` | Integer | Number of threads to run in parallel when generating HTML files from Markdown. Each link is still tested serially, however. | 52 | | `-k`, `--keep` | *None* | Option to keep temporary HTML files instead of deleting them. Only useful for debugging. | 53 | | `-v`, `--verbose` | *None* | Increase verbosity to print all files and links tested, instead of only errors. | 54 | -------------------------------------------------------------------------------- /tools/link-verifier/allowlist.txt: -------------------------------------------------------------------------------- 1 | https://aws-s3-endpoint/object-key.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ABABABABABABABABABAB%2F20201027%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20201027T194726Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=SomeHash12345UrlABcdEFgfIjK 2 | https://aws-s3-endpoint/object-key.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ABABABABABABABABABAB%2F20201027%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20201027T194726Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=SomeHash12345UrlLMnmOPqrStUvW 3 | https://www.somewebsite.com/path/to/item.txt?optionalquery=stuff 4 | https://dummy-url.com/ota.bin 5 | -------------------------------------------------------------------------------- /tools/link-verifier/requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.9.3 2 | bs4==0.0.1 3 | certifi==2020.12.5 4 | chardet==3.0.4 5 | idna==2.10 6 | requests==2.25.0 7 | soupsieve==2.1 8 | termcolor==1.1.0 9 | urllib3==1.26.2 10 | -------------------------------------------------------------------------------- /tools/release/README.md: -------------------------------------------------------------------------------- 1 | # Pre-release verification for AWS IoT Embedded C SDK 2 | 3 | ## Prerequisites 4 | 5 | - Linux environment 6 | - [Git](https://git-scm.com/downloads/) 7 | - [Python 3](https://www.python.org/downloads/) 8 | - See [requirements.txt](requirements.txt) for the versions of Python packages needed. 9 | 10 | This script accompanies the CSDK release CM. You must use it in conjunction with a Preflight step. 11 | 12 | ## Output 13 | This script checks that: 14 | - All unit tests and code quality checks pass in each library repo committed on the main branch. 15 | - All jobs pass in /view/CSDK%20Jobs/job/csdk/ 16 | - Only the main branch exists in library repos. 17 | - Only the main branch and v4_beta_deprecated exist in the CSDK. 18 | - Each library repo has a tag and release labeled with the version specified in the config. 19 | - manifest.yml has all libraries and versions expected in this script's config.yml 20 | - There are no pending PRs on the main branch. 21 | 22 | This script outputs: 23 | - **error.log** in the working directory for any errors found in verification. 24 | - **docs_to_review.txt** for all CHANGELOG.md and README.md files that need manual review. 25 | 26 | ## Usage 27 | 28 | 1. Clone https://github.com/aws/aws-iot-device-sdk-embedded-C/ 29 | ```console 30 | git clone git@github.com:aws/aws-iot-device-sdk-embedded-C.git --recurse-submodules 31 | ``` 32 | 33 | 1. You will need your [Github API Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) and Jenkins CI URL, Username and Password. These should be saved into your system's environment variables as GITHUB_ACCESS_TOKEN, JENKINS_USERNAME, JENKINS_PASSWORD, JENKINS_API_URL. 34 | ```console 35 | export GITHUB_ACCESS_TOKEN="my-secret-github-access-token" 36 | export JENKINS_API_URL="aws-team-jenkins-url" 37 | export JENKINS_USERNAME="my-jenkins-ci-username" 38 | export JENKINS_PASSWORD="my-jenkins-ci-password" 39 | ``` 40 | You can also enter these as parameters to the script. 41 | ``` 42 | --github-access-token "my-secret-github-access-token" 43 | --jenkins-api-url "aws-team-jenkins-url" 44 | --jenkins-user "my-jenkins-ci-username" 45 | --jenkins-password "my-jenkins-ci-password" 46 | ``` 47 | 48 | 1. Run the script with the versions of every library repo that exists under [libraries/aws](../../libraries/aws) and [libaries/standard](../../libraries/standard) directories. 49 | ```console 50 | python3 tools/release/release-verify.py \ 51 | --root aws-iot-device-sdk-embedded-c \ 52 | --csdk-version \ 53 | --coremqtt-version \ 54 | --corehttp-version \ 55 | --corejson-version \ 56 | --device-defender-for-aws-iot-embedded-sdk-version \ 57 | --device-shadow-for-aws-iot-embedded-sdk-version \ 58 | --jobs-for-aws-iot-embedded-sdk-version \ 59 | --corepkcs11-version \ 60 | --backoffalgorithm-version \ 61 | --ota-for-aws-iot-embedded-sdk \ 62 | --disable-cbmc-checks-for \ 63 | --disable-cbmc-checks-for \ 64 | --disable-jenkins-server-verify 65 | ``` 66 | 67 | -------------------------------------------------------------------------------- /tools/release/requirements.txt: -------------------------------------------------------------------------------- 1 | requests==2.24.0 2 | PyYAML==5.3.1 3 | -------------------------------------------------------------------------------- /tools/spell/README.md: -------------------------------------------------------------------------------- 1 | # Pre-requisites to running the spell check scripts 2 | 3 | 1. In your GNU environment, install the *spell* and *getopt* programs. Use the following commands in Debian distributions, to install the packages (*getopt* is part of the `util-linux` package): 4 | ```shell 5 | apt-get install spell 6 | apt-get install util-linux 7 | ``` 8 | 9 | 1. Add the folder containing the **tools/spell/ablexicon**, **tools/spell/extract-comments**, and **tools/spell/find-unknown-comment-words** scripts to your system's PATH. 10 | ```shell 11 | export PATH=/tools/spell:$PATH 12 | ``` 13 | 14 | # How to create a lexicon.txt for a new library. 15 | 16 | 1. Ensure there does not exist a file called "lexicon.txt" in your library's directory. Run the following command to create a lexicon.txt for your library: 17 | ```shell 18 | find-unknown-comment-words -d /libraries// > /libraries///words.txt 19 | mv /libraries///words.txt /libraries///lexicon.txt 20 | ``` 21 | 22 | 1. Check the contents of */libraries///lexicon.txt* for any misspelled words. Fix them in your library's source code and delete them from the lexicon.txt. 23 | 24 | # How to run for changes to an existing library. 25 | 26 | 1. If there exists a lexicon.txt in the library's directory, run the following command: 27 | ```shell 28 | find-unknown-comment-words -d /libraries// 29 | ``` 30 | 31 | 1. Add any non-dictionary correctly spelled words to */libraries///lexicon.txt*. Fix any misspelled words in your code comment change. 32 | -------------------------------------------------------------------------------- /tools/spell/ablexicon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ablexicon - Compare an input list of words against a dictionary and 4 | # optional lexicon. If any words are in neither the dictionary nor the 5 | # lexicon, log them to stdout. 6 | # 7 | set -e 8 | set -f 9 | 10 | function usage () { 11 | echo "Find occurrences of non-dictionary/lexicon words" 12 | echo "" 13 | echo "Usage:" 14 | echo " ${0##*/} [options]" 15 | echo "" 16 | echo "Options:" 17 | echo " -f, --file source text (defaults to /dev/fd/0)" 18 | echo " -l, --lexicon lexicon file (one word per line)" 19 | echo " -h, --help display this help" 20 | exit 1 21 | } 22 | 23 | # 24 | # Verify that required commands are present 25 | # 26 | REQUIRED=( "spell" "getopt" ) 27 | for i in "${REQUIRED[@]}" 28 | do 29 | command -v $i"" >/dev/null 30 | if [ $? -ne "0" ] 31 | then 32 | echo "'"$i"' must be installed, exiting...">&2 33 | exit 1 34 | fi 35 | done 36 | 37 | GETOPT_OUT=`getopt -o hf:l: --long help,file:,lexicon: -n "${0##*/}" -- "$@"` 38 | if [ $? != 0 ] 39 | then 40 | echo "Exiting..." >&2 41 | exit 1 42 | fi 43 | 44 | eval set -- "$GETOPT_OUT" 45 | 46 | INFILE=/dev/fd/0 47 | LEXICON=/dev/null 48 | while true; do 49 | case "$1" in 50 | -h | --help ) usage $0 ;; 51 | -f | --file ) INFILE="$2"; shift 2 ;; 52 | -l | --lexicon ) LEXICON="$2"; shift 2 ;; 53 | -- ) shift; break ;; 54 | * ) break ;; 55 | esac 56 | done 57 | 58 | if [ ! -f $INFILE"" ] && [ $INFILE"" != /dev/fd/0 ] 59 | then 60 | echo "Invalid input file" 61 | usage 62 | fi 63 | # 64 | # Read the lexicon into an array 65 | # 66 | readarray -t lexicon < $LEXICON"" 67 | lexicon_size="${#lexicon[@]}" 68 | 69 | # 70 | # Search for all input words in the dictionary 71 | # and sort the output 72 | # 73 | for word in `cat $INFILE"" | spell | sort -u` 74 | do 75 | # 76 | # Search for each remaining word in the lexicon 77 | # 78 | found="false" 79 | i="0" 80 | while [[ "$i" -lt "$lexicon_size" ]] && [ "$found" == "false" ] 81 | do 82 | if [ "${lexicon[i]}" == "$word" ] 83 | then 84 | found="true" 85 | fi 86 | i=$((i+1)) 87 | done 88 | if [ $found"" == "false" ] 89 | then 90 | # 91 | # The word is neither in the dictionary nor the lexicon, send 92 | # it to stdout. 93 | # 94 | echo $word 95 | fi 96 | done 97 | -------------------------------------------------------------------------------- /tools/spell/extract-comments: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Extract comments from C/C++ files 4 | # 5 | set -e 6 | set -f 7 | 8 | function usage () { 9 | echo "Extract comments from C/C++ files" 10 | echo "" 11 | echo "usage: "${0##*/}" file-list" 12 | exit 1 13 | } 14 | 15 | if [ $# -lt 1 ] 16 | then 17 | usage $0 18 | fi 19 | 20 | if [ $1 = "-h" ] || [ $1 == "--help" ] 21 | then 22 | usage $0 23 | fi 24 | 25 | while test $# -gt 0 26 | do 27 | if [ ! -f $1 ] 28 | then 29 | echo $0": '"$1"' is not a file." 2>/dev/null 30 | exit 1 31 | fi 32 | # 33 | # Extract all words from C/C++ language comments; add line 34 | # numbers to aid in searching. 35 | # 36 | # NOTE: This has some limitations. For example, it prints 37 | # non-comment text at the beginning of a comment line. 38 | # 39 | nl -ba $1 | awk '/\/\// {print $0}; /\/\*/ {comment=1}; {if(comment) print $0}; /\*\// {comment=0}' 40 | shift 41 | done 42 | --------------------------------------------------------------------------------