summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralfred gedeon <alfred2g@hotmail.com>2020-07-06 15:28:33 -0700
committerGitHub <noreply@github.com>2020-07-06 15:28:33 -0700
commit6669a6f9bfa4ddf8703859ff200bdf49a7de7652 (patch)
tree3eb7c740cc26e238ce35f76fe4bc8fe0222e8c6e
parentaa3fcbcb62005367b22ee6d555fbbb0010c205d2 (diff)
downloadfreertos-git-6669a6f9bfa4ddf8703859ff200bdf49a7de7652.tar.gz
Style: uncrustify FreeRTOS-Plus files (#120)
Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c82
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h507
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c728
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.h11
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c426
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c1228
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSConfig.h271
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSIPConfig.h375
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/demo_config.h8
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/iot_config.h10
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSConfig.h271
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSIPConfig.h375
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/demo_config.h8
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/iot_config.h12
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSConfig.h271
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSIPConfig.h375
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/demo_config.h8
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/iot_config.h12
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_demo_profile.h4
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_setup_check.h8
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c1270
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSConfig.h271
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSIPConfig.h375
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h507
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_config.h2
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c728
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.h11
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/iot_config.h14
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c426
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c1228
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c1028
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c84
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c76
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h507
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c728
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.h11
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c426
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c1228
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSConfig.h271
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSIPConfig.h375
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/demo_config.h8
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/iot_config.h16
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSConfig.h277
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSIPConfig.h375
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/demo_config.h8
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcConfig.h193
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcSnapshotConfig.h70
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSConfig.h271
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSIPConfig.h375
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/demo_config.h8
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/iot_config.h16
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c546
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_application_version.h6
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_demo_version.c6
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c910
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c728
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.h11
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_appversion32.h44
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c346
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.h28
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c403
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/mbedtls_config.h20
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSConfig.h268
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSIPConfig.h366
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/aws_ota_agent_config.h22
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/iot_config.h30
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSConfig.h268
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSIPConfig.h366
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/aws_ota_agent_config.h22
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/iot_config.h30
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSConfig.h268
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSIPConfig.h366
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/aws_ota_agent_config.h22
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/iot_config.h30
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c84
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSConfig.h284
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSIPConfig.h377
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c76
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h507
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c728
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.h11
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_config.h14
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_pkcs11_config.h122
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c264
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c1228
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c1216
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSConfig.h271
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSIPConfig.h375
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h507
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c728
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.h11
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c426
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c1228
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c89
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/threading_alt.h2
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/include/platform/iot_platform_types_freertos.h4
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c32
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c114
-rw-r--r--FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c78
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c14
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c660
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.h172
-rw-r--r--FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c454
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c68
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c56
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c703
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c28
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c16
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c16
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c6
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c40
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h22
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c186
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c184
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c102
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c142
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c102
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h10
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c286
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c16
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c322
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c6
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c246
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c186
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c142
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c6
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c140
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c104
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h10
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/platform/iot_threads.h3
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h507
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_error.h2
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h34
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_logging_setup.h58
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c26
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c432
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c12
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/private/iot_https_internal.h10
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c123
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c164
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c58
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c108
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c130
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c86
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c202
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c158
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c18
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_helper.h2
-rw-r--r--[-rwxr-xr-x]FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_internal.h1
-rw-r--r--FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt.c244
-rw-r--r--FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_lightweight.c182
-rw-r--r--FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_state.c78
-rw-r--r--tools/git/hooks/src/pre_commit.py194
-rw-r--r--tools/uncrustify.cfg167
154 files changed, 19093 insertions, 18406 deletions
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c
index 316cb48fb..ad45bf4cd 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c
@@ -152,7 +152,7 @@
/**
* @brief The HTTPS connection handle used in this example.
*/
-static IotHttpsConnectionHandle_t xHTTPSConnection = IOT_HTTPS_CONNECTION_HANDLE_INITIALIZER;
+static IotHttpsConnectionHandle_t xHTTPSConnection = IOT_HTTPS_CONNECTION_HANDLE_INITIALIZER;
/**
* @brief A buffer used to store the HTTPS Client library's connection context.
@@ -163,13 +163,13 @@ static uint8_t ucHTTPSConnectionUserBuffer[ httpsexampleCONNECTION_USER_BUFFER_L
* @brief A buffer used to store the HTTPS Client library's request context and
* some headers.
*/
-static uint8_t ucHTTPSRequestUserBuffer[ httpsexampleREQUEST_USER_BUFFER_LENGTH ] = { 0 };
+static uint8_t ucHTTPSRequestUserBuffer[ httpsexampleREQUEST_USER_BUFFER_LENGTH ] = { 0 };
/**
* @brief A buffer used to store the HTTPS Client library's response context and
* some headers.
*/
-static uint8_t ucHTTPSResponseUserBuffer[ httpsexampleRESPONSE_USER_BUFFER_LENGTH ] = { 0 };
+static uint8_t ucHTTPSResponseUserBuffer[ httpsexampleRESPONSE_USER_BUFFER_LENGTH ] = { 0 };
/**
* @brief The request body.
@@ -179,7 +179,7 @@ static char cHTTPSRequestBodyBuffer[] = httpsexampleREQUEST_BODY_TEXT;
/**
* @brief A buffer used to receive the HTTPS Client library's response body.
*/
-static uint8_t ucHTTPSResponseBodyBuffer[ httpsexampleRESPONSE_BODY_BUFFER_LENGTH ] = { 0 };
+static uint8_t ucHTTPSResponseBodyBuffer[ httpsexampleRESPONSE_BODY_BUFFER_LENGTH ] = { 0 };
/**
* @brief The task used to demonstrate the HTTPS Client API.
@@ -218,7 +218,7 @@ static void prvHTTPSDisconnect( void );
*/
static void prvInitialiseLibraries( void );
-static const IotHttpsConnectionInfo_t xConnectionInfo =
+static const IotHttpsConnectionInfo_t xConnectionInfo =
{
/* No connection to the HTTPS server has been established yet and we want to
* establish a new connection. */
@@ -366,14 +366,14 @@ static void prvHTTPSRequest( IotHttpsMethod_t xMethod,
const char * pcPath,
uint32_t ulPathLength )
{
- IotHttpsReturnCode_t xHTTPSClientResult;
- IotHttpsRequestInfo_t xHTTPSRequestInfo = IOT_HTTPS_REQUEST_INFO_INITIALIZER;
- IotHttpsResponseInfo_t xHTTPSResponseInfo = IOT_HTTPS_RESPONSE_INFO_INITIALIZER;
- IotHttpsRequestHandle_t xHTTPSRequest = IOT_HTTPS_REQUEST_HANDLE_INITIALIZER;
- IotHttpsResponseHandle_t xHTTPSResponse = IOT_HTTPS_RESPONSE_HANDLE_INITIALIZER;
- IotHttpsSyncInfo_t xHTTPSSyncRequestInfo = IOT_HTTPS_SYNC_INFO_INITIALIZER;
- IotHttpsSyncInfo_t xHTTPSSyncResponseInfo = IOT_HTTPS_SYNC_INFO_INITIALIZER;
- uint16_t usResponseStatus = 0;
+ IotHttpsReturnCode_t xHTTPSClientResult;
+ IotHttpsRequestInfo_t xHTTPSRequestInfo = IOT_HTTPS_REQUEST_INFO_INITIALIZER;
+ IotHttpsResponseInfo_t xHTTPSResponseInfo = IOT_HTTPS_RESPONSE_INFO_INITIALIZER;
+ IotHttpsRequestHandle_t xHTTPSRequest = IOT_HTTPS_REQUEST_HANDLE_INITIALIZER;
+ IotHttpsResponseHandle_t xHTTPSResponse = IOT_HTTPS_RESPONSE_HANDLE_INITIALIZER;
+ IotHttpsSyncInfo_t xHTTPSSyncRequestInfo = IOT_HTTPS_SYNC_INFO_INITIALIZER;
+ IotHttpsSyncInfo_t xHTTPSSyncResponseInfo = IOT_HTTPS_SYNC_INFO_INITIALIZER;
+ uint16_t usResponseStatus = 0;
configASSERT( pcPath != NULL );
@@ -381,28 +381,28 @@ static void prvHTTPSRequest( IotHttpsMethod_t xMethod,
if( ( xMethod == IOT_HTTPS_METHOD_PUT ) || ( xMethod == IOT_HTTPS_METHOD_POST ) )
{
- xHTTPSSyncRequestInfo.pBody = ( uint8_t * ) cHTTPSRequestBodyBuffer;
+ xHTTPSSyncRequestInfo.pBody = ( uint8_t * ) cHTTPSRequestBodyBuffer;
xHTTPSSyncRequestInfo.bodyLen = sizeof( cHTTPSRequestBodyBuffer );
}
else
{
- xHTTPSSyncRequestInfo.pBody = NULL;
+ xHTTPSSyncRequestInfo.pBody = NULL;
xHTTPSSyncRequestInfo.bodyLen = 0;
}
- xHTTPSRequestInfo.pHost = httpsexampleHTTPS_SERVER_ADDRESS;
- xHTTPSRequestInfo.hostLen = sizeof( httpsexampleHTTPS_SERVER_ADDRESS ) - 1;
- xHTTPSRequestInfo.pPath = pcPath;
- xHTTPSRequestInfo.pathLen = ulPathLength;
- xHTTPSRequestInfo.method = xMethod;
- xHTTPSRequestInfo.isNonPersistent = false;
- xHTTPSRequestInfo.userBuffer.pBuffer = ucHTTPSRequestUserBuffer;
- xHTTPSRequestInfo.userBuffer.bufferLen = sizeof( ucHTTPSRequestUserBuffer ) - 1;
- xHTTPSRequestInfo.isAsync = false;
- xHTTPSRequestInfo.u.pSyncInfo = &xHTTPSSyncRequestInfo;
-
- xHTTPSClientResult = IotHttpsClient_InitializeRequest( &( xHTTPSRequest ),
- &( xHTTPSRequestInfo ) );
+ xHTTPSRequestInfo.pHost = httpsexampleHTTPS_SERVER_ADDRESS;
+ xHTTPSRequestInfo.hostLen = sizeof( httpsexampleHTTPS_SERVER_ADDRESS ) - 1;
+ xHTTPSRequestInfo.pPath = pcPath;
+ xHTTPSRequestInfo.pathLen = ulPathLength;
+ xHTTPSRequestInfo.method = xMethod;
+ xHTTPSRequestInfo.isNonPersistent = false;
+ xHTTPSRequestInfo.userBuffer.pBuffer = ucHTTPSRequestUserBuffer;
+ xHTTPSRequestInfo.userBuffer.bufferLen = sizeof( ucHTTPSRequestUserBuffer ) - 1;
+ xHTTPSRequestInfo.isAsync = false;
+ xHTTPSRequestInfo.u.pSyncInfo = &xHTTPSSyncRequestInfo;
+
+ xHTTPSClientResult = IotHttpsClient_InitializeRequest( &( xHTTPSRequest ),
+ &( xHTTPSRequestInfo ) );
configASSERT( xHTTPSClientResult == IOT_HTTPS_OK );
/************************** HTTPS response setup. **************************/
@@ -411,28 +411,28 @@ static void prvHTTPSRequest( IotHttpsMethod_t xMethod,
if( xMethod == IOT_HTTPS_METHOD_HEAD )
{
- xHTTPSSyncResponseInfo.pBody = NULL;
+ xHTTPSSyncResponseInfo.pBody = NULL;
xHTTPSSyncResponseInfo.bodyLen = 0;
}
else
{
- xHTTPSSyncResponseInfo.pBody = ucHTTPSResponseBodyBuffer;
+ xHTTPSSyncResponseInfo.pBody = ucHTTPSResponseBodyBuffer;
xHTTPSSyncResponseInfo.bodyLen = sizeof( ucHTTPSResponseBodyBuffer );
}
- xHTTPSResponseInfo.userBuffer.pBuffer = ucHTTPSResponseUserBuffer;
+ xHTTPSResponseInfo.userBuffer.pBuffer = ucHTTPSResponseUserBuffer;
xHTTPSResponseInfo.userBuffer.bufferLen = sizeof( ucHTTPSResponseUserBuffer );
- xHTTPSResponseInfo.pSyncInfo = &xHTTPSSyncResponseInfo;
+ xHTTPSResponseInfo.pSyncInfo = &xHTTPSSyncResponseInfo;
/*************************** Send HTTPS request. ***************************/
/* This synchronous send function blocks until the full response is received
* from the network. */
- xHTTPSClientResult = IotHttpsClient_SendSync( xHTTPSConnection,
- xHTTPSRequest,
- &( xHTTPSResponse ),
- &( xHTTPSResponseInfo ),
- httpsexampleHTTPS_TIMEOUT_MS );
+ xHTTPSClientResult = IotHttpsClient_SendSync( xHTTPSConnection,
+ xHTTPSRequest,
+ &( xHTTPSResponse ),
+ &( xHTTPSResponseInfo ),
+ httpsexampleHTTPS_TIMEOUT_MS );
configASSERT( xHTTPSClientResult == IOT_HTTPS_OK );
/* The response status is only available if the httpsexampleRESPONSE_USER_BUFFER
@@ -440,8 +440,8 @@ static void prvHTTPSRequest( IotHttpsMethod_t xMethod,
* also the Status-Line of the response. The Status-Line and the response
* headers are stored in the provided ucHTTPSResponseUserBuffer right after
* the HTTPS Client response context. */
- xHTTPSClientResult = IotHttpsClient_ReadResponseStatus( xHTTPSResponse,
- &usResponseStatus );
+ xHTTPSClientResult = IotHttpsClient_ReadResponseStatus( xHTTPSResponse,
+ &usResponseStatus );
configASSERT( xHTTPSClientResult == IOT_HTTPS_OK );
configPRINTF( ( "Response status: %d\r\n", usResponseStatus ) );
@@ -469,10 +469,10 @@ static void prvHTTPSDisconnect( void )
static void prvInitialiseLibraries( void )
{
IotHttpsReturnCode_t xHTTPSClientResult;
- IotNetworkError_t xNetworkResult;
+ IotNetworkError_t xNetworkResult;
/* Initialize the network stack abstraction for FreeRTOS. */
- xNetworkResult = IotNetworkFreeRTOS_Init();
+ xNetworkResult = IotNetworkFreeRTOS_Init();
configASSERT( xNetworkResult == IOT_NETWORK_SUCCESS );
/* HTTPS Client library must be initialized before it can be used. This is
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h
index d9b063bf8..ee2402255 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h
@@ -47,68 +47,68 @@
*/
#ifndef ATOMIC_H
-#define ATOMIC_H
+ #define ATOMIC_H
-#ifndef INC_FREERTOS_H
- #error "include FreeRTOS.h must appear in source files before include atomic.h"
-#endif
+ #ifndef INC_FREERTOS_H
+ #error "include FreeRTOS.h must appear in source files before include atomic.h"
+ #endif
/* Standard includes. */
-#include <stdint.h>
+ #include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- /* Needed for __atomic_compare_exchange() weak=false. */
- #include <stdbool.h>
+/* Needed for __atomic_compare_exchange() weak=false. */
+ #include <stdbool.h>
- /* This branch is for GCC compiler and GCC compiler only. */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE inline __attribute__((always_inline))
- #endif
+/* This branch is for GCC compiler and GCC compiler only. */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE inline __attribute__( ( always_inline ) )
+ #endif
-#else
+ #else
- /* Port specific definitions -- entering/exiting critical section.
- * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
- *
- * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
- * ATOMIC_ENTER_CRITICAL().
- */
- #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
+/* Port specific definitions -- entering/exiting critical section.
+ * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
+ *
+ * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
+ * ATOMIC_ENTER_CRITICAL().
+ */
+ #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
- /* Nested interrupt scheme is supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() \
- UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
+/* Nested interrupt scheme is supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() \
+ UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
- #define ATOMIC_EXIT_CRITICAL() \
- portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
+ #define ATOMIC_EXIT_CRITICAL() \
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
- #else
+ #else
- /* Nested interrupt scheme is NOT supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
- #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
+/* Nested interrupt scheme is NOT supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
+ #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
- #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
+ #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
- /* Port specific definition -- "always inline".
- * Inline is compiler specific, and may not always get inlined depending on your optimization level.
- * For atomic operations, inline is considered a performance optimization.
- * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
- * simply define it.
- */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE
- #endif
+/* Port specific definition -- "always inline".
+ * Inline is compiler specific, and may not always get inlined depending on your optimization level.
+ * For atomic operations, inline is considered a performance optimization.
+ * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
+ * simply define it.
+ */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE
+ #endif
-#endif /* configUSE_GCC_BUILTIN_ATOMICS */
+ #endif /* configUSE_GCC_BUILTIN_ATOMICS */
-#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
-#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
+ #define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
+ #define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
/*----------------------------- Swap && CAS ------------------------------*/
@@ -127,44 +127,36 @@ extern "C" {
* @note This function only swaps *pDestination with ulExchange, if previous
* *pDestination value equals ulComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
- uint32_t volatile * pDestination,
- uint32_t ulExchange,
- uint32_t ulComparand )
-{
-
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- if ( __atomic_compare_exchange( pDestination,
- &ulComparand,
- &ulExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pDestination,
+ uint32_t ulExchange,
+ uint32_t ulComparand )
{
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( pDestination,
+ &ulComparand,
+ &ulExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *pDestination == ulComparand )
+ {
+ *pDestination = ulExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *pDestination == ulComparand )
- {
- *pDestination = ulExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-
-}
-
/**
* Atomic swap (pointers)
*
@@ -177,30 +169,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
*
* @return The initial value of *ppDestination.
*/
-static portFORCE_INLINE void * Atomic_SwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange )
-{
- void * pReturnValue;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange )
+ {
+ void * pReturnValue;
- pReturnValue = *ppDestination;
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
+ #else
+ ATOMIC_ENTER_CRITICAL();
- *ppDestination = pExchange;
+ pReturnValue = *ppDestination;
- ATOMIC_EXIT_CRITICAL();
+ *ppDestination = pExchange;
-#endif
+ ATOMIC_EXIT_CRITICAL();
+ #endif
- return pReturnValue;
-}
+ return pReturnValue;
+ }
/**
* Atomic compare-and-swap (pointers)
@@ -218,40 +205,36 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32(
* @note This function only swaps *ppDestination with pExchange, if previous
* *ppDestination value equals pComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange, void * pComparand )
-{
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- if ( __atomic_compare_exchange( ppDestination,
- &pComparand,
- &pExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
- {
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *ppDestination == pComparand )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange,
+ void * pComparand )
{
- *ppDestination = pExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( ppDestination,
+ &pComparand,
+ &pExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *ppDestination == pComparand )
+ {
+ *ppDestination = pExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-}
-
/*----------------------------- Arithmetic ------------------------------*/
@@ -266,30 +249,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Add_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic subtract
@@ -303,30 +281,25 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic increment
@@ -338,28 +311,24 @@ static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
*
* @return *pAddend value before increment.
*/
-static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic decrement
@@ -371,28 +340,24 @@ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAdde
*
* @return *pAddend value before decrement.
*/
-static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/*----------------------------- Bitwise Logical ------------------------------*/
@@ -407,30 +372,25 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_OR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_or(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_or( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination |= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination |= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic AND
@@ -443,30 +403,25 @@ static portFORCE_INLINE uint32_t Atomic_OR_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_AND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_and(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_and( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination &= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination &= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic NAND
@@ -479,30 +434,25 @@ static portFORCE_INLINE uint32_t Atomic_AND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_NAND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_nand(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_nand( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination = ~(ulCurrent & ulValue);
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination = ~( ulCurrent & ulValue );
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic XOR
@@ -515,33 +465,28 @@ static portFORCE_INLINE uint32_t Atomic_NAND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_XOR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_xor(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_xor( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination ^= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination ^= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
-#ifdef __cplusplus
-}
-#endif
+ #ifdef __cplusplus
+ }
+ #endif
#endif /* ATOMIC_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c
index 8f94f559a..3582eb56b 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c
@@ -57,19 +57,19 @@
/*-----------------------------------------------------------*/
/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
+ * to .ful. */
+#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 511
+#define dlMAX_PRINT_STRING_LENGTH 511
/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
+ * the Win32 thread that is responsible for making any Win32 system calls that are
+ * necessary for the selected logging method. */
+#define dlLOGGING_STREAM_BUFFER_SIZE 32768
/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
+#define dlDONT_BLOCK 0
/*-----------------------------------------------------------*/
@@ -81,7 +81,8 @@ static void prvFileLoggingInit( void );
/*
* Attempt to write a message to the file.
*/
-static void prvLogToFile( const char *pcMessage, size_t xLength );
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength );
/*
* Simply close the logging file, if it is open.
@@ -102,7 +103,7 @@ static void prvLoggingFlushBuffer( void );
* Win32 system calls. Only the windows thread can make system calls so as not
* to disrupt the simulation by making Windows calls from FreeRTOS tasks.
*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
+static DWORD WINAPI prvWin32LoggingThread( void * pvParam );
/*
* Creates the socket to which UDP messages are sent. This function is not
@@ -110,417 +111,426 @@ static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
* task - which could result in a deadlock. Instead the function call is
* deferred to run in the RTOS daemon task - hence it prototype.
*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 );
/*-----------------------------------------------------------*/
/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
+ * needs Win32 system calls. */
+static void * pvLoggingThreadEvent = NULL;
/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
+ * vLoggingInit() function. */
+BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
+ * thread that is responsible for making Win32 calls (when stdout or a disk log is
+ * used). */
+static StreamBuffer_t * xLogStreamBuffer = NULL;
/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
+ * messages waiting to be logged, then closed again in between logs. */
+static FILE * pxLoggingFileHandle = NULL;
/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
+ * to pdFALSE - at which time prints that require Win32 system calls are done by
+ * the Win32 thread responsible for logging. */
+BaseType_t xDirectPrint = pdTRUE;
/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
+static const char * pcLogFileName = "RTOSDemo.log";
+static const char * pcFullLogFileName = "RTOSDemo.ful";
/* As an optimization, the current file size is kept in a variable. */
-static size_t ulSizeOfLoggingFile = 0ul;
+static size_t ulSizeOfLoggingFile = 0ul;
/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
+Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
struct freertos_sockaddr xPrintUDPAddress;
/*-----------------------------------------------------------*/
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort )
{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialize it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialized. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
+ /* Can only be called before the scheduler has started. */
+ configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
+
+ #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
+ {
+ HANDLE Win32Thread;
+
+ /* Record which output methods are to be used. */
+ xStdoutLoggingUsed = xLogToStdout;
+ xDiskFileLoggingUsed = xLogToFile;
+ xUDPLoggingUsed = xLogToUDP;
+
+ /* If a disk file is used then initialize it now. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvFileLoggingInit();
+ }
+
+ /* If UDP logging is used then store the address to which the log data
+ * will be sent - but don't create the socket yet because the network is
+ * not initialized. */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ /* Set the address to which the print messages are sent. */
+ xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
+ xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
+ }
+
+ /* If a disk file or stdout are to be used then Win32 system calls will
+ * have to be made. Such system calls cannot be made from FreeRTOS tasks
+ * so create a stream buffer to pass the messages to a Win32 thread, then
+ * create the thread itself, along with a Win32 event that can be used to
+ * unblock the thread. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ /* Create the buffer. */
+ xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
+ configASSERT( xLogStreamBuffer );
+ memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
+ xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
+
+ /* Create the Windows event. */
+ pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
+
+ /* Create the thread itself. */
+ Win32Thread = CreateThread(
+ NULL, /* Pointer to thread security attributes. */
+ 0, /* Initial thread stack size, in bytes. */
+ prvWin32LoggingThread, /* Pointer to thread function. */
+ NULL, /* Argument for new thread. */
+ 0, /* Creation flags. */
+ NULL );
+
+ /* Use the cores that are not used by the FreeRTOS tasks. */
+ SetThreadAffinityMask( Win32Thread, ~0x01u );
+ SetThreadPriorityBoost( Win32Thread, TRUE );
+ SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
+ }
+ }
+ #else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */
+ {
+ /* FreeRTOSIPConfig is set such that no print messages will be output.
+ * Avoid compiler warnings about unused parameters. */
+ ( void ) xLogToStdout;
+ ( void ) xLogToFile;
+ ( void ) xLogToUDP;
+ ( void ) usRemotePort;
+ ( void ) ulRemoteIPAddress;
+ }
+ #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
}
/*-----------------------------------------------------------*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 )
{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
+ static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
+ Socket_t xSocket;
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
+ /* The function prototype is that of a deferred function, but the parameters
+ * are not actually used. */
+ ( void ) pvParameter1;
+ ( void ) ulParameter2;
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
+ if( xSocket != FREERTOS_INVALID_SOCKET )
+ {
+ /* FreeRTOS+TCP decides which port to bind to. */
+ FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
+ FreeRTOS_bind( xSocket, NULL, 0 );
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
+ /* Now the socket is bound it can be assigned to the print socket. */
+ xPrintSocket = xSocket;
+ }
}
/*-----------------------------------------------------------*/
-void vLoggingPrintf( const char *pcFormat, ... )
+void vLoggingPrintf( const char * pcFormat,
+ ... )
{
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
-char *pcSource, *pcTarget, *pcBegin;
-size_t xLength, xLength2, rc;
-static BaseType_t xMessageNumber = 0;
-va_list args;
-uint32_t ulIPAddress;
-const char *pcTaskName;
-const char *pcNoTask = "None";
-int iOriginalPriority;
-HANDLE xCurrentTask;
-
-
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
- {
- /* There are a variable number of parameters. */
- va_start( args, pcFormat );
-
- /* Additional info to place at the start of the log. */
- if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
- {
- pcTaskName = pcTaskGetName( NULL );
- }
- else
- {
- pcTaskName = pcNoTask;
- }
-
- if( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
-
- if( xLength2 < 0 )
- {
- /* Clean up. */
- xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
- cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
- }
-
- xLength += xLength2;
- va_end( args );
-
- /* For ease of viewing, copy the string into another buffer, converting
- IP addresses to dot notation on the way. */
- pcSource = cPrintString;
- pcTarget = cOutputString;
-
- while( ( *pcSource ) != '\0' )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- pcSource++;
-
- /* Look forward for an IP address denoted by 'ip'. */
- if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- *pcTarget = '\0';
- pcBegin = pcTarget - 8;
-
- while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
- {
- pcTarget--;
- }
-
- sscanf( pcTarget, "%8X", &ulIPAddress );
- rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
- ( unsigned long ) ( ulIPAddress >> 24UL ),
- ( unsigned long ) ( (ulIPAddress >> 16UL) & 0xffUL ),
- ( unsigned long ) ( (ulIPAddress >> 8UL) & 0xffUL ),
- ( unsigned long ) ( ulIPAddress & 0xffUL ) );
- pcTarget += rc;
- pcSource += 3; /* skip "<n>ip" */
- }
- }
-
- /* How far through the buffer was written? */
- xLength = ( BaseType_t ) ( pcTarget - cOutputString );
-
- /* If the message is to be logged to a UDP port then it can be sent directly
- because it only uses FreeRTOS function (not Win32 functions). */
- if( xUDPLoggingUsed != pdFALSE )
- {
- if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
- {
- /* Create and bind the socket to which print messages are sent. The
- xTimerPendFunctionCall() function is used even though this is
- not an interrupt because this function is called from the IP task
- and the IP task cannot itself wait for a socket to bind. The
- parameters to prvCreatePrintSocket() are not required so set to
- NULL or 0. */
- xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* If logging is also to go to either stdout or a disk file then it cannot
- be output here - so instead write the message to the stream buffer and wake
- the Win32 thread which will read it from the stream buffer and perform the
- actual output. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- configASSERT( xLogStreamBuffer );
-
- /* How much space is in the buffer? */
- xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
-
- /* There must be enough space to write both the string and the length of
- the string. */
- if( xLength2 >= ( xLength + sizeof( xLength ) ) )
- {
- /* First write in the length of the data, then write in the data
- itself. Raising the thread priority is used as a critical section
- as there are potentially multiple writers. The stream buffer is
- only thread safe when there is a single writer (likewise for
- reading from the buffer). */
- xCurrentTask = GetCurrentThread();
- iOriginalPriority = GetThreadPriority( xCurrentTask );
- SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
- SetThreadPriority( GetCurrentThread(), iOriginalPriority );
- }
-
- /* xDirectPrint is initialized to pdTRUE, and while it remains true the
- logging output function is called directly. When the system is running
- the output function cannot be called directly because it would get
- called from both FreeRTOS tasks and Win32 threads - so instead wake the
- Win32 thread responsible for the actual output. */
- if( xDirectPrint != pdFALSE )
- {
- /* While starting up, the thread which calls prvWin32LoggingThread()
- is not running yet and xDirectPrint will be pdTRUE. */
- prvLoggingFlushBuffer();
- }
- else if( pvLoggingThreadEvent != NULL )
- {
- /* While running, wake up prvWin32LoggingThread() to send the
- logging data. */
- SetEvent( pvLoggingThreadEvent );
- }
- }
- }
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+ char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
+ char * pcSource, * pcTarget, * pcBegin;
+ size_t xLength, xLength2, rc;
+ static BaseType_t xMessageNumber = 0;
+ va_list args;
+ uint32_t ulIPAddress;
+ const char * pcTaskName;
+ const char * pcNoTask = "None";
+ int iOriginalPriority;
+ HANDLE xCurrentTask;
+
+
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
+ {
+ /* There are a variable number of parameters. */
+ va_start( args, pcFormat );
+
+ /* Additional info to place at the start of the log. */
+ if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
+ {
+ pcTaskName = pcTaskGetName( NULL );
+ }
+ else
+ {
+ pcTaskName = pcNoTask;
+ }
+
+ if( strcmp( pcFormat, "\n" ) != 0 )
+ {
+ xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
+ xMessageNumber++,
+ ( unsigned long ) xTaskGetTickCount(),
+ pcTaskName );
+ }
+ else
+ {
+ xLength = 0;
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ }
+
+ xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
+
+ if( xLength2 < 0 )
+ {
+ /* Clean up. */
+ xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
+ cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
+ }
+
+ xLength += xLength2;
+ va_end( args );
+
+ /* For ease of viewing, copy the string into another buffer, converting
+ * IP addresses to dot notation on the way. */
+ pcSource = cPrintString;
+ pcTarget = cOutputString;
+
+ while( ( *pcSource ) != '\0' )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ pcSource++;
+
+ /* Look forward for an IP address denoted by 'ip'. */
+ if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ *pcTarget = '\0';
+ pcBegin = pcTarget - 8;
+
+ while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
+ {
+ pcTarget--;
+ }
+
+ sscanf( pcTarget, "%8X", &ulIPAddress );
+ rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
+ ( unsigned long ) ( ulIPAddress >> 24UL ),
+ ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ),
+ ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ),
+ ( unsigned long ) ( ulIPAddress & 0xffUL ) );
+ pcTarget += rc;
+ pcSource += 3; /* skip "<n>ip" */
+ }
+ }
+
+ /* How far through the buffer was written? */
+ xLength = ( BaseType_t ) ( pcTarget - cOutputString );
+
+ /* If the message is to be logged to a UDP port then it can be sent directly
+ * because it only uses FreeRTOS function (not Win32 functions). */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
+ {
+ /* Create and bind the socket to which print messages are sent. The
+ * xTimerPendFunctionCall() function is used even though this is
+ * not an interrupt because this function is called from the IP task
+ * and the IP task cannot itself wait for a socket to bind. The
+ * parameters to prvCreatePrintSocket() are not required so set to
+ * NULL or 0. */
+ xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
+ }
+
+ if( xPrintSocket != FREERTOS_INVALID_SOCKET )
+ {
+ FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+
+ /* Just because the UDP data logger I'm using is dumb. */
+ FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+ }
+ }
+
+ /* If logging is also to go to either stdout or a disk file then it cannot
+ * be output here - so instead write the message to the stream buffer and wake
+ * the Win32 thread which will read it from the stream buffer and perform the
+ * actual output. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ configASSERT( xLogStreamBuffer );
+
+ /* How much space is in the buffer? */
+ xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
+
+ /* There must be enough space to write both the string and the length of
+ * the string. */
+ if( xLength2 >= ( xLength + sizeof( xLength ) ) )
+ {
+ /* First write in the length of the data, then write in the data
+ * itself. Raising the thread priority is used as a critical section
+ * as there are potentially multiple writers. The stream buffer is
+ * only thread safe when there is a single writer (likewise for
+ * reading from the buffer). */
+ xCurrentTask = GetCurrentThread();
+ iOriginalPriority = GetThreadPriority( xCurrentTask );
+ SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
+ SetThreadPriority( GetCurrentThread(), iOriginalPriority );
+ }
+
+ /* xDirectPrint is initialized to pdTRUE, and while it remains true the
+ * logging output function is called directly. When the system is running
+ * the output function cannot be called directly because it would get
+ * called from both FreeRTOS tasks and Win32 threads - so instead wake the
+ * Win32 thread responsible for the actual output. */
+ if( xDirectPrint != pdFALSE )
+ {
+ /* While starting up, the thread which calls prvWin32LoggingThread()
+ * is not running yet and xDirectPrint will be pdTRUE. */
+ prvLoggingFlushBuffer();
+ }
+ else if( pvLoggingThreadEvent != NULL )
+ {
+ /* While running, wake up prvWin32LoggingThread() to send the
+ * logging data. */
+ SetEvent( pvLoggingThreadEvent );
+ }
+ }
+ }
}
/*-----------------------------------------------------------*/
static void prvLoggingFlushBuffer( void )
{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- _write( _fileno(stdout), cPrintString, strlen( cPrintString ) );
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
+ size_t xLength;
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+
+ /* Is there more than the length value stored in the circular buffer
+ * used to pass data from the FreeRTOS simulator into this Win32 thread? */
+ while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
+ {
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
+
+ /* Write the message to standard out if requested to do so when
+ * vLoggingInit() was called, or if the network is not yet up. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
+ {
+ /* Write the message to stdout. */
+ _write( _fileno( stdout ), cPrintString, strlen( cPrintString ) );
+ }
+
+ /* Write the message to a file if requested to do so when
+ * vLoggingInit() was called. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvLogToFile( cPrintString, xLength );
+ }
+ }
+
+ prvFileClose();
}
/*-----------------------------------------------------------*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
+static DWORD WINAPI prvWin32LoggingThread( void * pvParameter )
{
-const DWORD xMaxWait = 1000;
+ const DWORD xMaxWait = 1000;
- ( void ) pvParameter;
+ ( void ) pvParameter;
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
+ /* From now on, prvLoggingFlushBuffer() will only be called from this
+ * Windows thread */
+ xDirectPrint = pdFALSE;
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
+ for( ; ; )
+ {
+ /* Wait to be told there are message waiting to be logged. */
+ WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
+ /* Write out all waiting messages. */
+ prvLoggingFlushBuffer();
+ }
}
/*-----------------------------------------------------------*/
static void prvFileLoggingInit( void )
{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
+ FILE * pxHandle = fopen( pcLogFileName, "a" );
+
+ if( pxHandle != NULL )
+ {
+ fseek( pxHandle, SEEK_END, 0ul );
+ ulSizeOfLoggingFile = ftell( pxHandle );
+ fclose( pxHandle );
+ }
+ else
+ {
+ ulSizeOfLoggingFile = 0ul;
+ }
}
/*-----------------------------------------------------------*/
static void prvFileClose( void )
{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
+ if( pxLoggingFileHandle != NULL )
+ {
+ fclose( pxLoggingFileHandle );
+ pxLoggingFileHandle = NULL;
+ }
}
/*-----------------------------------------------------------*/
-static void prvLogToFile( const char *pcMessage, size_t xLength )
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength )
{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
+ if( pxLoggingFileHandle == NULL )
+ {
+ pxLoggingFileHandle = fopen( pcLogFileName, "a" );
+ }
+
+ if( pxLoggingFileHandle != NULL )
+ {
+ fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
+ ulSizeOfLoggingFile += xLength;
+
+ /* If the file has grown to its maximum permissible size then close and
+ * rename it - then start with a new file. */
+ if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
+ {
+ prvFileClose();
+
+ if( _access( pcFullLogFileName, 00 ) == 0 )
+ {
+ remove( pcFullLogFileName );
+ }
+
+ rename( pcLogFileName, pcFullLogFileName );
+ ulSizeOfLoggingFile = 0;
+ }
+ }
}
/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.h
index 2cc068ce9..773cc0d75 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.h
@@ -38,11 +38,10 @@
* If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
* to the IP address and port number to which UDP log messages will be sent.
*/
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort );
#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c
index 5da701f0f..89ec2ff33 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c
@@ -34,7 +34,7 @@
#include <time.h>
/* Visual studio intrinsics used so the __debugbreak() function is available
-should an assert get hit. */
+ * should an assert get hit. */
#include <intrin.h>
/* FreeRTOS includes. */
@@ -72,29 +72,29 @@ static void prvSRand( UBaseType_t ulSeed );
static void prvMiscInitialisation( void );
/* The default IP and MAC address used by the demo. The address configuration
-defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
-1 but a DHCP server could not be contacted. See the online documentation for
-more information. */
+ * defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
+ * 1 but a DHCP server could not be contacted. See the online documentation for
+ * more information. */
static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };
static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };
static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };
/* Set the following constant to pdTRUE to log using the method indicated by the
-name of the constant, or pdFALSE to not log using the method indicated by the
-name of the constant. Options include to standard out (xLogToStdout), to a disk
-file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
-then UDP messages are sent to the IP address configured as the echo server
-address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
-the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
+ * name of the constant, or pdFALSE to not log using the method indicated by the
+ * name of the constant. Options include to standard out (xLogToStdout), to a disk
+ * file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
+ * then UDP messages are sent to the IP address configured as the echo server
+ * address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
+ * the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALSE;
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition for information on how to configure
-the real network connection to use. */
-const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
+ * connection that uses this MAC address by accessing the raw Ethernet data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition for information on how to configure
+ * the real network connection to use. */
+const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
/* Use by the pseudo random number generator. */
static UBaseType_t ulNextRand;
@@ -102,186 +102,186 @@ static UBaseType_t ulNextRand;
int main( void )
{
- /***
- * See https://www.FreeRTOS.org/https/index.html for configuration and usage instructions.
- ***/
-
- /* Miscellaneous initialization including preparing the logging and seeding
- the random number generator. */
- prvMiscInitialisation();
-
- /* Initialize the network interface.
-
- ***NOTE*** Tasks that use the network are created in the network event hook
- when the network is connected and ready for use (see the implementation of
- vApplicationIPNetworkEventHook() below). The address values passed in here
- are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
- but a DHCP server cannot be contacted. */
- FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
-
- /* Start the RTOS scheduler. */
- vTaskStartScheduler();
-
- /* If all is well, the scheduler will now be running, and the following
- line will never be reached. If the following line does execute, then
- there was insufficient FreeRTOS heap memory available for the idle and/or
- timer tasks to be created. See the memory management section on the
- FreeRTOS web site for more details (this is standard text that is not
- really applicable to the Win32 simulator port). */
- for( ; ; )
- {
- __debugbreak();
- }
+ /***
+ * See https://www.FreeRTOS.org/https/index.html for configuration and usage instructions.
+ ***/
+
+ /* Miscellaneous initialization including preparing the logging and seeding
+ * the random number generator. */
+ prvMiscInitialisation();
+
+ /* Initialize the network interface.
+ *
+ ***NOTE*** Tasks that use the network are created in the network event hook
+ * when the network is connected and ready for use (see the implementation of
+ * vApplicationIPNetworkEventHook() below). The address values passed in here
+ * are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
+ * but a DHCP server cannot be contacted. */
+ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
+
+ /* Start the RTOS scheduler. */
+ vTaskStartScheduler();
+
+ /* If all is well, the scheduler will now be running, and the following
+ * line will never be reached. If the following line does execute, then
+ * there was insufficient FreeRTOS heap memory available for the idle and/or
+ * timer tasks to be created. See the memory management section on the
+ * FreeRTOS web site for more details (this is standard text that is not
+ * really applicable to the Win32 simulator port). */
+ for( ; ; )
+ {
+ __debugbreak();
+ }
}
/*-----------------------------------------------------------*/
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
-events are only received if implemented in the MAC driver. */
+ * events are only received if implemented in the MAC driver. */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
-uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
-char cBuffer[ 16 ];
-static BaseType_t xTasksAlreadyCreated = pdFALSE;
-
- /* If the network has just come up...*/
- if( eNetworkEvent == eNetworkUp )
- {
- /* Create the tasks that use the IP stack if they have not already been
- created. */
- if( xTasksAlreadyCreated == pdFALSE )
- {
- /* Demos that use the network are created after the network is
- up. */
- configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
- vStartSimpleHTTPSDemo();
- xTasksAlreadyCreated = pdTRUE;
- }
-
- /* Print out the network configuration, which may have come from a DHCP
- server. */
- FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
- FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
- FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) ); /*_RB_ Should use IoT libraries logging. */
-
- FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
- FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
- FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
- FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
- }
+ uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
+ char cBuffer[ 16 ];
+ static BaseType_t xTasksAlreadyCreated = pdFALSE;
+
+ /* If the network has just come up...*/
+ if( eNetworkEvent == eNetworkUp )
+ {
+ /* Create the tasks that use the IP stack if they have not already been
+ * created. */
+ if( xTasksAlreadyCreated == pdFALSE )
+ {
+ /* Demos that use the network are created after the network is
+ * up. */
+ configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
+ vStartSimpleHTTPSDemo();
+ xTasksAlreadyCreated = pdTRUE;
+ }
+
+ /* Print out the network configuration, which may have come from a DHCP
+ * server. */
+ FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
+ FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
+ FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) ); /*_RB_ Should use IoT libraries logging. */
+
+ FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
+ FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
+ FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
+ FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
+ }
}
/*-----------------------------------------------------------*/
-void vAssertCalled( const char *pcFile,
- uint32_t ulLine )
+void vAssertCalled( const char * pcFile,
+ uint32_t ulLine )
{
-volatile uint32_t ulBlockVariable = 0UL;
-volatile char *pcFileName = ( volatile char * ) pcFile;
-volatile uint32_t ulLineNumber = ulLine;
-
- ( void ) pcFileName;
- ( void ) ulLineNumber;
-
- printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
-
- /* Setting ulBlockVariable to a non-zero value in the debugger will allow
- this function to be exited. */
- taskDISABLE_INTERRUPTS();
- {
- while( ulBlockVariable == 0UL )
- {
- __debugbreak();
- }
- }
- taskENABLE_INTERRUPTS();
+ volatile uint32_t ulBlockVariable = 0UL;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
+ volatile uint32_t ulLineNumber = ulLine;
+
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
+
+ printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
+
+ /* Setting ulBlockVariable to a non-zero value in the debugger will allow
+ * this function to be exited. */
+ taskDISABLE_INTERRUPTS();
+ {
+ while( ulBlockVariable == 0UL )
+ {
+ __debugbreak();
+ }
+ }
+ taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
UBaseType_t uxRand( void )
{
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
-
- /*
- * Utility function to generate a pseudo random number.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
- return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
+ const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
+
+ /*
+ * Utility function to generate a pseudo random number.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
}
/*-----------------------------------------------------------*/
static void prvSRand( UBaseType_t ulSeed )
{
- /* Utility function to seed the pseudo random number generator. */
- ulNextRand = ulSeed;
+ /* Utility function to seed the pseudo random number generator. */
+ ulNextRand = ulSeed;
}
/*-----------------------------------------------------------*/
static void prvMiscInitialisation( void )
{
-time_t xTimeNow;
-uint32_t ulLoggingIPAddress;
-
- ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
- vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
-
- /*
- * Seed random number generator.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- time( &xTimeNow );
- FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
- prvSRand( ( uint32_t ) xTimeNow );
- FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
+ time_t xTimeNow;
+ uint32_t ulLoggingIPAddress;
+
+ ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
+ vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
+
+ /*
+ * Seed random number generator.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ time( &xTimeNow );
+ FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
+ prvSRand( ( uint32_t ) xTimeNow );
+ FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
}
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
- const char * pcApplicationHostnameHook( void )
- {
- /* Assign the name "FreeRTOS" to this network node. This function will
- be called during the DHCP: the machine will be registered with an IP
- address plus this name. */
- return mainHOST_NAME;
- }
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* Assign the name "FreeRTOS" to this network node. This function will
+ * be called during the DHCP: the machine will be registered with an IP
+ * address plus this name. */
+ return mainHOST_NAME;
+ }
#endif
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
- BaseType_t xApplicationDNSQueryHook( const char *pcName )
- {
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- to this node: that returned by pcApplicationHostnameHook() and that set
- by mainDEVICE_NICK_NAME. */
- if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
- {
- xReturn = pdPASS;
- }
- else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
- {
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
-
- return xReturn;
- }
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
+ {
+ BaseType_t xReturn;
+
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*-----------------------------------------------------------*/
@@ -293,85 +293,85 @@ uint32_t ulLoggingIPAddress;
* SYSTEMS.
*/
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort )
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- ( void ) ulSourceAddress;
- ( void ) usSourcePort;
- ( void ) ulDestinationAddress;
- ( void ) usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
- return uxRand();
+ return uxRand();
}
/*-----------------------------------------------------------*/
/*
* Set *pulNumber to a random number, and return pdTRUE. When the random number
* generator is broken, it shall return pdFALSE.
- * The macros ipconfigRAND32() and configRAND32() are not in use
+ * The macros ipconfigRAND32() and configRAND32() are not in use
* anymore in FreeRTOS+TCP.
- *
+ *
* THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS
* NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.
*/
BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
{
- *pulNumber = uxRand();
- return pdTRUE;
+ *pulNumber = uxRand();
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
-implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
-used by the Idle task. */
+ * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
+ * used by the Idle task. */
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
- StackType_t ** ppxIdleTaskStackBuffer,
- uint32_t * pulIdleTaskStackSize )
+ StackType_t ** ppxIdleTaskStackBuffer,
+ uint32_t * pulIdleTaskStackSize )
{
- /* If the buffers to be provided to the Idle task are declared inside this
- function then they must be declared static - otherwise they will be allocated on
- the stack and so not exists after this function exits. */
- static StaticTask_t xIdleTaskTCB;
- static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
- state will be stored. */
- *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
-
- /* Pass out the array that will be used as the Idle task's stack. */
- *ppxIdleTaskStackBuffer = uxIdleTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
- Note that, as the array is necessarily of type StackType_t,
- configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+ /* If the buffers to be provided to the Idle task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xIdleTaskTCB;
+ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
+ * state will be stored. */
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+
+ /* Pass out the array that will be used as the Idle task's stack. */
+ *ppxIdleTaskStackBuffer = uxIdleTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
-application must provide an implementation of vApplicationGetTimerTaskMemory()
-to provide the memory that is used by the Timer service task. */
+ * application must provide an implementation of vApplicationGetTimerTaskMemory()
+ * to provide the memory that is used by the Timer service task. */
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
- StackType_t ** ppxTimerTaskStackBuffer,
- uint32_t * pulTimerTaskStackSize )
+ StackType_t ** ppxTimerTaskStackBuffer,
+ uint32_t * pulTimerTaskStackSize )
{
- /* If the buffers to be provided to the Timer task are declared inside this
- function then they must be declared static - otherwise they will be allocated on
- the stack and so not exists after this function exits. */
- static StaticTask_t xTimerTaskTCB;
- static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Timer
- task's state will be stored. */
- *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
-
- /* Pass out the array that will be used as the Timer task's stack. */
- *ppxTimerTaskStackBuffer = uxTimerTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
- Note that, as the array is necessarily of type StackType_t,
- configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+ /* If the buffers to be provided to the Timer task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xTimerTaskTCB;
+ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Timer
+ * task's state will be stored. */
+ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+
+ /* Pass out the array that will be used as the Timer task's stack. */
+ *ppxTimerTaskStackBuffer = uxTimerTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c
index 84b87b2a4..f9bc5b5b1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c
@@ -1,21 +1,21 @@
/*
- Copyright 2001, 2002 Georges Menie (www.menie.org)
- stdarg version contributed by Christian Ettinger
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Changes for the FreeRTOS ports:
-
- - The dot in "%-8.8s"
- - The specifiers 'l' (long) and 'L' (long long)
- - The specifier 'u' for unsigned
- - Dot notation for IP addresses:
- sprintf("IP = %xip\n", 0xC0A80164);
- will produce "IP = 192.168.1.100\n"
-*/
+ * Copyright 2001, 2002 Georges Menie (www.menie.org)
+ * stdarg version contributed by Christian Ettinger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Changes for the FreeRTOS ports:
+ *
+ * - The dot in "%-8.8s"
+ * - The specifiers 'l' (long) and 'L' (long long)
+ * - The specifier 'u' for unsigned
+ * - Dot notation for IP addresses:
+ * sprintf("IP = %xip\n", 0xC0A80164);
+ * will produce "IP = 192.168.1.100\n"
+ */
#include <stdarg.h>
#include <stdio.h>
@@ -24,8 +24,8 @@
#include "FreeRTOS.h"
-#define PAD_RIGHT 1
-#define PAD_ZERO 2
+#define PAD_RIGHT 1
+#define PAD_ZERO 2
/*
* Return 1 for readable, 2 for writeable, 3 for both.
@@ -33,635 +33,721 @@
*/
extern BaseType_t xApplicationMemoryPermissions( uint32_t aAddress );
-extern void vOutputChar( const char cChar, const TickType_t xTicksToWait );
+extern void vOutputChar( const char cChar,
+ const TickType_t xTicksToWait );
static const TickType_t xTicksToWait = pdMS_TO_TICKS( 20 );
struct xPrintFlags
{
- int base;
- int width;
- int printLimit;
- unsigned
- pad : 8,
- letBase : 8,
- isSigned : 1,
- isNumber : 1,
- long32 : 1,
- long64 : 1;
+ int base;
+ int width;
+ int printLimit;
+ unsigned
+ pad : 8,
+ letBase : 8,
+ isSigned : 1,
+ isNumber : 1,
+ long32 : 1,
+ long64 : 1;
};
struct SStringBuf
{
- char *str;
- const char *orgStr;
- const char *nulPos;
- int curLen;
- struct xPrintFlags flags;
+ char * str;
+ const char * orgStr;
+ const char * nulPos;
+ int curLen;
+ struct xPrintFlags flags;
};
-static void strbuf_init( struct SStringBuf *apStr, char *apBuf, const char *apMaxStr )
+static void strbuf_init( struct SStringBuf * apStr,
+ char * apBuf,
+ const char * apMaxStr )
{
- apStr->str = apBuf;
- apStr->orgStr = apBuf;
- apStr->nulPos = apMaxStr-1;
- apStr->curLen = 0;
+ apStr->str = apBuf;
+ apStr->orgStr = apBuf;
+ apStr->nulPos = apMaxStr - 1;
+ apStr->curLen = 0;
- memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
+ memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
}
/*-----------------------------------------------------------*/
-static BaseType_t strbuf_printchar( struct SStringBuf *apStr, int c )
+static BaseType_t strbuf_printchar( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *( apStr->str++ ) = c;
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
-static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf *apStr, int c )
+static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *(apStr->str++) = c;
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
static portINLINE int i2hex( int aCh )
{
-int iResult;
-
- if( aCh < 10 )
- {
- iResult = '0' + aCh;
- }
- else
- {
- iResult = 'A' + aCh - 10;
- }
-
- return iResult;
+ int iResult;
+
+ if( aCh < 10 )
+ {
+ iResult = '0' + aCh;
+ }
+ else
+ {
+ iResult = 'A' + aCh - 10;
+ }
+
+ return iResult;
}
/*-----------------------------------------------------------*/
-static BaseType_t prints(struct SStringBuf *apBuf, const char *apString )
+static BaseType_t prints( struct SStringBuf * apBuf,
+ const char * apString )
{
- register int padchar = ' ';
- int i,len;
-
- if( xApplicationMemoryPermissions( ( uint32_t )apString ) == 0 )
- {
- /* The user has probably made a mistake with the parameter
- for '%s', the memory is not readbale. */
- apString = "INV_MEM";
- }
-
- if( apBuf->flags.width > 0 )
- {
- register int len = 0;
- register const char *ptr;
- for( ptr = apString; *ptr; ++ptr )
- {
- ++len;
- }
-
- if( len >= apBuf->flags.width )
- {
- apBuf->flags.width = 0;
- }
- else
- {
- apBuf->flags.width -= len;
- }
-
- if( apBuf->flags.pad & PAD_ZERO )
- {
- padchar = '0';
- }
- }
- if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
- {
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( strbuf_printchar( apBuf, padchar ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
- {
- /* The string to print represents an integer number.
- * In this case, printLimit is the min number of digits to print
- * If the length of the number to print is less than the min nb of i
- * digits to display, we add 0 before printing the number
- */
- len = strlen( apString );
-
- if( len < apBuf->flags.printLimit )
- {
- i = apBuf->flags.printLimit - len;
- for( ; i; i-- )
- {
- if( strbuf_printchar( apBuf, '0' ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- }
- /* The string to print is not the result of a number conversion to ascii.
- * For a string, printLimit is the max number of characters to display
- */
- for( ; apBuf->flags.printLimit && *apString ; ++apString, --apBuf->flags.printLimit )
- {
- if( !strbuf_printchar( apBuf, *apString ) )
- {
- return pdFALSE;
- }
- }
-
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( !strbuf_printchar( apBuf, padchar ) )
- {
- return pdFALSE;
- }
- }
-
- return pdTRUE;
+ register int padchar = ' ';
+ int i, len;
+
+ if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 )
+ {
+ /* The user has probably made a mistake with the parameter
+ * for '%s', the memory is not readbale. */
+ apString = "INV_MEM";
+ }
+
+ if( apBuf->flags.width > 0 )
+ {
+ register int len = 0;
+ register const char * ptr;
+
+ for( ptr = apString; *ptr; ++ptr )
+ {
+ ++len;
+ }
+
+ if( len >= apBuf->flags.width )
+ {
+ apBuf->flags.width = 0;
+ }
+ else
+ {
+ apBuf->flags.width -= len;
+ }
+
+ if( apBuf->flags.pad & PAD_ZERO )
+ {
+ padchar = '0';
+ }
+ }
+
+ if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
+ {
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( strbuf_printchar( apBuf, padchar ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+
+ if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
+ {
+ /* The string to print represents an integer number.
+ * In this case, printLimit is the min number of digits to print
+ * If the length of the number to print is less than the min nb of i
+ * digits to display, we add 0 before printing the number
+ */
+ len = strlen( apString );
+
+ if( len < apBuf->flags.printLimit )
+ {
+ i = apBuf->flags.printLimit - len;
+
+ for( ; i; i-- )
+ {
+ if( strbuf_printchar( apBuf, '0' ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+ }
+
+ /* The string to print is not the result of a number conversion to ascii.
+ * For a string, printLimit is the max number of characters to display
+ */
+ for( ; apBuf->flags.printLimit && *apString; ++apString, --apBuf->flags.printLimit )
+ {
+ if( !strbuf_printchar( apBuf, *apString ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( !strbuf_printchar( apBuf, padchar ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* the following should be enough for 32 bit int */
-#define PRINT_BUF_LEN 12 /* to print 4294967296 */
-
-#if SPRINTF_LONG_LONG
-#warning 64-bit libraries will be included as well
-static BaseType_t printll( struct SStringBuf *apBuf, long long i )
-{
- char print_buf[ 2 * PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned long long u = i;
- lldiv_t lldiv_result;
+#define PRINT_BUF_LEN 12 /* to print 4294967296 */
+
+#if SPRINTF_LONG_LONG
+ #warning 64-bit libraries will be included as well
+ static BaseType_t printll( struct SStringBuf * apBuf,
+ long long i )
+ {
+ char print_buf[ 2 * PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned long long u = i;
+ lldiv_t lldiv_result;
/* typedef struct
* {
- * long long int quot; // quotient
- * long long int rem; // remainder
+ * long long int quot; // quotient
+ * long long int rem; // remainder
* } lldiv_t;
*/
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- if( i == 0LL )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- /* 18446744073709551616 */
- while( u != 0 )
- {
- lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
- t = lldiv_result.rem;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u = lldiv_result.quot;
- }
-
- if( neg != 0 )
- {
- if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
- {
- if( !strbuf_printchar( apBuf, '-' ) )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
-}
-#endif /* SPRINTF_LONG_LONG */
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0LL )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ /* 18446744073709551616 */
+ while( u != 0 )
+ {
+ lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
+ t = lldiv_result.rem;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u = lldiv_result.quot;
+ }
+
+ if( neg != 0 )
+ {
+ if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( !strbuf_printchar( apBuf, '-' ) )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
+ }
+#endif /* SPRINTF_LONG_LONG */
/*-----------------------------------------------------------*/
-static BaseType_t printi( struct SStringBuf *apBuf, int i )
+static BaseType_t printi( struct SStringBuf * apBuf,
+ int i )
{
- char print_buf[ PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned int u = i;
- register unsigned base = apBuf->flags.base;
-
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
-
- if( i == 0 )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- switch( base )
- {
- case 16:
- while( u != 0 )
- {
- t = u & 0xF;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u >>= 4;
- }
- break;
-
- case 8:
- case 10:
- /* GCC compiles very efficient */
- while( u )
- {
- t = u % base;
- *( --s ) = t + '0';
- u /= base;
- }
- break;
+ char print_buf[ PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned int u = i;
+ register unsigned base = apBuf->flags.base;
+
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0 )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ switch( base )
+ {
+ case 16:
+
+ while( u != 0 )
+ {
+ t = u & 0xF;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u >>= 4;
+ }
+
+ break;
+
+ case 8:
+ case 10:
+
+ /* GCC compiles very efficient */
+ while( u )
+ {
+ t = u % base;
+ *( --s ) = t + '0';
+ u /= base;
+ }
+
+ break;
+
/*
- // The generic case, not yet in use
- default:
- while( u )
- {
- t = u % base;
- if( t >= 10)
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u /= base;
- }
- break;
-*/
- }
-
- if( neg != 0 )
- {
- if( apBuf->flags.width && (apBuf->flags.pad & PAD_ZERO ) )
- {
- if( strbuf_printchar( apBuf, '-' ) == 0 )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
+ * // The generic case, not yet in use
+ * default:
+ * while( u )
+ * {
+ * t = u % base;
+ * if( t >= 10)
+ * {
+ * t += apBuf->flags.letBase - '0' - 10;
+ * }
+ *( --s ) = t + '0';
+ * u /= base;
+ * }
+ * break;
+ */
+ }
+
+ if( neg != 0 )
+ {
+ if( apBuf->flags.width && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( strbuf_printchar( apBuf, '-' ) == 0 )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
}
/*-----------------------------------------------------------*/
-static BaseType_t printIp(struct SStringBuf *apBuf, unsigned i )
+static BaseType_t printIp( struct SStringBuf * apBuf,
+ unsigned i )
{
- char print_buf[16];
+ char print_buf[ 16 ];
- sprintf( print_buf, "%u.%u.%u.%u",
- i >> 24,
- ( i >> 16 ) & 0xff,
- ( i >> 8 ) & 0xff,
- i & 0xff );
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- prints( apBuf, print_buf );
+ sprintf( print_buf, "%u.%u.%u.%u",
+ i >> 24,
+ ( i >> 16 ) & 0xff,
+ ( i >> 8 ) & 0xff,
+ i & 0xff );
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+ prints( apBuf, print_buf );
- return pdTRUE;
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
-static void tiny_print( struct SStringBuf *apBuf, const char *format, va_list args )
+static void tiny_print( struct SStringBuf * apBuf,
+ const char * format,
+ va_list args )
{
- char scr[2];
-
- for( ; ; )
- {
- int ch = *( format++ );
-
- if( ch != '%' )
- {
- do
- {
- /* Put the most like flow in a small loop */
- if( strbuf_printchar_inline( apBuf, ch ) == 0 )
- {
- return;
- }
- ch = *( format++ );
- } while( ch != '%' );
- }
- ch = *( format++ );
- /* Now ch has character after '%', format pointing to next */
-
- if( ch == '\0' )
- {
- break;
- }
- if( ch == '%' )
- {
- if( strbuf_printchar( apBuf, ch ) == 0 )
- {
- return;
- }
- continue;
- }
- memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
-
- if( ch == '-' )
- {
- ch = *( format++ );
- apBuf->flags.pad = PAD_RIGHT;
- }
- while( ch == '0' )
- {
- ch = *( format++ );
- apBuf->flags.pad |= PAD_ZERO;
- }
- if( ch == '*' )
- {
- ch = *( format++ );
- apBuf->flags.width = va_arg( args, int );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.width *= 10;
- apBuf->flags.width += ch - '0';
- ch = *( format++ );
- }
- }
- if( ch == '.' )
- {
- ch = *( format++ );
- if( ch == '*' )
- {
- apBuf->flags.printLimit = va_arg( args, int );
- ch = *( format++ );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.printLimit *= 10;
- apBuf->flags.printLimit += ch - '0';
- ch = *( format++ );
- }
- }
- }
- if( apBuf->flags.printLimit == 0 )
- {
- apBuf->flags.printLimit--; /* -1: make it unlimited */
- }
- if( ch == 's' )
- {
- register char *s = ( char * )va_arg( args, int );
- if( prints( apBuf, s ? s : "(null)" ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'c' )
- {
- /* char are converted to int then pushed on the stack */
- scr[0] = ( char ) va_arg( args, int );
-
- if( strbuf_printchar( apBuf, scr[0] ) == 0 )
- {
- return;
- }
-
- continue;
- }
- if( ch == 'l' )
- {
- ch = *( format++ );
- apBuf->flags.long32 = 1;
- /* Makes not difference as u32 == long */
- }
- if( ch == 'L' )
- {
- ch = *( format++ );
- apBuf->flags.long64 = 1;
- /* Does make a difference */
- }
- apBuf->flags.base = 10;
- apBuf->flags.letBase = 'a';
-
- if( ch == 'd' || ch == 'u' )
- {
- apBuf->flags.isSigned = ( ch == 'd' );
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
-
- apBuf->flags.base = 16; /* From here all hexadecimal */
-
- if( ch == 'x' && format[0] == 'i' && format[1] == 'p' )
- {
- format += 2; /* eat the "xi" of "xip" */
- /* Will use base 10 again */
- if( printIp( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'x' || ch == 'X' || ch == 'p' || ch == 'o' )
- {
- if( ch == 'X' )
- {
- apBuf->flags.letBase = 'A';
- }
- else if( ch == 'o' )
- {
- apBuf->flags.base = 8;
- }
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- }
- strbuf_printchar( apBuf, '\0' );
+ char scr[ 2 ];
+
+ for( ; ; )
+ {
+ int ch = *( format++ );
+
+ if( ch != '%' )
+ {
+ do
+ {
+ /* Put the most like flow in a small loop */
+ if( strbuf_printchar_inline( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ ch = *( format++ );
+ } while( ch != '%' );
+ }
+
+ ch = *( format++ );
+ /* Now ch has character after '%', format pointing to next */
+
+ if( ch == '\0' )
+ {
+ break;
+ }
+
+ if( ch == '%' )
+ {
+ if( strbuf_printchar( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
+
+ if( ch == '-' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad = PAD_RIGHT;
+ }
+
+ while( ch == '0' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad |= PAD_ZERO;
+ }
+
+ if( ch == '*' )
+ {
+ ch = *( format++ );
+ apBuf->flags.width = va_arg( args, int );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.width *= 10;
+ apBuf->flags.width += ch - '0';
+ ch = *( format++ );
+ }
+ }
+
+ if( ch == '.' )
+ {
+ ch = *( format++ );
+
+ if( ch == '*' )
+ {
+ apBuf->flags.printLimit = va_arg( args, int );
+ ch = *( format++ );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.printLimit *= 10;
+ apBuf->flags.printLimit += ch - '0';
+ ch = *( format++ );
+ }
+ }
+ }
+
+ if( apBuf->flags.printLimit == 0 )
+ {
+ apBuf->flags.printLimit--; /* -1: make it unlimited */
+ }
+
+ if( ch == 's' )
+ {
+ register char * s = ( char * ) va_arg( args, int );
+
+ if( prints( apBuf, s ? s : "(null)" ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ch == 'c' )
+ {
+ /* char are converted to int then pushed on the stack */
+ scr[ 0 ] = ( char ) va_arg( args, int );
+
+ if( strbuf_printchar( apBuf, scr[ 0 ] ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ if( ch == 'l' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long32 = 1;
+ /* Makes not difference as u32 == long */
+ }
+
+ if( ch == 'L' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long64 = 1;
+ /* Does make a difference */
+ }
+
+ apBuf->flags.base = 10;
+ apBuf->flags.letBase = 'a';
+
+ if( ( ch == 'd' ) || ( ch == 'u' ) )
+ {
+ apBuf->flags.isSigned = ( ch == 'd' );
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ apBuf->flags.base = 16; /* From here all hexadecimal */
+
+ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) )
+ {
+ format += 2; /* eat the "xi" of "xip" */
+
+ /* Will use base 10 again */
+ if( printIp( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ( ch == 'x' ) || ( ch == 'X' ) || ( ch == 'p' ) || ( ch == 'o' ) )
+ {
+ if( ch == 'X' )
+ {
+ apBuf->flags.letBase = 'A';
+ }
+ else if( ch == 'o' )
+ {
+ apBuf->flags.base = 8;
+ }
+
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+ }
+
+ strbuf_printchar( apBuf, '\0' );
}
/*-----------------------------------------------------------*/
-int vsnprintf( char *apBuf, size_t aMaxLen, const char *apFmt, va_list args )
+int vsnprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int snprintf( char *apBuf, size_t aMaxLen, const char *apFmt, ... )
+int snprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int sprintf( char *apBuf, const char *apFmt, ... )
+int sprintf( char * apBuf,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char * )apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int vsprintf( char *apBuf, const char *apFmt, va_list args )
+int vsprintf( char * apBuf,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* ) apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-const char *mkSize (unsigned long long aSize, char *apBuf, int aLen)
+const char * mkSize( unsigned long long aSize,
+ char * apBuf,
+ int aLen )
{
-static char retString[33];
-size_t gb, mb, kb, sb;
-
- if (apBuf == NULL) {
- apBuf = retString;
- aLen = sizeof( retString );
- }
- gb = aSize / (1024*1024*1024);
- aSize -= gb * (1024*1024*1024);
- mb = aSize / (1024*1024);
- aSize -= mb * (1024*1024);
- kb = aSize / (1024);
- aSize -= kb * (1024);
- sb = aSize;
- if( gb )
- {
- snprintf (apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
- }
- else if( mb )
- {
- snprintf (apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb) / 1024ul ) );
- }
- else if( kb != 0ul )
- {
- snprintf (apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb) / 1024ul ) );
- }
- else
- {
- snprintf (apBuf, aLen, "%u bytes", ( unsigned ) sb);
- }
- return apBuf;
+ static char retString[ 33 ];
+ size_t gb, mb, kb, sb;
+
+ if( apBuf == NULL )
+ {
+ apBuf = retString;
+ aLen = sizeof( retString );
+ }
+
+ gb = aSize / ( 1024 * 1024 * 1024 );
+ aSize -= gb * ( 1024 * 1024 * 1024 );
+ mb = aSize / ( 1024 * 1024 );
+ aSize -= mb * ( 1024 * 1024 );
+ kb = aSize / ( 1024 );
+ aSize -= kb * ( 1024 );
+ sb = aSize;
+
+ if( gb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
+ }
+ else if( mb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb ) / 1024ul ) );
+ }
+ else if( kb != 0ul )
+ {
+ snprintf( apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb ) / 1024ul ) );
+ }
+ else
+ {
+ snprintf( apBuf, aLen, "%u bytes", ( unsigned ) sb );
+ }
+
+ return apBuf;
}
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSConfig.h
index dd495cd91..d7d554fd1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSConfig.h
@@ -29,94 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile, uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -124,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demo of the HTTP library. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-
-#if( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSIPConfig.h
index 1adbb82b2..0c090966e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/FreeRTOSIPConfig.h
@@ -27,284 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 32 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 32 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ( (x) != NULL )
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/demo_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/demo_config.h
index 1ba58ba59..5ed9c92b6 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/demo_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/demo_config.h
@@ -48,13 +48,13 @@
* For more information regarding TLS protocol:
* https://www.freertos.org/https/tls.html
*/
-#define democonfigENABLE_TLS 0
+#define democonfigENABLE_TLS 0
/**
* @brief Enable/Disable mutual authentication in demos. If enabled, require
* democonfigENABLE_TLS to be set to 1.
*/
-#define democonfigENABLE_MUTUAL_AUTH 0
+#define democonfigENABLE_MUTUAL_AUTH 0
/**
* @brief Select a connection profile.
@@ -65,7 +65,7 @@
* requires democonfigENABLE_MUTUAL_AUTH to be set to 1 since AWS IoT requires
* mutually authenticated connection.
*/
-#define democonfigPROFILE_USE_AWS_IOT 0
+#define democonfigPROFILE_USE_AWS_IOT 0
/**
* @brief Set the stack size of the main demo task.
@@ -73,6 +73,6 @@
* In the Windows port, this stack only holds a structure. The actual
* stack is created by an operating system thread.
*/
-#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
+#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
#endif /* DEMO_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/iot_config.h
index d3d489a4d..1f96a5111 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/http_plain_text/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/**
* @brief Set the log level of the HTTPS Client library.
@@ -75,7 +75,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
+#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -89,7 +89,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSConfig.h
index 642113c41..ebee2a143 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSConfig.h
@@ -29,94 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile, uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -124,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demos of IoT Libraries. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-
-#if( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSIPConfig.h
index 1adbb82b2..0c090966e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/FreeRTOSIPConfig.h
@@ -27,284 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 32 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 32 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ( (x) != NULL )
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/demo_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/demo_config.h
index 8ddc1fd93..ca279a01b 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/demo_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/demo_config.h
@@ -48,13 +48,13 @@
* For more information regarding TLS protocol:
* https://www.freertos.org/https/tls.html
*/
-#define democonfigENABLE_TLS 1
+#define democonfigENABLE_TLS 1
/**
* @brief Enable/Disable mutual authentication in demos. If enabled, require
* democonfigENABLE_TLS to be set to 1.
*/
-#define democonfigENABLE_MUTUAL_AUTH 0
+#define democonfigENABLE_MUTUAL_AUTH 0
/**
* @brief Select a connection profile.
@@ -65,7 +65,7 @@
* requires democonfigENABLE_MUTUAL_AUTH to be set to 1 since AWS IoT requires
* mutually authenticated connection.
*/
-#define democonfigPROFILE_USE_AWS_IOT 0
+#define democonfigPROFILE_USE_AWS_IOT 0
/**
* @brief Set the stack size of the main demo task.
@@ -73,6 +73,6 @@
* In the Windows port, this stack only holds a structure. The actual
* stack is created by an operating system thread.
*/
-#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
+#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
#endif /* DEMO_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/iot_config.h
index 4e69ce1c1..67ce29d94 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_basic_tls_server_auth/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/**
* @brief Set the log level of the HTTPS Client library.
@@ -75,14 +75,14 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
+#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
/**
* @brief Enable TLS in the network abstraction.
*
* The TLS implementation requires the mbed TLS library.
*/
-#define IOT_NETWORK_ENABLE_TLS 1
+#define IOT_NETWORK_ENABLE_TLS 1
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -96,7 +96,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSConfig.h
index 642113c41..ebee2a143 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSConfig.h
@@ -29,94 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile, uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -124,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demos of IoT Libraries. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-
-#if( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSIPConfig.h
index 96c93e394..68e49bacc 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/FreeRTOSIPConfig.h
@@ -27,284 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ( (x) != NULL )
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/demo_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/demo_config.h
index 6d638d792..9dd01a781 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/demo_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/demo_config.h
@@ -48,13 +48,13 @@
* For more information regarding TLS protocol:
* https://www.freertos.org/https/tls.html
*/
-#define democonfigENABLE_TLS 1
+#define democonfigENABLE_TLS 1
/**
* @brief Enable/Disable mutual authentication in demos. If enabled, require
* democonfigENABLE_TLS to be set to 1.
*/
-#define democonfigENABLE_MUTUAL_AUTH 1
+#define democonfigENABLE_MUTUAL_AUTH 1
/**
* @brief Select a connection profile.
@@ -65,7 +65,7 @@
* requires democonfigENABLE_MUTUAL_AUTH to be set to 1 since AWS IoT requires
* mutually authenticated connection.
*/
-#define democonfigPROFILE_USE_AWS_IOT 1
+#define democonfigPROFILE_USE_AWS_IOT 1
/**
* @brief Set the stack size of the main demo task.
@@ -73,6 +73,6 @@
* In the Windows port, this stack only holds a structure. The actual
* stack is created by an operating system thread.
*/
-#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
+#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
#endif /* DEMO_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/iot_config.h
index 4e69ce1c1..67ce29d94 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/https_tls_mutual_auth/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/**
* @brief Set the log level of the HTTPS Client library.
@@ -75,14 +75,14 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
+#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
/**
* @brief Enable TLS in the network abstraction.
*
* The TLS implementation requires the mbed TLS library.
*/
-#define IOT_NETWORK_ENABLE_TLS 1
+#define IOT_NETWORK_ENABLE_TLS 1
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -96,7 +96,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_demo_profile.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_demo_profile.h
index 1ac70b8c4..21836fd6b 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_demo_profile.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_demo_profile.h
@@ -63,14 +63,14 @@
*
* Use 8883 if connecting to AWS IoT services.
*/
-#define awsiotdemoprofileAWS_MQTT_PORT 8883
+#define awsiotdemoprofileAWS_MQTT_PORT 8883
/**
* @brief The port to use for the HTTPS demo.
*
* Use 8443 if connecting to AWS IoT services.
*/
-#define awsiotdemoprofileAWS_HTTPS_PORT 8443
+#define awsiotdemoprofileAWS_HTTPS_PORT 8443
/**
* @brief The AWS IoT server certificate.
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_setup_check.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_setup_check.h
index 7b25cec13..cfe377d7f 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_setup_check.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/include/aws_iot_setup_check.h
@@ -59,18 +59,18 @@
*/
#if defined( AWS_IOT_DEMO_PROFILE_H )
#ifndef awsiotdemoprofileAWS_ENDPOINT
- #error ACTION REQUIRED: Please ensure you have awsiotdemoprofileAWS_ENDPOINT (in aws_iot_demo_profile.h) configured. Refer to https://www.freertos.org/mqtt/preconfiguredexamplesMA.html for proper setup.
+ #error ACTION REQUIRED: Please ensure you have awsiotdemoprofileAWS_ENDPOINT (in aws_iot_demo_profile.h) configured. Refer to https: /*www.freertos.org/mqtt/preconfiguredexamplesMA.html for proper setup. */
#endif
#ifndef awsiotdemoprofileCLIENT_IDENTIFIER
- #error ACTION REQUIRED: Please ensure you have awsiotdemoprofileCLIENT_IDENTIFIER (in aws_iot_demo_profile.h) configured. Refer to https://www.freertos.org/mqtt/preconfiguredexamplesMA.html for proper setup.
+ #error ACTION REQUIRED: Please ensure you have awsiotdemoprofileCLIENT_IDENTIFIER (in aws_iot_demo_profile.h) configured. Refer to https: /*www.freertos.org/mqtt/preconfiguredexamplesMA.html for proper setup. */
#endif
#if ( democonfigENABLE_TLS )
#if ( democonfigENABLE_MUTUAL_AUTH )
#ifndef awsiotdemoprofileCLIENT_CERTIFICATE_PEM
- #error ACTION REQUIRED: Please ensure you have awsiotdemoprofileCLIENT_CERTIFICATE_PEM (in aws_iot_demo_profile.h) configured as required for mutual authentication. https://www.freertos.org/mqtt/preconfiguredexamplesMA.html for proper setup.
+ #error ACTION REQUIRED: Please ensure you have awsiotdemoprofileCLIENT_CERTIFICATE_PEM (in aws_iot_demo_profile.h) configured as required for mutual authentication. https: /*www.freertos.org/mqtt/preconfiguredexamplesMA.html for proper setup. */
#endif
#ifndef awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM
- #error ACTION REQUIRED: Please ensure you have awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM (in aws_iot_demo_profile.h) configured as required for mutual authentication. https://www.freertos.org/mqtt/preconfiguredexamplesMA.html for proper setup.
+ #error ACTION REQUIRED: Please ensure you have awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM (in aws_iot_demo_profile.h) configured as required for mutual authentication. https: /*www.freertos.org/mqtt/preconfiguredexamplesMA.html for proper setup. */
#endif
#endif
#endif /* if ( democonfigENABLE_TLS ) */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c
index 066098b01..afe65dfe2 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c
@@ -92,34 +92,34 @@
* To enable the keep alive feature, set this value
* to the desired interval in seconds.
*/
-#define jobsexampleKEEP_ALIVE_SECONDS ( 0 )
+#define jobsexampleKEEP_ALIVE_SECONDS ( 0 )
/**
* @brief The timeout for MQTT operations in this example.
*/
-#define jobsexampleMQTT_TIMEOUT_MS ( 5000 )
+#define jobsexampleMQTT_TIMEOUT_MS ( 5000 )
/**
* @brief Use default timeout when calling AwsIotJobs_Init.
*/
-#define jobsexampleUSE_DEFAULT_MQTT_TIMEOUT ( 0 )
+#define jobsexampleUSE_DEFAULT_MQTT_TIMEOUT ( 0 )
/**
* @brief The bit which is set in the demo task's notification value from the
* disconnect callback to inform the demo task about the MQTT disconnect.
*/
-#define jobsexampleDISCONNECTED_BIT ( 1UL << 0UL )
+#define jobsexampleDISCONNECTED_BIT ( 1UL << 0UL )
/**
* @brief The bit which is set in the demo task's notification value from the
* operation complete callback to inform the demo task to exit.
*/
-#define jobsexampleEXIT_BIT ( 1UL << 1UL )
+#define jobsexampleEXIT_BIT ( 1UL << 1UL )
/**
* @brief Length of the client identifier for this demo.
*/
-#define jobsexampleCLIENT_IDENTIFIER_LENGTH ( sizeof( awsiotdemoprofileCLIENT_IDENTIFIER ) - 1 )
+#define jobsexampleCLIENT_IDENTIFIER_LENGTH ( sizeof( awsiotdemoprofileCLIENT_IDENTIFIER ) - 1 )
/**
* @brief The JSON key of the Job ID.
@@ -128,12 +128,12 @@
* All such JSON documents will contain this key, whose value represents the unique
* identifier of a Job.
*/
-#define jobsexampleID_KEY "jobId"
+#define jobsexampleID_KEY "jobId"
/**
* @brief The length of #jobsexampleID_KEY.
*/
-#define jobsexampleID_KEY_LENGTH ( sizeof( jobsexampleID_KEY ) - 1 )
+#define jobsexampleID_KEY_LENGTH ( sizeof( jobsexampleID_KEY ) - 1 )
/**
* @brief The JSON key of the Job document.
@@ -142,12 +142,12 @@
* All such JSON documents will contain this key, whose value is an application-specific
* Job document.
*/
-#define jobsexampleDOC_KEY "jobDocument"
+#define jobsexampleDOC_KEY "jobDocument"
/**
* @brief The length of #jobsexampleDOC_KEY.
*/
-#define jobsexampleDOC_KEY_LENGTH ( sizeof( jobsexampleDOC_KEY ) - 1 )
+#define jobsexampleDOC_KEY_LENGTH ( sizeof( jobsexampleDOC_KEY ) - 1 )
/**
* @brief The JSON key whose value represents the action this demo should take.
@@ -155,12 +155,12 @@
* This demo program expects this key to be in the Job document. It is a key
* specific to this demo.
*/
-#define jobsexampleACTION_KEY "action"
+#define jobsexampleACTION_KEY "action"
/**
* @brief The length of #jobsexampleACTION_KEY.
*/
-#define jobsexampleACTION_KEY_LENGTH ( sizeof( jobsexampleACTION_KEY ) - 1 )
+#define jobsexampleACTION_KEY_LENGTH ( sizeof( jobsexampleACTION_KEY ) - 1 )
/**
* @brief A message associated with the Job action.
@@ -169,12 +169,12 @@
* is either "publish" or "print". It represents the message that should be
* published or printed, respectively.
*/
-#define jobsexampleMESSAGE_KEY "message"
+#define jobsexampleMESSAGE_KEY "message"
/**
* @brief The length of #jobsexampleMESSAGE_KEY.
*/
-#define jobsexampleMESSAGE_KEY_LENGTH ( sizeof( jobsexampleMESSAGE_KEY ) - 1 )
+#define jobsexampleMESSAGE_KEY_LENGTH ( sizeof( jobsexampleMESSAGE_KEY ) - 1 )
/**
* @brief An MQTT topic associated with the Job "publish" action.
@@ -183,12 +183,12 @@
* is "publish". It represents the MQTT topic on which the message should be
* published.
*/
-#define jobsexampleTOPIC_KEY "topic"
+#define jobsexampleTOPIC_KEY "topic"
/**
* @brief The length of #jobsexampleTOPIC_KEY.
*/
-#define jobsexampleTOPIC_KEY_LENGTH ( sizeof( jobsexampleTOPIC_KEY ) - 1 )
+#define jobsexampleTOPIC_KEY_LENGTH ( sizeof( jobsexampleTOPIC_KEY ) - 1 )
/**
* @brief The minimum length of a string in a JSON Job document.
@@ -196,7 +196,7 @@
* At the very least the Job ID must have the quotes that identify it as a JSON
* string and 1 character for the string itself (the string must not be empty).
*/
-#define jobsexampleJSON_STRING_MIN_LENGTH ( ( size_t ) 3 )
+#define jobsexampleJSON_STRING_MIN_LENGTH ( ( size_t ) 3 )
/**
* @brief The maximum length of a Job ID.
@@ -206,13 +206,13 @@
*
* https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#job-limits
*/
-#define jobsexampleID_MAX_LENGTH ( ( size_t ) 64 )
+#define jobsexampleID_MAX_LENGTH ( ( size_t ) 64 )
/**
* @brief A value passed as context to #prvOperationCompleteCallback to specify that
* it should notify the demo task of an exit request.
*/
-#define jobsexampleSHOULD_EXIT ( ( void * ) ( ( intptr_t ) 1 ) )
+#define jobsexampleSHOULD_EXIT ( ( void * ) ( ( intptr_t ) 1 ) )
/**
* @brief Time to wait before exiting demo.
@@ -220,7 +220,7 @@
* The milliseconds to wait before exiting. This is because the MQTT Broker
* will disconnect us if we are idle too long, and we have disabled keep alive.
*/
-#define jobsexampleMS_BEFORE_EXIT ( 10 * 60 * 1000 )
+#define jobsexampleMS_BEFORE_EXIT ( 10 * 60 * 1000 )
/*-----------------------------------------------------------*/
@@ -229,10 +229,10 @@
*/
typedef enum _jobAction
{
- JOB_ACTION_PRINT, /**< Print a message. */
- JOB_ACTION_PUBLISH, /**< Publish a message to an MQTT topic. */
- JOB_ACTION_EXIT, /**< Exit the demo. */
- JOB_ACTION_UNKNOWN /**< Unknown action. */
+ JOB_ACTION_PRINT, /**< Print a message. */
+ JOB_ACTION_PUBLISH, /**< Publish a message to an MQTT topic. */
+ JOB_ACTION_EXIT, /**< Exit the demo. */
+ JOB_ACTION_UNKNOWN /**< Unknown action. */
} _jobAction_t;
/**
@@ -253,7 +253,7 @@ static void prvJobsDemoTask( void * pvParameters );
* disconnected.
*/
static void prvExample_OnDisconnect( void * pvCallbackContext,
- IotMqttCallbackParam_t * pxCallbackParams );
+ IotMqttCallbackParam_t * pxCallbackParams );
/**
* @brief Connects to the MQTT broker as specified in awsiotdemoprofileAWS_ENDPOINT
@@ -281,7 +281,7 @@ static void prvSetNotifyNextCallback( void );
* @return A #_jobAction_t equivalent to the given string.
*/
static _jobAction_t prvGetAction( const char * pcAction,
- size_t xActionLength );
+ size_t xActionLength );
/**
* @brief Extracts a JSON string from the Job document.
@@ -296,11 +296,11 @@ static _jobAction_t prvGetAction( const char * pcAction,
* @return `pdTRUE` if the key was found and the value is valid; `pdFALSE` otherwise.
*/
static BaseType_t prvGetJsonString( const char * pcJsonDoc,
- size_t xJsonDocLength,
- const char * pcKey,
- size_t xKeyLength,
- const char ** ppcValue,
- size_t * pxValueLength );
+ size_t xJsonDocLength,
+ const char * pcKey,
+ size_t xKeyLength,
+ const char ** ppcValue,
+ size_t * pxValueLength );
/**
* @brief Job operation completion callback. This function is invoked when an
@@ -310,7 +310,7 @@ static BaseType_t prvGetJsonString( const char * pcJsonDoc,
* @param[in] pxCallbackParam Information on the Job operation that completed.
*/
static void prvOperationCompleteCallback( void * pvCallbackContext,
- AwsIotJobsCallbackParam_t * pxCallbackParam );
+ AwsIotJobsCallbackParam_t * pxCallbackParam );
/**
@@ -324,9 +324,9 @@ static void prvOperationCompleteCallback( void * pvCallbackContext,
* @return #AWS_IOT_JOB_STATE_SUCCEEDED on success; #AWS_IOT_JOB_STATE_FAILED otherwise.
*/
static AwsIotJobState_t prvProcessMessage( IotMqttConnection_t xMqttConnection,
- _jobAction_t xAction,
- const char * pcJobDoc,
- size_t xJobDocLength );
+ _jobAction_t xAction,
+ const char * pcJobDoc,
+ size_t xJobDocLength );
/**
* @brief Process a Job received from the Notify Next callback.
@@ -339,10 +339,10 @@ static AwsIotJobState_t prvProcessMessage( IotMqttConnection_t xMqttConnection,
* @param[in] xJobDocLength The length of the Job document.
*/
static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo,
- const char * pcJobId,
- size_t xJobIdLength,
- const char * pcJobDoc,
- size_t xJobDocLength );
+ const char * pcJobId,
+ size_t xJobIdLength,
+ const char * pcJobDoc,
+ size_t xJobDocLength );
/**
* @brief Jobs Notify Next callback. This function is invoked when a new Job is
@@ -352,14 +352,14 @@ static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo,
* @param[in] pxCallbackInfo Contains the received Job.
*/
static void prvJobsCallback( void * pCallbackContext,
- AwsIotJobsCallbackParam_t * pxCallbackInfo );
+ AwsIotJobsCallbackParam_t * pxCallbackInfo );
/*-----------------------------------------------------------*/
/**
* @brief The MQTT connection handle used in this example.
*/
-static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
+static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
/*
* @brief The main task handle in this demo.
@@ -369,678 +369,678 @@ static TaskHandle_t xMainTaskHandle;
/***************** Structures that define the connection. *********************/
-static const struct IotNetworkServerInfo xMQTTBrokerInfo =
+static const struct IotNetworkServerInfo xMQTTBrokerInfo =
{
- .pHostName = awsiotdemoprofileAWS_ENDPOINT,
- .port = awsiotdemoprofileAWS_MQTT_PORT
+ .pHostName = awsiotdemoprofileAWS_ENDPOINT,
+ .port = awsiotdemoprofileAWS_MQTT_PORT
};
-static struct IotNetworkCredentials xNetworkSecurityCredentials =
+static struct IotNetworkCredentials xNetworkSecurityCredentials =
{
- /* Optional TLS extensions. For this demo, they are disabled. */
- .pAlpnProtos = NULL,
- .maxFragmentLength = 0,
-
- /* SNI is enabled by default. */
- .disableSni = false,
-
- /* Provide the certificate for validating the server. Only required for
- * demos using TLS. */
- .pRootCa = awsiotdemoprofileAWS_CERTIFICATE_PEM,
- .rootCaSize = sizeof( awsiotdemoprofileAWS_CERTIFICATE_PEM ),
-
- /* Strong mutual authentication to authenticate both the broker and
- * the client. */
- .pClientCert = awsiotdemoprofileCLIENT_CERTIFICATE_PEM,
- .clientCertSize = sizeof( awsiotdemoprofileCLIENT_CERTIFICATE_PEM ),
- .pPrivateKey = awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM,
- .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM )
+ /* Optional TLS extensions. For this demo, they are disabled. */
+ .pAlpnProtos = NULL,
+ .maxFragmentLength = 0,
+
+ /* SNI is enabled by default. */
+ .disableSni = false,
+
+ /* Provide the certificate for validating the server. Only required for
+ * demos using TLS. */
+ .pRootCa = awsiotdemoprofileAWS_CERTIFICATE_PEM,
+ .rootCaSize = sizeof( awsiotdemoprofileAWS_CERTIFICATE_PEM ),
+
+ /* Strong mutual authentication to authenticate both the broker and
+ * the client. */
+ .pClientCert = awsiotdemoprofileCLIENT_CERTIFICATE_PEM,
+ .clientCertSize = sizeof( awsiotdemoprofileCLIENT_CERTIFICATE_PEM ),
+ .pPrivateKey = awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM,
+ .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM )
};
-static IotMqttNetworkInfo_t xNetworkInfo =
+static IotMqttNetworkInfo_t xNetworkInfo =
{
- /* No connection to the MQTT broker has been established yet and we want to
- * establish a new connection. */
- .createNetworkConnection = true,
- .u.setup.pNetworkServerInfo = &( xMQTTBrokerInfo ),
+ /* No connection to the MQTT broker has been established yet and we want to
+ * establish a new connection. */
+ .createNetworkConnection = true,
+ .u.setup.pNetworkServerInfo = &( xMQTTBrokerInfo ),
- /* Set the TLS credentials for the new MQTT connection. */
- .u.setup.pNetworkCredentialInfo = &xNetworkSecurityCredentials,
+ /* Set the TLS credentials for the new MQTT connection. */
+ .u.setup.pNetworkCredentialInfo = &xNetworkSecurityCredentials,
- /* Use FreeRTOS+TCP network interface. */
- .pNetworkInterface = IOT_NETWORK_INTERFACE_FREERTOS,
+ /* Use FreeRTOS+TCP network interface. */
+ .pNetworkInterface = IOT_NETWORK_INTERFACE_FREERTOS,
- /* Setup the callback which is called when the MQTT connection is
- * disconnected. The task handle is passed as the callback context which
- * is used by the callback to send a task notification to this task.*/
- .disconnectCallback.function = prvExample_OnDisconnect
+ /* Setup the callback which is called when the MQTT connection is
+ * disconnected. The task handle is passed as the callback context which
+ * is used by the callback to send a task notification to this task.*/
+ .disconnectCallback.function = prvExample_OnDisconnect
};
-static const IotMqttConnectInfo_t xConnectInfo =
+static const IotMqttConnectInfo_t xConnectInfo =
{
- /* Set this flag to true if connecting to the AWS IoT MQTT broker. */
- .awsIotMqttMode = false,
-
- /* Start with a clean session i.e. direct the MQTT broker to discard any
- * previous session data. Also, establishing a connection with clean session
- * will ensure that the broker does not store any data when this client
- * gets disconnected. */
- .cleanSession = true,
-
- /* Since we are starting with a clean session, there are no previous
- * subscriptions to be restored. */
- .pPreviousSubscriptions = NULL,
- .previousSubscriptionCount = 0,
-
- /* We do not want to publish Last Will and Testament (LWT) message if the
- * client gets disconnected. */
- .pWillInfo = NULL,
-
- /* Send an MQTT PING request every minute to keep the connection open if
- * there is no other MQTT traffic. */
- .keepAliveSeconds = jobsexampleKEEP_ALIVE_SECONDS,
-
- /* The client identifier is used to uniquely identify this MQTT client to
- * the MQTT broker. In a production device the identifier can be something
- * unique, such as a device serial number. */
- .pClientIdentifier = awsiotdemoprofileCLIENT_IDENTIFIER,
- .clientIdentifierLength = ( uint16_t ) sizeof( awsiotdemoprofileCLIENT_IDENTIFIER ) - 1,
-
- /* This example does not authenticate the client and therefore username and
- * password fields are not used. */
- .pUserName = NULL,
- .userNameLength = 0,
- .pPassword = NULL,
- .passwordLength = 0
+ /* Set this flag to true if connecting to the AWS IoT MQTT broker. */
+ .awsIotMqttMode = false,
+
+ /* Start with a clean session i.e. direct the MQTT broker to discard any
+ * previous session data. Also, establishing a connection with clean session
+ * will ensure that the broker does not store any data when this client
+ * gets disconnected. */
+ .cleanSession = true,
+
+ /* Since we are starting with a clean session, there are no previous
+ * subscriptions to be restored. */
+ .pPreviousSubscriptions = NULL,
+ .previousSubscriptionCount = 0,
+
+ /* We do not want to publish Last Will and Testament (LWT) message if the
+ * client gets disconnected. */
+ .pWillInfo = NULL,
+
+ /* Send an MQTT PING request every minute to keep the connection open if
+ * there is no other MQTT traffic. */
+ .keepAliveSeconds = jobsexampleKEEP_ALIVE_SECONDS,
+
+ /* The client identifier is used to uniquely identify this MQTT client to
+ * the MQTT broker. In a production device the identifier can be something
+ * unique, such as a device serial number. */
+ .pClientIdentifier = awsiotdemoprofileCLIENT_IDENTIFIER,
+ .clientIdentifierLength = ( uint16_t ) sizeof( awsiotdemoprofileCLIENT_IDENTIFIER ) - 1,
+
+ /* This example does not authenticate the client and therefore username and
+ * password fields are not used. */
+ .pUserName = NULL,
+ .userNameLength = 0,
+ .pPassword = NULL,
+ .passwordLength = 0
};
/*-----------------------------------------------------------*/
static void prvExample_OnDisconnect( void * pvCallbackContext,
- IotMqttCallbackParam_t * pxCallbackParams )
+ IotMqttCallbackParam_t * pxCallbackParams )
{
-TaskHandle_t xDemoTaskHandle = ( TaskHandle_t ) pvCallbackContext;
+ TaskHandle_t xDemoTaskHandle = ( TaskHandle_t ) pvCallbackContext;
- /* Ensure that we initiated the disconnect. */
- configASSERT( pxCallbackParams->u.disconnectReason == IOT_MQTT_DISCONNECT_CALLED );
+ /* Ensure that we initiated the disconnect. */
+ configASSERT( pxCallbackParams->u.disconnectReason == IOT_MQTT_DISCONNECT_CALLED );
- /* Inform the demo task about the disconnect. */
- xTaskNotify( xDemoTaskHandle,
- jobsexampleDISCONNECTED_BIT,
- eSetBits /* Set the jobsexampleDISCONNECTED_BIT in the demo task's notification value. */
- );
+ /* Inform the demo task about the disconnect. */
+ xTaskNotify( xDemoTaskHandle,
+ jobsexampleDISCONNECTED_BIT,
+ eSetBits /* Set the jobsexampleDISCONNECTED_BIT in the demo task's notification value. */
+ );
}
/*-----------------------------------------------------------*/
void vStartJobsDemo( void )
{
-TickType_t xShortDelay = ( TickType_t ) pdMS_TO_TICKS( ( TickType_t ) 500 );
-
- /* Wait a short time to allow receipt of the ARP replies. */
- vTaskDelay( xShortDelay );
-
- /* This example uses a single application task, which in turn is used to
- * connect, subscribe, publish, unsubscribe and disconnect from the MQTT
- * broker. */
- xTaskCreate( prvJobsDemoTask, /* Function that implements the task. */
- "JobsDemo", /* Text name for the task - only used for debugging. */
- democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
- NULL, /* Task parameter - not used in this case. */
- tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */
- NULL ); /* Used to pass out a handle to the created task - not used in this case. */
+ TickType_t xShortDelay = ( TickType_t ) pdMS_TO_TICKS( ( TickType_t ) 500 );
+
+ /* Wait a short time to allow receipt of the ARP replies. */
+ vTaskDelay( xShortDelay );
+
+ /* This example uses a single application task, which in turn is used to
+ * connect, subscribe, publish, unsubscribe and disconnect from the MQTT
+ * broker. */
+ xTaskCreate( prvJobsDemoTask, /* Function that implements the task. */
+ "JobsDemo", /* Text name for the task - only used for debugging. */
+ democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
+ NULL, /* Task parameter - not used in this case. */
+ tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */
+ NULL ); /* Used to pass out a handle to the created task - not used in this case. */
}
/*-----------------------------------------------------------*/
static void prvJobsDemoTask( void * pvParameters )
{
-IotMqttError_t xResult;
-IotNetworkError_t xNetworkInit;
-uint32_t ulNotificationValue = 0;
-const TickType_t xNoDelay = ( TickType_t ) 0;
-AwsIotJobsError_t xStatus = AWS_IOT_JOBS_SUCCESS;
-AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
-AwsIotJobsRequestInfo_t xRequestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER;
-
- /* Remove compiler warnings about unused parameters. */
- ( void ) pvParameters;
-
- xMainTaskHandle = xTaskGetCurrentTaskHandle();
-
- /* Initialize the network stack abstraction for FreeRTOS. */
- xNetworkInit = IotNetworkFreeRTOS_Init();
- configASSERT( xNetworkInit == IOT_NETWORK_SUCCESS );
-
- /* MQTT library must be initialized before it can be used. This is just one
- * time initialization. */
- xResult = IotMqtt_Init();
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- /* Initialize Jobs library. */
- xResult = AwsIotJobs_Init( jobsexampleUSE_DEFAULT_MQTT_TIMEOUT );
- configASSERT( xResult == AWS_IOT_JOBS_SUCCESS );
-
- /****************************** Connect. ******************************/
-
- /* Establish a connection to the AWS IoT MQTT broker. This example connects to
- * the MQTT broker as specified in awsiotdemoprofileAWS_ENDPOINT and
- * awsiotdemoprofileAWS_MQTT_PORT at the top of this file.
- */
- configPRINTF( ( "Attempt to connect to %s\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
- prvMQTTConnect();
- configPRINTF( ( "Connected to %s\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
-
- /* Don't expect any notifications to be pending yet. */
- configASSERT( ulTaskNotifyTake( pdTRUE, xNoDelay ) == 0 );
-
- configPRINTF( ( "Setting callback for jobs/notify-next\r\n" ) );
- prvSetNotifyNextCallback();
-
- /* Call DescribeAsync to see if there are any pending jobs. */
- xRequestInfo.mqttConnection = xMQTTConnection;
- xRequestInfo.pThingName = awsiotdemoprofileCLIENT_IDENTIFIER;
- xRequestInfo.thingNameLength = jobsexampleCLIENT_IDENTIFIER_LENGTH;
- xRequestInfo.pJobId = AWS_IOT_JOBS_NEXT_JOB;
- xRequestInfo.jobIdLength = AWS_IOT_JOBS_NEXT_JOB_LENGTH;
-
- /* Use the same callback as notify-next so any pending jobs will be
- * executed the same way. */
- xCallbackInfo.function = prvJobsCallback;
-
- xStatus = AwsIotJobs_DescribeAsync( &xRequestInfo, AWS_IOT_JOBS_NO_EXECUTION_NUMBER, true, 0, &xCallbackInfo, NULL );
- configPRINTF( ( "Describe queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) );
-
- /* Print out a short user guide to the console. The default logging
- * limit of 255 characters can be changed in demo_logging.c, but breaking
- * up the only instance of a 1000+ character string is more practical. */
- configPRINTF( (
- "\r\n"
- "/*-----------------------------------------------------------*/\r\n"
- "\r\n"
- "The Jobs demo is now ready to accept Jobs.\r\n"
- "Jobs may be created using the AWS IoT console or AWS CLI.\r\n"
- "See the following link for more information.\r\n"
- "\r\n" ) );
- configPRINTF( (
- "\r"
- "https://docs.aws.amazon.com/cli/latest/reference/iot/create-job.html\r\n"
- "\r\n"
- "This demo expects Job documents to have an \"action\" JSON key.\r\n"
- "The following actions are currently supported:\r\n" ) );
- configPRINTF( (
- "\r"
- " - print \r\n"
- " Logs a message to the local console. The Job document must also contain a \"message\".\r\n"
- " For example: { \"action\": \"print\", \"message\": \"Hello world!\"} will cause\r\n"
- " \"Hello world!\" to be printed on the console.\r\n" ) );
- configPRINTF( (
- "\r"
- " - publish \r\n"
- " Publishes a message to an MQTT topic. The Job document must also contain a \"message\" and \"topic\".\r\n" ) );
- configPRINTF( (
- "\r"
- " For example: { \"action\": \"publish\", \"topic\": \"demo/jobs\", \"message\": \"Hello world!\"} will cause\r\n"
- " \"Hello world!\" to be published to the topic \"demo/jobs\".\r\n" ) );
- configPRINTF( (
- "\r"
- " - exit \r\n"
- " Exits the demo program. This program will run until { \"action\": \"exit\" } is received.\r\n"
- "\r\n"
- "/*-----------------------------------------------------------*/\r\n" ) );
-
- /* Wait for an exit job to be received. If an exit job is not received within
- * jobsexampleMS_BEFORE_EXIT, exit anyway. This is because we have disabled
- * keep-alive, and the server will disconnect as after some time. */
- xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
- jobsexampleEXIT_BIT, /* Clear bit on exit. */
- &( ulNotificationValue ), /* Obtain the notification value. */
- pdMS_TO_TICKS( jobsexampleMS_BEFORE_EXIT ) );
-
- /* Check was due to receiving an exit job. */
- if( ( ulNotificationValue & jobsexampleEXIT_BIT ) != jobsexampleEXIT_BIT )
- {
- configPRINTF( ( "Disconnecting as %u milliseconds have elapsed.\r\n", jobsexampleMS_BEFORE_EXIT ) );
- }
-
- /* Disconnect MQTT gracefully. */
- prvMQTTDisconnect();
- configPRINTF( ( "Disconnected from %s\r\n\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
-
- /* Wait for the disconnect operation to complete which is informed to us
- * by the disconnect callback (prvExample_OnDisconnect)by setting
- * the jobsexampleDISCONNECTED_BIT in this task's notification value. */
- xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
- jobsexampleDISCONNECTED_BIT, /* Clear bit on exit. */
- &( ulNotificationValue ), /* Obtain the notification value. */
- pdMS_TO_TICKS( jobsexampleMQTT_TIMEOUT_MS ) );
- configASSERT( ( ulNotificationValue & jobsexampleDISCONNECTED_BIT ) == jobsexampleDISCONNECTED_BIT );
-
- configPRINTF( ( "prvJobsDemoTask() completed successfully. Total free heap is %u\r\n", xPortGetFreeHeapSize() ) );
- configPRINTF( ( "Demo completed successfully.\r\n" ) );
-
- /* Clean up initialized libraries. */
- AwsIotJobs_Cleanup();
- IotMqtt_Cleanup();
- IotNetworkFreeRTOS_Cleanup();
-
- /* FreeRTOS Tasks must _vTaskDelete( NULL )_ before exiting the function. */
- vTaskDelete( NULL );
+ IotMqttError_t xResult;
+ IotNetworkError_t xNetworkInit;
+ uint32_t ulNotificationValue = 0;
+ const TickType_t xNoDelay = ( TickType_t ) 0;
+ AwsIotJobsError_t xStatus = AWS_IOT_JOBS_SUCCESS;
+ AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
+ AwsIotJobsRequestInfo_t xRequestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER;
+
+ /* Remove compiler warnings about unused parameters. */
+ ( void ) pvParameters;
+
+ xMainTaskHandle = xTaskGetCurrentTaskHandle();
+
+ /* Initialize the network stack abstraction for FreeRTOS. */
+ xNetworkInit = IotNetworkFreeRTOS_Init();
+ configASSERT( xNetworkInit == IOT_NETWORK_SUCCESS );
+
+ /* MQTT library must be initialized before it can be used. This is just one
+ * time initialization. */
+ xResult = IotMqtt_Init();
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ /* Initialize Jobs library. */
+ xResult = AwsIotJobs_Init( jobsexampleUSE_DEFAULT_MQTT_TIMEOUT );
+ configASSERT( xResult == AWS_IOT_JOBS_SUCCESS );
+
+ /****************************** Connect. ******************************/
+
+ /* Establish a connection to the AWS IoT MQTT broker. This example connects to
+ * the MQTT broker as specified in awsiotdemoprofileAWS_ENDPOINT and
+ * awsiotdemoprofileAWS_MQTT_PORT at the top of this file.
+ */
+ configPRINTF( ( "Attempt to connect to %s\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
+ prvMQTTConnect();
+ configPRINTF( ( "Connected to %s\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
+
+ /* Don't expect any notifications to be pending yet. */
+ configASSERT( ulTaskNotifyTake( pdTRUE, xNoDelay ) == 0 );
+
+ configPRINTF( ( "Setting callback for jobs/notify-next\r\n" ) );
+ prvSetNotifyNextCallback();
+
+ /* Call DescribeAsync to see if there are any pending jobs. */
+ xRequestInfo.mqttConnection = xMQTTConnection;
+ xRequestInfo.pThingName = awsiotdemoprofileCLIENT_IDENTIFIER;
+ xRequestInfo.thingNameLength = jobsexampleCLIENT_IDENTIFIER_LENGTH;
+ xRequestInfo.pJobId = AWS_IOT_JOBS_NEXT_JOB;
+ xRequestInfo.jobIdLength = AWS_IOT_JOBS_NEXT_JOB_LENGTH;
+
+ /* Use the same callback as notify-next so any pending jobs will be
+ * executed the same way. */
+ xCallbackInfo.function = prvJobsCallback;
+
+ xStatus = AwsIotJobs_DescribeAsync( &xRequestInfo, AWS_IOT_JOBS_NO_EXECUTION_NUMBER, true, 0, &xCallbackInfo, NULL );
+ configPRINTF( ( "Describe queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) );
+
+ /* Print out a short user guide to the console. The default logging
+ * limit of 255 characters can be changed in demo_logging.c, but breaking
+ * up the only instance of a 1000+ character string is more practical. */
+ configPRINTF( (
+ "\r\n"
+ "/*-----------------------------------------------------------*/\r\n"
+ "\r\n"
+ "The Jobs demo is now ready to accept Jobs.\r\n"
+ "Jobs may be created using the AWS IoT console or AWS CLI.\r\n"
+ "See the following link for more information.\r\n"
+ "\r\n" ) );
+ configPRINTF( (
+ "\r"
+ "https://docs.aws.amazon.com/cli/latest/reference/iot/create-job.html\r\n"
+ "\r\n"
+ "This demo expects Job documents to have an \"action\" JSON key.\r\n"
+ "The following actions are currently supported:\r\n" ) );
+ configPRINTF( (
+ "\r"
+ " - print \r\n"
+ " Logs a message to the local console. The Job document must also contain a \"message\".\r\n"
+ " For example: { \"action\": \"print\", \"message\": \"Hello world!\"} will cause\r\n"
+ " \"Hello world!\" to be printed on the console.\r\n" ) );
+ configPRINTF( (
+ "\r"
+ " - publish \r\n"
+ " Publishes a message to an MQTT topic. The Job document must also contain a \"message\" and \"topic\".\r\n" ) );
+ configPRINTF( (
+ "\r"
+ " For example: { \"action\": \"publish\", \"topic\": \"demo/jobs\", \"message\": \"Hello world!\"} will cause\r\n"
+ " \"Hello world!\" to be published to the topic \"demo/jobs\".\r\n" ) );
+ configPRINTF( (
+ "\r"
+ " - exit \r\n"
+ " Exits the demo program. This program will run until { \"action\": \"exit\" } is received.\r\n"
+ "\r\n"
+ "/*-----------------------------------------------------------*/\r\n" ) );
+
+ /* Wait for an exit job to be received. If an exit job is not received within
+ * jobsexampleMS_BEFORE_EXIT, exit anyway. This is because we have disabled
+ * keep-alive, and the server will disconnect as after some time. */
+ xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
+ jobsexampleEXIT_BIT, /* Clear bit on exit. */
+ &( ulNotificationValue ), /* Obtain the notification value. */
+ pdMS_TO_TICKS( jobsexampleMS_BEFORE_EXIT ) );
+
+ /* Check was due to receiving an exit job. */
+ if( ( ulNotificationValue & jobsexampleEXIT_BIT ) != jobsexampleEXIT_BIT )
+ {
+ configPRINTF( ( "Disconnecting as %u milliseconds have elapsed.\r\n", jobsexampleMS_BEFORE_EXIT ) );
+ }
+
+ /* Disconnect MQTT gracefully. */
+ prvMQTTDisconnect();
+ configPRINTF( ( "Disconnected from %s\r\n\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
+
+ /* Wait for the disconnect operation to complete which is informed to us
+ * by the disconnect callback (prvExample_OnDisconnect)by setting
+ * the jobsexampleDISCONNECTED_BIT in this task's notification value. */
+ xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
+ jobsexampleDISCONNECTED_BIT, /* Clear bit on exit. */
+ &( ulNotificationValue ), /* Obtain the notification value. */
+ pdMS_TO_TICKS( jobsexampleMQTT_TIMEOUT_MS ) );
+ configASSERT( ( ulNotificationValue & jobsexampleDISCONNECTED_BIT ) == jobsexampleDISCONNECTED_BIT );
+
+ configPRINTF( ( "prvJobsDemoTask() completed successfully. Total free heap is %u\r\n", xPortGetFreeHeapSize() ) );
+ configPRINTF( ( "Demo completed successfully.\r\n" ) );
+
+ /* Clean up initialized libraries. */
+ AwsIotJobs_Cleanup();
+ IotMqtt_Cleanup();
+ IotNetworkFreeRTOS_Cleanup();
+
+ /* FreeRTOS Tasks must _vTaskDelete( NULL )_ before exiting the function. */
+ vTaskDelete( NULL );
}
/*-----------------------------------------------------------*/
static void prvMQTTConnect( void )
{
-IotMqttError_t xResult;
-
- /* Set the context to pass into the disconnect callback function. */
- xNetworkInfo.disconnectCallback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();
-
- /* Establish the connection to the MQTT broker - It is a blocking call and
- * will return only when connection is complete or a timeout occurs. */
- xResult = IotMqtt_Connect( &( xNetworkInfo ),
- &( xConnectInfo ),
- jobsexampleMQTT_TIMEOUT_MS,
- &( xMQTTConnection ) );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
+ IotMqttError_t xResult;
+
+ /* Set the context to pass into the disconnect callback function. */
+ xNetworkInfo.disconnectCallback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();
+
+ /* Establish the connection to the MQTT broker - It is a blocking call and
+ * will return only when connection is complete or a timeout occurs. */
+ xResult = IotMqtt_Connect( &( xNetworkInfo ),
+ &( xConnectInfo ),
+ jobsexampleMQTT_TIMEOUT_MS,
+ &( xMQTTConnection ) );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvMQTTDisconnect( void )
{
- /* Send a MQTT DISCONNECT packet to the MQTT broker to do a graceful
- * disconnect. */
- IotMqtt_Disconnect( xMQTTConnection,
- 0 /* flags - 0 means a graceful disconnect by sending MQTT DISCONNECT. */
- );
+ /* Send a MQTT DISCONNECT packet to the MQTT broker to do a graceful
+ * disconnect. */
+ IotMqtt_Disconnect( xMQTTConnection,
+ 0 /* flags - 0 means a graceful disconnect by sending MQTT DISCONNECT. */
+ );
}
/*-----------------------------------------------------------*/
static void prvSetNotifyNextCallback( void )
{
-AwsIotJobsError_t xCallbackStatus = AWS_IOT_JOBS_SUCCESS;
-AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
+ AwsIotJobsError_t xCallbackStatus = AWS_IOT_JOBS_SUCCESS;
+ AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
- /* Set the jobs callback function. */
- xCallbackInfo.function = prvJobsCallback;
+ /* Set the jobs callback function. */
+ xCallbackInfo.function = prvJobsCallback;
- /************************ Set notify-next callbacks **********************/
+ /************************ Set notify-next callbacks **********************/
- xCallbackStatus = AwsIotJobs_SetNotifyNextCallback( xMQTTConnection,
- awsiotdemoprofileCLIENT_IDENTIFIER,
- jobsexampleCLIENT_IDENTIFIER_LENGTH,
- 0,
- &xCallbackInfo );
+ xCallbackStatus = AwsIotJobs_SetNotifyNextCallback( xMQTTConnection,
+ awsiotdemoprofileCLIENT_IDENTIFIER,
+ jobsexampleCLIENT_IDENTIFIER_LENGTH,
+ 0,
+ &xCallbackInfo );
- configASSERT( xCallbackStatus == AWS_IOT_JOBS_SUCCESS );
+ configASSERT( xCallbackStatus == AWS_IOT_JOBS_SUCCESS );
}
/*-----------------------------------------------------------*/
static _jobAction_t prvGetAction( const char * pcAction,
- size_t xActionLength )
+ size_t xActionLength )
{
-_jobAction_t xAction = JOB_ACTION_UNKNOWN;
-
- configASSERT( pcAction != NULL );
-
- if( strncmp( pcAction, "print", xActionLength ) == 0 )
- {
- xAction = JOB_ACTION_PRINT;
- }
- else if( strncmp( pcAction, "publish", xActionLength ) == 0 )
- {
- xAction = JOB_ACTION_PUBLISH;
- }
- else if( strncmp( pcAction, "exit", xActionLength ) == 0 )
- {
- xAction = JOB_ACTION_EXIT;
- }
-
- return xAction;
+ _jobAction_t xAction = JOB_ACTION_UNKNOWN;
+
+ configASSERT( pcAction != NULL );
+
+ if( strncmp( pcAction, "print", xActionLength ) == 0 )
+ {
+ xAction = JOB_ACTION_PRINT;
+ }
+ else if( strncmp( pcAction, "publish", xActionLength ) == 0 )
+ {
+ xAction = JOB_ACTION_PUBLISH;
+ }
+ else if( strncmp( pcAction, "exit", xActionLength ) == 0 )
+ {
+ xAction = JOB_ACTION_EXIT;
+ }
+
+ return xAction;
}
/*-----------------------------------------------------------*/
static BaseType_t prvGetJsonString( const char * pcJsonDoc,
- size_t xJsonDocLength,
- const char * pcKey,
- size_t xKeyLength,
- const char ** ppcValue,
- size_t * pxValueLength )
+ size_t xJsonDocLength,
+ const char * pcKey,
+ size_t xKeyLength,
+ const char ** ppcValue,
+ size_t * pxValueLength )
{
-BaseType_t xKeyFound = pdFALSE;
-
- configASSERT( pcJsonDoc != NULL );
- configASSERT( pcKey != NULL );
-
- /*
- * Note: This parser used is specific for parsing AWS IoT document received
- * through a mutually authenticated connection. This parser will not check
- * for the correctness of the document as it is designed for low memory
- * footprint rather than checking for correctness of the document. This
- * parser is not meant to be used as a general purpose JSON parser.
- */
- xKeyFound = ( BaseType_t ) AwsIotDocParser_FindValue(
- pcJsonDoc,
- xJsonDocLength,
- pcKey,
- xKeyLength,
- ppcValue,
- pxValueLength );
-
- if( xKeyFound == pdTRUE )
- {
- /* Exclude empty strings. */
- if( *pxValueLength < jobsexampleJSON_STRING_MIN_LENGTH )
- {
- xKeyFound = pdFALSE;
- }
- else
- {
- /* Adjust the value to remove the quotes. */
- ( *ppcValue )++;
- ( *pxValueLength ) -= 2;
- }
- }
-
- return xKeyFound;
+ BaseType_t xKeyFound = pdFALSE;
+
+ configASSERT( pcJsonDoc != NULL );
+ configASSERT( pcKey != NULL );
+
+ /*
+ * Note: This parser used is specific for parsing AWS IoT document received
+ * through a mutually authenticated connection. This parser will not check
+ * for the correctness of the document as it is designed for low memory
+ * footprint rather than checking for correctness of the document. This
+ * parser is not meant to be used as a general purpose JSON parser.
+ */
+ xKeyFound = ( BaseType_t ) AwsIotDocParser_FindValue(
+ pcJsonDoc,
+ xJsonDocLength,
+ pcKey,
+ xKeyLength,
+ ppcValue,
+ pxValueLength );
+
+ if( xKeyFound == pdTRUE )
+ {
+ /* Exclude empty strings. */
+ if( *pxValueLength < jobsexampleJSON_STRING_MIN_LENGTH )
+ {
+ xKeyFound = pdFALSE;
+ }
+ else
+ {
+ /* Adjust the value to remove the quotes. */
+ ( *ppcValue )++;
+ ( *pxValueLength ) -= 2;
+ }
+ }
+
+ return xKeyFound;
}
/*-----------------------------------------------------------*/
static void prvOperationCompleteCallback( void * pvCallbackContext,
- AwsIotJobsCallbackParam_t * pxCallbackParam )
+ AwsIotJobsCallbackParam_t * pxCallbackParam )
{
- configASSERT( pxCallbackParam != NULL );
-
- /* This function is invoked when either a StartNext or Update completes. */
- if( pxCallbackParam->callbackType == AWS_IOT_JOBS_START_NEXT_COMPLETE )
- {
- configPRINTF( ( "Job StartNext complete with result %s.\r\n",
- AwsIotJobs_strerror( pxCallbackParam->u.operation.result ) ) );
- }
- else
- {
- configPRINTF( ( "Job Update complete with result %s.\r\n",
- AwsIotJobs_strerror( pxCallbackParam->u.operation.result ) ) );
- }
-
- /* If a non-NULL context is given, set the flag to exit the demo. */
- if( pvCallbackContext != NULL )
- {
- xTaskNotify( xMainTaskHandle,
- jobsexampleEXIT_BIT,
- eSetBits /* Set the jobsexampleEXIT_BIT in the demo task's notification value. */
- );
- }
+ configASSERT( pxCallbackParam != NULL );
+
+ /* This function is invoked when either a StartNext or Update completes. */
+ if( pxCallbackParam->callbackType == AWS_IOT_JOBS_START_NEXT_COMPLETE )
+ {
+ configPRINTF( ( "Job StartNext complete with result %s.\r\n",
+ AwsIotJobs_strerror( pxCallbackParam->u.operation.result ) ) );
+ }
+ else
+ {
+ configPRINTF( ( "Job Update complete with result %s.\r\n",
+ AwsIotJobs_strerror( pxCallbackParam->u.operation.result ) ) );
+ }
+
+ /* If a non-NULL context is given, set the flag to exit the demo. */
+ if( pvCallbackContext != NULL )
+ {
+ xTaskNotify( xMainTaskHandle,
+ jobsexampleEXIT_BIT,
+ eSetBits /* Set the jobsexampleEXIT_BIT in the demo task's notification value. */
+ );
+ }
}
/*-----------------------------------------------------------*/
static AwsIotJobState_t prvProcessMessage( IotMqttConnection_t xMqttConnection,
- _jobAction_t xAction,
- const char * pcJobDoc,
- size_t xJobDocLength )
+ _jobAction_t xAction,
+ const char * pcJobDoc,
+ size_t xJobDocLength )
{
-AwsIotJobState_t xStatus = AWS_IOT_JOB_STATE_SUCCEEDED;
-IotMqttError_t xMqttStatus = IOT_MQTT_STATUS_PENDING;
-IotMqttPublishInfo_t xPublishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER;
-const char * pcMessage = NULL, * pcTopic = NULL;
-size_t xMessageLength = 0, xTopicLength = 0;
-
- configASSERT( pcJobDoc != NULL );
-
- /* Both "print" and "publish" require a "message" key. Search the Job
- * document for this key. */
- if( prvGetJsonString( pcJobDoc,
- xJobDocLength,
- jobsexampleMESSAGE_KEY,
- jobsexampleMESSAGE_KEY_LENGTH,
- &pcMessage,
- &xMessageLength ) == pdFALSE )
- {
- configPRINTF( ( "Job document for \"print\" or \"publish\" does not contain a %s key.\r\n",
- jobsexampleMESSAGE_KEY ) );
-
- xStatus = AWS_IOT_JOB_STATE_FAILED;
- }
-
- if( xStatus == AWS_IOT_JOB_STATE_SUCCEEDED )
- {
- if( xAction == JOB_ACTION_PRINT )
- {
- /* Print the given message if the action is "print". */
- configPRINTF( (
- "\r\n"
- "/*-----------------------------------------------------------*/\r\n"
- "\r\n"
- "%.*s\r\n"
- "\r\n"
- "/*-----------------------------------------------------------*/\r\n"
- "\r\n", xMessageLength, pcMessage ) );
- }
- else
- {
- /* Extract the topic if the action is "publish". */
- if( prvGetJsonString( pcJobDoc,
- xJobDocLength,
- jobsexampleTOPIC_KEY,
- jobsexampleTOPIC_KEY_LENGTH,
- &pcTopic,
- &xTopicLength ) == pdFALSE )
- {
- configPRINTF( ( "Job document for action \"publish\" does not contain a %s key.\r\n",
- jobsexampleTOPIC_KEY ) );
-
- xStatus = AWS_IOT_JOB_STATE_FAILED;
- }
-
- if( xStatus == AWS_IOT_JOB_STATE_SUCCEEDED )
- {
- xPublishInfo.qos = IOT_MQTT_QOS_0;
- xPublishInfo.pTopicName = pcTopic;
- xPublishInfo.topicNameLength = ( uint16_t ) xTopicLength;
- xPublishInfo.pPayload = pcMessage;
- xPublishInfo.payloadLength = xMessageLength;
-
- xMqttStatus = IotMqtt_PublishAsync( xMqttConnection, &xPublishInfo, 0, NULL, NULL );
-
- if( xMqttStatus != IOT_MQTT_SUCCESS )
- {
- xStatus = AWS_IOT_JOB_STATE_FAILED;
- }
- }
- }
- }
-
- return xStatus;
+ AwsIotJobState_t xStatus = AWS_IOT_JOB_STATE_SUCCEEDED;
+ IotMqttError_t xMqttStatus = IOT_MQTT_STATUS_PENDING;
+ IotMqttPublishInfo_t xPublishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER;
+ const char * pcMessage = NULL, * pcTopic = NULL;
+ size_t xMessageLength = 0, xTopicLength = 0;
+
+ configASSERT( pcJobDoc != NULL );
+
+ /* Both "print" and "publish" require a "message" key. Search the Job
+ * document for this key. */
+ if( prvGetJsonString( pcJobDoc,
+ xJobDocLength,
+ jobsexampleMESSAGE_KEY,
+ jobsexampleMESSAGE_KEY_LENGTH,
+ &pcMessage,
+ &xMessageLength ) == pdFALSE )
+ {
+ configPRINTF( ( "Job document for \"print\" or \"publish\" does not contain a %s key.\r\n",
+ jobsexampleMESSAGE_KEY ) );
+
+ xStatus = AWS_IOT_JOB_STATE_FAILED;
+ }
+
+ if( xStatus == AWS_IOT_JOB_STATE_SUCCEEDED )
+ {
+ if( xAction == JOB_ACTION_PRINT )
+ {
+ /* Print the given message if the action is "print". */
+ configPRINTF( (
+ "\r\n"
+ "/*-----------------------------------------------------------*/\r\n"
+ "\r\n"
+ "%.*s\r\n"
+ "\r\n"
+ "/*-----------------------------------------------------------*/\r\n"
+ "\r\n", xMessageLength, pcMessage ) );
+ }
+ else
+ {
+ /* Extract the topic if the action is "publish". */
+ if( prvGetJsonString( pcJobDoc,
+ xJobDocLength,
+ jobsexampleTOPIC_KEY,
+ jobsexampleTOPIC_KEY_LENGTH,
+ &pcTopic,
+ &xTopicLength ) == pdFALSE )
+ {
+ configPRINTF( ( "Job document for action \"publish\" does not contain a %s key.\r\n",
+ jobsexampleTOPIC_KEY ) );
+
+ xStatus = AWS_IOT_JOB_STATE_FAILED;
+ }
+
+ if( xStatus == AWS_IOT_JOB_STATE_SUCCEEDED )
+ {
+ xPublishInfo.qos = IOT_MQTT_QOS_0;
+ xPublishInfo.pTopicName = pcTopic;
+ xPublishInfo.topicNameLength = ( uint16_t ) xTopicLength;
+ xPublishInfo.pPayload = pcMessage;
+ xPublishInfo.payloadLength = xMessageLength;
+
+ xMqttStatus = IotMqtt_PublishAsync( xMqttConnection, &xPublishInfo, 0, NULL, NULL );
+
+ if( xMqttStatus != IOT_MQTT_SUCCESS )
+ {
+ xStatus = AWS_IOT_JOB_STATE_FAILED;
+ }
+ }
+ }
+ }
+
+ return xStatus;
}
/*-----------------------------------------------------------*/
static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo,
- const char * pcJobId,
- size_t xJobIdLength,
- const char * pcJobDoc,
- size_t xJobDocLength )
+ const char * pcJobId,
+ size_t xJobIdLength,
+ const char * pcJobDoc,
+ size_t xJobDocLength )
{
-AwsIotJobsError_t xStatus = AWS_IOT_JOBS_SUCCESS;
-AwsIotJobsUpdateInfo_t xUpdateInfo = AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER;
-AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
-const char * pcAction = NULL;
-size_t xActionLength = 0;
-_jobAction_t xAction = JOB_ACTION_UNKNOWN;
-AwsIotJobsRequestInfo_t xRequestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER;
-
- configASSERT( pxJobInfo != NULL );
- configASSERT( pcJobId != NULL );
- configASSERT( pcJobDoc != NULL );
-
- configPRINTF( ( "Job document received: %.*s\r\n", xJobDocLength, pcJobDoc ) );
-
- xRequestInfo.mqttConnection = pxJobInfo->mqttConnection;
- xRequestInfo.pThingName = pxJobInfo->pThingName;
- xRequestInfo.thingNameLength = pxJobInfo->thingNameLength;
- xRequestInfo.pJobId = pcJobId;
- xRequestInfo.jobIdLength = xJobIdLength;
-
- /* Tell the Jobs service that the device has started working on the Job.
- * Use the StartNext API to set the Job's status to IN_PROGRESS. */
- xCallbackInfo.function = prvOperationCompleteCallback;
-
- xStatus = AwsIotJobs_StartNextAsync( &xRequestInfo, &xUpdateInfo, 0, &xCallbackInfo, NULL );
-
- configPRINTF( ( "Jobs StartNext queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) );
-
- /* Get the action for this device. */
- if( prvGetJsonString( pcJobDoc,
- xJobDocLength,
- jobsexampleACTION_KEY,
- jobsexampleACTION_KEY_LENGTH,
- &pcAction,
- &xActionLength ) == pdTRUE )
- {
- xAction = prvGetAction( pcAction, xActionLength );
-
- switch( xAction )
- {
- case JOB_ACTION_EXIT:
- xCallbackInfo.pCallbackContext = jobsexampleSHOULD_EXIT;
- xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_SUCCEEDED;
- break;
-
- case JOB_ACTION_PRINT:
- case JOB_ACTION_PUBLISH:
- xUpdateInfo.newStatus = prvProcessMessage( pxJobInfo->mqttConnection,
- xAction,
- pcJobDoc,
- xJobDocLength );
- break;
-
- default:
- configPRINTF( ( "Received Job document with unknown action %.*s.\r\n",
- xActionLength,
- pcAction ) );
-
- xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_FAILED;
- break;
- }
- }
- else
- {
- configPRINTF( ( "Received Job document does not contain an %s key.\r\n",
- jobsexampleACTION_KEY ) );
-
- /* The given Job document is not valid for this demo. */
- xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_FAILED;
- }
-
- configPRINTF( ( "Setting state of %.*s to %s.\r\n",
- xJobIdLength,
- pcJobId,
- AwsIotJobs_StateName( xUpdateInfo.newStatus ) ) );
-
- /* Tell the Jobs service that the device has finished the Job. */
- xStatus = AwsIotJobs_UpdateAsync( &xRequestInfo, &xUpdateInfo, 0, &xCallbackInfo, NULL );
-
- configPRINTF( ( "Jobs Update queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) );
+ AwsIotJobsError_t xStatus = AWS_IOT_JOBS_SUCCESS;
+ AwsIotJobsUpdateInfo_t xUpdateInfo = AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER;
+ AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
+ const char * pcAction = NULL;
+ size_t xActionLength = 0;
+ _jobAction_t xAction = JOB_ACTION_UNKNOWN;
+ AwsIotJobsRequestInfo_t xRequestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER;
+
+ configASSERT( pxJobInfo != NULL );
+ configASSERT( pcJobId != NULL );
+ configASSERT( pcJobDoc != NULL );
+
+ configPRINTF( ( "Job document received: %.*s\r\n", xJobDocLength, pcJobDoc ) );
+
+ xRequestInfo.mqttConnection = pxJobInfo->mqttConnection;
+ xRequestInfo.pThingName = pxJobInfo->pThingName;
+ xRequestInfo.thingNameLength = pxJobInfo->thingNameLength;
+ xRequestInfo.pJobId = pcJobId;
+ xRequestInfo.jobIdLength = xJobIdLength;
+
+ /* Tell the Jobs service that the device has started working on the Job.
+ * Use the StartNext API to set the Job's status to IN_PROGRESS. */
+ xCallbackInfo.function = prvOperationCompleteCallback;
+
+ xStatus = AwsIotJobs_StartNextAsync( &xRequestInfo, &xUpdateInfo, 0, &xCallbackInfo, NULL );
+
+ configPRINTF( ( "Jobs StartNext queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) );
+
+ /* Get the action for this device. */
+ if( prvGetJsonString( pcJobDoc,
+ xJobDocLength,
+ jobsexampleACTION_KEY,
+ jobsexampleACTION_KEY_LENGTH,
+ &pcAction,
+ &xActionLength ) == pdTRUE )
+ {
+ xAction = prvGetAction( pcAction, xActionLength );
+
+ switch( xAction )
+ {
+ case JOB_ACTION_EXIT:
+ xCallbackInfo.pCallbackContext = jobsexampleSHOULD_EXIT;
+ xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_SUCCEEDED;
+ break;
+
+ case JOB_ACTION_PRINT:
+ case JOB_ACTION_PUBLISH:
+ xUpdateInfo.newStatus = prvProcessMessage( pxJobInfo->mqttConnection,
+ xAction,
+ pcJobDoc,
+ xJobDocLength );
+ break;
+
+ default:
+ configPRINTF( ( "Received Job document with unknown action %.*s.\r\n",
+ xActionLength,
+ pcAction ) );
+
+ xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_FAILED;
+ break;
+ }
+ }
+ else
+ {
+ configPRINTF( ( "Received Job document does not contain an %s key.\r\n",
+ jobsexampleACTION_KEY ) );
+
+ /* The given Job document is not valid for this demo. */
+ xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_FAILED;
+ }
+
+ configPRINTF( ( "Setting state of %.*s to %s.\r\n",
+ xJobIdLength,
+ pcJobId,
+ AwsIotJobs_StateName( xUpdateInfo.newStatus ) ) );
+
+ /* Tell the Jobs service that the device has finished the Job. */
+ xStatus = AwsIotJobs_UpdateAsync( &xRequestInfo, &xUpdateInfo, 0, &xCallbackInfo, NULL );
+
+ configPRINTF( ( "Jobs Update queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) );
}
/*-----------------------------------------------------------*/
static void prvJobsCallback( void * pCallbackContext,
- AwsIotJobsCallbackParam_t * pxCallbackInfo )
+ AwsIotJobsCallbackParam_t * pxCallbackInfo )
{
-BaseType_t xIdKeyFound = pdFALSE, xDocKeyFound = pdFALSE;
-const char * pcJobId = NULL;
-size_t xJobIdLength = 0;
-const char * pcJobDoc = NULL;
-size_t xJobDocLength = 0;
-const char * pcRawDocument = NULL;
-size_t xRawDocumentLength = 0;
-
- /* Silence warnings about unused parameters. */
- ( void ) pCallbackContext;
-
- configASSERT( pxCallbackInfo != NULL );
-
- /* Check if this callback was called from a describe operation or
- * due to notify-next. */
- if( pxCallbackInfo->callbackType == AWS_IOT_JOBS_DESCRIBE_COMPLETE )
- {
- pcRawDocument = pxCallbackInfo->u.operation.pResponse;
- xRawDocumentLength = pxCallbackInfo->u.operation.responseLength;
- }
- else
- {
- pcRawDocument = pxCallbackInfo->u.callback.pDocument;
- xRawDocumentLength = pxCallbackInfo->u.callback.documentLength;
- }
-
- /* Get the Job ID. */
- xIdKeyFound = prvGetJsonString( pcRawDocument,
- xRawDocumentLength,
- jobsexampleID_KEY,
- jobsexampleID_KEY_LENGTH,
- &pcJobId,
- &xJobIdLength );
-
- if( xIdKeyFound == pdTRUE )
- {
- if( xJobIdLength > jobsexampleID_MAX_LENGTH )
- {
- configPRINTF( ( "Received Job ID %.*s longer than %lu, which is the "
- "maximum allowed by AWS IoT. Ignoring Job.\r\n",
- xJobIdLength,
- pcJobId,
- ( unsigned long ) jobsexampleID_MAX_LENGTH ) );
-
- xIdKeyFound = pdFALSE;
- }
- else
- {
- configPRINTF( ( "Job %.*s received.\r\n", xJobIdLength, pcJobId ) );
- }
- }
-
- /* Get the Job document.
- *
- * Note: This parser used is specific for parsing AWS IoT document received
- * through a mutually authenticated connection. This parser will not check
- * for the correctness of the document as it is designed for low memory
- * footprint rather than checking for correctness of the document. This
- * parser is not meant to be used as a general purpose JSON parser.
- */
- xDocKeyFound = ( BaseType_t ) AwsIotDocParser_FindValue(
- pcRawDocument,
- xRawDocumentLength,
- jobsexampleDOC_KEY,
- jobsexampleDOC_KEY_LENGTH,
- &pcJobDoc,
- &xJobDocLength );
-
- /* When both the Job ID and Job document are available, process the Job. */
- if( ( xIdKeyFound == pdTRUE ) && ( xDocKeyFound == pdTRUE ) )
- {
- /* Process the Job document. */
- prvProcessJob( pxCallbackInfo,
- pcJobId,
- xJobIdLength,
- pcJobDoc,
- xJobDocLength );
- }
- else
- {
- /* The Jobs service sends an empty Job document when all Jobs are complete. */
- if( ( xIdKeyFound == pdFALSE ) && ( xDocKeyFound == pdFALSE ) )
- {
- configPRINTF( (
- "\r\n"
- "/*-----------------------------------------------------------*/\r\n"
- "\r\n"
- "All available Jobs complete.\r\n"
- "\r\n"
- "/*-----------------------------------------------------------*/\r\n"
- "\r\n" ) );
- }
- else
- {
- configPRINTF( ( "Received an invalid Job document: %.*s\r\n",
- xRawDocumentLength,
- pcRawDocument ) );
- }
- }
+ BaseType_t xIdKeyFound = pdFALSE, xDocKeyFound = pdFALSE;
+ const char * pcJobId = NULL;
+ size_t xJobIdLength = 0;
+ const char * pcJobDoc = NULL;
+ size_t xJobDocLength = 0;
+ const char * pcRawDocument = NULL;
+ size_t xRawDocumentLength = 0;
+
+ /* Silence warnings about unused parameters. */
+ ( void ) pCallbackContext;
+
+ configASSERT( pxCallbackInfo != NULL );
+
+ /* Check if this callback was called from a describe operation or
+ * due to notify-next. */
+ if( pxCallbackInfo->callbackType == AWS_IOT_JOBS_DESCRIBE_COMPLETE )
+ {
+ pcRawDocument = pxCallbackInfo->u.operation.pResponse;
+ xRawDocumentLength = pxCallbackInfo->u.operation.responseLength;
+ }
+ else
+ {
+ pcRawDocument = pxCallbackInfo->u.callback.pDocument;
+ xRawDocumentLength = pxCallbackInfo->u.callback.documentLength;
+ }
+
+ /* Get the Job ID. */
+ xIdKeyFound = prvGetJsonString( pcRawDocument,
+ xRawDocumentLength,
+ jobsexampleID_KEY,
+ jobsexampleID_KEY_LENGTH,
+ &pcJobId,
+ &xJobIdLength );
+
+ if( xIdKeyFound == pdTRUE )
+ {
+ if( xJobIdLength > jobsexampleID_MAX_LENGTH )
+ {
+ configPRINTF( ( "Received Job ID %.*s longer than %lu, which is the "
+ "maximum allowed by AWS IoT. Ignoring Job.\r\n",
+ xJobIdLength,
+ pcJobId,
+ ( unsigned long ) jobsexampleID_MAX_LENGTH ) );
+
+ xIdKeyFound = pdFALSE;
+ }
+ else
+ {
+ configPRINTF( ( "Job %.*s received.\r\n", xJobIdLength, pcJobId ) );
+ }
+ }
+
+ /* Get the Job document.
+ *
+ * Note: This parser used is specific for parsing AWS IoT document received
+ * through a mutually authenticated connection. This parser will not check
+ * for the correctness of the document as it is designed for low memory
+ * footprint rather than checking for correctness of the document. This
+ * parser is not meant to be used as a general purpose JSON parser.
+ */
+ xDocKeyFound = ( BaseType_t ) AwsIotDocParser_FindValue(
+ pcRawDocument,
+ xRawDocumentLength,
+ jobsexampleDOC_KEY,
+ jobsexampleDOC_KEY_LENGTH,
+ &pcJobDoc,
+ &xJobDocLength );
+
+ /* When both the Job ID and Job document are available, process the Job. */
+ if( ( xIdKeyFound == pdTRUE ) && ( xDocKeyFound == pdTRUE ) )
+ {
+ /* Process the Job document. */
+ prvProcessJob( pxCallbackInfo,
+ pcJobId,
+ xJobIdLength,
+ pcJobDoc,
+ xJobDocLength );
+ }
+ else
+ {
+ /* The Jobs service sends an empty Job document when all Jobs are complete. */
+ if( ( xIdKeyFound == pdFALSE ) && ( xDocKeyFound == pdFALSE ) )
+ {
+ configPRINTF( (
+ "\r\n"
+ "/*-----------------------------------------------------------*/\r\n"
+ "\r\n"
+ "All available Jobs complete.\r\n"
+ "\r\n"
+ "/*-----------------------------------------------------------*/\r\n"
+ "\r\n" ) );
+ }
+ else
+ {
+ configPRINTF( ( "Received an invalid Job document: %.*s\r\n",
+ xRawDocumentLength,
+ pcRawDocument ) );
+ }
+ }
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSConfig.h
index 642113c41..ebee2a143 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSConfig.h
@@ -29,94 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile, uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -124,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demos of IoT Libraries. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-
-#if( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSIPConfig.h
index 39a61856b..0375594c1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/FreeRTOSIPConfig.h
@@ -27,284 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ( (x) != NULL )
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h
index d9b063bf8..ee2402255 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h
@@ -47,68 +47,68 @@
*/
#ifndef ATOMIC_H
-#define ATOMIC_H
+ #define ATOMIC_H
-#ifndef INC_FREERTOS_H
- #error "include FreeRTOS.h must appear in source files before include atomic.h"
-#endif
+ #ifndef INC_FREERTOS_H
+ #error "include FreeRTOS.h must appear in source files before include atomic.h"
+ #endif
/* Standard includes. */
-#include <stdint.h>
+ #include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- /* Needed for __atomic_compare_exchange() weak=false. */
- #include <stdbool.h>
+/* Needed for __atomic_compare_exchange() weak=false. */
+ #include <stdbool.h>
- /* This branch is for GCC compiler and GCC compiler only. */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE inline __attribute__((always_inline))
- #endif
+/* This branch is for GCC compiler and GCC compiler only. */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE inline __attribute__( ( always_inline ) )
+ #endif
-#else
+ #else
- /* Port specific definitions -- entering/exiting critical section.
- * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
- *
- * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
- * ATOMIC_ENTER_CRITICAL().
- */
- #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
+/* Port specific definitions -- entering/exiting critical section.
+ * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
+ *
+ * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
+ * ATOMIC_ENTER_CRITICAL().
+ */
+ #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
- /* Nested interrupt scheme is supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() \
- UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
+/* Nested interrupt scheme is supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() \
+ UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
- #define ATOMIC_EXIT_CRITICAL() \
- portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
+ #define ATOMIC_EXIT_CRITICAL() \
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
- #else
+ #else
- /* Nested interrupt scheme is NOT supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
- #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
+/* Nested interrupt scheme is NOT supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
+ #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
- #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
+ #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
- /* Port specific definition -- "always inline".
- * Inline is compiler specific, and may not always get inlined depending on your optimization level.
- * For atomic operations, inline is considered a performance optimization.
- * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
- * simply define it.
- */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE
- #endif
+/* Port specific definition -- "always inline".
+ * Inline is compiler specific, and may not always get inlined depending on your optimization level.
+ * For atomic operations, inline is considered a performance optimization.
+ * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
+ * simply define it.
+ */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE
+ #endif
-#endif /* configUSE_GCC_BUILTIN_ATOMICS */
+ #endif /* configUSE_GCC_BUILTIN_ATOMICS */
-#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
-#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
+ #define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
+ #define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
/*----------------------------- Swap && CAS ------------------------------*/
@@ -127,44 +127,36 @@ extern "C" {
* @note This function only swaps *pDestination with ulExchange, if previous
* *pDestination value equals ulComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
- uint32_t volatile * pDestination,
- uint32_t ulExchange,
- uint32_t ulComparand )
-{
-
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- if ( __atomic_compare_exchange( pDestination,
- &ulComparand,
- &ulExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pDestination,
+ uint32_t ulExchange,
+ uint32_t ulComparand )
{
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( pDestination,
+ &ulComparand,
+ &ulExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *pDestination == ulComparand )
+ {
+ *pDestination = ulExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *pDestination == ulComparand )
- {
- *pDestination = ulExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-
-}
-
/**
* Atomic swap (pointers)
*
@@ -177,30 +169,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
*
* @return The initial value of *ppDestination.
*/
-static portFORCE_INLINE void * Atomic_SwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange )
-{
- void * pReturnValue;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange )
+ {
+ void * pReturnValue;
- pReturnValue = *ppDestination;
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
+ #else
+ ATOMIC_ENTER_CRITICAL();
- *ppDestination = pExchange;
+ pReturnValue = *ppDestination;
- ATOMIC_EXIT_CRITICAL();
+ *ppDestination = pExchange;
-#endif
+ ATOMIC_EXIT_CRITICAL();
+ #endif
- return pReturnValue;
-}
+ return pReturnValue;
+ }
/**
* Atomic compare-and-swap (pointers)
@@ -218,40 +205,36 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32(
* @note This function only swaps *ppDestination with pExchange, if previous
* *ppDestination value equals pComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange, void * pComparand )
-{
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- if ( __atomic_compare_exchange( ppDestination,
- &pComparand,
- &pExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
- {
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *ppDestination == pComparand )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange,
+ void * pComparand )
{
- *ppDestination = pExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( ppDestination,
+ &pComparand,
+ &pExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *ppDestination == pComparand )
+ {
+ *ppDestination = pExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-}
-
/*----------------------------- Arithmetic ------------------------------*/
@@ -266,30 +249,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Add_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic subtract
@@ -303,30 +281,25 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic increment
@@ -338,28 +311,24 @@ static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
*
* @return *pAddend value before increment.
*/
-static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic decrement
@@ -371,28 +340,24 @@ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAdde
*
* @return *pAddend value before decrement.
*/
-static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/*----------------------------- Bitwise Logical ------------------------------*/
@@ -407,30 +372,25 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_OR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_or(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_or( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination |= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination |= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic AND
@@ -443,30 +403,25 @@ static portFORCE_INLINE uint32_t Atomic_OR_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_AND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_and(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_and( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination &= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination &= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic NAND
@@ -479,30 +434,25 @@ static portFORCE_INLINE uint32_t Atomic_AND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_NAND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_nand(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_nand( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination = ~(ulCurrent & ulValue);
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination = ~( ulCurrent & ulValue );
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic XOR
@@ -515,33 +465,28 @@ static portFORCE_INLINE uint32_t Atomic_NAND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_XOR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_xor(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_xor( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination ^= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination ^= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
-#ifdef __cplusplus
-}
-#endif
+ #ifdef __cplusplus
+ }
+ #endif
#endif /* ATOMIC_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_config.h
index f08a98f27..9d1cc5346 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_config.h
@@ -34,6 +34,6 @@
* In the Windows port, this stack only holds a structure. The actual
* stack is created by an operating system thread.
*/
-#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
+#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
#endif /* DEMO_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c
index 3c46ff835..e6aa16c3e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c
@@ -57,19 +57,19 @@
/*-----------------------------------------------------------*/
/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
+ * to .ful. */
+#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
+#define dlMAX_PRINT_STRING_LENGTH 255
/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
+ * the Win32 thread that is responsible for making any Win32 system calls that are
+ * necessary for the selected logging method. */
+#define dlLOGGING_STREAM_BUFFER_SIZE 32768
/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
+#define dlDONT_BLOCK 0
/*-----------------------------------------------------------*/
@@ -81,7 +81,8 @@ static void prvFileLoggingInit( void );
/*
* Attempt to write a message to the file.
*/
-static void prvLogToFile( const char *pcMessage, size_t xLength );
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength );
/*
* Simply close the logging file, if it is open.
@@ -102,7 +103,7 @@ static void prvLoggingFlushBuffer( void );
* Win32 system calls. Only the windows thread can make system calls so as not
* to disrupt the simulation by making Windows calls from FreeRTOS tasks.
*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
+static DWORD WINAPI prvWin32LoggingThread( void * pvParam );
/*
* Creates the socket to which UDP messages are sent. This function is not
@@ -110,417 +111,426 @@ static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
* task - which could result in a deadlock. Instead the function call is
* deferred to run in the RTOS daemon task - hence it prototype.
*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 );
/*-----------------------------------------------------------*/
/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
+ * needs Win32 system calls. */
+static void * pvLoggingThreadEvent = NULL;
/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
+ * vLoggingInit() function. */
+BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
+ * thread that is responsible for making Win32 calls (when stdout or a disk log is
+ * used). */
+static StreamBuffer_t * xLogStreamBuffer = NULL;
/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
+ * messages waiting to be logged, then closed again in between logs. */
+static FILE * pxLoggingFileHandle = NULL;
/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
+ * to pdFALSE - at which time prints that require Win32 system calls are done by
+ * the Win32 thread responsible for logging. */
+BaseType_t xDirectPrint = pdTRUE;
/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
+static const char * pcLogFileName = "RTOSDemo.log";
+static const char * pcFullLogFileName = "RTOSDemo.ful";
/* As an optimization, the current file size is kept in a variable. */
-static size_t ulSizeOfLoggingFile = 0ul;
+static size_t ulSizeOfLoggingFile = 0ul;
/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
+Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
struct freertos_sockaddr xPrintUDPAddress;
/*-----------------------------------------------------------*/
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort )
{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialize it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialized. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
+ /* Can only be called before the scheduler has started. */
+ configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
+
+ #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
+ {
+ HANDLE Win32Thread;
+
+ /* Record which output methods are to be used. */
+ xStdoutLoggingUsed = xLogToStdout;
+ xDiskFileLoggingUsed = xLogToFile;
+ xUDPLoggingUsed = xLogToUDP;
+
+ /* If a disk file is used then initialize it now. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvFileLoggingInit();
+ }
+
+ /* If UDP logging is used then store the address to which the log data
+ * will be sent - but don't create the socket yet because the network is
+ * not initialized. */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ /* Set the address to which the print messages are sent. */
+ xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
+ xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
+ }
+
+ /* If a disk file or stdout are to be used then Win32 system calls will
+ * have to be made. Such system calls cannot be made from FreeRTOS tasks
+ * so create a stream buffer to pass the messages to a Win32 thread, then
+ * create the thread itself, along with a Win32 event that can be used to
+ * unblock the thread. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ /* Create the buffer. */
+ xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
+ configASSERT( xLogStreamBuffer );
+ memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
+ xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
+
+ /* Create the Windows event. */
+ pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
+
+ /* Create the thread itself. */
+ Win32Thread = CreateThread(
+ NULL, /* Pointer to thread security attributes. */
+ 0, /* Initial thread stack size, in bytes. */
+ prvWin32LoggingThread, /* Pointer to thread function. */
+ NULL, /* Argument for new thread. */
+ 0, /* Creation flags. */
+ NULL );
+
+ /* Use the cores that are not used by the FreeRTOS tasks. */
+ SetThreadAffinityMask( Win32Thread, ~0x01u );
+ SetThreadPriorityBoost( Win32Thread, TRUE );
+ SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
+ }
+ }
+ #else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */
+ {
+ /* FreeRTOSIPConfig is set such that no print messages will be output.
+ * Avoid compiler warnings about unused parameters. */
+ ( void ) xLogToStdout;
+ ( void ) xLogToFile;
+ ( void ) xLogToUDP;
+ ( void ) usRemotePort;
+ ( void ) ulRemoteIPAddress;
+ }
+ #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
}
/*-----------------------------------------------------------*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 )
{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
+ static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
+ Socket_t xSocket;
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
+ /* The function prototype is that of a deferred function, but the parameters
+ * are not actually used. */
+ ( void ) pvParameter1;
+ ( void ) ulParameter2;
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
+ if( xSocket != FREERTOS_INVALID_SOCKET )
+ {
+ /* FreeRTOS+TCP decides which port to bind to. */
+ FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
+ FreeRTOS_bind( xSocket, NULL, 0 );
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
+ /* Now the socket is bound it can be assigned to the print socket. */
+ xPrintSocket = xSocket;
+ }
}
/*-----------------------------------------------------------*/
-void vLoggingPrintf( const char *pcFormat, ... )
+void vLoggingPrintf( const char * pcFormat,
+ ... )
{
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
-char *pcSource, *pcTarget, *pcBegin;
-size_t xLength, xLength2, rc;
-static BaseType_t xMessageNumber = 0;
-va_list args;
-uint32_t ulIPAddress;
-const char *pcTaskName;
-const char *pcNoTask = "None";
-int iOriginalPriority;
-HANDLE xCurrentTask;
-
-
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
- {
- /* There are a variable number of parameters. */
- va_start( args, pcFormat );
-
- /* Additional info to place at the start of the log. */
- if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
- {
- pcTaskName = pcTaskGetName( NULL );
- }
- else
- {
- pcTaskName = pcNoTask;
- }
-
- if( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
-
- if( xLength2 < 0 )
- {
- /* Clean up. */
- xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
- cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
- }
-
- xLength += xLength2;
- va_end( args );
-
- /* For ease of viewing, copy the string into another buffer, converting
- IP addresses to dot notation on the way. */
- pcSource = cPrintString;
- pcTarget = cOutputString;
-
- while( ( *pcSource ) != '\0' )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- pcSource++;
-
- /* Look forward for an IP address denoted by 'ip'. */
- if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- *pcTarget = '\0';
- pcBegin = pcTarget - 8;
-
- while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
- {
- pcTarget--;
- }
-
- sscanf( pcTarget, "%8X", &ulIPAddress );
- rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
- ( unsigned long ) ( ulIPAddress >> 24UL ),
- ( unsigned long ) ( (ulIPAddress >> 16UL) & 0xffUL ),
- ( unsigned long ) ( (ulIPAddress >> 8UL) & 0xffUL ),
- ( unsigned long ) ( ulIPAddress & 0xffUL ) );
- pcTarget += rc;
- pcSource += 3; /* skip "<n>ip" */
- }
- }
-
- /* How far through the buffer was written? */
- xLength = ( BaseType_t ) ( pcTarget - cOutputString );
-
- /* If the message is to be logged to a UDP port then it can be sent directly
- because it only uses FreeRTOS function (not Win32 functions). */
- if( xUDPLoggingUsed != pdFALSE )
- {
- if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
- {
- /* Create and bind the socket to which print messages are sent. The
- xTimerPendFunctionCall() function is used even though this is
- not an interrupt because this function is called from the IP task
- and the IP task cannot itself wait for a socket to bind. The
- parameters to prvCreatePrintSocket() are not required so set to
- NULL or 0. */
- xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* If logging is also to go to either stdout or a disk file then it cannot
- be output here - so instead write the message to the stream buffer and wake
- the Win32 thread which will read it from the stream buffer and perform the
- actual output. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- configASSERT( xLogStreamBuffer );
-
- /* How much space is in the buffer? */
- xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
-
- /* There must be enough space to write both the string and the length of
- the string. */
- if( xLength2 >= ( xLength + sizeof( xLength ) ) )
- {
- /* First write in the length of the data, then write in the data
- itself. Raising the thread priority is used as a critical section
- as there are potentially multiple writers. The stream buffer is
- only thread safe when there is a single writer (likewise for
- reading from the buffer). */
- xCurrentTask = GetCurrentThread();
- iOriginalPriority = GetThreadPriority( xCurrentTask );
- SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
- SetThreadPriority( GetCurrentThread(), iOriginalPriority );
- }
-
- /* xDirectPrint is initialized to pdTRUE, and while it remains true the
- logging output function is called directly. When the system is running
- the output function cannot be called directly because it would get
- called from both FreeRTOS tasks and Win32 threads - so instead wake the
- Win32 thread responsible for the actual output. */
- if( xDirectPrint != pdFALSE )
- {
- /* While starting up, the thread which calls prvWin32LoggingThread()
- is not running yet and xDirectPrint will be pdTRUE. */
- prvLoggingFlushBuffer();
- }
- else if( pvLoggingThreadEvent != NULL )
- {
- /* While running, wake up prvWin32LoggingThread() to send the
- logging data. */
- SetEvent( pvLoggingThreadEvent );
- }
- }
- }
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+ char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
+ char * pcSource, * pcTarget, * pcBegin;
+ size_t xLength, xLength2, rc;
+ static BaseType_t xMessageNumber = 0;
+ va_list args;
+ uint32_t ulIPAddress;
+ const char * pcTaskName;
+ const char * pcNoTask = "None";
+ int iOriginalPriority;
+ HANDLE xCurrentTask;
+
+
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
+ {
+ /* There are a variable number of parameters. */
+ va_start( args, pcFormat );
+
+ /* Additional info to place at the start of the log. */
+ if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
+ {
+ pcTaskName = pcTaskGetName( NULL );
+ }
+ else
+ {
+ pcTaskName = pcNoTask;
+ }
+
+ if( strcmp( pcFormat, "\n" ) != 0 )
+ {
+ xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
+ xMessageNumber++,
+ ( unsigned long ) xTaskGetTickCount(),
+ pcTaskName );
+ }
+ else
+ {
+ xLength = 0;
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ }
+
+ xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
+
+ if( xLength2 < 0 )
+ {
+ /* Clean up. */
+ xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
+ cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
+ }
+
+ xLength += xLength2;
+ va_end( args );
+
+ /* For ease of viewing, copy the string into another buffer, converting
+ * IP addresses to dot notation on the way. */
+ pcSource = cPrintString;
+ pcTarget = cOutputString;
+
+ while( ( *pcSource ) != '\0' )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ pcSource++;
+
+ /* Look forward for an IP address denoted by 'ip'. */
+ if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ *pcTarget = '\0';
+ pcBegin = pcTarget - 8;
+
+ while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
+ {
+ pcTarget--;
+ }
+
+ sscanf( pcTarget, "%8X", &ulIPAddress );
+ rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
+ ( unsigned long ) ( ulIPAddress >> 24UL ),
+ ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ),
+ ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ),
+ ( unsigned long ) ( ulIPAddress & 0xffUL ) );
+ pcTarget += rc;
+ pcSource += 3; /* skip "<n>ip" */
+ }
+ }
+
+ /* How far through the buffer was written? */
+ xLength = ( BaseType_t ) ( pcTarget - cOutputString );
+
+ /* If the message is to be logged to a UDP port then it can be sent directly
+ * because it only uses FreeRTOS function (not Win32 functions). */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
+ {
+ /* Create and bind the socket to which print messages are sent. The
+ * xTimerPendFunctionCall() function is used even though this is
+ * not an interrupt because this function is called from the IP task
+ * and the IP task cannot itself wait for a socket to bind. The
+ * parameters to prvCreatePrintSocket() are not required so set to
+ * NULL or 0. */
+ xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
+ }
+
+ if( xPrintSocket != FREERTOS_INVALID_SOCKET )
+ {
+ FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+
+ /* Just because the UDP data logger I'm using is dumb. */
+ FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+ }
+ }
+
+ /* If logging is also to go to either stdout or a disk file then it cannot
+ * be output here - so instead write the message to the stream buffer and wake
+ * the Win32 thread which will read it from the stream buffer and perform the
+ * actual output. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ configASSERT( xLogStreamBuffer );
+
+ /* How much space is in the buffer? */
+ xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
+
+ /* There must be enough space to write both the string and the length of
+ * the string. */
+ if( xLength2 >= ( xLength + sizeof( xLength ) ) )
+ {
+ /* First write in the length of the data, then write in the data
+ * itself. Raising the thread priority is used as a critical section
+ * as there are potentially multiple writers. The stream buffer is
+ * only thread safe when there is a single writer (likewise for
+ * reading from the buffer). */
+ xCurrentTask = GetCurrentThread();
+ iOriginalPriority = GetThreadPriority( xCurrentTask );
+ SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
+ SetThreadPriority( GetCurrentThread(), iOriginalPriority );
+ }
+
+ /* xDirectPrint is initialized to pdTRUE, and while it remains true the
+ * logging output function is called directly. When the system is running
+ * the output function cannot be called directly because it would get
+ * called from both FreeRTOS tasks and Win32 threads - so instead wake the
+ * Win32 thread responsible for the actual output. */
+ if( xDirectPrint != pdFALSE )
+ {
+ /* While starting up, the thread which calls prvWin32LoggingThread()
+ * is not running yet and xDirectPrint will be pdTRUE. */
+ prvLoggingFlushBuffer();
+ }
+ else if( pvLoggingThreadEvent != NULL )
+ {
+ /* While running, wake up prvWin32LoggingThread() to send the
+ * logging data. */
+ SetEvent( pvLoggingThreadEvent );
+ }
+ }
+ }
}
/*-----------------------------------------------------------*/
static void prvLoggingFlushBuffer( void )
{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- _write( _fileno(stdout), cPrintString, strlen( cPrintString ) );
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
+ size_t xLength;
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+
+ /* Is there more than the length value stored in the circular buffer
+ * used to pass data from the FreeRTOS simulator into this Win32 thread? */
+ while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
+ {
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
+
+ /* Write the message to standard out if requested to do so when
+ * vLoggingInit() was called, or if the network is not yet up. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
+ {
+ /* Write the message to stdout. */
+ _write( _fileno( stdout ), cPrintString, strlen( cPrintString ) );
+ }
+
+ /* Write the message to a file if requested to do so when
+ * vLoggingInit() was called. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvLogToFile( cPrintString, xLength );
+ }
+ }
+
+ prvFileClose();
}
/*-----------------------------------------------------------*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
+static DWORD WINAPI prvWin32LoggingThread( void * pvParameter )
{
-const DWORD xMaxWait = 1000;
+ const DWORD xMaxWait = 1000;
- ( void ) pvParameter;
+ ( void ) pvParameter;
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
+ /* From now on, prvLoggingFlushBuffer() will only be called from this
+ * Windows thread */
+ xDirectPrint = pdFALSE;
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
+ for( ; ; )
+ {
+ /* Wait to be told there are message waiting to be logged. */
+ WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
+ /* Write out all waiting messages. */
+ prvLoggingFlushBuffer();
+ }
}
/*-----------------------------------------------------------*/
static void prvFileLoggingInit( void )
{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
+ FILE * pxHandle = fopen( pcLogFileName, "a" );
+
+ if( pxHandle != NULL )
+ {
+ fseek( pxHandle, SEEK_END, 0ul );
+ ulSizeOfLoggingFile = ftell( pxHandle );
+ fclose( pxHandle );
+ }
+ else
+ {
+ ulSizeOfLoggingFile = 0ul;
+ }
}
/*-----------------------------------------------------------*/
static void prvFileClose( void )
{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
+ if( pxLoggingFileHandle != NULL )
+ {
+ fclose( pxLoggingFileHandle );
+ pxLoggingFileHandle = NULL;
+ }
}
/*-----------------------------------------------------------*/
-static void prvLogToFile( const char *pcMessage, size_t xLength )
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength )
{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
+ if( pxLoggingFileHandle == NULL )
+ {
+ pxLoggingFileHandle = fopen( pcLogFileName, "a" );
+ }
+
+ if( pxLoggingFileHandle != NULL )
+ {
+ fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
+ ulSizeOfLoggingFile += xLength;
+
+ /* If the file has grown to its maximum permissible size then close and
+ * rename it - then start with a new file. */
+ if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
+ {
+ prvFileClose();
+
+ if( _access( pcFullLogFileName, 00 ) == 0 )
+ {
+ remove( pcFullLogFileName );
+ }
+
+ rename( pcLogFileName, pcFullLogFileName );
+ ulSizeOfLoggingFile = 0;
+ }
+ }
}
/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.h
index 2cc068ce9..773cc0d75 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.h
@@ -38,11 +38,10 @@
* If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
* to the IP address and port number to which UDP log messages will be sent.
*/
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort );
#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/iot_config.h
index 5ff1bcc2a..81eda1d04 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/**
* @brief Set the log level of the MQTT library.
@@ -75,14 +75,14 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
+#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
/**
* @brief Enable TLS in the network abstraction.
*
* The TLS implementation requires the mbed TLS library.
*/
-#define IOT_NETWORK_ENABLE_TLS 1
+#define IOT_NETWORK_ENABLE_TLS 1
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -96,7 +96,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/**
* @brief Enable/Disable anonymous metrics collection when using AWS IoT.
@@ -104,7 +104,7 @@
* This demo does not use TLS and so does not work with AWS IoT. Therefore,
* the metric collection must be disabled.
*/
-#define AWS_IOT_MQTT_ENABLE_METRICS 0
+#define AWS_IOT_MQTT_ENABLE_METRICS 0
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c
index 5b19167f4..5cfd017ed 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c
@@ -34,7 +34,7 @@
#include <time.h>
/* Visual studio intrinsics used so the __debugbreak() function is available
-should an assert get hit. */
+ * should an assert get hit. */
#include <intrin.h>
/* FreeRTOS includes. */
@@ -72,29 +72,29 @@ static void prvSRand( UBaseType_t ulSeed );
static void prvMiscInitialisation( void );
/* The default IP and MAC address used by the demo. The address configuration
-defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
-1 but a DHCP server could not be contacted. See the online documentation for
-more information. */
+ * defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
+ * 1 but a DHCP server could not be contacted. See the online documentation for
+ * more information. */
static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };
static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };
static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };
/* Set the following constant to pdTRUE to log using the method indicated by the
-name of the constant, or pdFALSE to not log using the method indicated by the
-name of the constant. Options include to standard out (xLogToStdout), to a disk
-file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
-then UDP messages are sent to the IP address configured as the echo server
-address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
-the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
+ * name of the constant, or pdFALSE to not log using the method indicated by the
+ * name of the constant. Options include to standard out (xLogToStdout), to a disk
+ * file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
+ * then UDP messages are sent to the IP address configured as the echo server
+ * address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
+ * the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALSE;
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition for information on how to configure
-the real network connection to use. */
-const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
+ * connection that uses this MAC address by accessing the raw Ethernet data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition for information on how to configure
+ * the real network connection to use. */
+const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
/* Use by the pseudo random number generator. */
static UBaseType_t ulNextRand;
@@ -102,186 +102,186 @@ static UBaseType_t ulNextRand;
int main( void )
{
- /***
- * See https://www.FreeRTOS.org/jobs/index.html for configuration and usage instructions.
- ***/
-
- /* Miscellaneous initialization including preparing the logging and seeding
- the random number generator. */
- prvMiscInitialisation();
-
- /* Initialize the network interface.
-
- ***NOTE*** Tasks that use the network are created in the network event hook
- when the network is connected and ready for use (see the implementation of
- vApplicationIPNetworkEventHook() below). The address values passed in here
- are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
- but a DHCP server cannot be contacted. */
- FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
-
- /* Start the RTOS scheduler. */
- vTaskStartScheduler();
-
- /* If all is well, the scheduler will now be running, and the following
- line will never be reached. If the following line does execute, then
- there was insufficient FreeRTOS heap memory available for the idle and/or
- timer tasks to be created. See the memory management section on the
- FreeRTOS web site for more details (this is standard text that is not
- really applicable to the Win32 simulator port). */
- for( ; ; )
- {
- __debugbreak();
- }
+ /***
+ * See https://www.FreeRTOS.org/jobs/index.html for configuration and usage instructions.
+ ***/
+
+ /* Miscellaneous initialization including preparing the logging and seeding
+ * the random number generator. */
+ prvMiscInitialisation();
+
+ /* Initialize the network interface.
+ *
+ ***NOTE*** Tasks that use the network are created in the network event hook
+ * when the network is connected and ready for use (see the implementation of
+ * vApplicationIPNetworkEventHook() below). The address values passed in here
+ * are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
+ * but a DHCP server cannot be contacted. */
+ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
+
+ /* Start the RTOS scheduler. */
+ vTaskStartScheduler();
+
+ /* If all is well, the scheduler will now be running, and the following
+ * line will never be reached. If the following line does execute, then
+ * there was insufficient FreeRTOS heap memory available for the idle and/or
+ * timer tasks to be created. See the memory management section on the
+ * FreeRTOS web site for more details (this is standard text that is not
+ * really applicable to the Win32 simulator port). */
+ for( ; ; )
+ {
+ __debugbreak();
+ }
}
/*-----------------------------------------------------------*/
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
-events are only received if implemented in the MAC driver. */
+ * events are only received if implemented in the MAC driver. */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
-uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
-char cBuffer[ 16 ];
-static BaseType_t xTasksAlreadyCreated = pdFALSE;
-
- /* If the network has just come up...*/
- if( eNetworkEvent == eNetworkUp )
- {
- /* Create the tasks that use the IP stack if they have not already been
- created. */
- if( xTasksAlreadyCreated == pdFALSE )
- {
- /* Demos that use the network are created after the network is
- up. */
- configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
- vStartJobsDemo();
- xTasksAlreadyCreated = pdTRUE;
- }
-
- /* Print out the network configuration, which may have come from a DHCP
- server. */
- FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
- FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
- FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
- FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
- FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
- FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
- }
+ uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
+ char cBuffer[ 16 ];
+ static BaseType_t xTasksAlreadyCreated = pdFALSE;
+
+ /* If the network has just come up...*/
+ if( eNetworkEvent == eNetworkUp )
+ {
+ /* Create the tasks that use the IP stack if they have not already been
+ * created. */
+ if( xTasksAlreadyCreated == pdFALSE )
+ {
+ /* Demos that use the network are created after the network is
+ * up. */
+ configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
+ vStartJobsDemo();
+ xTasksAlreadyCreated = pdTRUE;
+ }
+
+ /* Print out the network configuration, which may have come from a DHCP
+ * server. */
+ FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
+ FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
+ FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
+ FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
+ FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
+ FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
+ }
}
/*-----------------------------------------------------------*/
-void vAssertCalled( const char *pcFile,
- uint32_t ulLine )
+void vAssertCalled( const char * pcFile,
+ uint32_t ulLine )
{
-volatile uint32_t ulBlockVariable = 0UL;
-volatile char *pcFileName = ( volatile char * ) pcFile;
-volatile uint32_t ulLineNumber = ulLine;
-
- ( void ) pcFileName;
- ( void ) ulLineNumber;
-
- printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
-
- /* Setting ulBlockVariable to a non-zero value in the debugger will allow
- this function to be exited. */
- taskDISABLE_INTERRUPTS();
- {
- while( ulBlockVariable == 0UL )
- {
- __debugbreak();
- }
- }
- taskENABLE_INTERRUPTS();
+ volatile uint32_t ulBlockVariable = 0UL;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
+ volatile uint32_t ulLineNumber = ulLine;
+
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
+
+ printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
+
+ /* Setting ulBlockVariable to a non-zero value in the debugger will allow
+ * this function to be exited. */
+ taskDISABLE_INTERRUPTS();
+ {
+ while( ulBlockVariable == 0UL )
+ {
+ __debugbreak();
+ }
+ }
+ taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
UBaseType_t uxRand( void )
{
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
-
- /*
- * Utility function to generate a pseudo random number.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
- return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
+ const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
+
+ /*
+ * Utility function to generate a pseudo random number.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
}
/*-----------------------------------------------------------*/
static void prvSRand( UBaseType_t ulSeed )
{
- /* Utility function to seed the pseudo random number generator. */
- ulNextRand = ulSeed;
+ /* Utility function to seed the pseudo random number generator. */
+ ulNextRand = ulSeed;
}
/*-----------------------------------------------------------*/
static void prvMiscInitialisation( void )
{
-time_t xTimeNow;
-uint32_t ulLoggingIPAddress;
-
- ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
- vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
-
- /*
- * Seed random number generator.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- time( &xTimeNow );
- FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
- prvSRand( ( uint32_t ) xTimeNow );
- FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
+ time_t xTimeNow;
+ uint32_t ulLoggingIPAddress;
+
+ ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
+ vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
+
+ /*
+ * Seed random number generator.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ time( &xTimeNow );
+ FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
+ prvSRand( ( uint32_t ) xTimeNow );
+ FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
}
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
- const char * pcApplicationHostnameHook( void )
- {
- /* Assign the name "FreeRTOS" to this network node. This function will
- be called during the DHCP: the machine will be registered with an IP
- address plus this name. */
- return mainHOST_NAME;
- }
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* Assign the name "FreeRTOS" to this network node. This function will
+ * be called during the DHCP: the machine will be registered with an IP
+ * address plus this name. */
+ return mainHOST_NAME;
+ }
#endif
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
- BaseType_t xApplicationDNSQueryHook( const char *pcName )
- {
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- to this node: that returned by pcApplicationHostnameHook() and that set
- by mainDEVICE_NICK_NAME. */
- if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
- {
- xReturn = pdPASS;
- }
- else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
- {
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
-
- return xReturn;
- }
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
+ {
+ BaseType_t xReturn;
+
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*-----------------------------------------------------------*/
@@ -293,85 +293,85 @@ uint32_t ulLoggingIPAddress;
* SYSTEMS.
*/
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort )
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- ( void ) ulSourceAddress;
- ( void ) usSourcePort;
- ( void ) ulDestinationAddress;
- ( void ) usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
- return uxRand();
+ return uxRand();
}
/*-----------------------------------------------------------*/
/*
* Set *pulNumber to a random number, and return pdTRUE. When the random number
* generator is broken, it shall return pdFALSE.
- * The macros ipconfigRAND32() and configRAND32() are not in use
+ * The macros ipconfigRAND32() and configRAND32() are not in use
* anymore in FreeRTOS+TCP.
- *
+ *
* THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS
* NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.
*/
BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
{
- *pulNumber = uxRand();
- return pdTRUE;
+ *pulNumber = uxRand();
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
-implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
-used by the Idle task. */
+ * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
+ * used by the Idle task. */
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
- StackType_t ** ppxIdleTaskStackBuffer,
- uint32_t * pulIdleTaskStackSize )
+ StackType_t ** ppxIdleTaskStackBuffer,
+ uint32_t * pulIdleTaskStackSize )
{
- /* If the buffers to be provided to the Idle task are declared inside this
- function then they must be declared static - otherwise they will be allocated on
- the stack and so not exists after this function exits. */
- static StaticTask_t xIdleTaskTCB;
- static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
- state will be stored. */
- *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
-
- /* Pass out the array that will be used as the Idle task's stack. */
- *ppxIdleTaskStackBuffer = uxIdleTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
- Note that, as the array is necessarily of type StackType_t,
- configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+ /* If the buffers to be provided to the Idle task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xIdleTaskTCB;
+ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
+ * state will be stored. */
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+
+ /* Pass out the array that will be used as the Idle task's stack. */
+ *ppxIdleTaskStackBuffer = uxIdleTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
-application must provide an implementation of vApplicationGetTimerTaskMemory()
-to provide the memory that is used by the Timer service task. */
+ * application must provide an implementation of vApplicationGetTimerTaskMemory()
+ * to provide the memory that is used by the Timer service task. */
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
- StackType_t ** ppxTimerTaskStackBuffer,
- uint32_t * pulTimerTaskStackSize )
+ StackType_t ** ppxTimerTaskStackBuffer,
+ uint32_t * pulTimerTaskStackSize )
{
- /* If the buffers to be provided to the Timer task are declared inside this
- function then they must be declared static - otherwise they will be allocated on
- the stack and so not exists after this function exits. */
- static StaticTask_t xTimerTaskTCB;
- static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Timer
- task's state will be stored. */
- *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
-
- /* Pass out the array that will be used as the Timer task's stack. */
- *ppxTimerTaskStackBuffer = uxTimerTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
- Note that, as the array is necessarily of type StackType_t,
- configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+ /* If the buffers to be provided to the Timer task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xTimerTaskTCB;
+ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Timer
+ * task's state will be stored. */
+ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+
+ /* Pass out the array that will be used as the Timer task's stack. */
+ *ppxTimerTaskStackBuffer = uxTimerTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c
index 84b87b2a4..f9bc5b5b1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c
@@ -1,21 +1,21 @@
/*
- Copyright 2001, 2002 Georges Menie (www.menie.org)
- stdarg version contributed by Christian Ettinger
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Changes for the FreeRTOS ports:
-
- - The dot in "%-8.8s"
- - The specifiers 'l' (long) and 'L' (long long)
- - The specifier 'u' for unsigned
- - Dot notation for IP addresses:
- sprintf("IP = %xip\n", 0xC0A80164);
- will produce "IP = 192.168.1.100\n"
-*/
+ * Copyright 2001, 2002 Georges Menie (www.menie.org)
+ * stdarg version contributed by Christian Ettinger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Changes for the FreeRTOS ports:
+ *
+ * - The dot in "%-8.8s"
+ * - The specifiers 'l' (long) and 'L' (long long)
+ * - The specifier 'u' for unsigned
+ * - Dot notation for IP addresses:
+ * sprintf("IP = %xip\n", 0xC0A80164);
+ * will produce "IP = 192.168.1.100\n"
+ */
#include <stdarg.h>
#include <stdio.h>
@@ -24,8 +24,8 @@
#include "FreeRTOS.h"
-#define PAD_RIGHT 1
-#define PAD_ZERO 2
+#define PAD_RIGHT 1
+#define PAD_ZERO 2
/*
* Return 1 for readable, 2 for writeable, 3 for both.
@@ -33,635 +33,721 @@
*/
extern BaseType_t xApplicationMemoryPermissions( uint32_t aAddress );
-extern void vOutputChar( const char cChar, const TickType_t xTicksToWait );
+extern void vOutputChar( const char cChar,
+ const TickType_t xTicksToWait );
static const TickType_t xTicksToWait = pdMS_TO_TICKS( 20 );
struct xPrintFlags
{
- int base;
- int width;
- int printLimit;
- unsigned
- pad : 8,
- letBase : 8,
- isSigned : 1,
- isNumber : 1,
- long32 : 1,
- long64 : 1;
+ int base;
+ int width;
+ int printLimit;
+ unsigned
+ pad : 8,
+ letBase : 8,
+ isSigned : 1,
+ isNumber : 1,
+ long32 : 1,
+ long64 : 1;
};
struct SStringBuf
{
- char *str;
- const char *orgStr;
- const char *nulPos;
- int curLen;
- struct xPrintFlags flags;
+ char * str;
+ const char * orgStr;
+ const char * nulPos;
+ int curLen;
+ struct xPrintFlags flags;
};
-static void strbuf_init( struct SStringBuf *apStr, char *apBuf, const char *apMaxStr )
+static void strbuf_init( struct SStringBuf * apStr,
+ char * apBuf,
+ const char * apMaxStr )
{
- apStr->str = apBuf;
- apStr->orgStr = apBuf;
- apStr->nulPos = apMaxStr-1;
- apStr->curLen = 0;
+ apStr->str = apBuf;
+ apStr->orgStr = apBuf;
+ apStr->nulPos = apMaxStr - 1;
+ apStr->curLen = 0;
- memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
+ memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
}
/*-----------------------------------------------------------*/
-static BaseType_t strbuf_printchar( struct SStringBuf *apStr, int c )
+static BaseType_t strbuf_printchar( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *( apStr->str++ ) = c;
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
-static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf *apStr, int c )
+static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *(apStr->str++) = c;
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
static portINLINE int i2hex( int aCh )
{
-int iResult;
-
- if( aCh < 10 )
- {
- iResult = '0' + aCh;
- }
- else
- {
- iResult = 'A' + aCh - 10;
- }
-
- return iResult;
+ int iResult;
+
+ if( aCh < 10 )
+ {
+ iResult = '0' + aCh;
+ }
+ else
+ {
+ iResult = 'A' + aCh - 10;
+ }
+
+ return iResult;
}
/*-----------------------------------------------------------*/
-static BaseType_t prints(struct SStringBuf *apBuf, const char *apString )
+static BaseType_t prints( struct SStringBuf * apBuf,
+ const char * apString )
{
- register int padchar = ' ';
- int i,len;
-
- if( xApplicationMemoryPermissions( ( uint32_t )apString ) == 0 )
- {
- /* The user has probably made a mistake with the parameter
- for '%s', the memory is not readbale. */
- apString = "INV_MEM";
- }
-
- if( apBuf->flags.width > 0 )
- {
- register int len = 0;
- register const char *ptr;
- for( ptr = apString; *ptr; ++ptr )
- {
- ++len;
- }
-
- if( len >= apBuf->flags.width )
- {
- apBuf->flags.width = 0;
- }
- else
- {
- apBuf->flags.width -= len;
- }
-
- if( apBuf->flags.pad & PAD_ZERO )
- {
- padchar = '0';
- }
- }
- if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
- {
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( strbuf_printchar( apBuf, padchar ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
- {
- /* The string to print represents an integer number.
- * In this case, printLimit is the min number of digits to print
- * If the length of the number to print is less than the min nb of i
- * digits to display, we add 0 before printing the number
- */
- len = strlen( apString );
-
- if( len < apBuf->flags.printLimit )
- {
- i = apBuf->flags.printLimit - len;
- for( ; i; i-- )
- {
- if( strbuf_printchar( apBuf, '0' ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- }
- /* The string to print is not the result of a number conversion to ascii.
- * For a string, printLimit is the max number of characters to display
- */
- for( ; apBuf->flags.printLimit && *apString ; ++apString, --apBuf->flags.printLimit )
- {
- if( !strbuf_printchar( apBuf, *apString ) )
- {
- return pdFALSE;
- }
- }
-
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( !strbuf_printchar( apBuf, padchar ) )
- {
- return pdFALSE;
- }
- }
-
- return pdTRUE;
+ register int padchar = ' ';
+ int i, len;
+
+ if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 )
+ {
+ /* The user has probably made a mistake with the parameter
+ * for '%s', the memory is not readbale. */
+ apString = "INV_MEM";
+ }
+
+ if( apBuf->flags.width > 0 )
+ {
+ register int len = 0;
+ register const char * ptr;
+
+ for( ptr = apString; *ptr; ++ptr )
+ {
+ ++len;
+ }
+
+ if( len >= apBuf->flags.width )
+ {
+ apBuf->flags.width = 0;
+ }
+ else
+ {
+ apBuf->flags.width -= len;
+ }
+
+ if( apBuf->flags.pad & PAD_ZERO )
+ {
+ padchar = '0';
+ }
+ }
+
+ if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
+ {
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( strbuf_printchar( apBuf, padchar ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+
+ if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
+ {
+ /* The string to print represents an integer number.
+ * In this case, printLimit is the min number of digits to print
+ * If the length of the number to print is less than the min nb of i
+ * digits to display, we add 0 before printing the number
+ */
+ len = strlen( apString );
+
+ if( len < apBuf->flags.printLimit )
+ {
+ i = apBuf->flags.printLimit - len;
+
+ for( ; i; i-- )
+ {
+ if( strbuf_printchar( apBuf, '0' ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+ }
+
+ /* The string to print is not the result of a number conversion to ascii.
+ * For a string, printLimit is the max number of characters to display
+ */
+ for( ; apBuf->flags.printLimit && *apString; ++apString, --apBuf->flags.printLimit )
+ {
+ if( !strbuf_printchar( apBuf, *apString ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( !strbuf_printchar( apBuf, padchar ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* the following should be enough for 32 bit int */
-#define PRINT_BUF_LEN 12 /* to print 4294967296 */
-
-#if SPRINTF_LONG_LONG
-#warning 64-bit libraries will be included as well
-static BaseType_t printll( struct SStringBuf *apBuf, long long i )
-{
- char print_buf[ 2 * PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned long long u = i;
- lldiv_t lldiv_result;
+#define PRINT_BUF_LEN 12 /* to print 4294967296 */
+
+#if SPRINTF_LONG_LONG
+ #warning 64-bit libraries will be included as well
+ static BaseType_t printll( struct SStringBuf * apBuf,
+ long long i )
+ {
+ char print_buf[ 2 * PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned long long u = i;
+ lldiv_t lldiv_result;
/* typedef struct
* {
- * long long int quot; // quotient
- * long long int rem; // remainder
+ * long long int quot; // quotient
+ * long long int rem; // remainder
* } lldiv_t;
*/
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- if( i == 0LL )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- /* 18446744073709551616 */
- while( u != 0 )
- {
- lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
- t = lldiv_result.rem;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u = lldiv_result.quot;
- }
-
- if( neg != 0 )
- {
- if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
- {
- if( !strbuf_printchar( apBuf, '-' ) )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
-}
-#endif /* SPRINTF_LONG_LONG */
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0LL )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ /* 18446744073709551616 */
+ while( u != 0 )
+ {
+ lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
+ t = lldiv_result.rem;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u = lldiv_result.quot;
+ }
+
+ if( neg != 0 )
+ {
+ if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( !strbuf_printchar( apBuf, '-' ) )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
+ }
+#endif /* SPRINTF_LONG_LONG */
/*-----------------------------------------------------------*/
-static BaseType_t printi( struct SStringBuf *apBuf, int i )
+static BaseType_t printi( struct SStringBuf * apBuf,
+ int i )
{
- char print_buf[ PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned int u = i;
- register unsigned base = apBuf->flags.base;
-
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
-
- if( i == 0 )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- switch( base )
- {
- case 16:
- while( u != 0 )
- {
- t = u & 0xF;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u >>= 4;
- }
- break;
-
- case 8:
- case 10:
- /* GCC compiles very efficient */
- while( u )
- {
- t = u % base;
- *( --s ) = t + '0';
- u /= base;
- }
- break;
+ char print_buf[ PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned int u = i;
+ register unsigned base = apBuf->flags.base;
+
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0 )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ switch( base )
+ {
+ case 16:
+
+ while( u != 0 )
+ {
+ t = u & 0xF;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u >>= 4;
+ }
+
+ break;
+
+ case 8:
+ case 10:
+
+ /* GCC compiles very efficient */
+ while( u )
+ {
+ t = u % base;
+ *( --s ) = t + '0';
+ u /= base;
+ }
+
+ break;
+
/*
- // The generic case, not yet in use
- default:
- while( u )
- {
- t = u % base;
- if( t >= 10)
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u /= base;
- }
- break;
-*/
- }
-
- if( neg != 0 )
- {
- if( apBuf->flags.width && (apBuf->flags.pad & PAD_ZERO ) )
- {
- if( strbuf_printchar( apBuf, '-' ) == 0 )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
+ * // The generic case, not yet in use
+ * default:
+ * while( u )
+ * {
+ * t = u % base;
+ * if( t >= 10)
+ * {
+ * t += apBuf->flags.letBase - '0' - 10;
+ * }
+ *( --s ) = t + '0';
+ * u /= base;
+ * }
+ * break;
+ */
+ }
+
+ if( neg != 0 )
+ {
+ if( apBuf->flags.width && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( strbuf_printchar( apBuf, '-' ) == 0 )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
}
/*-----------------------------------------------------------*/
-static BaseType_t printIp(struct SStringBuf *apBuf, unsigned i )
+static BaseType_t printIp( struct SStringBuf * apBuf,
+ unsigned i )
{
- char print_buf[16];
+ char print_buf[ 16 ];
- sprintf( print_buf, "%u.%u.%u.%u",
- i >> 24,
- ( i >> 16 ) & 0xff,
- ( i >> 8 ) & 0xff,
- i & 0xff );
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- prints( apBuf, print_buf );
+ sprintf( print_buf, "%u.%u.%u.%u",
+ i >> 24,
+ ( i >> 16 ) & 0xff,
+ ( i >> 8 ) & 0xff,
+ i & 0xff );
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+ prints( apBuf, print_buf );
- return pdTRUE;
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
-static void tiny_print( struct SStringBuf *apBuf, const char *format, va_list args )
+static void tiny_print( struct SStringBuf * apBuf,
+ const char * format,
+ va_list args )
{
- char scr[2];
-
- for( ; ; )
- {
- int ch = *( format++ );
-
- if( ch != '%' )
- {
- do
- {
- /* Put the most like flow in a small loop */
- if( strbuf_printchar_inline( apBuf, ch ) == 0 )
- {
- return;
- }
- ch = *( format++ );
- } while( ch != '%' );
- }
- ch = *( format++ );
- /* Now ch has character after '%', format pointing to next */
-
- if( ch == '\0' )
- {
- break;
- }
- if( ch == '%' )
- {
- if( strbuf_printchar( apBuf, ch ) == 0 )
- {
- return;
- }
- continue;
- }
- memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
-
- if( ch == '-' )
- {
- ch = *( format++ );
- apBuf->flags.pad = PAD_RIGHT;
- }
- while( ch == '0' )
- {
- ch = *( format++ );
- apBuf->flags.pad |= PAD_ZERO;
- }
- if( ch == '*' )
- {
- ch = *( format++ );
- apBuf->flags.width = va_arg( args, int );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.width *= 10;
- apBuf->flags.width += ch - '0';
- ch = *( format++ );
- }
- }
- if( ch == '.' )
- {
- ch = *( format++ );
- if( ch == '*' )
- {
- apBuf->flags.printLimit = va_arg( args, int );
- ch = *( format++ );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.printLimit *= 10;
- apBuf->flags.printLimit += ch - '0';
- ch = *( format++ );
- }
- }
- }
- if( apBuf->flags.printLimit == 0 )
- {
- apBuf->flags.printLimit--; /* -1: make it unlimited */
- }
- if( ch == 's' )
- {
- register char *s = ( char * )va_arg( args, int );
- if( prints( apBuf, s ? s : "(null)" ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'c' )
- {
- /* char are converted to int then pushed on the stack */
- scr[0] = ( char ) va_arg( args, int );
-
- if( strbuf_printchar( apBuf, scr[0] ) == 0 )
- {
- return;
- }
-
- continue;
- }
- if( ch == 'l' )
- {
- ch = *( format++ );
- apBuf->flags.long32 = 1;
- /* Makes not difference as u32 == long */
- }
- if( ch == 'L' )
- {
- ch = *( format++ );
- apBuf->flags.long64 = 1;
- /* Does make a difference */
- }
- apBuf->flags.base = 10;
- apBuf->flags.letBase = 'a';
-
- if( ch == 'd' || ch == 'u' )
- {
- apBuf->flags.isSigned = ( ch == 'd' );
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
-
- apBuf->flags.base = 16; /* From here all hexadecimal */
-
- if( ch == 'x' && format[0] == 'i' && format[1] == 'p' )
- {
- format += 2; /* eat the "xi" of "xip" */
- /* Will use base 10 again */
- if( printIp( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'x' || ch == 'X' || ch == 'p' || ch == 'o' )
- {
- if( ch == 'X' )
- {
- apBuf->flags.letBase = 'A';
- }
- else if( ch == 'o' )
- {
- apBuf->flags.base = 8;
- }
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- }
- strbuf_printchar( apBuf, '\0' );
+ char scr[ 2 ];
+
+ for( ; ; )
+ {
+ int ch = *( format++ );
+
+ if( ch != '%' )
+ {
+ do
+ {
+ /* Put the most like flow in a small loop */
+ if( strbuf_printchar_inline( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ ch = *( format++ );
+ } while( ch != '%' );
+ }
+
+ ch = *( format++ );
+ /* Now ch has character after '%', format pointing to next */
+
+ if( ch == '\0' )
+ {
+ break;
+ }
+
+ if( ch == '%' )
+ {
+ if( strbuf_printchar( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
+
+ if( ch == '-' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad = PAD_RIGHT;
+ }
+
+ while( ch == '0' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad |= PAD_ZERO;
+ }
+
+ if( ch == '*' )
+ {
+ ch = *( format++ );
+ apBuf->flags.width = va_arg( args, int );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.width *= 10;
+ apBuf->flags.width += ch - '0';
+ ch = *( format++ );
+ }
+ }
+
+ if( ch == '.' )
+ {
+ ch = *( format++ );
+
+ if( ch == '*' )
+ {
+ apBuf->flags.printLimit = va_arg( args, int );
+ ch = *( format++ );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.printLimit *= 10;
+ apBuf->flags.printLimit += ch - '0';
+ ch = *( format++ );
+ }
+ }
+ }
+
+ if( apBuf->flags.printLimit == 0 )
+ {
+ apBuf->flags.printLimit--; /* -1: make it unlimited */
+ }
+
+ if( ch == 's' )
+ {
+ register char * s = ( char * ) va_arg( args, int );
+
+ if( prints( apBuf, s ? s : "(null)" ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ch == 'c' )
+ {
+ /* char are converted to int then pushed on the stack */
+ scr[ 0 ] = ( char ) va_arg( args, int );
+
+ if( strbuf_printchar( apBuf, scr[ 0 ] ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ if( ch == 'l' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long32 = 1;
+ /* Makes not difference as u32 == long */
+ }
+
+ if( ch == 'L' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long64 = 1;
+ /* Does make a difference */
+ }
+
+ apBuf->flags.base = 10;
+ apBuf->flags.letBase = 'a';
+
+ if( ( ch == 'd' ) || ( ch == 'u' ) )
+ {
+ apBuf->flags.isSigned = ( ch == 'd' );
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ apBuf->flags.base = 16; /* From here all hexadecimal */
+
+ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) )
+ {
+ format += 2; /* eat the "xi" of "xip" */
+
+ /* Will use base 10 again */
+ if( printIp( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ( ch == 'x' ) || ( ch == 'X' ) || ( ch == 'p' ) || ( ch == 'o' ) )
+ {
+ if( ch == 'X' )
+ {
+ apBuf->flags.letBase = 'A';
+ }
+ else if( ch == 'o' )
+ {
+ apBuf->flags.base = 8;
+ }
+
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+ }
+
+ strbuf_printchar( apBuf, '\0' );
}
/*-----------------------------------------------------------*/
-int vsnprintf( char *apBuf, size_t aMaxLen, const char *apFmt, va_list args )
+int vsnprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int snprintf( char *apBuf, size_t aMaxLen, const char *apFmt, ... )
+int snprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int sprintf( char *apBuf, const char *apFmt, ... )
+int sprintf( char * apBuf,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char * )apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int vsprintf( char *apBuf, const char *apFmt, va_list args )
+int vsprintf( char * apBuf,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* ) apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-const char *mkSize (unsigned long long aSize, char *apBuf, int aLen)
+const char * mkSize( unsigned long long aSize,
+ char * apBuf,
+ int aLen )
{
-static char retString[33];
-size_t gb, mb, kb, sb;
-
- if (apBuf == NULL) {
- apBuf = retString;
- aLen = sizeof( retString );
- }
- gb = aSize / (1024*1024*1024);
- aSize -= gb * (1024*1024*1024);
- mb = aSize / (1024*1024);
- aSize -= mb * (1024*1024);
- kb = aSize / (1024);
- aSize -= kb * (1024);
- sb = aSize;
- if( gb )
- {
- snprintf (apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
- }
- else if( mb )
- {
- snprintf (apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb) / 1024ul ) );
- }
- else if( kb != 0ul )
- {
- snprintf (apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb) / 1024ul ) );
- }
- else
- {
- snprintf (apBuf, aLen, "%u bytes", ( unsigned ) sb);
- }
- return apBuf;
+ static char retString[ 33 ];
+ size_t gb, mb, kb, sb;
+
+ if( apBuf == NULL )
+ {
+ apBuf = retString;
+ aLen = sizeof( retString );
+ }
+
+ gb = aSize / ( 1024 * 1024 * 1024 );
+ aSize -= gb * ( 1024 * 1024 * 1024 );
+ mb = aSize / ( 1024 * 1024 );
+ aSize -= mb * ( 1024 * 1024 );
+ kb = aSize / ( 1024 );
+ aSize -= kb * ( 1024 );
+ sb = aSize;
+
+ if( gb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
+ }
+ else if( mb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb ) / 1024ul ) );
+ }
+ else if( kb != 0ul )
+ {
+ snprintf( apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb ) / 1024ul ) );
+ }
+ else
+ {
+ snprintf( apBuf, aLen, "%u bytes", ( unsigned ) sb );
+ }
+
+ return apBuf;
}
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c
index 1d4cbd916..eea317e44 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c
@@ -67,12 +67,12 @@
/**
* @brief Time to wait between each cycle of the demo implemented by prvMQTTDemoTask().
*/
-#define mqttexampleDELAY_BETWEEN_DEMO_ITERATIONS ( pdMS_TO_TICKS( 5000 ) )
+#define mqttexampleDELAY_BETWEEN_DEMO_ITERATIONS ( pdMS_TO_TICKS( 5000 ) )
/**
* @brief Time to wait before sending ping request to keep MQTT connection alive.
*/
-#define mqttexampleKEEP_ALIVE_DELAY ( pdMS_TO_TICKS( 1000 ) )
+#define mqttexampleKEEP_ALIVE_DELAY ( pdMS_TO_TICKS( 1000 ) )
/**
@@ -80,17 +80,17 @@
* must be unique so edit as required to ensure no two clients connecting to the
* same broker use the same client identifier.
*/
-#define mqttexampleCLIENT_IDENTIFIER mqttdemoprofileCLIENT_IDENTIFIER
+#define mqttexampleCLIENT_IDENTIFIER mqttdemoprofileCLIENT_IDENTIFIER
/**
* @brief Details of the MQTT broker to connect to.
*/
-#define mqttexampleMQTT_BROKER_ENDPOINT mqttdemoprofileBROKER_ENDPOINT
+#define mqttexampleMQTT_BROKER_ENDPOINT mqttdemoprofileBROKER_ENDPOINT
/**
* @brief The port to use for the demo.
*/
-#define mqttexampleMQTT_BROKER_PORT mqttdemoprofileBROKER_PORT
+#define mqttexampleMQTT_BROKER_PORT mqttdemoprofileBROKER_PORT
/**
* @brief The topic to subscribe and publish to in the example.
@@ -98,18 +98,18 @@
* The topic name starts with the client identifier to ensure that each demo
* interacts with a unique topic name.
*/
-#define mqttexampleTOPIC mqttexampleCLIENT_IDENTIFIER "/example/topic"
+#define mqttexampleTOPIC mqttexampleCLIENT_IDENTIFIER "/example/topic"
/**
* @brief The MQTT message published in this example.
*/
-#define mqttexampleMESSAGE "Hello Light Weight MQTT World!"
+#define mqttexampleMESSAGE "Hello Light Weight MQTT World!"
/**
* @brief Dimensions a file scope buffer currently used to send and receive MQTT data
* from a socket.
*/
-#define mqttexampleSHARED_BUFFER_SIZE 500
+#define mqttexampleSHARED_BUFFER_SIZE 500
/*-----------------------------------------------------------*/
@@ -232,7 +232,7 @@ static void prvMQTTProcessIncomingPacket( Socket_t xMQTTSocket );
*/
static IotMqttError_t getNextByte( IotNetworkConnection_t pvContext,
- uint8_t * pNextByte );
+ uint8_t * pNextByte );
/*-----------------------------------------------------------*/
@@ -266,586 +266,586 @@ static uint16_t usPublishPacketIdentifier;
*/
void vStartSimpleMQTTDemo( void )
{
- /* This example uses a single application task, which in turn is used to
- * connect, subscribe, publish, unsubscribe and disconnect from the MQTT
- * broker. */
- xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
- "MQTTLWDemo", /* Text name for the task - only used for debugging. */
- democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
- NULL, /* Task parameter - not used in this case. */
- tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */
- NULL ); /* Used to pass out a handle to the created task - not used in this case. */
+ /* This example uses a single application task, which in turn is used to
+ * connect, subscribe, publish, unsubscribe and disconnect from the MQTT
+ * broker. */
+ xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
+ "MQTTLWDemo", /* Text name for the task - only used for debugging. */
+ democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
+ NULL, /* Task parameter - not used in this case. */
+ tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */
+ NULL ); /* Used to pass out a handle to the created task - not used in this case. */
}
/*-----------------------------------------------------------*/
static void prvGracefulShutDown( Socket_t xSocket )
{
-uint8_t ucDummy[ 20 ];
-const TickType_t xShortDelay = pdMS_TO_MIN_TICKS( 250 );
-
- if( xSocket != ( Socket_t ) 0 )
- {
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* Initiate graceful shutdown. */
- FreeRTOS_shutdown( xSocket, FREERTOS_SHUT_RDWR );
-
- /* Wait for the socket to disconnect gracefully (indicated by FreeRTOS_recv()
- * returning a FREERTOS_EINVAL error) before closing the socket. */
- while( FreeRTOS_recv( xSocket, ucDummy, sizeof( ucDummy ), 0 ) >= 0 )
- {
- /* Wait for shutdown to complete. If a receive block time is used then
- * this delay will not be necessary as FreeRTOS_recv() will place the RTOS task
- * into the Blocked state anyway. */
- vTaskDelay( xShortDelay );
-
- /* Note a real applications should implement a timeout here, not just
- * loop forever. */
- }
-
- /* The socket has shut down and is safe to close. */
- FreeRTOS_closesocket( xSocket );
- }
- }
+ uint8_t ucDummy[ 20 ];
+ const TickType_t xShortDelay = pdMS_TO_MIN_TICKS( 250 );
+
+ if( xSocket != ( Socket_t ) 0 )
+ {
+ if( xSocket != FREERTOS_INVALID_SOCKET )
+ {
+ /* Initiate graceful shutdown. */
+ FreeRTOS_shutdown( xSocket, FREERTOS_SHUT_RDWR );
+
+ /* Wait for the socket to disconnect gracefully (indicated by FreeRTOS_recv()
+ * returning a FREERTOS_EINVAL error) before closing the socket. */
+ while( FreeRTOS_recv( xSocket, ucDummy, sizeof( ucDummy ), 0 ) >= 0 )
+ {
+ /* Wait for shutdown to complete. If a receive block time is used then
+ * this delay will not be necessary as FreeRTOS_recv() will place the RTOS task
+ * into the Blocked state anyway. */
+ vTaskDelay( xShortDelay );
+
+ /* Note a real applications should implement a timeout here, not just
+ * loop forever. */
+ }
+
+ /* The socket has shut down and is safe to close. */
+ FreeRTOS_closesocket( xSocket );
+ }
+ }
}
/*-----------------------------------------------------------*/
static IotMqttError_t getNextByte( IotNetworkConnection_t pvContext,
- uint8_t * pNextByte )
+ uint8_t * pNextByte )
{
-Socket_t xMQTTSocket = ( Socket_t ) pvContext;
-BaseType_t receivedBytes;
-IotMqttError_t result;
-
- /* Receive one byte from network. Note the use of this function may be
- deprecated before the final light weight API release. */
- receivedBytes = FreeRTOS_recv( xMQTTSocket, ( void * ) pNextByte, sizeof( uint8_t ), 0 );
-
- if( receivedBytes == sizeof( uint8_t ) )
- {
- result = IOT_MQTT_SUCCESS;
- }
- else
- {
- result = IOT_MQTT_TIMEOUT;
- }
-
- return result;
+ Socket_t xMQTTSocket = ( Socket_t ) pvContext;
+ BaseType_t receivedBytes;
+ IotMqttError_t result;
+
+ /* Receive one byte from network. Note the use of this function may be
+ * deprecated before the final light weight API release. */
+ receivedBytes = FreeRTOS_recv( xMQTTSocket, ( void * ) pNextByte, sizeof( uint8_t ), 0 );
+
+ if( receivedBytes == sizeof( uint8_t ) )
+ {
+ result = IOT_MQTT_SUCCESS;
+ }
+ else
+ {
+ result = IOT_MQTT_TIMEOUT;
+ }
+
+ return result;
}
/*-----------------------------------------------------------*/
static void prvMQTTDemoTask( void * pvParameters )
{
-Socket_t xMQTTSocket;
-uint32_t ulPublishCount = 0;
-const uint32_t ulMaxPublishCount = 5UL;
-
- /* Remove compiler warnings about unused parameters. */
- ( void ) pvParameters;
-
- for( ; ; )
- {
- /****************************** Connect. ******************************/
-
- /* Establish a TCP connection with the MQTT broker. This example connects to
- * the MQTT broker as specified in mqttexampleMQTT_BROKER_ENDPOINT and
- * mqttexampleMQTT_BROKER_PORT at the top of this file. */
- configPRINTF( ( "Create a TCP connection to %s\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
- xMQTTSocket = prvCreateTCPConnectionToBroker();
-
- /* Sends an MQTT Connect packet over the already connected TCP socket
- * xMQTTSocket, and waits for connection acknowledgment (CONNACK) packet. */
- configPRINTF( ( "Creating an MQTT connection to %s\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
- prvCreateMQTTConnectionWithBroker( xMQTTSocket );
-
- /**************************** Subscribe. ******************************/
-
- /* The client is now connected to the broker. Subscribe to the topic
- * as specified in mqttexampleTOPIC at the top of this file by sending a
- * subscribe packet then waiting for a subscribe acknowledgment (SUBACK).
- * This client will then publish to the same topic it subscribed to, so it
- * will expect all the messages it sends to the broker to be sent back to it
- * from the broker. This demo uses QOS0 in Subscribe, therefore, the Publish
- * messages received from the broker will have QOS0. */
- configPRINTF( ( "Attempt to subscribed to the MQTT topic %s\r\n", mqttexampleTOPIC ) );
- prvMQTTSubscribeToTopic( xMQTTSocket );
-
- /* Process incoming packet from the broker. After sending the subscribe, the
- * client may receive a publish before it receives a subscribe ack. Therefore,
- * call generic incoming packet processing function. Since this demo is
- * subscribing to the topic to which no one is publishing, probability of
- * receiving Publish message before subscribe ack is zero; but application
- * must be ready to receive any packet. This demo uses the generic packet
- * processing function everywhere to highlight this fact. */
- prvMQTTProcessIncomingPacket( xMQTTSocket );
-
- /**************************** Publish and Keep Alive Loop. ******************************/
- /* Publish messages with QOS0, send and process Keep alive messages. */
- for( ulPublishCount = 0; ulPublishCount < ulMaxPublishCount; ulPublishCount++ )
- {
- configPRINTF( ( "Publish to the MQTT topic %s\r\n", mqttexampleTOPIC ) );
- prvMQTTPublishToTopic( xMQTTSocket );
-
- /* Process incoming publish echo, since application subscribed to the same
- * topic the broker will send publish message back to the application. */
- configPRINTF( ( "Attempt to receive publish message from broker\r\n" ) );
- prvMQTTProcessIncomingPacket( xMQTTSocket );
-
- /* Leave Connection Idle for some time */
- configPRINTF( ( "Keeping Connection Idle\r\n" ) );
- vTaskDelay( pdMS_TO_TICKS( mqttexampleKEEP_ALIVE_DELAY ) );
-
- /* Send Ping request to broker and receive ping response */
- configPRINTF( ( "Sending Ping Request to the broker\r\n" ) );
- prvMQTTKeepAlive( xMQTTSocket );
-
- /* Process Incoming packet from the broker */
- prvMQTTProcessIncomingPacket( xMQTTSocket );
- }
-
- /************************ Unsubscribe from the topic. **************************/
- configPRINTF( ( "Unsubscribe from the MQTT topic %s.\r\n", mqttexampleTOPIC ) );
- prvMQTTUnsubscribeFromTopic( xMQTTSocket );
-
- /* Process Incoming packet from the broker. */
- prvMQTTProcessIncomingPacket( xMQTTSocket );
-
- /**************************** Disconnect. ******************************/
-
- /* Send an MQTT Disconnect packet over the already connected TCP socket.
- * There is no corresponding response for the disconnect packet. After sending
- * disconnect, client must close the network connection. */
- configPRINTF( ( "Disconnecting the MQTT connection with %s.\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
- prvMQTTDisconnect( xMQTTSocket );
-
- /* Close the network connection. */
- prvGracefulShutDown( xMQTTSocket );
-
- /* Wait for some time between two iterations to ensure that we do not
- * bombard the public test mosquitto broker. */
- configPRINTF( ( "prvMQTTDemoTask() completed an iteration successfully. Total free heap is %u\r\n", xPortGetFreeHeapSize() ) );
- configPRINTF( ( "Demo completed successfully.\r\n" ) );
- configPRINTF( ( "Short delay before starting the next iteration.... \r\n\r\n" ) );
- vTaskDelay( pdMS_TO_TICKS( mqttexampleDELAY_BETWEEN_DEMO_ITERATIONS ) );
- }
+ Socket_t xMQTTSocket;
+ uint32_t ulPublishCount = 0;
+ const uint32_t ulMaxPublishCount = 5UL;
+
+ /* Remove compiler warnings about unused parameters. */
+ ( void ) pvParameters;
+
+ for( ; ; )
+ {
+ /****************************** Connect. ******************************/
+
+ /* Establish a TCP connection with the MQTT broker. This example connects to
+ * the MQTT broker as specified in mqttexampleMQTT_BROKER_ENDPOINT and
+ * mqttexampleMQTT_BROKER_PORT at the top of this file. */
+ configPRINTF( ( "Create a TCP connection to %s\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
+ xMQTTSocket = prvCreateTCPConnectionToBroker();
+
+ /* Sends an MQTT Connect packet over the already connected TCP socket
+ * xMQTTSocket, and waits for connection acknowledgment (CONNACK) packet. */
+ configPRINTF( ( "Creating an MQTT connection to %s\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
+ prvCreateMQTTConnectionWithBroker( xMQTTSocket );
+
+ /**************************** Subscribe. ******************************/
+
+ /* The client is now connected to the broker. Subscribe to the topic
+ * as specified in mqttexampleTOPIC at the top of this file by sending a
+ * subscribe packet then waiting for a subscribe acknowledgment (SUBACK).
+ * This client will then publish to the same topic it subscribed to, so it
+ * will expect all the messages it sends to the broker to be sent back to it
+ * from the broker. This demo uses QOS0 in Subscribe, therefore, the Publish
+ * messages received from the broker will have QOS0. */
+ configPRINTF( ( "Attempt to subscribed to the MQTT topic %s\r\n", mqttexampleTOPIC ) );
+ prvMQTTSubscribeToTopic( xMQTTSocket );
+
+ /* Process incoming packet from the broker. After sending the subscribe, the
+ * client may receive a publish before it receives a subscribe ack. Therefore,
+ * call generic incoming packet processing function. Since this demo is
+ * subscribing to the topic to which no one is publishing, probability of
+ * receiving Publish message before subscribe ack is zero; but application
+ * must be ready to receive any packet. This demo uses the generic packet
+ * processing function everywhere to highlight this fact. */
+ prvMQTTProcessIncomingPacket( xMQTTSocket );
+
+ /**************************** Publish and Keep Alive Loop. ******************************/
+ /* Publish messages with QOS0, send and process Keep alive messages. */
+ for( ulPublishCount = 0; ulPublishCount < ulMaxPublishCount; ulPublishCount++ )
+ {
+ configPRINTF( ( "Publish to the MQTT topic %s\r\n", mqttexampleTOPIC ) );
+ prvMQTTPublishToTopic( xMQTTSocket );
+
+ /* Process incoming publish echo, since application subscribed to the same
+ * topic the broker will send publish message back to the application. */
+ configPRINTF( ( "Attempt to receive publish message from broker\r\n" ) );
+ prvMQTTProcessIncomingPacket( xMQTTSocket );
+
+ /* Leave Connection Idle for some time */
+ configPRINTF( ( "Keeping Connection Idle\r\n" ) );
+ vTaskDelay( pdMS_TO_TICKS( mqttexampleKEEP_ALIVE_DELAY ) );
+
+ /* Send Ping request to broker and receive ping response */
+ configPRINTF( ( "Sending Ping Request to the broker\r\n" ) );
+ prvMQTTKeepAlive( xMQTTSocket );
+
+ /* Process Incoming packet from the broker */
+ prvMQTTProcessIncomingPacket( xMQTTSocket );
+ }
+
+ /************************ Unsubscribe from the topic. **************************/
+ configPRINTF( ( "Unsubscribe from the MQTT topic %s.\r\n", mqttexampleTOPIC ) );
+ prvMQTTUnsubscribeFromTopic( xMQTTSocket );
+
+ /* Process Incoming packet from the broker. */
+ prvMQTTProcessIncomingPacket( xMQTTSocket );
+
+ /**************************** Disconnect. ******************************/
+
+ /* Send an MQTT Disconnect packet over the already connected TCP socket.
+ * There is no corresponding response for the disconnect packet. After sending
+ * disconnect, client must close the network connection. */
+ configPRINTF( ( "Disconnecting the MQTT connection with %s.\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
+ prvMQTTDisconnect( xMQTTSocket );
+
+ /* Close the network connection. */
+ prvGracefulShutDown( xMQTTSocket );
+
+ /* Wait for some time between two iterations to ensure that we do not
+ * bombard the public test mosquitto broker. */
+ configPRINTF( ( "prvMQTTDemoTask() completed an iteration successfully. Total free heap is %u\r\n", xPortGetFreeHeapSize() ) );
+ configPRINTF( ( "Demo completed successfully.\r\n" ) );
+ configPRINTF( ( "Short delay before starting the next iteration.... \r\n\r\n" ) );
+ vTaskDelay( pdMS_TO_TICKS( mqttexampleDELAY_BETWEEN_DEMO_ITERATIONS ) );
+ }
}
/*-----------------------------------------------------------*/
static Socket_t prvCreateTCPConnectionToBroker( void )
{
-Socket_t xMQTTSocket = FREERTOS_INVALID_SOCKET;
-struct freertos_sockaddr xBrokerAddress;
-uint32_t ulBrokerIPAddress;
-BaseType_t xStatus = pdFAIL;
-
- /* This is the socket used to connect to the MQTT broker. */
- xMQTTSocket = FreeRTOS_socket( FREERTOS_AF_INET,
- FREERTOS_SOCK_STREAM,
- FREERTOS_IPPROTO_TCP );
-
- if( xMQTTSocket != FREERTOS_INVALID_SOCKET )
- {
- /* Socket was created. Locate then connect to the MQTT broker. */
- ulBrokerIPAddress = FreeRTOS_gethostbyname( mqttexampleMQTT_BROKER_ENDPOINT );
-
- if( ulBrokerIPAddress != 0 )
- {
- xBrokerAddress.sin_port = FreeRTOS_htons( mqttexampleMQTT_BROKER_PORT );
- xBrokerAddress.sin_addr = ulBrokerIPAddress;
-
- if( FreeRTOS_connect( xMQTTSocket, &xBrokerAddress, sizeof( xBrokerAddress ) ) == 0 )
- {
- /* Connection was successful. */
- xStatus = pdPASS;
- }
- else
- {
- configPRINTF( ( "Located but could not connect to MQTT broker %s.\r\n\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
- }
- }
- else
- {
- configPRINTF( ( "Could not locate MQTT broker %s.\r\n\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
- }
- }
- else
- {
- configPRINTF( ( "Could not create TCP socket.\r\n\r\n" ) );
- }
-
- /* If the socket was created but the connection was not successful then delete
- the socket again. */
- if( xStatus == pdFAIL )
- {
- if( xMQTTSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_closesocket( xMQTTSocket );
- xMQTTSocket = FREERTOS_INVALID_SOCKET;
- }
- }
-
- return xMQTTSocket;
+ Socket_t xMQTTSocket = FREERTOS_INVALID_SOCKET;
+ struct freertos_sockaddr xBrokerAddress;
+ uint32_t ulBrokerIPAddress;
+ BaseType_t xStatus = pdFAIL;
+
+ /* This is the socket used to connect to the MQTT broker. */
+ xMQTTSocket = FreeRTOS_socket( FREERTOS_AF_INET,
+ FREERTOS_SOCK_STREAM,
+ FREERTOS_IPPROTO_TCP );
+
+ if( xMQTTSocket != FREERTOS_INVALID_SOCKET )
+ {
+ /* Socket was created. Locate then connect to the MQTT broker. */
+ ulBrokerIPAddress = FreeRTOS_gethostbyname( mqttexampleMQTT_BROKER_ENDPOINT );
+
+ if( ulBrokerIPAddress != 0 )
+ {
+ xBrokerAddress.sin_port = FreeRTOS_htons( mqttexampleMQTT_BROKER_PORT );
+ xBrokerAddress.sin_addr = ulBrokerIPAddress;
+
+ if( FreeRTOS_connect( xMQTTSocket, &xBrokerAddress, sizeof( xBrokerAddress ) ) == 0 )
+ {
+ /* Connection was successful. */
+ xStatus = pdPASS;
+ }
+ else
+ {
+ configPRINTF( ( "Located but could not connect to MQTT broker %s.\r\n\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
+ }
+ }
+ else
+ {
+ configPRINTF( ( "Could not locate MQTT broker %s.\r\n\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
+ }
+ }
+ else
+ {
+ configPRINTF( ( "Could not create TCP socket.\r\n\r\n" ) );
+ }
+
+ /* If the socket was created but the connection was not successful then delete
+ * the socket again. */
+ if( xStatus == pdFAIL )
+ {
+ if( xMQTTSocket != FREERTOS_INVALID_SOCKET )
+ {
+ FreeRTOS_closesocket( xMQTTSocket );
+ xMQTTSocket = FREERTOS_INVALID_SOCKET;
+ }
+ }
+
+ return xMQTTSocket;
}
/*-----------------------------------------------------------*/
static void prvCreateMQTTConnectionWithBroker( Socket_t xMQTTSocket )
{
-IotMqttConnectInfo_t xConnectInfo;
-size_t xRemainingLength;
-size_t xPacketSize;
-IotMqttError_t xResult;
-IotMqttPacketInfo_t xIncomingPacket;
-BaseType_t xStatus;
-
- /***
- * For readability, error handling in this function is restricted to the use of
- * asserts().
- ***/
-
- /* Many fields not used in this demo so start with everything at 0. */
- memset( ( void * ) &xConnectInfo, 0x00, sizeof( xConnectInfo ) );
-
- /* Start with a clean session i.e. direct the MQTT broker to discard any
- * previous session data. Also, establishing a connection with clean session
- * will ensure that the broker does not store any data when this client
- * gets disconnected. */
- xConnectInfo.cleanSession = true;
-
- /* The client identifier is used to uniquely identify this MQTT client to
- * the MQTT broker. In a production device the identifier can be something
- * unique, such as a device serial number. */
- xConnectInfo.pClientIdentifier = mqttexampleCLIENT_IDENTIFIER;
- xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( mqttexampleCLIENT_IDENTIFIER );
-
- /* Get size requirement for the connect packet */
- xResult = IotMqtt_GetConnectPacketSize( &xConnectInfo, &xRemainingLength, &xPacketSize );
-
- /* Make sure the packet size is less than static buffer size. */
- configASSERT( xResult == IOT_MQTT_SUCCESS );
- configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE );
-
- /* Serialize MQTT connect packet into the provided buffer. */
- xResult = IotMqtt_SerializeConnect( &xConnectInfo, xRemainingLength, ucSharedBuffer, xPacketSize );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 );
- configASSERT( xStatus == ( BaseType_t ) xPacketSize );
-
- /* Reset all fields of the incoming packet structure. */
- memset( ( void * ) &xIncomingPacket, 0x00, sizeof( IotMqttPacketInfo_t ) );
-
- /* Wait for connection acknowledgment. We cannot assume received data is the
- * connection acknowledgment. Therefore this function reads type and remaining
- * length of the received packet, before processing entire packet - although in
- * this case to keep the example simple error checks are just performed by
- * asserts.
- */
- xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
- configASSERT( xIncomingPacket.type == MQTT_PACKET_TYPE_CONNACK );
- configASSERT( xIncomingPacket.remainingLength <= mqttexampleSHARED_BUFFER_SIZE );
-
- /* Now receive the reset of the packet into the statically allocated buffer. */
- xStatus = FreeRTOS_recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 );
- configASSERT( xStatus == ( BaseType_t ) xIncomingPacket.remainingLength );
-
- xIncomingPacket.pRemainingData = ucSharedBuffer;
- xResult = IotMqtt_DeserializeResponse( &xIncomingPacket );
-
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- if( xResult != IOT_MQTT_SUCCESS )
- {
- configPRINTF( ( "Connection with MQTT broker failed.\r\n" ) );
- }
+ IotMqttConnectInfo_t xConnectInfo;
+ size_t xRemainingLength;
+ size_t xPacketSize;
+ IotMqttError_t xResult;
+ IotMqttPacketInfo_t xIncomingPacket;
+ BaseType_t xStatus;
+
+ /***
+ * For readability, error handling in this function is restricted to the use of
+ * asserts().
+ ***/
+
+ /* Many fields not used in this demo so start with everything at 0. */
+ memset( ( void * ) &xConnectInfo, 0x00, sizeof( xConnectInfo ) );
+
+ /* Start with a clean session i.e. direct the MQTT broker to discard any
+ * previous session data. Also, establishing a connection with clean session
+ * will ensure that the broker does not store any data when this client
+ * gets disconnected. */
+ xConnectInfo.cleanSession = true;
+
+ /* The client identifier is used to uniquely identify this MQTT client to
+ * the MQTT broker. In a production device the identifier can be something
+ * unique, such as a device serial number. */
+ xConnectInfo.pClientIdentifier = mqttexampleCLIENT_IDENTIFIER;
+ xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( mqttexampleCLIENT_IDENTIFIER );
+
+ /* Get size requirement for the connect packet */
+ xResult = IotMqtt_GetConnectPacketSize( &xConnectInfo, &xRemainingLength, &xPacketSize );
+
+ /* Make sure the packet size is less than static buffer size. */
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+ configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE );
+
+ /* Serialize MQTT connect packet into the provided buffer. */
+ xResult = IotMqtt_SerializeConnect( &xConnectInfo, xRemainingLength, ucSharedBuffer, xPacketSize );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 );
+ configASSERT( xStatus == ( BaseType_t ) xPacketSize );
+
+ /* Reset all fields of the incoming packet structure. */
+ memset( ( void * ) &xIncomingPacket, 0x00, sizeof( IotMqttPacketInfo_t ) );
+
+ /* Wait for connection acknowledgment. We cannot assume received data is the
+ * connection acknowledgment. Therefore this function reads type and remaining
+ * length of the received packet, before processing entire packet - although in
+ * this case to keep the example simple error checks are just performed by
+ * asserts.
+ */
+ xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+ configASSERT( xIncomingPacket.type == MQTT_PACKET_TYPE_CONNACK );
+ configASSERT( xIncomingPacket.remainingLength <= mqttexampleSHARED_BUFFER_SIZE );
+
+ /* Now receive the reset of the packet into the statically allocated buffer. */
+ xStatus = FreeRTOS_recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 );
+ configASSERT( xStatus == ( BaseType_t ) xIncomingPacket.remainingLength );
+
+ xIncomingPacket.pRemainingData = ucSharedBuffer;
+ xResult = IotMqtt_DeserializeResponse( &xIncomingPacket );
+
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ if( xResult != IOT_MQTT_SUCCESS )
+ {
+ configPRINTF( ( "Connection with MQTT broker failed.\r\n" ) );
+ }
}
/*-----------------------------------------------------------*/
static void prvMQTTSubscribeToTopic( Socket_t xMQTTSocket )
{
-IotMqttError_t xResult;
-IotMqttSubscription_t xMQTTSubscription[ 1 ];
-size_t xRemainingLength;
-size_t xPacketSize;
-BaseType_t xStatus;
-
- /***
- * For readability, error handling in this function is restricted to the use of
- * asserts().
- ***/
-
- /* Some fields not used by this demo so start with everything at 0. */
- memset( ( void * ) &xMQTTSubscription, 0x00, sizeof( xMQTTSubscription ) );
-
- /* Subscribe to the mqttexampleTOPIC topic filter. This example subscribes to
- * only one topic and uses QOS0. */
- xMQTTSubscription[ 0 ].qos = IOT_MQTT_QOS_0;
- xMQTTSubscription[ 0 ].pTopicFilter = mqttexampleTOPIC;
- xMQTTSubscription[ 0 ].topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
-
- xResult = IotMqtt_GetSubscriptionPacketSize( IOT_MQTT_SUBSCRIBE,
- xMQTTSubscription,
- sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ),
- &xRemainingLength, &xPacketSize );
-
- /* Make sure the packet size is less than static buffer size. */
- configASSERT( xResult == IOT_MQTT_SUCCESS );
- configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE );
-
- /* Serialize subscribe into statically allocated ucSharedBuffer. */
- xResult = IotMqtt_SerializeSubscribe( xMQTTSubscription,
- sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ),
- xRemainingLength,
- &usSubscribePacketIdentifier,
- ucSharedBuffer,
- xPacketSize );
-
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- /* Send Subscribe request to the broker. */
- xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 );
- configASSERT( xStatus == ( BaseType_t ) xPacketSize );
+ IotMqttError_t xResult;
+ IotMqttSubscription_t xMQTTSubscription[ 1 ];
+ size_t xRemainingLength;
+ size_t xPacketSize;
+ BaseType_t xStatus;
+
+ /***
+ * For readability, error handling in this function is restricted to the use of
+ * asserts().
+ ***/
+
+ /* Some fields not used by this demo so start with everything at 0. */
+ memset( ( void * ) &xMQTTSubscription, 0x00, sizeof( xMQTTSubscription ) );
+
+ /* Subscribe to the mqttexampleTOPIC topic filter. This example subscribes to
+ * only one topic and uses QOS0. */
+ xMQTTSubscription[ 0 ].qos = IOT_MQTT_QOS_0;
+ xMQTTSubscription[ 0 ].pTopicFilter = mqttexampleTOPIC;
+ xMQTTSubscription[ 0 ].topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
+
+ xResult = IotMqtt_GetSubscriptionPacketSize( IOT_MQTT_SUBSCRIBE,
+ xMQTTSubscription,
+ sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ),
+ &xRemainingLength, &xPacketSize );
+
+ /* Make sure the packet size is less than static buffer size. */
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+ configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE );
+
+ /* Serialize subscribe into statically allocated ucSharedBuffer. */
+ xResult = IotMqtt_SerializeSubscribe( xMQTTSubscription,
+ sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ),
+ xRemainingLength,
+ &usSubscribePacketIdentifier,
+ ucSharedBuffer,
+ xPacketSize );
+
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ /* Send Subscribe request to the broker. */
+ xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 );
+ configASSERT( xStatus == ( BaseType_t ) xPacketSize );
}
/*-----------------------------------------------------------*/
static void prvMQTTPublishToTopic( Socket_t xMQTTSocket )
{
-IotMqttError_t xResult;
-IotMqttPublishInfo_t xMQTTPublishInfo;
-size_t xRemainingLength;
-size_t xPacketSize = 0;
-uint8_t * pusPacketIdentifierHigh;
-BaseType_t xStatus;
-
-
- /***
- * For readability, error handling in this function is restricted to the use of
- * asserts().
- ***/
-
- /* Some fields not used by this demo so start with everything at 0. */
- memset( ( void * ) &xMQTTPublishInfo, 0x00, sizeof( xMQTTPublishInfo ) );
-
- /* This demo uses QOS0 */
- xMQTTPublishInfo.qos = IOT_MQTT_QOS_0;
- xMQTTPublishInfo.retain = false;
- xMQTTPublishInfo.pTopicName = mqttexampleTOPIC;
- xMQTTPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC );
- xMQTTPublishInfo.pPayload = mqttexampleMESSAGE;
- xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE );
-
- /* Find out length of Publish packet size. */
- xResult = IotMqtt_GetPublishPacketSize( &xMQTTPublishInfo, &xRemainingLength, &xPacketSize );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- /* Make sure the packet size is less than static buffer size. */
- configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE );
-
- xResult = IotMqtt_SerializePublish( &xMQTTPublishInfo,
- xRemainingLength,
- &usPublishPacketIdentifier,
- &pusPacketIdentifierHigh,
- ucSharedBuffer,
- xPacketSize );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- /* Send Publish message to the broker. */
- xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 );
- configASSERT( xStatus == ( BaseType_t ) xPacketSize );
+ IotMqttError_t xResult;
+ IotMqttPublishInfo_t xMQTTPublishInfo;
+ size_t xRemainingLength;
+ size_t xPacketSize = 0;
+ uint8_t * pusPacketIdentifierHigh;
+ BaseType_t xStatus;
+
+
+ /***
+ * For readability, error handling in this function is restricted to the use of
+ * asserts().
+ ***/
+
+ /* Some fields not used by this demo so start with everything at 0. */
+ memset( ( void * ) &xMQTTPublishInfo, 0x00, sizeof( xMQTTPublishInfo ) );
+
+ /* This demo uses QOS0 */
+ xMQTTPublishInfo.qos = IOT_MQTT_QOS_0;
+ xMQTTPublishInfo.retain = false;
+ xMQTTPublishInfo.pTopicName = mqttexampleTOPIC;
+ xMQTTPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC );
+ xMQTTPublishInfo.pPayload = mqttexampleMESSAGE;
+ xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE );
+
+ /* Find out length of Publish packet size. */
+ xResult = IotMqtt_GetPublishPacketSize( &xMQTTPublishInfo, &xRemainingLength, &xPacketSize );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ /* Make sure the packet size is less than static buffer size. */
+ configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE );
+
+ xResult = IotMqtt_SerializePublish( &xMQTTPublishInfo,
+ xRemainingLength,
+ &usPublishPacketIdentifier,
+ &pusPacketIdentifierHigh,
+ ucSharedBuffer,
+ xPacketSize );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ /* Send Publish message to the broker. */
+ xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 );
+ configASSERT( xStatus == ( BaseType_t ) xPacketSize );
}
/*-----------------------------------------------------------*/
static void prvMQTTUnsubscribeFromTopic( Socket_t xMQTTSocket )
{
-IotMqttError_t xResult;
-IotMqttSubscription_t xMQTTSubscription[ 1 ];
-size_t xRemainingLength;
-size_t xPacketSize;
-BaseType_t xStatus;
-
- /* Some fields not used by this demo so start with everything at 0. */
- memset( ( void * ) &xMQTTSubscription, 0x00, sizeof( xMQTTSubscription ) );
-
- /* Unsubscribe to the mqttexampleTOPIC topic filter. The task handle is passed
- * as the callback context which is used by the callback to send a task
- * notification to this task.*/
- xMQTTSubscription[ 0 ].qos = IOT_MQTT_QOS_0;
- xMQTTSubscription[ 0 ].pTopicFilter = mqttexampleTOPIC;
- xMQTTSubscription[ 0 ].topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
-
- xResult = IotMqtt_GetSubscriptionPacketSize( IOT_MQTT_UNSUBSCRIBE,
- xMQTTSubscription,
- sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ),
- &xRemainingLength,
- &xPacketSize );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
- /* Make sure the packet size is less than static buffer size */
- configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE );
-
- xResult = IotMqtt_SerializeUnsubscribe( xMQTTSubscription,
- sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ),
- xRemainingLength,
- &usUnsubscribePacketIdentifier,
- ucSharedBuffer,
- xPacketSize );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- /* Send Unsubscribe request to the broker. */
- xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 );
- configASSERT( xStatus == ( BaseType_t ) xPacketSize );
+ IotMqttError_t xResult;
+ IotMqttSubscription_t xMQTTSubscription[ 1 ];
+ size_t xRemainingLength;
+ size_t xPacketSize;
+ BaseType_t xStatus;
+
+ /* Some fields not used by this demo so start with everything at 0. */
+ memset( ( void * ) &xMQTTSubscription, 0x00, sizeof( xMQTTSubscription ) );
+
+ /* Unsubscribe to the mqttexampleTOPIC topic filter. The task handle is passed
+ * as the callback context which is used by the callback to send a task
+ * notification to this task.*/
+ xMQTTSubscription[ 0 ].qos = IOT_MQTT_QOS_0;
+ xMQTTSubscription[ 0 ].pTopicFilter = mqttexampleTOPIC;
+ xMQTTSubscription[ 0 ].topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
+
+ xResult = IotMqtt_GetSubscriptionPacketSize( IOT_MQTT_UNSUBSCRIBE,
+ xMQTTSubscription,
+ sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ),
+ &xRemainingLength,
+ &xPacketSize );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+ /* Make sure the packet size is less than static buffer size */
+ configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE );
+
+ xResult = IotMqtt_SerializeUnsubscribe( xMQTTSubscription,
+ sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ),
+ xRemainingLength,
+ &usUnsubscribePacketIdentifier,
+ ucSharedBuffer,
+ xPacketSize );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ /* Send Unsubscribe request to the broker. */
+ xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 );
+ configASSERT( xStatus == ( BaseType_t ) xPacketSize );
}
/*-----------------------------------------------------------*/
static void prvMQTTKeepAlive( Socket_t xMQTTSocket )
{
-IotMqttError_t xResult;
-BaseType_t xStatus;
+ IotMqttError_t xResult;
+ BaseType_t xStatus;
- /* PingReq is fixed length packet, therefore there is no need to calculate the size,
- * just makes sure static buffer can accommodate ping request. */
- configASSERT( MQTT_PACKET_PINGREQ_SIZE <= mqttexampleSHARED_BUFFER_SIZE );
+ /* PingReq is fixed length packet, therefore there is no need to calculate the size,
+ * just makes sure static buffer can accommodate ping request. */
+ configASSERT( MQTT_PACKET_PINGREQ_SIZE <= mqttexampleSHARED_BUFFER_SIZE );
- xResult = IotMqtt_SerializePingreq( ucSharedBuffer, MQTT_PACKET_PINGREQ_SIZE );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
+ xResult = IotMqtt_SerializePingreq( ucSharedBuffer, MQTT_PACKET_PINGREQ_SIZE );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
- /* Send Ping Request to the broker. */
- xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, MQTT_PACKET_PINGREQ_SIZE, 0 );
- configASSERT( xStatus == ( BaseType_t ) MQTT_PACKET_PINGREQ_SIZE );
+ /* Send Ping Request to the broker. */
+ xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, MQTT_PACKET_PINGREQ_SIZE, 0 );
+ configASSERT( xStatus == ( BaseType_t ) MQTT_PACKET_PINGREQ_SIZE );
}
/*-----------------------------------------------------------*/
static void prvMQTTDisconnect( Socket_t xMQTTSocket )
{
-IotMqttError_t xResult;
-BaseType_t xStatus;
+ IotMqttError_t xResult;
+ BaseType_t xStatus;
- /* Disconnect is fixed length packet, therefore there is no need to calculate the size,
- * just makes sure static buffer can accommodate disconnect request. */
- configASSERT( MQTT_PACKET_DISCONNECT_SIZE <= mqttexampleSHARED_BUFFER_SIZE );
+ /* Disconnect is fixed length packet, therefore there is no need to calculate the size,
+ * just makes sure static buffer can accommodate disconnect request. */
+ configASSERT( MQTT_PACKET_DISCONNECT_SIZE <= mqttexampleSHARED_BUFFER_SIZE );
- xResult = IotMqtt_SerializeDisconnect( ucSharedBuffer, MQTT_PACKET_DISCONNECT_SIZE );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
+ xResult = IotMqtt_SerializeDisconnect( ucSharedBuffer, MQTT_PACKET_DISCONNECT_SIZE );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
- xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, MQTT_PACKET_DISCONNECT_SIZE, 0 );
- configASSERT( xStatus == ( BaseType_t ) MQTT_PACKET_DISCONNECT_SIZE );
+ xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, MQTT_PACKET_DISCONNECT_SIZE, 0 );
+ configASSERT( xStatus == ( BaseType_t ) MQTT_PACKET_DISCONNECT_SIZE );
}
/*-----------------------------------------------------------*/
static void prvMQTTProcessResponse( IotMqttPacketInfo_t * pxIncomingPacket )
{
- switch( pxIncomingPacket->type & 0xf0 )
- {
- case MQTT_PACKET_TYPE_SUBACK:
- configPRINTF( ( "Subscribed to the topic %s.\r\n", mqttexampleTOPIC ) );
- /* Make sure ACK packet identifier matches with Request packet identifier. */
- configASSERT( usSubscribePacketIdentifier == pxIncomingPacket->packetIdentifier );
- break;
-
- case MQTT_PACKET_TYPE_UNSUBACK:
- configPRINTF( ( "Unsubscribed from the topic %s.\r\n", mqttexampleTOPIC ) );
- /* Make sure ACK packet identifier matches with Request packet identifier. */
- configASSERT( usUnsubscribePacketIdentifier == pxIncomingPacket->packetIdentifier );
- break;
-
- case MQTT_PACKET_TYPE_PINGRESP:
- configPRINTF( ( "Ping Response successfully received.\r\n" ) );
- break;
-
- /* Any other packet type is invalid. */
- default:
- configPRINTF( ( "prvMQTTProcessResponse() called with unknown packet type:(%lu).", pxIncomingPacket->type ) );
- }
+ switch( pxIncomingPacket->type & 0xf0 )
+ {
+ case MQTT_PACKET_TYPE_SUBACK:
+ configPRINTF( ( "Subscribed to the topic %s.\r\n", mqttexampleTOPIC ) );
+ /* Make sure ACK packet identifier matches with Request packet identifier. */
+ configASSERT( usSubscribePacketIdentifier == pxIncomingPacket->packetIdentifier );
+ break;
+
+ case MQTT_PACKET_TYPE_UNSUBACK:
+ configPRINTF( ( "Unsubscribed from the topic %s.\r\n", mqttexampleTOPIC ) );
+ /* Make sure ACK packet identifier matches with Request packet identifier. */
+ configASSERT( usUnsubscribePacketIdentifier == pxIncomingPacket->packetIdentifier );
+ break;
+
+ case MQTT_PACKET_TYPE_PINGRESP:
+ configPRINTF( ( "Ping Response successfully received.\r\n" ) );
+ break;
+
+ /* Any other packet type is invalid. */
+ default:
+ configPRINTF( ( "prvMQTTProcessResponse() called with unknown packet type:(%lu).", pxIncomingPacket->type ) );
+ }
}
/*-----------------------------------------------------------*/
static void prvMQTTProcessIncomingPublish( IotMqttPacketInfo_t * pxIncomingPacket )
{
- configASSERT( pxIncomingPacket != NULL );
-
- /* Process incoming Publish. */
- configPRINTF( ( "Incoming QOS : %d\n", pxIncomingPacket->pubInfo.qos ) );
-
- /* Verify the received publish is for the we have subscribed to. */
- if( ( pxIncomingPacket->pubInfo.topicNameLength == strlen( mqttexampleTOPIC ) ) &&
- ( 0 == strncmp( mqttexampleTOPIC, pxIncomingPacket->pubInfo.pTopicName, pxIncomingPacket->pubInfo.topicNameLength ) ) )
- {
- configPRINTF( ( "Incoming Publish Topic Name: %.*s matches subscribed topic.\n",
- pxIncomingPacket->pubInfo.topicNameLength,
- pxIncomingPacket->pubInfo.pTopicName ) );
- configPRINTF( ( "Incoming Publish Message : %.*s\n",
- pxIncomingPacket->pubInfo.payloadLength,
- pxIncomingPacket->pubInfo.pPayload ) );
-
- /* Check if the incoming Publish message is echo of the last Publish message
- * we sent out. */
- if( pxIncomingPacket->packetIdentifier != usPublishPacketIdentifier )
- {
- configPRINTF( ( "Incoming Publish has different packet identifier than outgoing Publish.\n" ) );
- }
- else
- {
- configPRINTF( ( "Incoming Publish packet identifier matches with outgoing Publish. \n" ) );
- }
- }
- else
- {
- configPRINTF( ( "Incoming Publish Topic Name: %.*s does not match subscribed topic. \n",
- pxIncomingPacket->pubInfo.topicNameLength,
- pxIncomingPacket->pubInfo.pTopicName ) );
- }
+ configASSERT( pxIncomingPacket != NULL );
+
+ /* Process incoming Publish. */
+ configPRINTF( ( "Incoming QOS : %d\n", pxIncomingPacket->pubInfo.qos ) );
+
+ /* Verify the received publish is for the we have subscribed to. */
+ if( ( pxIncomingPacket->pubInfo.topicNameLength == strlen( mqttexampleTOPIC ) ) &&
+ ( 0 == strncmp( mqttexampleTOPIC, pxIncomingPacket->pubInfo.pTopicName, pxIncomingPacket->pubInfo.topicNameLength ) ) )
+ {
+ configPRINTF( ( "Incoming Publish Topic Name: %.*s matches subscribed topic.\n",
+ pxIncomingPacket->pubInfo.topicNameLength,
+ pxIncomingPacket->pubInfo.pTopicName ) );
+ configPRINTF( ( "Incoming Publish Message : %.*s\n",
+ pxIncomingPacket->pubInfo.payloadLength,
+ pxIncomingPacket->pubInfo.pPayload ) );
+
+ /* Check if the incoming Publish message is echo of the last Publish message
+ * we sent out. */
+ if( pxIncomingPacket->packetIdentifier != usPublishPacketIdentifier )
+ {
+ configPRINTF( ( "Incoming Publish has different packet identifier than outgoing Publish.\n" ) );
+ }
+ else
+ {
+ configPRINTF( ( "Incoming Publish packet identifier matches with outgoing Publish. \n" ) );
+ }
+ }
+ else
+ {
+ configPRINTF( ( "Incoming Publish Topic Name: %.*s does not match subscribed topic. \n",
+ pxIncomingPacket->pubInfo.topicNameLength,
+ pxIncomingPacket->pubInfo.pTopicName ) );
+ }
}
/*-----------------------------------------------------------*/
static void prvMQTTProcessIncomingPacket( Socket_t xMQTTSocket )
{
-IotMqttError_t xResult;
-IotMqttPacketInfo_t xIncomingPacket;
-BaseType_t xStatus;
-
- /***
- * For readability, error handling in this function is restricted to the use of
- * asserts().
- ***/
-
- memset( ( void * ) &xIncomingPacket, 0x00, sizeof( IotMqttPacketInfo_t ) );
-
- /* Determine incoming packet type and remaining length. */
- xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
- configASSERT( xIncomingPacket.remainingLength <= mqttexampleSHARED_BUFFER_SIZE );
-
- /* Current implementation expects an incoming Publish and three different
- * responses ( SUBACK, PINGRESP and UNSUBACK ). */
-
- /* Receive the remaining bytes. */
- xStatus = FreeRTOS_recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 );
- configASSERT( xStatus == ( BaseType_t ) xIncomingPacket.remainingLength );
-
- xIncomingPacket.pRemainingData = ucSharedBuffer;
-
- if( ( xIncomingPacket.type & 0xf0 ) == MQTT_PACKET_TYPE_PUBLISH )
- {
- xResult = IotMqtt_DeserializePublish( &xIncomingPacket );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- /* Process incoming Publish message. */
- prvMQTTProcessIncomingPublish( &xIncomingPacket );
- }
- else
- {
- /* If the received packet is not a Publish message, then it is an ACK for one
- * of the messages we sent out, verify that the ACK packet is a valid MQTT
- * packet. */
- xResult = IotMqtt_DeserializeResponse( &xIncomingPacket );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
-
- /* Process the response. */
- prvMQTTProcessResponse( &xIncomingPacket );
- }
+ IotMqttError_t xResult;
+ IotMqttPacketInfo_t xIncomingPacket;
+ BaseType_t xStatus;
+
+ /***
+ * For readability, error handling in this function is restricted to the use of
+ * asserts().
+ ***/
+
+ memset( ( void * ) &xIncomingPacket, 0x00, sizeof( IotMqttPacketInfo_t ) );
+
+ /* Determine incoming packet type and remaining length. */
+ xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+ configASSERT( xIncomingPacket.remainingLength <= mqttexampleSHARED_BUFFER_SIZE );
+
+ /* Current implementation expects an incoming Publish and three different
+ * responses ( SUBACK, PINGRESP and UNSUBACK ). */
+
+ /* Receive the remaining bytes. */
+ xStatus = FreeRTOS_recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 );
+ configASSERT( xStatus == ( BaseType_t ) xIncomingPacket.remainingLength );
+
+ xIncomingPacket.pRemainingData = ucSharedBuffer;
+
+ if( ( xIncomingPacket.type & 0xf0 ) == MQTT_PACKET_TYPE_PUBLISH )
+ {
+ xResult = IotMqtt_DeserializePublish( &xIncomingPacket );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ /* Process incoming Publish message. */
+ prvMQTTProcessIncomingPublish( &xIncomingPacket );
+ }
+ else
+ {
+ /* If the received packet is not a Publish message, then it is an ACK for one
+ * of the messages we sent out, verify that the ACK packet is a valid MQTT
+ * packet. */
+ xResult = IotMqtt_DeserializeResponse( &xIncomingPacket );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
+
+ /* Process the response. */
+ prvMQTTProcessResponse( &xIncomingPacket );
+ }
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c
index 2ec2e10aa..6fae4b1d2 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c
@@ -231,18 +231,18 @@ static void prvInitialiseLibraries( void );
/**
* @brief The MQTT connection handle used in this example.
*/
-static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
+static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
/*-----------------------------------------------------------*/
-static const struct IotNetworkServerInfo xMQTTBrokerInfo =
+static const struct IotNetworkServerInfo xMQTTBrokerInfo =
{
.pHostName = mqttexampleBROKER_ENDPOINT,
.port = mqttexampleBROKER_PORT
};
#if ( democonfigENABLE_TLS )
- static struct IotNetworkCredentials xNetworkSecurityCredentials =
+ static struct IotNetworkCredentials xNetworkSecurityCredentials =
{
/* Optional TLS extensions. For this demo, they are disabled. */
.pAlpnProtos = NULL,
@@ -272,7 +272,7 @@ static const struct IotNetworkServerInfo xMQTTBrokerInfo =
};
#endif /* if ( democonfigENABLE_TLS ) */
-static IotMqttNetworkInfo_t xNetworkInfo =
+static IotMqttNetworkInfo_t xNetworkInfo =
{
/* No connection to the MQTT broker has been established yet and we want to
* establish a new connection. */
@@ -296,7 +296,7 @@ static IotMqttNetworkInfo_t xNetworkInfo =
.disconnectCallback.function = prvExample_OnDisconnect
};
-static const IotMqttConnectInfo_t xConnectInfo =
+static const IotMqttConnectInfo_t xConnectInfo =
{
/* Set this flag to true if connecting to the AWS IoT MQTT broker. */
#if ( democonfigPROFILE_USE_AWS_IOT == 1 )
@@ -361,9 +361,9 @@ void vStartSimpleMQTTDemo( void )
static void prvMQTTDemoTask( void * pvParameters )
{
- uint32_t ulNotificationValue = 0, ulPublishCount;
- const uint32_t ulMaxPublishCount = 5UL;
- const TickType_t xNoDelay = ( TickType_t ) 0;
+ uint32_t ulNotificationValue = 0, ulPublishCount;
+ const uint32_t ulMaxPublishCount = 5UL;
+ const TickType_t xNoDelay = ( TickType_t ) 0;
/* Remove compiler warnings about unused parameters. */
( void ) pvParameters;
@@ -537,86 +537,86 @@ static void prvMQTTDisconnect( void )
static void prvMQTTSubscribe( void )
{
- IotMqttError_t xResult;
+ IotMqttError_t xResult;
IotMqttSubscription_t xMQTTSubscription;
/* Subscribe to the mqttexampleTOPIC topic filter. The task handle is passed
* as the callback context, which is then used by the callback to send a task
* notification to this task.*/
- xMQTTSubscription.qos = IOT_MQTT_QOS_1;
- xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
- xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
+ xMQTTSubscription.qos = IOT_MQTT_QOS_1;
+ xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
+ xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
xMQTTSubscription.callback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();
- xMQTTSubscription.callback.function = prvExample_OnMessageReceived;
+ xMQTTSubscription.callback.function = prvExample_OnMessageReceived;
/* Use the synchronous API to subscribe - It is a blocking call and only
* returns when the subscribe operation is complete or a timeout occurs. */
- xResult = IotMqtt_SubscribeSync( xMQTTConnection,
- &( xMQTTSubscription ),
- 1, /* We are subscribing to one topic filter. */
- 0, /* flags - currently ignored. */
- mqttexampleMQTT_TIMEOUT_MS );
+ xResult = IotMqtt_SubscribeSync( xMQTTConnection,
+ &( xMQTTSubscription ),
+ 1, /* We are subscribing to one topic filter. */
+ 0, /* flags - currently ignored. */
+ mqttexampleMQTT_TIMEOUT_MS );
configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvMQTTPublish( void )
{
- IotMqttError_t xResult;
+ IotMqttError_t xResult;
IotMqttPublishInfo_t xMQTTPublishInfo;
/* Publish a message with QoS1 on the mqttexampleTOPIC topic. Since we are
* subscribed to the same topic, the MQTT broker will send the same message
* back to us. It is verified in the publish callback. */
- xMQTTPublishInfo.qos = IOT_MQTT_QOS_1;
- xMQTTPublishInfo.retain = false;
- xMQTTPublishInfo.pTopicName = mqttexampleTOPIC;
+ xMQTTPublishInfo.qos = IOT_MQTT_QOS_1;
+ xMQTTPublishInfo.retain = false;
+ xMQTTPublishInfo.pTopicName = mqttexampleTOPIC;
xMQTTPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC );
- xMQTTPublishInfo.pPayload = mqttexampleMESSAGE;
- xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE );
- xMQTTPublishInfo.retryMs = mqttexamplePUBLISH_RETRY_MS;
- xMQTTPublishInfo.retryLimit = mqttexamplePUBLISH_RETRY_LIMIT;
+ xMQTTPublishInfo.pPayload = mqttexampleMESSAGE;
+ xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE );
+ xMQTTPublishInfo.retryMs = mqttexamplePUBLISH_RETRY_MS;
+ xMQTTPublishInfo.retryLimit = mqttexamplePUBLISH_RETRY_LIMIT;
/* Use the synchronous API to publish - It is a blocking call and only
* returns when the publish operation is complete or a timeout occurs. */
- xResult = IotMqtt_PublishSync( xMQTTConnection,
- &( xMQTTPublishInfo ),
- 0, /* flags - currently ignored. */
- mqttexampleMQTT_TIMEOUT_MS );
+ xResult = IotMqtt_PublishSync( xMQTTConnection,
+ &( xMQTTPublishInfo ),
+ 0, /* flags - currently ignored. */
+ mqttexampleMQTT_TIMEOUT_MS );
configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvMQTTUnsubscribe( void )
{
- IotMqttError_t xResult;
+ IotMqttError_t xResult;
IotMqttSubscription_t xMQTTSubscription;
/* Unsubscribe from the mqttexampleTOPIC topic filter. */
- xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
- xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
+ xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
+ xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
/* The following members of the IotMqttSubscription_t are ignored by the
* unsubscribe operation. Just initialize them to avoid "use of uninitialized
* variable" warnings. */
- xMQTTSubscription.qos = IOT_MQTT_QOS_1;
+ xMQTTSubscription.qos = IOT_MQTT_QOS_1;
xMQTTSubscription.callback.pCallbackContext = NULL;
- xMQTTSubscription.callback.function = NULL;
+ xMQTTSubscription.callback.function = NULL;
/* Use the synchronous API to unsubscribe - It is a blocking call and only
* returns when the unsubscribe operation is complete or a timeout occurs. */
- xResult = IotMqtt_UnsubscribeSync( xMQTTConnection,
- &( xMQTTSubscription ),
- 1, /* We are unsubscribing from one topic filter. */
- 0, /* flags - currently ignored. */
- mqttexampleMQTT_TIMEOUT_MS );
+ xResult = IotMqtt_UnsubscribeSync( xMQTTConnection,
+ &( xMQTTSubscription ),
+ 1, /* We are unsubscribing from one topic filter. */
+ 0, /* flags - currently ignored. */
+ mqttexampleMQTT_TIMEOUT_MS );
configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvInitialiseLibraries( void )
{
- IotMqttError_t xResult;
+ IotMqttError_t xResult;
IotNetworkError_t xNetworkResult;
/* Initialize the network stack abstraction for FreeRTOS. */
@@ -625,7 +625,7 @@ static void prvInitialiseLibraries( void )
/* MQTT library must be initialized before it can be used. This is just one
* time initialization. */
- xResult = IotMqtt_Init();
+ xResult = IotMqtt_Init();
configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c
index 0b2388f93..61a68dc82 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c
@@ -35,65 +35,65 @@
*
* Also note that it is assumed this demo is going to be used for short periods
* of time only, and therefore timer overflows are not handled.
-*/
+ */
/* FreeRTOS includes. */
#include <FreeRTOS.h>
/* Variables used in the creation of the run time stats time base. Run time
-stats record how much time each task spends in the Running state. */
+ * stats record how much time each task spends in the Running state. */
static long long llInitialRunTimeCounterValue = 0LL, llTicksPerHundedthMillisecond = 0LL;
/*-----------------------------------------------------------*/
void vConfigureTimerForRunTimeStats( void )
{
-LARGE_INTEGER liPerformanceCounterFrequency, liInitialRunTimeValue;
+ LARGE_INTEGER liPerformanceCounterFrequency, liInitialRunTimeValue;
- /* Initialise the variables used to create the run time stats time base.
- Run time stats record how much time each task spends in the Running
- state. */
+ /* Initialise the variables used to create the run time stats time base.
+ * Run time stats record how much time each task spends in the Running
+ * state. */
- if( QueryPerformanceFrequency( &liPerformanceCounterFrequency ) == 0 )
- {
- llTicksPerHundedthMillisecond = 1;
- }
- else
- {
- /* How many times does the performance counter increment in 1/100th
- millisecond. */
- llTicksPerHundedthMillisecond = liPerformanceCounterFrequency.QuadPart / 100000LL;
+ if( QueryPerformanceFrequency( &liPerformanceCounterFrequency ) == 0 )
+ {
+ llTicksPerHundedthMillisecond = 1;
+ }
+ else
+ {
+ /* How many times does the performance counter increment in 1/100th
+ * millisecond. */
+ llTicksPerHundedthMillisecond = liPerformanceCounterFrequency.QuadPart / 100000LL;
- /* What is the performance counter value now, this will be subtracted
- from readings taken at run time. */
- QueryPerformanceCounter( &liInitialRunTimeValue );
- llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart;
- }
+ /* What is the performance counter value now, this will be subtracted
+ * from readings taken at run time. */
+ QueryPerformanceCounter( &liInitialRunTimeValue );
+ llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart;
+ }
}
/*-----------------------------------------------------------*/
unsigned long ulGetRunTimeCounterValue( void )
{
-LARGE_INTEGER liCurrentCount;
-unsigned long ulReturn;
+ LARGE_INTEGER liCurrentCount;
+ unsigned long ulReturn;
- /* What is the performance counter value now? */
- QueryPerformanceCounter( &liCurrentCount );
+ /* What is the performance counter value now? */
+ QueryPerformanceCounter( &liCurrentCount );
- /* Subtract the performance counter value reading taken when the
- application started to get a count from that reference point, then
- scale to (simulated) 1/100ths of a millisecond. */
- if( llTicksPerHundedthMillisecond == 0 )
- {
- /* The trace macros are probably calling this function before the
- scheduler has been started. */
- ulReturn = 0;
- }
- else
- {
- ulReturn = ( unsigned long ) ( ( liCurrentCount.QuadPart - llInitialRunTimeCounterValue ) / llTicksPerHundedthMillisecond );
- }
+ /* Subtract the performance counter value reading taken when the
+ * application started to get a count from that reference point, then
+ * scale to (simulated) 1/100ths of a millisecond. */
+ if( llTicksPerHundedthMillisecond == 0 )
+ {
+ /* The trace macros are probably calling this function before the
+ * scheduler has been started. */
+ ulReturn = 0;
+ }
+ else
+ {
+ ulReturn = ( unsigned long ) ( ( liCurrentCount.QuadPart - llInitialRunTimeCounterValue ) / llTicksPerHundedthMillisecond );
+ }
- return ulReturn;
+ return ulReturn;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h
index d9b063bf8..ee2402255 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h
@@ -47,68 +47,68 @@
*/
#ifndef ATOMIC_H
-#define ATOMIC_H
+ #define ATOMIC_H
-#ifndef INC_FREERTOS_H
- #error "include FreeRTOS.h must appear in source files before include atomic.h"
-#endif
+ #ifndef INC_FREERTOS_H
+ #error "include FreeRTOS.h must appear in source files before include atomic.h"
+ #endif
/* Standard includes. */
-#include <stdint.h>
+ #include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- /* Needed for __atomic_compare_exchange() weak=false. */
- #include <stdbool.h>
+/* Needed for __atomic_compare_exchange() weak=false. */
+ #include <stdbool.h>
- /* This branch is for GCC compiler and GCC compiler only. */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE inline __attribute__((always_inline))
- #endif
+/* This branch is for GCC compiler and GCC compiler only. */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE inline __attribute__( ( always_inline ) )
+ #endif
-#else
+ #else
- /* Port specific definitions -- entering/exiting critical section.
- * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
- *
- * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
- * ATOMIC_ENTER_CRITICAL().
- */
- #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
+/* Port specific definitions -- entering/exiting critical section.
+ * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
+ *
+ * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
+ * ATOMIC_ENTER_CRITICAL().
+ */
+ #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
- /* Nested interrupt scheme is supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() \
- UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
+/* Nested interrupt scheme is supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() \
+ UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
- #define ATOMIC_EXIT_CRITICAL() \
- portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
+ #define ATOMIC_EXIT_CRITICAL() \
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
- #else
+ #else
- /* Nested interrupt scheme is NOT supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
- #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
+/* Nested interrupt scheme is NOT supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
+ #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
- #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
+ #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
- /* Port specific definition -- "always inline".
- * Inline is compiler specific, and may not always get inlined depending on your optimization level.
- * For atomic operations, inline is considered a performance optimization.
- * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
- * simply define it.
- */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE
- #endif
+/* Port specific definition -- "always inline".
+ * Inline is compiler specific, and may not always get inlined depending on your optimization level.
+ * For atomic operations, inline is considered a performance optimization.
+ * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
+ * simply define it.
+ */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE
+ #endif
-#endif /* configUSE_GCC_BUILTIN_ATOMICS */
+ #endif /* configUSE_GCC_BUILTIN_ATOMICS */
-#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
-#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
+ #define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
+ #define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
/*----------------------------- Swap && CAS ------------------------------*/
@@ -127,44 +127,36 @@ extern "C" {
* @note This function only swaps *pDestination with ulExchange, if previous
* *pDestination value equals ulComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
- uint32_t volatile * pDestination,
- uint32_t ulExchange,
- uint32_t ulComparand )
-{
-
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- if ( __atomic_compare_exchange( pDestination,
- &ulComparand,
- &ulExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pDestination,
+ uint32_t ulExchange,
+ uint32_t ulComparand )
{
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( pDestination,
+ &ulComparand,
+ &ulExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *pDestination == ulComparand )
+ {
+ *pDestination = ulExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *pDestination == ulComparand )
- {
- *pDestination = ulExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-
-}
-
/**
* Atomic swap (pointers)
*
@@ -177,30 +169,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
*
* @return The initial value of *ppDestination.
*/
-static portFORCE_INLINE void * Atomic_SwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange )
-{
- void * pReturnValue;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange )
+ {
+ void * pReturnValue;
- pReturnValue = *ppDestination;
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
+ #else
+ ATOMIC_ENTER_CRITICAL();
- *ppDestination = pExchange;
+ pReturnValue = *ppDestination;
- ATOMIC_EXIT_CRITICAL();
+ *ppDestination = pExchange;
-#endif
+ ATOMIC_EXIT_CRITICAL();
+ #endif
- return pReturnValue;
-}
+ return pReturnValue;
+ }
/**
* Atomic compare-and-swap (pointers)
@@ -218,40 +205,36 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32(
* @note This function only swaps *ppDestination with pExchange, if previous
* *ppDestination value equals pComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange, void * pComparand )
-{
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- if ( __atomic_compare_exchange( ppDestination,
- &pComparand,
- &pExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
- {
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *ppDestination == pComparand )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange,
+ void * pComparand )
{
- *ppDestination = pExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( ppDestination,
+ &pComparand,
+ &pExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *ppDestination == pComparand )
+ {
+ *ppDestination = pExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-}
-
/*----------------------------- Arithmetic ------------------------------*/
@@ -266,30 +249,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Add_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic subtract
@@ -303,30 +281,25 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic increment
@@ -338,28 +311,24 @@ static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
*
* @return *pAddend value before increment.
*/
-static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic decrement
@@ -371,28 +340,24 @@ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAdde
*
* @return *pAddend value before decrement.
*/
-static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/*----------------------------- Bitwise Logical ------------------------------*/
@@ -407,30 +372,25 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_OR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_or(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_or( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination |= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination |= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic AND
@@ -443,30 +403,25 @@ static portFORCE_INLINE uint32_t Atomic_OR_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_AND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_and(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_and( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination &= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination &= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic NAND
@@ -479,30 +434,25 @@ static portFORCE_INLINE uint32_t Atomic_AND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_NAND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_nand(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_nand( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination = ~(ulCurrent & ulValue);
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination = ~( ulCurrent & ulValue );
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic XOR
@@ -515,33 +465,28 @@ static portFORCE_INLINE uint32_t Atomic_NAND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_XOR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_xor(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_xor( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination ^= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination ^= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
-#ifdef __cplusplus
-}
-#endif
+ #ifdef __cplusplus
+ }
+ #endif
#endif /* ATOMIC_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c
index 3c46ff835..e6aa16c3e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c
@@ -57,19 +57,19 @@
/*-----------------------------------------------------------*/
/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
+ * to .ful. */
+#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
+#define dlMAX_PRINT_STRING_LENGTH 255
/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
+ * the Win32 thread that is responsible for making any Win32 system calls that are
+ * necessary for the selected logging method. */
+#define dlLOGGING_STREAM_BUFFER_SIZE 32768
/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
+#define dlDONT_BLOCK 0
/*-----------------------------------------------------------*/
@@ -81,7 +81,8 @@ static void prvFileLoggingInit( void );
/*
* Attempt to write a message to the file.
*/
-static void prvLogToFile( const char *pcMessage, size_t xLength );
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength );
/*
* Simply close the logging file, if it is open.
@@ -102,7 +103,7 @@ static void prvLoggingFlushBuffer( void );
* Win32 system calls. Only the windows thread can make system calls so as not
* to disrupt the simulation by making Windows calls from FreeRTOS tasks.
*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
+static DWORD WINAPI prvWin32LoggingThread( void * pvParam );
/*
* Creates the socket to which UDP messages are sent. This function is not
@@ -110,417 +111,426 @@ static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
* task - which could result in a deadlock. Instead the function call is
* deferred to run in the RTOS daemon task - hence it prototype.
*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 );
/*-----------------------------------------------------------*/
/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
+ * needs Win32 system calls. */
+static void * pvLoggingThreadEvent = NULL;
/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
+ * vLoggingInit() function. */
+BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
+ * thread that is responsible for making Win32 calls (when stdout or a disk log is
+ * used). */
+static StreamBuffer_t * xLogStreamBuffer = NULL;
/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
+ * messages waiting to be logged, then closed again in between logs. */
+static FILE * pxLoggingFileHandle = NULL;
/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
+ * to pdFALSE - at which time prints that require Win32 system calls are done by
+ * the Win32 thread responsible for logging. */
+BaseType_t xDirectPrint = pdTRUE;
/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
+static const char * pcLogFileName = "RTOSDemo.log";
+static const char * pcFullLogFileName = "RTOSDemo.ful";
/* As an optimization, the current file size is kept in a variable. */
-static size_t ulSizeOfLoggingFile = 0ul;
+static size_t ulSizeOfLoggingFile = 0ul;
/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
+Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
struct freertos_sockaddr xPrintUDPAddress;
/*-----------------------------------------------------------*/
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort )
{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialize it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialized. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
+ /* Can only be called before the scheduler has started. */
+ configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
+
+ #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
+ {
+ HANDLE Win32Thread;
+
+ /* Record which output methods are to be used. */
+ xStdoutLoggingUsed = xLogToStdout;
+ xDiskFileLoggingUsed = xLogToFile;
+ xUDPLoggingUsed = xLogToUDP;
+
+ /* If a disk file is used then initialize it now. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvFileLoggingInit();
+ }
+
+ /* If UDP logging is used then store the address to which the log data
+ * will be sent - but don't create the socket yet because the network is
+ * not initialized. */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ /* Set the address to which the print messages are sent. */
+ xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
+ xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
+ }
+
+ /* If a disk file or stdout are to be used then Win32 system calls will
+ * have to be made. Such system calls cannot be made from FreeRTOS tasks
+ * so create a stream buffer to pass the messages to a Win32 thread, then
+ * create the thread itself, along with a Win32 event that can be used to
+ * unblock the thread. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ /* Create the buffer. */
+ xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
+ configASSERT( xLogStreamBuffer );
+ memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
+ xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
+
+ /* Create the Windows event. */
+ pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
+
+ /* Create the thread itself. */
+ Win32Thread = CreateThread(
+ NULL, /* Pointer to thread security attributes. */
+ 0, /* Initial thread stack size, in bytes. */
+ prvWin32LoggingThread, /* Pointer to thread function. */
+ NULL, /* Argument for new thread. */
+ 0, /* Creation flags. */
+ NULL );
+
+ /* Use the cores that are not used by the FreeRTOS tasks. */
+ SetThreadAffinityMask( Win32Thread, ~0x01u );
+ SetThreadPriorityBoost( Win32Thread, TRUE );
+ SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
+ }
+ }
+ #else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */
+ {
+ /* FreeRTOSIPConfig is set such that no print messages will be output.
+ * Avoid compiler warnings about unused parameters. */
+ ( void ) xLogToStdout;
+ ( void ) xLogToFile;
+ ( void ) xLogToUDP;
+ ( void ) usRemotePort;
+ ( void ) ulRemoteIPAddress;
+ }
+ #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
}
/*-----------------------------------------------------------*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 )
{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
+ static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
+ Socket_t xSocket;
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
+ /* The function prototype is that of a deferred function, but the parameters
+ * are not actually used. */
+ ( void ) pvParameter1;
+ ( void ) ulParameter2;
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
+ if( xSocket != FREERTOS_INVALID_SOCKET )
+ {
+ /* FreeRTOS+TCP decides which port to bind to. */
+ FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
+ FreeRTOS_bind( xSocket, NULL, 0 );
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
+ /* Now the socket is bound it can be assigned to the print socket. */
+ xPrintSocket = xSocket;
+ }
}
/*-----------------------------------------------------------*/
-void vLoggingPrintf( const char *pcFormat, ... )
+void vLoggingPrintf( const char * pcFormat,
+ ... )
{
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
-char *pcSource, *pcTarget, *pcBegin;
-size_t xLength, xLength2, rc;
-static BaseType_t xMessageNumber = 0;
-va_list args;
-uint32_t ulIPAddress;
-const char *pcTaskName;
-const char *pcNoTask = "None";
-int iOriginalPriority;
-HANDLE xCurrentTask;
-
-
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
- {
- /* There are a variable number of parameters. */
- va_start( args, pcFormat );
-
- /* Additional info to place at the start of the log. */
- if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
- {
- pcTaskName = pcTaskGetName( NULL );
- }
- else
- {
- pcTaskName = pcNoTask;
- }
-
- if( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
-
- if( xLength2 < 0 )
- {
- /* Clean up. */
- xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
- cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
- }
-
- xLength += xLength2;
- va_end( args );
-
- /* For ease of viewing, copy the string into another buffer, converting
- IP addresses to dot notation on the way. */
- pcSource = cPrintString;
- pcTarget = cOutputString;
-
- while( ( *pcSource ) != '\0' )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- pcSource++;
-
- /* Look forward for an IP address denoted by 'ip'. */
- if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- *pcTarget = '\0';
- pcBegin = pcTarget - 8;
-
- while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
- {
- pcTarget--;
- }
-
- sscanf( pcTarget, "%8X", &ulIPAddress );
- rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
- ( unsigned long ) ( ulIPAddress >> 24UL ),
- ( unsigned long ) ( (ulIPAddress >> 16UL) & 0xffUL ),
- ( unsigned long ) ( (ulIPAddress >> 8UL) & 0xffUL ),
- ( unsigned long ) ( ulIPAddress & 0xffUL ) );
- pcTarget += rc;
- pcSource += 3; /* skip "<n>ip" */
- }
- }
-
- /* How far through the buffer was written? */
- xLength = ( BaseType_t ) ( pcTarget - cOutputString );
-
- /* If the message is to be logged to a UDP port then it can be sent directly
- because it only uses FreeRTOS function (not Win32 functions). */
- if( xUDPLoggingUsed != pdFALSE )
- {
- if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
- {
- /* Create and bind the socket to which print messages are sent. The
- xTimerPendFunctionCall() function is used even though this is
- not an interrupt because this function is called from the IP task
- and the IP task cannot itself wait for a socket to bind. The
- parameters to prvCreatePrintSocket() are not required so set to
- NULL or 0. */
- xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* If logging is also to go to either stdout or a disk file then it cannot
- be output here - so instead write the message to the stream buffer and wake
- the Win32 thread which will read it from the stream buffer and perform the
- actual output. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- configASSERT( xLogStreamBuffer );
-
- /* How much space is in the buffer? */
- xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
-
- /* There must be enough space to write both the string and the length of
- the string. */
- if( xLength2 >= ( xLength + sizeof( xLength ) ) )
- {
- /* First write in the length of the data, then write in the data
- itself. Raising the thread priority is used as a critical section
- as there are potentially multiple writers. The stream buffer is
- only thread safe when there is a single writer (likewise for
- reading from the buffer). */
- xCurrentTask = GetCurrentThread();
- iOriginalPriority = GetThreadPriority( xCurrentTask );
- SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
- SetThreadPriority( GetCurrentThread(), iOriginalPriority );
- }
-
- /* xDirectPrint is initialized to pdTRUE, and while it remains true the
- logging output function is called directly. When the system is running
- the output function cannot be called directly because it would get
- called from both FreeRTOS tasks and Win32 threads - so instead wake the
- Win32 thread responsible for the actual output. */
- if( xDirectPrint != pdFALSE )
- {
- /* While starting up, the thread which calls prvWin32LoggingThread()
- is not running yet and xDirectPrint will be pdTRUE. */
- prvLoggingFlushBuffer();
- }
- else if( pvLoggingThreadEvent != NULL )
- {
- /* While running, wake up prvWin32LoggingThread() to send the
- logging data. */
- SetEvent( pvLoggingThreadEvent );
- }
- }
- }
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+ char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
+ char * pcSource, * pcTarget, * pcBegin;
+ size_t xLength, xLength2, rc;
+ static BaseType_t xMessageNumber = 0;
+ va_list args;
+ uint32_t ulIPAddress;
+ const char * pcTaskName;
+ const char * pcNoTask = "None";
+ int iOriginalPriority;
+ HANDLE xCurrentTask;
+
+
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
+ {
+ /* There are a variable number of parameters. */
+ va_start( args, pcFormat );
+
+ /* Additional info to place at the start of the log. */
+ if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
+ {
+ pcTaskName = pcTaskGetName( NULL );
+ }
+ else
+ {
+ pcTaskName = pcNoTask;
+ }
+
+ if( strcmp( pcFormat, "\n" ) != 0 )
+ {
+ xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
+ xMessageNumber++,
+ ( unsigned long ) xTaskGetTickCount(),
+ pcTaskName );
+ }
+ else
+ {
+ xLength = 0;
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ }
+
+ xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
+
+ if( xLength2 < 0 )
+ {
+ /* Clean up. */
+ xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
+ cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
+ }
+
+ xLength += xLength2;
+ va_end( args );
+
+ /* For ease of viewing, copy the string into another buffer, converting
+ * IP addresses to dot notation on the way. */
+ pcSource = cPrintString;
+ pcTarget = cOutputString;
+
+ while( ( *pcSource ) != '\0' )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ pcSource++;
+
+ /* Look forward for an IP address denoted by 'ip'. */
+ if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ *pcTarget = '\0';
+ pcBegin = pcTarget - 8;
+
+ while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
+ {
+ pcTarget--;
+ }
+
+ sscanf( pcTarget, "%8X", &ulIPAddress );
+ rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
+ ( unsigned long ) ( ulIPAddress >> 24UL ),
+ ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ),
+ ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ),
+ ( unsigned long ) ( ulIPAddress & 0xffUL ) );
+ pcTarget += rc;
+ pcSource += 3; /* skip "<n>ip" */
+ }
+ }
+
+ /* How far through the buffer was written? */
+ xLength = ( BaseType_t ) ( pcTarget - cOutputString );
+
+ /* If the message is to be logged to a UDP port then it can be sent directly
+ * because it only uses FreeRTOS function (not Win32 functions). */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
+ {
+ /* Create and bind the socket to which print messages are sent. The
+ * xTimerPendFunctionCall() function is used even though this is
+ * not an interrupt because this function is called from the IP task
+ * and the IP task cannot itself wait for a socket to bind. The
+ * parameters to prvCreatePrintSocket() are not required so set to
+ * NULL or 0. */
+ xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
+ }
+
+ if( xPrintSocket != FREERTOS_INVALID_SOCKET )
+ {
+ FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+
+ /* Just because the UDP data logger I'm using is dumb. */
+ FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+ }
+ }
+
+ /* If logging is also to go to either stdout or a disk file then it cannot
+ * be output here - so instead write the message to the stream buffer and wake
+ * the Win32 thread which will read it from the stream buffer and perform the
+ * actual output. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ configASSERT( xLogStreamBuffer );
+
+ /* How much space is in the buffer? */
+ xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
+
+ /* There must be enough space to write both the string and the length of
+ * the string. */
+ if( xLength2 >= ( xLength + sizeof( xLength ) ) )
+ {
+ /* First write in the length of the data, then write in the data
+ * itself. Raising the thread priority is used as a critical section
+ * as there are potentially multiple writers. The stream buffer is
+ * only thread safe when there is a single writer (likewise for
+ * reading from the buffer). */
+ xCurrentTask = GetCurrentThread();
+ iOriginalPriority = GetThreadPriority( xCurrentTask );
+ SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
+ SetThreadPriority( GetCurrentThread(), iOriginalPriority );
+ }
+
+ /* xDirectPrint is initialized to pdTRUE, and while it remains true the
+ * logging output function is called directly. When the system is running
+ * the output function cannot be called directly because it would get
+ * called from both FreeRTOS tasks and Win32 threads - so instead wake the
+ * Win32 thread responsible for the actual output. */
+ if( xDirectPrint != pdFALSE )
+ {
+ /* While starting up, the thread which calls prvWin32LoggingThread()
+ * is not running yet and xDirectPrint will be pdTRUE. */
+ prvLoggingFlushBuffer();
+ }
+ else if( pvLoggingThreadEvent != NULL )
+ {
+ /* While running, wake up prvWin32LoggingThread() to send the
+ * logging data. */
+ SetEvent( pvLoggingThreadEvent );
+ }
+ }
+ }
}
/*-----------------------------------------------------------*/
static void prvLoggingFlushBuffer( void )
{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- _write( _fileno(stdout), cPrintString, strlen( cPrintString ) );
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
+ size_t xLength;
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+
+ /* Is there more than the length value stored in the circular buffer
+ * used to pass data from the FreeRTOS simulator into this Win32 thread? */
+ while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
+ {
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
+
+ /* Write the message to standard out if requested to do so when
+ * vLoggingInit() was called, or if the network is not yet up. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
+ {
+ /* Write the message to stdout. */
+ _write( _fileno( stdout ), cPrintString, strlen( cPrintString ) );
+ }
+
+ /* Write the message to a file if requested to do so when
+ * vLoggingInit() was called. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvLogToFile( cPrintString, xLength );
+ }
+ }
+
+ prvFileClose();
}
/*-----------------------------------------------------------*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
+static DWORD WINAPI prvWin32LoggingThread( void * pvParameter )
{
-const DWORD xMaxWait = 1000;
+ const DWORD xMaxWait = 1000;
- ( void ) pvParameter;
+ ( void ) pvParameter;
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
+ /* From now on, prvLoggingFlushBuffer() will only be called from this
+ * Windows thread */
+ xDirectPrint = pdFALSE;
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
+ for( ; ; )
+ {
+ /* Wait to be told there are message waiting to be logged. */
+ WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
+ /* Write out all waiting messages. */
+ prvLoggingFlushBuffer();
+ }
}
/*-----------------------------------------------------------*/
static void prvFileLoggingInit( void )
{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
+ FILE * pxHandle = fopen( pcLogFileName, "a" );
+
+ if( pxHandle != NULL )
+ {
+ fseek( pxHandle, SEEK_END, 0ul );
+ ulSizeOfLoggingFile = ftell( pxHandle );
+ fclose( pxHandle );
+ }
+ else
+ {
+ ulSizeOfLoggingFile = 0ul;
+ }
}
/*-----------------------------------------------------------*/
static void prvFileClose( void )
{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
+ if( pxLoggingFileHandle != NULL )
+ {
+ fclose( pxLoggingFileHandle );
+ pxLoggingFileHandle = NULL;
+ }
}
/*-----------------------------------------------------------*/
-static void prvLogToFile( const char *pcMessage, size_t xLength )
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength )
{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
+ if( pxLoggingFileHandle == NULL )
+ {
+ pxLoggingFileHandle = fopen( pcLogFileName, "a" );
+ }
+
+ if( pxLoggingFileHandle != NULL )
+ {
+ fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
+ ulSizeOfLoggingFile += xLength;
+
+ /* If the file has grown to its maximum permissible size then close and
+ * rename it - then start with a new file. */
+ if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
+ {
+ prvFileClose();
+
+ if( _access( pcFullLogFileName, 00 ) == 0 )
+ {
+ remove( pcFullLogFileName );
+ }
+
+ rename( pcLogFileName, pcFullLogFileName );
+ ulSizeOfLoggingFile = 0;
+ }
+ }
}
/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.h
index 2cc068ce9..773cc0d75 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.h
@@ -38,11 +38,10 @@
* If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
* to the IP address and port number to which UDP log messages will be sent.
*/
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort );
#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c
index 2b6d66739..31a420480 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c
@@ -34,7 +34,7 @@
#include <time.h>
/* Visual studio intrinsics used so the __debugbreak() function is available
-should an assert get hit. */
+ * should an assert get hit. */
#include <intrin.h>
/* FreeRTOS includes. */
@@ -72,29 +72,29 @@ static void prvSRand( UBaseType_t ulSeed );
static void prvMiscInitialisation( void );
/* The default IP and MAC address used by the demo. The address configuration
-defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
-1 but a DHCP server could not be contacted. See the online documentation for
-more information. */
+ * defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
+ * 1 but a DHCP server could not be contacted. See the online documentation for
+ * more information. */
static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };
static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };
static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };
/* Set the following constant to pdTRUE to log using the method indicated by the
-name of the constant, or pdFALSE to not log using the method indicated by the
-name of the constant. Options include to standard out (xLogToStdout), to a disk
-file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
-then UDP messages are sent to the IP address configured as the echo server
-address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
-the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
+ * name of the constant, or pdFALSE to not log using the method indicated by the
+ * name of the constant. Options include to standard out (xLogToStdout), to a disk
+ * file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
+ * then UDP messages are sent to the IP address configured as the echo server
+ * address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
+ * the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALSE;
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition for information on how to configure
-the real network connection to use. */
-const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
+ * connection that uses this MAC address by accessing the raw Ethernet data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition for information on how to configure
+ * the real network connection to use. */
+const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
/* Use by the pseudo random number generator. */
static UBaseType_t ulNextRand;
@@ -102,186 +102,186 @@ static UBaseType_t ulNextRand;
int main( void )
{
- /***
- * See https://www.FreeRTOS.org/mqtt/index.html for configuration and usage instructions.
- ***/
-
- /* Miscellaneous initialization including preparing the logging and seeding
- the random number generator. */
- prvMiscInitialisation();
-
- /* Initialize the network interface.
-
- ***NOTE*** Tasks that use the network are created in the network event hook
- when the network is connected and ready for use (see the implementation of
- vApplicationIPNetworkEventHook() below). The address values passed in here
- are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
- but a DHCP server cannot be contacted. */
- FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
-
- /* Start the RTOS scheduler. */
- vTaskStartScheduler();
-
- /* If all is well, the scheduler will now be running, and the following
- line will never be reached. If the following line does execute, then
- there was insufficient FreeRTOS heap memory available for the idle and/or
- timer tasks to be created. See the memory management section on the
- FreeRTOS web site for more details (this is standard text that is not
- really applicable to the Win32 simulator port). */
- for( ; ; )
- {
- __debugbreak();
- }
+ /***
+ * See https://www.FreeRTOS.org/mqtt/index.html for configuration and usage instructions.
+ ***/
+
+ /* Miscellaneous initialization including preparing the logging and seeding
+ * the random number generator. */
+ prvMiscInitialisation();
+
+ /* Initialize the network interface.
+ *
+ ***NOTE*** Tasks that use the network are created in the network event hook
+ * when the network is connected and ready for use (see the implementation of
+ * vApplicationIPNetworkEventHook() below). The address values passed in here
+ * are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
+ * but a DHCP server cannot be contacted. */
+ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
+
+ /* Start the RTOS scheduler. */
+ vTaskStartScheduler();
+
+ /* If all is well, the scheduler will now be running, and the following
+ * line will never be reached. If the following line does execute, then
+ * there was insufficient FreeRTOS heap memory available for the idle and/or
+ * timer tasks to be created. See the memory management section on the
+ * FreeRTOS web site for more details (this is standard text that is not
+ * really applicable to the Win32 simulator port). */
+ for( ; ; )
+ {
+ __debugbreak();
+ }
}
/*-----------------------------------------------------------*/
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
-events are only received if implemented in the MAC driver. */
+ * events are only received if implemented in the MAC driver. */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
-uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
-char cBuffer[ 16 ];
-static BaseType_t xTasksAlreadyCreated = pdFALSE;
-
- /* If the network has just come up...*/
- if( eNetworkEvent == eNetworkUp )
- {
- /* Create the tasks that use the IP stack if they have not already been
- created. */
- if( xTasksAlreadyCreated == pdFALSE )
- {
- /* Demos that use the network are created after the network is
- up. */
- configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
- vStartSimpleMQTTDemo();
- xTasksAlreadyCreated = pdTRUE;
- }
-
- /* Print out the network configuration, which may have come from a DHCP
- server. */
- FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
- FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
- FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
- FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
- FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
- FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
- }
+ uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
+ char cBuffer[ 16 ];
+ static BaseType_t xTasksAlreadyCreated = pdFALSE;
+
+ /* If the network has just come up...*/
+ if( eNetworkEvent == eNetworkUp )
+ {
+ /* Create the tasks that use the IP stack if they have not already been
+ * created. */
+ if( xTasksAlreadyCreated == pdFALSE )
+ {
+ /* Demos that use the network are created after the network is
+ * up. */
+ configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
+ vStartSimpleMQTTDemo();
+ xTasksAlreadyCreated = pdTRUE;
+ }
+
+ /* Print out the network configuration, which may have come from a DHCP
+ * server. */
+ FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
+ FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
+ FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
+ FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
+ FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
+ FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
+ }
}
/*-----------------------------------------------------------*/
-void vAssertCalled( const char *pcFile,
- uint32_t ulLine )
+void vAssertCalled( const char * pcFile,
+ uint32_t ulLine )
{
-volatile uint32_t ulBlockVariable = 0UL;
-volatile char *pcFileName = ( volatile char * ) pcFile;
-volatile uint32_t ulLineNumber = ulLine;
-
- ( void ) pcFileName;
- ( void ) ulLineNumber;
-
- printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
-
- /* Setting ulBlockVariable to a non-zero value in the debugger will allow
- this function to be exited. */
- taskDISABLE_INTERRUPTS();
- {
- while( ulBlockVariable == 0UL )
- {
- __debugbreak();
- }
- }
- taskENABLE_INTERRUPTS();
+ volatile uint32_t ulBlockVariable = 0UL;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
+ volatile uint32_t ulLineNumber = ulLine;
+
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
+
+ printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
+
+ /* Setting ulBlockVariable to a non-zero value in the debugger will allow
+ * this function to be exited. */
+ taskDISABLE_INTERRUPTS();
+ {
+ while( ulBlockVariable == 0UL )
+ {
+ __debugbreak();
+ }
+ }
+ taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
UBaseType_t uxRand( void )
{
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
-
- /*
- * Utility function to generate a pseudo random number.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
- return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
+ const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
+
+ /*
+ * Utility function to generate a pseudo random number.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
}
/*-----------------------------------------------------------*/
static void prvSRand( UBaseType_t ulSeed )
{
- /* Utility function to seed the pseudo random number generator. */
- ulNextRand = ulSeed;
+ /* Utility function to seed the pseudo random number generator. */
+ ulNextRand = ulSeed;
}
/*-----------------------------------------------------------*/
static void prvMiscInitialisation( void )
{
-time_t xTimeNow;
-uint32_t ulLoggingIPAddress;
-
- ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
- vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
-
- /*
- * Seed random number generator.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- time( &xTimeNow );
- FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
- prvSRand( ( uint32_t ) xTimeNow );
- FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
+ time_t xTimeNow;
+ uint32_t ulLoggingIPAddress;
+
+ ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
+ vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
+
+ /*
+ * Seed random number generator.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ time( &xTimeNow );
+ FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
+ prvSRand( ( uint32_t ) xTimeNow );
+ FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
}
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
- const char * pcApplicationHostnameHook( void )
- {
- /* Assign the name "FreeRTOS" to this network node. This function will
- be called during the DHCP: the machine will be registered with an IP
- address plus this name. */
- return mainHOST_NAME;
- }
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* Assign the name "FreeRTOS" to this network node. This function will
+ * be called during the DHCP: the machine will be registered with an IP
+ * address plus this name. */
+ return mainHOST_NAME;
+ }
#endif
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
- BaseType_t xApplicationDNSQueryHook( const char *pcName )
- {
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- to this node: that returned by pcApplicationHostnameHook() and that set
- by mainDEVICE_NICK_NAME. */
- if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
- {
- xReturn = pdPASS;
- }
- else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
- {
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
-
- return xReturn;
- }
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
+ {
+ BaseType_t xReturn;
+
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*-----------------------------------------------------------*/
@@ -293,85 +293,85 @@ uint32_t ulLoggingIPAddress;
* SYSTEMS.
*/
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort )
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- ( void ) ulSourceAddress;
- ( void ) usSourcePort;
- ( void ) ulDestinationAddress;
- ( void ) usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
- return uxRand();
+ return uxRand();
}
/*-----------------------------------------------------------*/
/*
* Set *pulNumber to a random number, and return pdTRUE. When the random number
* generator is broken, it shall return pdFALSE.
- * The macros ipconfigRAND32() and configRAND32() are not in use
+ * The macros ipconfigRAND32() and configRAND32() are not in use
* anymore in FreeRTOS+TCP.
- *
+ *
* THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS
* NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.
*/
BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
{
- *pulNumber = uxRand();
- return pdTRUE;
+ *pulNumber = uxRand();
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
-implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
-used by the Idle task. */
+ * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
+ * used by the Idle task. */
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
- StackType_t ** ppxIdleTaskStackBuffer,
- uint32_t * pulIdleTaskStackSize )
+ StackType_t ** ppxIdleTaskStackBuffer,
+ uint32_t * pulIdleTaskStackSize )
{
- /* If the buffers to be provided to the Idle task are declared inside this
- function then they must be declared static - otherwise they will be allocated on
- the stack and so not exists after this function exits. */
- static StaticTask_t xIdleTaskTCB;
- static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
- state will be stored. */
- *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
-
- /* Pass out the array that will be used as the Idle task's stack. */
- *ppxIdleTaskStackBuffer = uxIdleTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
- Note that, as the array is necessarily of type StackType_t,
- configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+ /* If the buffers to be provided to the Idle task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xIdleTaskTCB;
+ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
+ * state will be stored. */
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+
+ /* Pass out the array that will be used as the Idle task's stack. */
+ *ppxIdleTaskStackBuffer = uxIdleTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
-application must provide an implementation of vApplicationGetTimerTaskMemory()
-to provide the memory that is used by the Timer service task. */
+ * application must provide an implementation of vApplicationGetTimerTaskMemory()
+ * to provide the memory that is used by the Timer service task. */
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
- StackType_t ** ppxTimerTaskStackBuffer,
- uint32_t * pulTimerTaskStackSize )
+ StackType_t ** ppxTimerTaskStackBuffer,
+ uint32_t * pulTimerTaskStackSize )
{
- /* If the buffers to be provided to the Timer task are declared inside this
- function then they must be declared static - otherwise they will be allocated on
- the stack and so not exists after this function exits. */
- static StaticTask_t xTimerTaskTCB;
- static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Timer
- task's state will be stored. */
- *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
-
- /* Pass out the array that will be used as the Timer task's stack. */
- *ppxTimerTaskStackBuffer = uxTimerTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
- Note that, as the array is necessarily of type StackType_t,
- configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+ /* If the buffers to be provided to the Timer task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xTimerTaskTCB;
+ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Timer
+ * task's state will be stored. */
+ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+
+ /* Pass out the array that will be used as the Timer task's stack. */
+ *ppxTimerTaskStackBuffer = uxTimerTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c
index 84b87b2a4..f9bc5b5b1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c
@@ -1,21 +1,21 @@
/*
- Copyright 2001, 2002 Georges Menie (www.menie.org)
- stdarg version contributed by Christian Ettinger
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Changes for the FreeRTOS ports:
-
- - The dot in "%-8.8s"
- - The specifiers 'l' (long) and 'L' (long long)
- - The specifier 'u' for unsigned
- - Dot notation for IP addresses:
- sprintf("IP = %xip\n", 0xC0A80164);
- will produce "IP = 192.168.1.100\n"
-*/
+ * Copyright 2001, 2002 Georges Menie (www.menie.org)
+ * stdarg version contributed by Christian Ettinger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Changes for the FreeRTOS ports:
+ *
+ * - The dot in "%-8.8s"
+ * - The specifiers 'l' (long) and 'L' (long long)
+ * - The specifier 'u' for unsigned
+ * - Dot notation for IP addresses:
+ * sprintf("IP = %xip\n", 0xC0A80164);
+ * will produce "IP = 192.168.1.100\n"
+ */
#include <stdarg.h>
#include <stdio.h>
@@ -24,8 +24,8 @@
#include "FreeRTOS.h"
-#define PAD_RIGHT 1
-#define PAD_ZERO 2
+#define PAD_RIGHT 1
+#define PAD_ZERO 2
/*
* Return 1 for readable, 2 for writeable, 3 for both.
@@ -33,635 +33,721 @@
*/
extern BaseType_t xApplicationMemoryPermissions( uint32_t aAddress );
-extern void vOutputChar( const char cChar, const TickType_t xTicksToWait );
+extern void vOutputChar( const char cChar,
+ const TickType_t xTicksToWait );
static const TickType_t xTicksToWait = pdMS_TO_TICKS( 20 );
struct xPrintFlags
{
- int base;
- int width;
- int printLimit;
- unsigned
- pad : 8,
- letBase : 8,
- isSigned : 1,
- isNumber : 1,
- long32 : 1,
- long64 : 1;
+ int base;
+ int width;
+ int printLimit;
+ unsigned
+ pad : 8,
+ letBase : 8,
+ isSigned : 1,
+ isNumber : 1,
+ long32 : 1,
+ long64 : 1;
};
struct SStringBuf
{
- char *str;
- const char *orgStr;
- const char *nulPos;
- int curLen;
- struct xPrintFlags flags;
+ char * str;
+ const char * orgStr;
+ const char * nulPos;
+ int curLen;
+ struct xPrintFlags flags;
};
-static void strbuf_init( struct SStringBuf *apStr, char *apBuf, const char *apMaxStr )
+static void strbuf_init( struct SStringBuf * apStr,
+ char * apBuf,
+ const char * apMaxStr )
{
- apStr->str = apBuf;
- apStr->orgStr = apBuf;
- apStr->nulPos = apMaxStr-1;
- apStr->curLen = 0;
+ apStr->str = apBuf;
+ apStr->orgStr = apBuf;
+ apStr->nulPos = apMaxStr - 1;
+ apStr->curLen = 0;
- memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
+ memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
}
/*-----------------------------------------------------------*/
-static BaseType_t strbuf_printchar( struct SStringBuf *apStr, int c )
+static BaseType_t strbuf_printchar( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *( apStr->str++ ) = c;
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
-static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf *apStr, int c )
+static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *(apStr->str++) = c;
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
static portINLINE int i2hex( int aCh )
{
-int iResult;
-
- if( aCh < 10 )
- {
- iResult = '0' + aCh;
- }
- else
- {
- iResult = 'A' + aCh - 10;
- }
-
- return iResult;
+ int iResult;
+
+ if( aCh < 10 )
+ {
+ iResult = '0' + aCh;
+ }
+ else
+ {
+ iResult = 'A' + aCh - 10;
+ }
+
+ return iResult;
}
/*-----------------------------------------------------------*/
-static BaseType_t prints(struct SStringBuf *apBuf, const char *apString )
+static BaseType_t prints( struct SStringBuf * apBuf,
+ const char * apString )
{
- register int padchar = ' ';
- int i,len;
-
- if( xApplicationMemoryPermissions( ( uint32_t )apString ) == 0 )
- {
- /* The user has probably made a mistake with the parameter
- for '%s', the memory is not readbale. */
- apString = "INV_MEM";
- }
-
- if( apBuf->flags.width > 0 )
- {
- register int len = 0;
- register const char *ptr;
- for( ptr = apString; *ptr; ++ptr )
- {
- ++len;
- }
-
- if( len >= apBuf->flags.width )
- {
- apBuf->flags.width = 0;
- }
- else
- {
- apBuf->flags.width -= len;
- }
-
- if( apBuf->flags.pad & PAD_ZERO )
- {
- padchar = '0';
- }
- }
- if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
- {
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( strbuf_printchar( apBuf, padchar ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
- {
- /* The string to print represents an integer number.
- * In this case, printLimit is the min number of digits to print
- * If the length of the number to print is less than the min nb of i
- * digits to display, we add 0 before printing the number
- */
- len = strlen( apString );
-
- if( len < apBuf->flags.printLimit )
- {
- i = apBuf->flags.printLimit - len;
- for( ; i; i-- )
- {
- if( strbuf_printchar( apBuf, '0' ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- }
- /* The string to print is not the result of a number conversion to ascii.
- * For a string, printLimit is the max number of characters to display
- */
- for( ; apBuf->flags.printLimit && *apString ; ++apString, --apBuf->flags.printLimit )
- {
- if( !strbuf_printchar( apBuf, *apString ) )
- {
- return pdFALSE;
- }
- }
-
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( !strbuf_printchar( apBuf, padchar ) )
- {
- return pdFALSE;
- }
- }
-
- return pdTRUE;
+ register int padchar = ' ';
+ int i, len;
+
+ if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 )
+ {
+ /* The user has probably made a mistake with the parameter
+ * for '%s', the memory is not readbale. */
+ apString = "INV_MEM";
+ }
+
+ if( apBuf->flags.width > 0 )
+ {
+ register int len = 0;
+ register const char * ptr;
+
+ for( ptr = apString; *ptr; ++ptr )
+ {
+ ++len;
+ }
+
+ if( len >= apBuf->flags.width )
+ {
+ apBuf->flags.width = 0;
+ }
+ else
+ {
+ apBuf->flags.width -= len;
+ }
+
+ if( apBuf->flags.pad & PAD_ZERO )
+ {
+ padchar = '0';
+ }
+ }
+
+ if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
+ {
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( strbuf_printchar( apBuf, padchar ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+
+ if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
+ {
+ /* The string to print represents an integer number.
+ * In this case, printLimit is the min number of digits to print
+ * If the length of the number to print is less than the min nb of i
+ * digits to display, we add 0 before printing the number
+ */
+ len = strlen( apString );
+
+ if( len < apBuf->flags.printLimit )
+ {
+ i = apBuf->flags.printLimit - len;
+
+ for( ; i; i-- )
+ {
+ if( strbuf_printchar( apBuf, '0' ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+ }
+
+ /* The string to print is not the result of a number conversion to ascii.
+ * For a string, printLimit is the max number of characters to display
+ */
+ for( ; apBuf->flags.printLimit && *apString; ++apString, --apBuf->flags.printLimit )
+ {
+ if( !strbuf_printchar( apBuf, *apString ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( !strbuf_printchar( apBuf, padchar ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* the following should be enough for 32 bit int */
-#define PRINT_BUF_LEN 12 /* to print 4294967296 */
-
-#if SPRINTF_LONG_LONG
-#warning 64-bit libraries will be included as well
-static BaseType_t printll( struct SStringBuf *apBuf, long long i )
-{
- char print_buf[ 2 * PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned long long u = i;
- lldiv_t lldiv_result;
+#define PRINT_BUF_LEN 12 /* to print 4294967296 */
+
+#if SPRINTF_LONG_LONG
+ #warning 64-bit libraries will be included as well
+ static BaseType_t printll( struct SStringBuf * apBuf,
+ long long i )
+ {
+ char print_buf[ 2 * PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned long long u = i;
+ lldiv_t lldiv_result;
/* typedef struct
* {
- * long long int quot; // quotient
- * long long int rem; // remainder
+ * long long int quot; // quotient
+ * long long int rem; // remainder
* } lldiv_t;
*/
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- if( i == 0LL )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- /* 18446744073709551616 */
- while( u != 0 )
- {
- lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
- t = lldiv_result.rem;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u = lldiv_result.quot;
- }
-
- if( neg != 0 )
- {
- if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
- {
- if( !strbuf_printchar( apBuf, '-' ) )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
-}
-#endif /* SPRINTF_LONG_LONG */
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0LL )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ /* 18446744073709551616 */
+ while( u != 0 )
+ {
+ lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
+ t = lldiv_result.rem;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u = lldiv_result.quot;
+ }
+
+ if( neg != 0 )
+ {
+ if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( !strbuf_printchar( apBuf, '-' ) )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
+ }
+#endif /* SPRINTF_LONG_LONG */
/*-----------------------------------------------------------*/
-static BaseType_t printi( struct SStringBuf *apBuf, int i )
+static BaseType_t printi( struct SStringBuf * apBuf,
+ int i )
{
- char print_buf[ PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned int u = i;
- register unsigned base = apBuf->flags.base;
-
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
-
- if( i == 0 )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- switch( base )
- {
- case 16:
- while( u != 0 )
- {
- t = u & 0xF;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u >>= 4;
- }
- break;
-
- case 8:
- case 10:
- /* GCC compiles very efficient */
- while( u )
- {
- t = u % base;
- *( --s ) = t + '0';
- u /= base;
- }
- break;
+ char print_buf[ PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned int u = i;
+ register unsigned base = apBuf->flags.base;
+
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0 )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ switch( base )
+ {
+ case 16:
+
+ while( u != 0 )
+ {
+ t = u & 0xF;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u >>= 4;
+ }
+
+ break;
+
+ case 8:
+ case 10:
+
+ /* GCC compiles very efficient */
+ while( u )
+ {
+ t = u % base;
+ *( --s ) = t + '0';
+ u /= base;
+ }
+
+ break;
+
/*
- // The generic case, not yet in use
- default:
- while( u )
- {
- t = u % base;
- if( t >= 10)
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u /= base;
- }
- break;
-*/
- }
-
- if( neg != 0 )
- {
- if( apBuf->flags.width && (apBuf->flags.pad & PAD_ZERO ) )
- {
- if( strbuf_printchar( apBuf, '-' ) == 0 )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
+ * // The generic case, not yet in use
+ * default:
+ * while( u )
+ * {
+ * t = u % base;
+ * if( t >= 10)
+ * {
+ * t += apBuf->flags.letBase - '0' - 10;
+ * }
+ *( --s ) = t + '0';
+ * u /= base;
+ * }
+ * break;
+ */
+ }
+
+ if( neg != 0 )
+ {
+ if( apBuf->flags.width && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( strbuf_printchar( apBuf, '-' ) == 0 )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
}
/*-----------------------------------------------------------*/
-static BaseType_t printIp(struct SStringBuf *apBuf, unsigned i )
+static BaseType_t printIp( struct SStringBuf * apBuf,
+ unsigned i )
{
- char print_buf[16];
+ char print_buf[ 16 ];
- sprintf( print_buf, "%u.%u.%u.%u",
- i >> 24,
- ( i >> 16 ) & 0xff,
- ( i >> 8 ) & 0xff,
- i & 0xff );
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- prints( apBuf, print_buf );
+ sprintf( print_buf, "%u.%u.%u.%u",
+ i >> 24,
+ ( i >> 16 ) & 0xff,
+ ( i >> 8 ) & 0xff,
+ i & 0xff );
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+ prints( apBuf, print_buf );
- return pdTRUE;
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
-static void tiny_print( struct SStringBuf *apBuf, const char *format, va_list args )
+static void tiny_print( struct SStringBuf * apBuf,
+ const char * format,
+ va_list args )
{
- char scr[2];
-
- for( ; ; )
- {
- int ch = *( format++ );
-
- if( ch != '%' )
- {
- do
- {
- /* Put the most like flow in a small loop */
- if( strbuf_printchar_inline( apBuf, ch ) == 0 )
- {
- return;
- }
- ch = *( format++ );
- } while( ch != '%' );
- }
- ch = *( format++ );
- /* Now ch has character after '%', format pointing to next */
-
- if( ch == '\0' )
- {
- break;
- }
- if( ch == '%' )
- {
- if( strbuf_printchar( apBuf, ch ) == 0 )
- {
- return;
- }
- continue;
- }
- memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
-
- if( ch == '-' )
- {
- ch = *( format++ );
- apBuf->flags.pad = PAD_RIGHT;
- }
- while( ch == '0' )
- {
- ch = *( format++ );
- apBuf->flags.pad |= PAD_ZERO;
- }
- if( ch == '*' )
- {
- ch = *( format++ );
- apBuf->flags.width = va_arg( args, int );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.width *= 10;
- apBuf->flags.width += ch - '0';
- ch = *( format++ );
- }
- }
- if( ch == '.' )
- {
- ch = *( format++ );
- if( ch == '*' )
- {
- apBuf->flags.printLimit = va_arg( args, int );
- ch = *( format++ );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.printLimit *= 10;
- apBuf->flags.printLimit += ch - '0';
- ch = *( format++ );
- }
- }
- }
- if( apBuf->flags.printLimit == 0 )
- {
- apBuf->flags.printLimit--; /* -1: make it unlimited */
- }
- if( ch == 's' )
- {
- register char *s = ( char * )va_arg( args, int );
- if( prints( apBuf, s ? s : "(null)" ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'c' )
- {
- /* char are converted to int then pushed on the stack */
- scr[0] = ( char ) va_arg( args, int );
-
- if( strbuf_printchar( apBuf, scr[0] ) == 0 )
- {
- return;
- }
-
- continue;
- }
- if( ch == 'l' )
- {
- ch = *( format++ );
- apBuf->flags.long32 = 1;
- /* Makes not difference as u32 == long */
- }
- if( ch == 'L' )
- {
- ch = *( format++ );
- apBuf->flags.long64 = 1;
- /* Does make a difference */
- }
- apBuf->flags.base = 10;
- apBuf->flags.letBase = 'a';
-
- if( ch == 'd' || ch == 'u' )
- {
- apBuf->flags.isSigned = ( ch == 'd' );
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
-
- apBuf->flags.base = 16; /* From here all hexadecimal */
-
- if( ch == 'x' && format[0] == 'i' && format[1] == 'p' )
- {
- format += 2; /* eat the "xi" of "xip" */
- /* Will use base 10 again */
- if( printIp( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'x' || ch == 'X' || ch == 'p' || ch == 'o' )
- {
- if( ch == 'X' )
- {
- apBuf->flags.letBase = 'A';
- }
- else if( ch == 'o' )
- {
- apBuf->flags.base = 8;
- }
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- }
- strbuf_printchar( apBuf, '\0' );
+ char scr[ 2 ];
+
+ for( ; ; )
+ {
+ int ch = *( format++ );
+
+ if( ch != '%' )
+ {
+ do
+ {
+ /* Put the most like flow in a small loop */
+ if( strbuf_printchar_inline( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ ch = *( format++ );
+ } while( ch != '%' );
+ }
+
+ ch = *( format++ );
+ /* Now ch has character after '%', format pointing to next */
+
+ if( ch == '\0' )
+ {
+ break;
+ }
+
+ if( ch == '%' )
+ {
+ if( strbuf_printchar( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
+
+ if( ch == '-' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad = PAD_RIGHT;
+ }
+
+ while( ch == '0' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad |= PAD_ZERO;
+ }
+
+ if( ch == '*' )
+ {
+ ch = *( format++ );
+ apBuf->flags.width = va_arg( args, int );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.width *= 10;
+ apBuf->flags.width += ch - '0';
+ ch = *( format++ );
+ }
+ }
+
+ if( ch == '.' )
+ {
+ ch = *( format++ );
+
+ if( ch == '*' )
+ {
+ apBuf->flags.printLimit = va_arg( args, int );
+ ch = *( format++ );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.printLimit *= 10;
+ apBuf->flags.printLimit += ch - '0';
+ ch = *( format++ );
+ }
+ }
+ }
+
+ if( apBuf->flags.printLimit == 0 )
+ {
+ apBuf->flags.printLimit--; /* -1: make it unlimited */
+ }
+
+ if( ch == 's' )
+ {
+ register char * s = ( char * ) va_arg( args, int );
+
+ if( prints( apBuf, s ? s : "(null)" ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ch == 'c' )
+ {
+ /* char are converted to int then pushed on the stack */
+ scr[ 0 ] = ( char ) va_arg( args, int );
+
+ if( strbuf_printchar( apBuf, scr[ 0 ] ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ if( ch == 'l' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long32 = 1;
+ /* Makes not difference as u32 == long */
+ }
+
+ if( ch == 'L' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long64 = 1;
+ /* Does make a difference */
+ }
+
+ apBuf->flags.base = 10;
+ apBuf->flags.letBase = 'a';
+
+ if( ( ch == 'd' ) || ( ch == 'u' ) )
+ {
+ apBuf->flags.isSigned = ( ch == 'd' );
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ apBuf->flags.base = 16; /* From here all hexadecimal */
+
+ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) )
+ {
+ format += 2; /* eat the "xi" of "xip" */
+
+ /* Will use base 10 again */
+ if( printIp( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ( ch == 'x' ) || ( ch == 'X' ) || ( ch == 'p' ) || ( ch == 'o' ) )
+ {
+ if( ch == 'X' )
+ {
+ apBuf->flags.letBase = 'A';
+ }
+ else if( ch == 'o' )
+ {
+ apBuf->flags.base = 8;
+ }
+
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+ }
+
+ strbuf_printchar( apBuf, '\0' );
}
/*-----------------------------------------------------------*/
-int vsnprintf( char *apBuf, size_t aMaxLen, const char *apFmt, va_list args )
+int vsnprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int snprintf( char *apBuf, size_t aMaxLen, const char *apFmt, ... )
+int snprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int sprintf( char *apBuf, const char *apFmt, ... )
+int sprintf( char * apBuf,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char * )apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int vsprintf( char *apBuf, const char *apFmt, va_list args )
+int vsprintf( char * apBuf,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* ) apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-const char *mkSize (unsigned long long aSize, char *apBuf, int aLen)
+const char * mkSize( unsigned long long aSize,
+ char * apBuf,
+ int aLen )
{
-static char retString[33];
-size_t gb, mb, kb, sb;
-
- if (apBuf == NULL) {
- apBuf = retString;
- aLen = sizeof( retString );
- }
- gb = aSize / (1024*1024*1024);
- aSize -= gb * (1024*1024*1024);
- mb = aSize / (1024*1024);
- aSize -= mb * (1024*1024);
- kb = aSize / (1024);
- aSize -= kb * (1024);
- sb = aSize;
- if( gb )
- {
- snprintf (apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
- }
- else if( mb )
- {
- snprintf (apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb) / 1024ul ) );
- }
- else if( kb != 0ul )
- {
- snprintf (apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb) / 1024ul ) );
- }
- else
- {
- snprintf (apBuf, aLen, "%u bytes", ( unsigned ) sb);
- }
- return apBuf;
+ static char retString[ 33 ];
+ size_t gb, mb, kb, sb;
+
+ if( apBuf == NULL )
+ {
+ apBuf = retString;
+ aLen = sizeof( retString );
+ }
+
+ gb = aSize / ( 1024 * 1024 * 1024 );
+ aSize -= gb * ( 1024 * 1024 * 1024 );
+ mb = aSize / ( 1024 * 1024 );
+ aSize -= mb * ( 1024 * 1024 );
+ kb = aSize / ( 1024 );
+ aSize -= kb * ( 1024 );
+ sb = aSize;
+
+ if( gb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
+ }
+ else if( mb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb ) / 1024ul ) );
+ }
+ else if( kb != 0ul )
+ {
+ snprintf( apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb ) / 1024ul ) );
+ }
+ else
+ {
+ snprintf( apBuf, aLen, "%u bytes", ( unsigned ) sb );
+ }
+
+ return apBuf;
}
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSConfig.h
index 642113c41..ebee2a143 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSConfig.h
@@ -29,94 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile, uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -124,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demos of IoT Libraries. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-
-#if( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSIPConfig.h
index e02b16b66..7c019229e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/FreeRTOSIPConfig.h
@@ -27,284 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 32 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 32 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ( (x) != NULL )
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/demo_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/demo_config.h
index 6343f7772..a02aa36f6 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/demo_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/demo_config.h
@@ -48,13 +48,13 @@
* For more information regarding TLS protocol:
* https://www.freertos.org/mqtt/tls.html
*/
-#define democonfigENABLE_TLS 1
+#define democonfigENABLE_TLS 1
/**
* @brief Enable/Disable mutual authentication in demos. If enabled, require
* democonfigENABLE_TLS to be set to 1.
*/
-#define democonfigENABLE_MUTUAL_AUTH 0
+#define democonfigENABLE_MUTUAL_AUTH 0
/**
* @brief Select a connection profile.
@@ -65,7 +65,7 @@
* enabled, requires democonfigENABLE_MUTUAL_AUTH to be set to 1 since AWS IoT
* requires mutually authenticated connection.
*/
-#define democonfigPROFILE_USE_AWS_IOT 0
+#define democonfigPROFILE_USE_AWS_IOT 0
/**
* @brief Set the stack size of the main demo task.
@@ -73,6 +73,6 @@
* In the Windows port, this stack only holds a structure. The actual
* stack is created by an operating system thread.
*/
-#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
+#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
#endif /* DEMO_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/iot_config.h
index 3d74a285e..946da6986 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_basic_tls_server_auth/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/**
* @brief Set the log level of the MQTT library.
@@ -75,14 +75,14 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
+#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
/**
* @brief Enable TLS in the network abstraction.
*
* The TLS implementation requires the mbed TLS library.
*/
-#define IOT_NETWORK_ENABLE_TLS 1
+#define IOT_NETWORK_ENABLE_TLS 1
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -96,7 +96,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/**
* @brief Enable/Disable asserts for the MQTT library.
@@ -110,7 +110,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_MQTT_ENABLE_ASSERTS 1
+#define IOT_MQTT_ENABLE_ASSERTS 1
/**
* @brief Enable/Disable anonymous metrics collection when using AWS IoT.
@@ -118,7 +118,7 @@
* This demo does not work with AWS IoT. Therefore, the metric collection must
* be disabled.
*/
-#define AWS_IOT_MQTT_ENABLE_METRICS 0
+#define AWS_IOT_MQTT_ENABLE_METRICS 0
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSConfig.h
index b0a542f02..c2ec4b32c 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSConfig.h
@@ -29,98 +29,99 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 0
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 0
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering configuration options. */
unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */
-void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initializes the run time counter. */
-#define configGENERATE_RUN_TIME_STATS 0
-#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
-#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
+void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initializes the run time counter. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
+#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile, uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -128,92 +129,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demos of IoT Libraries. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-
-#if( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
/* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */
@@ -221,4 +223,3 @@ void vSaveTraceFile( void );
#include "trcRecorder.h"
#endif /* FREERTOS_CONFIG_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSIPConfig.h
index 1adbb82b2..0c090966e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/FreeRTOSIPConfig.h
@@ -27,284 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 32 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 32 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ( (x) != NULL )
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/demo_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/demo_config.h
index 713edfb38..457ed935b 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/demo_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/demo_config.h
@@ -48,13 +48,13 @@
* For more information regarding TLS protocol:
* https://www.freertos.org/mqtt/tls.html
*/
-#define democonfigENABLE_TLS 0
+#define democonfigENABLE_TLS 0
/**
* @brief Enable/Disable mutual authentication in demos. If enabled, require
* democonfigENABLE_TLS to be set to 1.
*/
-#define democonfigENABLE_MUTUAL_AUTH 0
+#define democonfigENABLE_MUTUAL_AUTH 0
/**
* @brief Select a connection profile.
@@ -65,7 +65,7 @@
* enabled, requires democonfigENABLE_MUTUAL_AUTH to be set to 1 since AWS IoT
* requires mutually authenticated connection.
*/
-#define democonfigPROFILE_USE_AWS_IOT 0
+#define democonfigPROFILE_USE_AWS_IOT 0
/**
* @brief Set the stack size of the main demo task.
@@ -73,6 +73,6 @@
* In the Windows port, this stack only holds a structure. The actual
* stack is created by an operating system thread.
*/
-#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
+#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
#endif /* DEMO_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcConfig.h
index f4c7ffe24..c0009240e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcConfig.h
@@ -46,13 +46,13 @@
******************************************************************************/
#ifndef TRC_CONFIG_H
-#define TRC_CONFIG_H
+ #define TRC_CONFIG_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
-#include "trcPortDefines.h"
+ #include "trcPortDefines.h"
/******************************************************************************
* Include of processor header file
@@ -61,7 +61,7 @@ extern "C" {
* required at least for the ARM Cortex-M port, that uses the ARM CMSIS API.
* Try that in case of build problems. Otherwise, remove the #error line below.
*****************************************************************************/
-//#error "Trace Recorder: Please include your processor's header file here and remove this line."
+/*#error "Trace Recorder: Please include your processor's header file here and remove this line." */
/*******************************************************************************
* Configuration Macro: TRC_CFG_HARDWARE_PORT
@@ -81,7 +81,7 @@ extern "C" {
* See trcHardwarePort.h for available ports and information on how to
* define your own port, if not already present.
******************************************************************************/
-#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_Win32
+ #define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_Win32
/*******************************************************************************
* Configuration Macro: TRC_CFG_RECORDER_MODE
@@ -97,7 +97,8 @@ extern "C" {
* TRC_RECORDER_MODE_SNAPSHOT
* TRC_RECORDER_MODE_STREAMING
******************************************************************************/
-#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
+ #define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
+
/******************************************************************************
* TRC_CFG_FREERTOS_VERSION
*
@@ -113,7 +114,7 @@ extern "C" {
* TRC_FREERTOS_VERSION_9_0_2 If using FreeRTOS v9.0.2
* TRC_FREERTOS_VERSION_10_0_0 If using FreeRTOS v10.0.0 or later
*****************************************************************************/
-#define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_0_0
+ #define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_0_0
/*******************************************************************************
* TRC_CFG_SCHEDULING_ONLY
@@ -125,9 +126,9 @@ extern "C" {
*
* Default value is 0 (= include additional events).
******************************************************************************/
-#define TRC_CFG_SCHEDULING_ONLY 0
+ #define TRC_CFG_SCHEDULING_ONLY 0
- /******************************************************************************
+/******************************************************************************
* TRC_CFG_INCLUDE_MEMMANG_EVENTS
*
* Macro which should be defined as either zero (0) or one (1).
@@ -137,9 +138,9 @@ extern "C" {
*
* Default value is 1.
*****************************************************************************/
-#define TRC_CFG_INCLUDE_MEMMANG_EVENTS 1
+ #define TRC_CFG_INCLUDE_MEMMANG_EVENTS 1
- /******************************************************************************
+/******************************************************************************
* TRC_CFG_INCLUDE_USER_EVENTS
*
* Macro which should be defined as either zero (0) or one (1).
@@ -162,84 +163,84 @@ extern "C" {
*
* Default value is 1.
*****************************************************************************/
-#define TRC_CFG_INCLUDE_USER_EVENTS 1
+ #define TRC_CFG_INCLUDE_USER_EVENTS 1
- /*****************************************************************************
- * TRC_CFG_INCLUDE_ISR_TRACING
- *
- * Macro which should be defined as either zero (0) or one (1).
- *
- * If this is zero (0), the code for recording Interrupt Service Routines is
- * excluded, in order to reduce code size.
- *
- * Default value is 1.
- *
- * Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin
- * and vTraceStoreISREnd in your interrupt handlers.
- *****************************************************************************/
-#define TRC_CFG_INCLUDE_ISR_TRACING 1
+/*****************************************************************************
+* TRC_CFG_INCLUDE_ISR_TRACING
+*
+* Macro which should be defined as either zero (0) or one (1).
+*
+* If this is zero (0), the code for recording Interrupt Service Routines is
+* excluded, in order to reduce code size.
+*
+* Default value is 1.
+*
+* Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin
+* and vTraceStoreISREnd in your interrupt handlers.
+*****************************************************************************/
+ #define TRC_CFG_INCLUDE_ISR_TRACING 1
- /*****************************************************************************
- * TRC_CFG_INCLUDE_READY_EVENTS
- *
- * Macro which should be defined as either zero (0) or one (1).
- *
- * If one (1), events are recorded when tasks enter scheduling state "ready".
- * This allows Tracealyzer to show the initial pending time before tasks enter
- * the execution state, and present accurate response times.
- * If zero (0), "ready events" are not created, which allows for recording
- * longer traces in the same amount of RAM.
- *
- * Default value is 1.
- *****************************************************************************/
-#define TRC_CFG_INCLUDE_READY_EVENTS 1
+/*****************************************************************************
+* TRC_CFG_INCLUDE_READY_EVENTS
+*
+* Macro which should be defined as either zero (0) or one (1).
+*
+* If one (1), events are recorded when tasks enter scheduling state "ready".
+* This allows Tracealyzer to show the initial pending time before tasks enter
+* the execution state, and present accurate response times.
+* If zero (0), "ready events" are not created, which allows for recording
+* longer traces in the same amount of RAM.
+*
+* Default value is 1.
+*****************************************************************************/
+ #define TRC_CFG_INCLUDE_READY_EVENTS 1
- /*****************************************************************************
- * TRC_CFG_INCLUDE_OSTICK_EVENTS
- *
- * Macro which should be defined as either zero (0) or one (1).
- *
- * If this is one (1), events will be generated whenever the OS clock is
- * increased. If zero (0), OS tick events are not generated, which allows for
- * recording longer traces in the same amount of RAM.
- *
- * Default value is 1.
- *****************************************************************************/
-#define TRC_CFG_INCLUDE_OSTICK_EVENTS 1
+/*****************************************************************************
+* TRC_CFG_INCLUDE_OSTICK_EVENTS
+*
+* Macro which should be defined as either zero (0) or one (1).
+*
+* If this is one (1), events will be generated whenever the OS clock is
+* increased. If zero (0), OS tick events are not generated, which allows for
+* recording longer traces in the same amount of RAM.
+*
+* Default value is 1.
+*****************************************************************************/
+ #define TRC_CFG_INCLUDE_OSTICK_EVENTS 1
- /*****************************************************************************
- * TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS
- *
- * Macro which should be defined as either zero (0) or one (1).
- *
- * If this is zero (0), the trace will exclude any "event group" events.
- *
- * Default value is 0 (excluded) since dependent on event_groups.c
- *****************************************************************************/
-#define TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS 1
+/*****************************************************************************
+* TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS
+*
+* Macro which should be defined as either zero (0) or one (1).
+*
+* If this is zero (0), the trace will exclude any "event group" events.
+*
+* Default value is 0 (excluded) since dependent on event_groups.c
+*****************************************************************************/
+ #define TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS 1
- /*****************************************************************************
- * TRC_CFG_INCLUDE_TIMER_EVENTS
- *
- * Macro which should be defined as either zero (0) or one (1).
- *
- * If this is zero (0), the trace will exclude any Timer events.
- *
- * Default value is 0 since dependent on timers.c
- *****************************************************************************/
-#define TRC_CFG_INCLUDE_TIMER_EVENTS 1
+/*****************************************************************************
+* TRC_CFG_INCLUDE_TIMER_EVENTS
+*
+* Macro which should be defined as either zero (0) or one (1).
+*
+* If this is zero (0), the trace will exclude any Timer events.
+*
+* Default value is 0 since dependent on timers.c
+*****************************************************************************/
+ #define TRC_CFG_INCLUDE_TIMER_EVENTS 1
- /*****************************************************************************
- * TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS
- *
- * Macro which should be defined as either zero (0) or one (1).
- *
- * If this is zero (0), the trace will exclude any "pending function call"
- * events, such as xTimerPendFunctionCall().
- *
- * Default value is 0 since dependent on timers.c
- *****************************************************************************/
-#define TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS 1
+/*****************************************************************************
+* TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS
+*
+* Macro which should be defined as either zero (0) or one (1).
+*
+* If this is zero (0), the trace will exclude any "pending function call"
+* events, such as xTimerPendFunctionCall().
+*
+* Default value is 0 since dependent on timers.c
+*****************************************************************************/
+ #define TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS 1
/*******************************************************************************
* Configuration Macro: TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS
@@ -251,7 +252,7 @@ extern "C" {
*
* Default value is 0 since dependent on stream_buffer.c (new in FreeRTOS v10)
******************************************************************************/
-#define TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS 1
+ #define TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS 1
/*******************************************************************************
* Configuration Macro: TRC_CFG_RECORDER_BUFFER_ALLOCATION
@@ -269,7 +270,7 @@ extern "C" {
* The custom mode allows you to control how and where the allocation is made,
* for details see TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer().
******************************************************************************/
-#define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC
+ #define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC
/******************************************************************************
* TRC_CFG_MAX_ISR_NESTING
@@ -284,17 +285,17 @@ extern "C" {
*
* Default value: 8
*****************************************************************************/
-#define TRC_CFG_MAX_ISR_NESTING 8
+ #define TRC_CFG_MAX_ISR_NESTING 8
/* Specific configuration, depending on Streaming/Snapshot mode */
-#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
-#include "trcSnapshotConfig.h"
-#elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
-#include "trcStreamingConfig.h"
-#endif
+ #if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT )
+ #include "trcSnapshotConfig.h"
+ #elif ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
+ #include "trcStreamingConfig.h"
+ #endif
-#ifdef __cplusplus
-}
-#endif
+ #ifdef __cplusplus
+ }
+ #endif
#endif /* _TRC_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcSnapshotConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcSnapshotConfig.h
index 9ccb32d47..ed640494e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcSnapshotConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_plain_text/trcSnapshotConfig.h
@@ -46,8 +46,8 @@
#ifndef TRC_SNAPSHOT_CONFIG_H
#define TRC_SNAPSHOT_CONFIG_H
-#define TRC_SNAPSHOT_MODE_RING_BUFFER (0x01)
-#define TRC_SNAPSHOT_MODE_STOP_WHEN_FULL (0x02)
+#define TRC_SNAPSHOT_MODE_RING_BUFFER ( 0x01 )
+#define TRC_SNAPSHOT_MODE_STOP_WHEN_FULL ( 0x02 )
/******************************************************************************
* TRC_CFG_SNAPSHOT_MODE
@@ -67,7 +67,7 @@
* recording is stopped when the buffer becomes full. This is useful for
* recording events following a specific state, e.g., the startup sequence.
*****************************************************************************/
-#define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER
+#define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER
/*******************************************************************************
* TRC_CFG_EVENT_BUFFER_SIZE
@@ -82,7 +82,7 @@
* Default value is 1000, which means that 4000 bytes is allocated for the
* event buffer.
******************************************************************************/
-#define TRC_CFG_EVENT_BUFFER_SIZE 50000
+#define TRC_CFG_EVENT_BUFFER_SIZE 50000
/*******************************************************************************
* TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE...
@@ -106,15 +106,15 @@
* check the actual usage by selecting View menu -> Trace Details ->
* Resource Usage -> Object Table.
******************************************************************************/
-#define TRC_CFG_NTASK 15
-#define TRC_CFG_NISR 10
-#define TRC_CFG_NQUEUE 10
-#define TRC_CFG_NSEMAPHORE 20
-#define TRC_CFG_NMUTEX 20
-#define TRC_CFG_NTIMER 20
-#define TRC_CFG_NEVENTGROUP 20
-#define TRC_CFG_NSTREAMBUFFER 10
-#define TRC_CFG_NMESSAGEBUFFER 10
+#define TRC_CFG_NTASK 15
+#define TRC_CFG_NISR 10
+#define TRC_CFG_NQUEUE 10
+#define TRC_CFG_NSEMAPHORE 20
+#define TRC_CFG_NMUTEX 20
+#define TRC_CFG_NTIMER 20
+#define TRC_CFG_NEVENTGROUP 20
+#define TRC_CFG_NSTREAMBUFFER 10
+#define TRC_CFG_NMESSAGEBUFFER 10
/******************************************************************************
@@ -133,7 +133,7 @@
*
* Default value is 0.
*****************************************************************************/
-#define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0
+#define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0
/*******************************************************************************
* TRC_CFG_SYMBOL_TABLE_SIZE
@@ -149,10 +149,10 @@
*
* Default value is 800.
******************************************************************************/
-#define TRC_CFG_SYMBOL_TABLE_SIZE 8000
+#define TRC_CFG_SYMBOL_TABLE_SIZE 8000
-#if (TRC_CFG_SYMBOL_TABLE_SIZE == 0)
-#error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!"
+#if ( TRC_CFG_SYMBOL_TABLE_SIZE == 0 )
+ #error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!"
#endif
/******************************************************************************
@@ -162,15 +162,15 @@
* kernel objects, such as tasks and queues. If longer names are used, they will
* be truncated when stored in the recorder.
*****************************************************************************/
-#define TRC_CFG_NAME_LEN_TASK 15
-#define TRC_CFG_NAME_LEN_ISR 15
-#define TRC_CFG_NAME_LEN_QUEUE 15
-#define TRC_CFG_NAME_LEN_SEMAPHORE 15
-#define TRC_CFG_NAME_LEN_MUTEX 15
-#define TRC_CFG_NAME_LEN_TIMER 15
-#define TRC_CFG_NAME_LEN_EVENTGROUP 15
-#define TRC_CFG_NAME_LEN_STREAMBUFFER 15
-#define TRC_CFG_NAME_LEN_MESSAGEBUFFER 15
+#define TRC_CFG_NAME_LEN_TASK 15
+#define TRC_CFG_NAME_LEN_ISR 15
+#define TRC_CFG_NAME_LEN_QUEUE 15
+#define TRC_CFG_NAME_LEN_SEMAPHORE 15
+#define TRC_CFG_NAME_LEN_MUTEX 15
+#define TRC_CFG_NAME_LEN_TIMER 15
+#define TRC_CFG_NAME_LEN_EVENTGROUP 15
+#define TRC_CFG_NAME_LEN_STREAMBUFFER 15
+#define TRC_CFG_NAME_LEN_MESSAGEBUFFER 15
/******************************************************************************
*** ADVANCED SETTINGS ********************************************************
@@ -190,7 +190,7 @@
*
* Default value is 0.
******************************************************************************/
-#define TRC_CFG_HEAP_SIZE_BELOW_16M 0
+#define TRC_CFG_HEAP_SIZE_BELOW_16M 0
/******************************************************************************
* TRC_CFG_USE_IMPLICIT_IFE_RULES
@@ -222,7 +222,7 @@
* For details, see trcSnapshotKernelPort.h and look for references to the
* macro trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED.
*****************************************************************************/
-#define TRC_CFG_USE_IMPLICIT_IFE_RULES 1
+#define TRC_CFG_USE_IMPLICIT_IFE_RULES 1
/******************************************************************************
* TRC_CFG_USE_16BIT_OBJECT_HANDLES
@@ -246,7 +246,7 @@
* the event buffer whenever the object is referenced. Moreover, some internal
* tables in the recorder gets slightly larger when using 16-bit handles.
*****************************************************************************/
-#define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0
+#define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0
/******************************************************************************
* TRC_CFG_USE_TRACE_ASSERT
@@ -264,7 +264,7 @@
* parameters. Can be switched off to reduce the footprint of the tracing, but
* we recommend to have it enabled initially.
*****************************************************************************/
-#define TRC_CFG_USE_TRACE_ASSERT 1
+#define TRC_CFG_USE_TRACE_ASSERT 1
/*******************************************************************************
* TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER
@@ -320,9 +320,9 @@
*
* // Finds the existing UB channel
* vTracePrintF(chn2, "%Z: %d", value2);
-
+ *
******************************************************************************/
-#define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0
+#define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0
/*******************************************************************************
* TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE
@@ -334,7 +334,7 @@
*
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
******************************************************************************/
-#define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200
+#define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200
/*******************************************************************************
* TRC_CFG_UB_CHANNELS
@@ -348,7 +348,7 @@
*
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
******************************************************************************/
-#define TRC_CFG_UB_CHANNELS 32
+#define TRC_CFG_UB_CHANNELS 32
/*******************************************************************************
* TRC_CFG_ISR_TAILCHAINING_THRESHOLD
@@ -373,6 +373,6 @@
* Note: This setting has separate definitions in trcSnapshotConfig.h and
* trcStreamingConfig.h, since it is affected by the recorder mode.
******************************************************************************/
-#define TRC_CFG_ISR_TAILCHAINING_THRESHOLD 0
+#define TRC_CFG_ISR_TAILCHAINING_THRESHOLD 0
#endif /*TRC_SNAPSHOT_CONFIG_H*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSConfig.h
index 642113c41..ebee2a143 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSConfig.h
@@ -29,94 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile, uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -124,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demos of IoT Libraries. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-
-#if( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSIPConfig.h
index 39a61856b..0375594c1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/FreeRTOSIPConfig.h
@@ -27,284 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ( (x) != NULL )
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/demo_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/demo_config.h
index 3a1cfdad0..bc7b32b15 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/demo_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/demo_config.h
@@ -48,13 +48,13 @@
* For more information regarding TLS protocol:
* https://www.freertos.org/mqtt/tls.html
*/
-#define democonfigENABLE_TLS 1
+#define democonfigENABLE_TLS 1
/**
* @brief Enable/Disable mutual authentication in demos. If enabled, require
* democonfigENABLE_TLS to be set to 1.
*/
-#define democonfigENABLE_MUTUAL_AUTH 1
+#define democonfigENABLE_MUTUAL_AUTH 1
/**
* @brief Select a connection profile.
@@ -65,7 +65,7 @@
* enabled, requires democonfigENABLE_MUTUAL_AUTH to be set to 1 since AWS IoT
* requires mutually authenticated connection.
*/
-#define democonfigPROFILE_USE_AWS_IOT 1
+#define democonfigPROFILE_USE_AWS_IOT 1
/**
* @brief Set the stack size of the main demo task.
@@ -73,6 +73,6 @@
* In the Windows port, this stack only holds a structure. The actual
* stack is created by an operating system thread.
*/
-#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
+#define democonfigDEMO_STACKSIZE configMINIMAL_STACK_SIZE
#endif /* DEMO_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/iot_config.h
index 03ed26deb..5290ceaf1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/mqtt_tls_mutual_auth/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/**
* @brief Set the log level of the MQTT library.
@@ -75,14 +75,14 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
+#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
/**
* @brief Enable TLS in the network abstraction.
*
* The TLS implementation requires the mbed TLS library.
*/
-#define IOT_NETWORK_ENABLE_TLS 1
+#define IOT_NETWORK_ENABLE_TLS 1
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -96,7 +96,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/**
* @brief Enable/Disable asserts for the MQTT library.
@@ -110,12 +110,12 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_MQTT_ENABLE_ASSERTS 1
+#define IOT_MQTT_ENABLE_ASSERTS 1
/**
* @brief Enable/Disable anonymous metrics collection when using AWS IoT.
*/
-#define AWS_IOT_MQTT_ENABLE_METRICS 0
+#define AWS_IOT_MQTT_ENABLE_METRICS 0
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c
index e01839c71..4ee43aaea 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c
@@ -85,7 +85,7 @@ static void _connectionRetryDelay( void );
*/
static void prvNetworkDisconnectCallback( void * param,
- IotMqttCallbackParam_t * mqttCallbackParams );
+ IotMqttCallbackParam_t * mqttCallbackParams );
/**
@@ -105,99 +105,99 @@ static void prvNetworkDisconnectCallback( void * param,
* error code returned by `IotMqtt_Connect`.
*/
static IotMqttError_t _establishMqttConnection( bool awsIotMqttMode,
- IotMqttConnection_t * pMqttConnection );
+ IotMqttConnection_t * pMqttConnection );
/*-----------------------------------------------------------*/
-#define otaDemoCONN_TIMEOUT_MS ( 2000UL )
+#define otaDemoCONN_TIMEOUT_MS ( 2000UL )
-#define otaDemoKEEPALIVE_SECONDS ( 120 )
+#define otaDemoKEEPALIVE_SECONDS ( 120 )
-#define otaDemoCONN_RETRY_BASE_INTERVAL_SECONDS ( 4U )
+#define otaDemoCONN_RETRY_BASE_INTERVAL_SECONDS ( 4U )
-#define otaDemoCONN_RETRY_MAX_INTERVAL_SECONDS ( 360U )
+#define otaDemoCONN_RETRY_MAX_INTERVAL_SECONDS ( 360U )
-#define otaDemoTASK_DELAY_SECONDS ( 1UL )
+#define otaDemoTASK_DELAY_SECONDS ( 1UL )
/**
* @brief OTA state machine string.
*/
-static const char * pcStateStr[ eOTA_AgentState_All ] =
+static const char * pcStateStr[ eOTA_AgentState_All ] =
{
- "Init",
- "Ready",
- "RequestingJob",
- "WaitingForJob",
- "CreatingFile",
- "RequestingFileBlock",
- "WaitingForFileBlock",
- "ClosingFile",
- "ShuttingDown",
- "Stopped"
+ "Init",
+ "Ready",
+ "RequestingJob",
+ "WaitingForJob",
+ "CreatingFile",
+ "RequestingFileBlock",
+ "WaitingForFileBlock",
+ "ClosingFile",
+ "ShuttingDown",
+ "Stopped"
};
-static const struct IotNetworkServerInfo xMQTTBrokerInfo =
+static const struct IotNetworkServerInfo xMQTTBrokerInfo =
{
- .pHostName = awsiotdemoprofileAWS_ENDPOINT,
- .port = awsiotdemoprofileAWS_MQTT_PORT
+ .pHostName = awsiotdemoprofileAWS_ENDPOINT,
+ .port = awsiotdemoprofileAWS_MQTT_PORT
};
-static struct IotNetworkCredentials xNetworkSecurityCredentials =
+static struct IotNetworkCredentials xNetworkSecurityCredentials =
{
- /* Optional TLS extensions. For this demo, they are disabled. */
- .pAlpnProtos = NULL,
- .maxFragmentLength = 0,
-
- /* SNI is enabled by default. */
- .disableSni = false,
-
- /* Provide the certificate for validating the server. Only required for
- * demos using TLS. */
- .pRootCa = awsiotdemoprofileAWS_CERTIFICATE_PEM,
- .rootCaSize = sizeof( awsiotdemoprofileAWS_CERTIFICATE_PEM ),
-
- /* Strong mutual authentication to authenticate both the broker and
- * the client. */
- .pClientCert = awsiotdemoprofileCLIENT_CERTIFICATE_PEM,
- .clientCertSize = sizeof( awsiotdemoprofileCLIENT_CERTIFICATE_PEM ),
- .pPrivateKey = awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM,
- .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM )
+ /* Optional TLS extensions. For this demo, they are disabled. */
+ .pAlpnProtos = NULL,
+ .maxFragmentLength = 0,
+
+ /* SNI is enabled by default. */
+ .disableSni = false,
+
+ /* Provide the certificate for validating the server. Only required for
+ * demos using TLS. */
+ .pRootCa = awsiotdemoprofileAWS_CERTIFICATE_PEM,
+ .rootCaSize = sizeof( awsiotdemoprofileAWS_CERTIFICATE_PEM ),
+
+ /* Strong mutual authentication to authenticate both the broker and
+ * the client. */
+ .pClientCert = awsiotdemoprofileCLIENT_CERTIFICATE_PEM,
+ .clientCertSize = sizeof( awsiotdemoprofileCLIENT_CERTIFICATE_PEM ),
+ .pPrivateKey = awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM,
+ .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM )
};
-static IotMqttNetworkInfo_t xNetworkInfo =
+static IotMqttNetworkInfo_t xNetworkInfo =
{
- /* No connection to the MQTT broker has been established yet and we want to
- * establish a new connection. */
- .createNetworkConnection = true,
- .u.setup.pNetworkServerInfo = &( xMQTTBrokerInfo ),
-
- /* Set the TLS credentials for the new MQTT connection. This member is NULL
- * for the plain text MQTT demo. */
- .u.setup.pNetworkCredentialInfo = &xNetworkSecurityCredentials,
-
- /* Use FreeRTOS+TCP network interface. */
- .pNetworkInterface = IOT_NETWORK_INTERFACE_FREERTOS,
-
- /* Setup the callback which is called when the MQTT connection is
- * disconnected. The task handle is passed as the callback context which
- * is used by the callback to send a task notification to this task.*/
- .disconnectCallback.function = prvNetworkDisconnectCallback
+ /* No connection to the MQTT broker has been established yet and we want to
+ * establish a new connection. */
+ .createNetworkConnection = true,
+ .u.setup.pNetworkServerInfo = &( xMQTTBrokerInfo ),
+
+ /* Set the TLS credentials for the new MQTT connection. This member is NULL
+ * for the plain text MQTT demo. */
+ .u.setup.pNetworkCredentialInfo = &xNetworkSecurityCredentials,
+
+ /* Use FreeRTOS+TCP network interface. */
+ .pNetworkInterface = IOT_NETWORK_INTERFACE_FREERTOS,
+
+ /* Setup the callback which is called when the MQTT connection is
+ * disconnected. The task handle is passed as the callback context which
+ * is used by the callback to send a task notification to this task.*/
+ .disconnectCallback.function = prvNetworkDisconnectCallback
};
/**
* @brief The MQTT connection handle used in this example.
*/
-static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
+static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
/**
* @brief The MQTT connection info used for MQTT connection.
*/
-IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER;
+IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER;
/**
* @brief Flag used to unset, during disconnection of currently connected network. This will
* trigger a reconnection from the OTA demo task.
*/
-volatile static bool _networkConnected = false;
+volatile static bool _networkConnected = false;
/**
* @brief Connection retry interval in seconds.
@@ -208,92 +208,92 @@ static int _retryInterval = otaDemoCONN_RETRY_BASE_INTERVAL_SECONDS;
void vOTAUpdateDemoTask( void * pvParameters )
{
-OTA_State_t eState;
-OTA_ConnectionContext_t xOTAConnectionCtx = { 0 };
-
- /* Remove compiler warnings about unused parameters. */
- ( void ) pvParameters;
-
- /* One time initialization of the libraries used by this demo. */
- prvInitialiseLibraries();
-
- configPRINTF( ( "OTA demo version %u.%u.%u\r\n",
- xAppFirmwareVersion.u.x.ucMajor,
- xAppFirmwareVersion.u.x.ucMinor,
- xAppFirmwareVersion.u.x.usBuild ) );
- configPRINTF( ( "Creating MQTT Client...\r\n" ) );
-
- /* Create the MQTT Client. */
-
- for( ; ; )
- {
- configPRINTF( ( "Connecting to broker...\r\n" ) );
-
- /* Establish a new MQTT connection. */
- if( _establishMqttConnection( true,
- &xMQTTConnection ) == IOT_MQTT_SUCCESS )
- {
- configPRINTF( ( "Connected to broker.\r\n" ) );
- xOTAConnectionCtx.pvControlClient = xMQTTConnection;
- xOTAConnectionCtx.pxNetworkInterface = ( void * ) IOT_NETWORK_INTERFACE_FREERTOS;
- xOTAConnectionCtx.pvNetworkCredentials = &xNetworkSecurityCredentials;
-
- /* Set the base interval for connection retry.*/
- _retryInterval = otaDemoCONN_RETRY_BASE_INTERVAL_SECONDS;
-
- /* Update the connection available flag.*/
- _networkConnected = true;
-
- /* Check if OTA Agent is suspended and resume.*/
- if( ( eState = OTA_GetAgentState() ) == eOTA_AgentState_Suspended )
- {
- OTA_Resume( &xOTAConnectionCtx );
- }
-
- /* Check if OTA Agent is suspended and resume.*/
- if( ( eState = OTA_GetAgentState() ) == eOTA_AgentState_Suspended )
- {
- OTA_Resume( &xOTAConnectionCtx );
- }
-
- /* Initialize the OTA Agent , if it is resuming the OTA statistics will be cleared for new connection.*/
- OTA_AgentInit( ( void * ) ( &xOTAConnectionCtx ), ( const uint8_t * ) ( awsiotdemoprofileCLIENT_IDENTIFIER ), App_OTACompleteCallback, ( TickType_t ) ~0 );
-
- while( ( ( eState = OTA_GetAgentState() ) != eOTA_AgentState_Stopped ) && _networkConnected )
- {
- /* Wait forever for OTA traffic but allow other tasks to run and output statistics only once per second. */
- IotClock_SleepMs( otaDemoTASK_DELAY_SECONDS * 1000 );
-
- configPRINTF( ( "State: %s Received: %u Queued: %u Processed: %u Dropped: %u\r\n", pcStateStr[ eState ],
- OTA_GetPacketsReceived(), OTA_GetPacketsQueued(), OTA_GetPacketsProcessed(), OTA_GetPacketsDropped() ) );
- }
-
- /* Check if we got network disconnect callback and suspend OTA Agent.*/
- if( _networkConnected == false )
- {
- /* Suspend OTA agent.*/
- if( OTA_Suspend() == kOTA_Err_None )
- {
- while( ( eState = OTA_GetAgentState() ) != eOTA_AgentState_Suspended )
- {
- /* Wait for OTA Agent to process the suspend event. */
- IotClock_SleepMs( otaDemoTASK_DELAY_SECONDS * 1000 );
- }
- }
- }
- else
- {
- IotMqtt_Disconnect( xMQTTConnection, false );
- }
- }
- else
- {
- configPRINTF( ( "ERROR: Failed to connect to MQTT broker.\r\n" ) );
- }
-
- /* After failure to connect or a disconnect, delay for retrying connection. */
- _connectionRetryDelay();
- }
+ OTA_State_t eState;
+ OTA_ConnectionContext_t xOTAConnectionCtx = { 0 };
+
+ /* Remove compiler warnings about unused parameters. */
+ ( void ) pvParameters;
+
+ /* One time initialization of the libraries used by this demo. */
+ prvInitialiseLibraries();
+
+ configPRINTF( ( "OTA demo version %u.%u.%u\r\n",
+ xAppFirmwareVersion.u.x.ucMajor,
+ xAppFirmwareVersion.u.x.ucMinor,
+ xAppFirmwareVersion.u.x.usBuild ) );
+ configPRINTF( ( "Creating MQTT Client...\r\n" ) );
+
+ /* Create the MQTT Client. */
+
+ for( ; ; )
+ {
+ configPRINTF( ( "Connecting to broker...\r\n" ) );
+
+ /* Establish a new MQTT connection. */
+ if( _establishMqttConnection( true,
+ &xMQTTConnection ) == IOT_MQTT_SUCCESS )
+ {
+ configPRINTF( ( "Connected to broker.\r\n" ) );
+ xOTAConnectionCtx.pvControlClient = xMQTTConnection;
+ xOTAConnectionCtx.pxNetworkInterface = ( void * ) IOT_NETWORK_INTERFACE_FREERTOS;
+ xOTAConnectionCtx.pvNetworkCredentials = &xNetworkSecurityCredentials;
+
+ /* Set the base interval for connection retry.*/
+ _retryInterval = otaDemoCONN_RETRY_BASE_INTERVAL_SECONDS;
+
+ /* Update the connection available flag.*/
+ _networkConnected = true;
+
+ /* Check if OTA Agent is suspended and resume.*/
+ if( ( eState = OTA_GetAgentState() ) == eOTA_AgentState_Suspended )
+ {
+ OTA_Resume( &xOTAConnectionCtx );
+ }
+
+ /* Check if OTA Agent is suspended and resume.*/
+ if( ( eState = OTA_GetAgentState() ) == eOTA_AgentState_Suspended )
+ {
+ OTA_Resume( &xOTAConnectionCtx );
+ }
+
+ /* Initialize the OTA Agent , if it is resuming the OTA statistics will be cleared for new connection.*/
+ OTA_AgentInit( ( void * ) ( &xOTAConnectionCtx ), ( const uint8_t * ) ( awsiotdemoprofileCLIENT_IDENTIFIER ), App_OTACompleteCallback, ( TickType_t ) ~0 );
+
+ while( ( ( eState = OTA_GetAgentState() ) != eOTA_AgentState_Stopped ) && _networkConnected )
+ {
+ /* Wait forever for OTA traffic but allow other tasks to run and output statistics only once per second. */
+ IotClock_SleepMs( otaDemoTASK_DELAY_SECONDS * 1000 );
+
+ configPRINTF( ( "State: %s Received: %u Queued: %u Processed: %u Dropped: %u\r\n", pcStateStr[ eState ],
+ OTA_GetPacketsReceived(), OTA_GetPacketsQueued(), OTA_GetPacketsProcessed(), OTA_GetPacketsDropped() ) );
+ }
+
+ /* Check if we got network disconnect callback and suspend OTA Agent.*/
+ if( _networkConnected == false )
+ {
+ /* Suspend OTA agent.*/
+ if( OTA_Suspend() == kOTA_Err_None )
+ {
+ while( ( eState = OTA_GetAgentState() ) != eOTA_AgentState_Suspended )
+ {
+ /* Wait for OTA Agent to process the suspend event. */
+ IotClock_SleepMs( otaDemoTASK_DELAY_SECONDS * 1000 );
+ }
+ }
+ }
+ else
+ {
+ IotMqtt_Disconnect( xMQTTConnection, false );
+ }
+ }
+ else
+ {
+ configPRINTF( ( "ERROR: Failed to connect to MQTT broker.\r\n" ) );
+ }
+
+ /* After failure to connect or a disconnect, delay for retrying connection. */
+ _connectionRetryDelay();
+ }
}
@@ -313,160 +313,160 @@ OTA_ConnectionContext_t xOTAConnectionCtx = { 0 };
static void App_OTACompleteCallback( OTA_JobEvent_t eEvent )
{
-OTA_Err_t xErr = kOTA_Err_Uninitialized;
-
-
- /* OTA job is completed. so delete the MQTT and network connection. */
- if( eEvent == eOTA_JobEvent_Activate )
- {
- configPRINTF( ( "Received eOTA_JobEvent_Activate callback from OTA Agent.\r\n" ) );
- IotMqtt_Disconnect( xMQTTConnection, 0 );
- OTA_ActivateNewImage();
-
- /* We should never get here as new image activation must reset the device.*/
- configPRINTF( ( "ERROR: New image activation failed.\r\n" ) );
-
- for( ; ; )
- {
- IotClock_SleepMs( otaDemoTASK_DELAY_SECONDS * 1000 );
- }
- }
- else if( eEvent == eOTA_JobEvent_Fail )
- {
- configPRINTF( ( "Received eOTA_JobEvent_Fail callback from OTA Agent.\r\n" ) );
- /* Nothing special to do. The OTA agent handles it. */
- }
- else if( eEvent == eOTA_JobEvent_StartTest )
- {
- /* This demo just accepts the image since it was a good OTA update and networking
- * and services are all working (or we wouldn't have made it this far). If this
- * were some custom device that wants to test other things before calling it OK,
- * this would be the place to kick off those tests before calling OTA_SetImageState()
- * with the final result of either accepted or rejected. */
- configPRINTF( ( "Received eOTA_JobEvent_StartTest callback from OTA Agent.\r\n" ) );
- xErr = OTA_SetImageState( eOTA_ImageState_Accepted );
-
- if( xErr != kOTA_Err_None )
- {
- OTA_LOG_L1( " Error! Failed to set image state as accepted.\r\n" );
- }
- }
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
+
+
+ /* OTA job is completed. so delete the MQTT and network connection. */
+ if( eEvent == eOTA_JobEvent_Activate )
+ {
+ configPRINTF( ( "Received eOTA_JobEvent_Activate callback from OTA Agent.\r\n" ) );
+ IotMqtt_Disconnect( xMQTTConnection, 0 );
+ OTA_ActivateNewImage();
+
+ /* We should never get here as new image activation must reset the device.*/
+ configPRINTF( ( "ERROR: New image activation failed.\r\n" ) );
+
+ for( ; ; )
+ {
+ IotClock_SleepMs( otaDemoTASK_DELAY_SECONDS * 1000 );
+ }
+ }
+ else if( eEvent == eOTA_JobEvent_Fail )
+ {
+ configPRINTF( ( "Received eOTA_JobEvent_Fail callback from OTA Agent.\r\n" ) );
+ /* Nothing special to do. The OTA agent handles it. */
+ }
+ else if( eEvent == eOTA_JobEvent_StartTest )
+ {
+ /* This demo just accepts the image since it was a good OTA update and networking
+ * and services are all working (or we wouldn't have made it this far). If this
+ * were some custom device that wants to test other things before calling it OK,
+ * this would be the place to kick off those tests before calling OTA_SetImageState()
+ * with the final result of either accepted or rejected. */
+ configPRINTF( ( "Received eOTA_JobEvent_StartTest callback from OTA Agent.\r\n" ) );
+ xErr = OTA_SetImageState( eOTA_ImageState_Accepted );
+
+ if( xErr != kOTA_Err_None )
+ {
+ OTA_LOG_L1( " Error! Failed to set image state as accepted.\r\n" );
+ }
+ }
}
/*-----------------------------------------------------------*/
void vStartOTAUpdateDemo( void )
{
- xTaskCreate( vOTAUpdateDemoTask, /* Function that implements the task. */
- "OTAUpdateDemo", /* Text name for the task - only used for debugging. */
- democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
- NULL, /* Task parameter - not used in this case. */
- tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */
- NULL ); /* Used to pass out a handle to the created task - not used in this case. */
+ xTaskCreate( vOTAUpdateDemoTask, /* Function that implements the task. */
+ "OTAUpdateDemo", /* Text name for the task - only used for debugging. */
+ democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
+ NULL, /* Task parameter - not used in this case. */
+ tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */
+ NULL ); /* Used to pass out a handle to the created task - not used in this case. */
}
/*-----------------------------------------------------------*/
static void prvInitialiseLibraries( void )
{
-IotMqttError_t xResult;
-IotNetworkError_t xNetworkResult;
+ IotMqttError_t xResult;
+ IotNetworkError_t xNetworkResult;
- /* Initialize the network stack abstraction for FreeRTOS. */
- xNetworkResult = IotNetworkFreeRTOS_Init();
- configASSERT( xNetworkResult == IOT_NETWORK_SUCCESS );
+ /* Initialize the network stack abstraction for FreeRTOS. */
+ xNetworkResult = IotNetworkFreeRTOS_Init();
+ configASSERT( xNetworkResult == IOT_NETWORK_SUCCESS );
- /* MQTT library must be initialized before it can be used. This is just one
- * time initialization. */
- xResult = IotMqtt_Init();
- configASSERT( xResult == IOT_MQTT_SUCCESS );
+ /* MQTT library must be initialized before it can be used. This is just one
+ * time initialization. */
+ xResult = IotMqtt_Init();
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void _connectionRetryDelay( void )
{
-unsigned int retryIntervalwithJitter = 0;
-
- if( ( _retryInterval * 2 ) >= otaDemoCONN_RETRY_MAX_INTERVAL_SECONDS )
- {
- /* Retry interval is already max.*/
- _retryInterval = otaDemoCONN_RETRY_MAX_INTERVAL_SECONDS;
- }
- else
- {
- /* Double the retry interval time.*/
- _retryInterval *= 2;
- }
-
- /* Add random jitter upto current retry interval .*/
- retryIntervalwithJitter = _retryInterval + ( rand() % _retryInterval );
-
- configPRINTF( ( "Retrying network connection in %d Secs ", retryIntervalwithJitter ) );
-
- /* Delay for the calculated time interval .*/
- IotClock_SleepMs( retryIntervalwithJitter * 1000 );
+ unsigned int retryIntervalwithJitter = 0;
+
+ if( ( _retryInterval * 2 ) >= otaDemoCONN_RETRY_MAX_INTERVAL_SECONDS )
+ {
+ /* Retry interval is already max.*/
+ _retryInterval = otaDemoCONN_RETRY_MAX_INTERVAL_SECONDS;
+ }
+ else
+ {
+ /* Double the retry interval time.*/
+ _retryInterval *= 2;
+ }
+
+ /* Add random jitter upto current retry interval .*/
+ retryIntervalwithJitter = _retryInterval + ( rand() % _retryInterval );
+
+ configPRINTF( ( "Retrying network connection in %d Secs ", retryIntervalwithJitter ) );
+
+ /* Delay for the calculated time interval .*/
+ IotClock_SleepMs( retryIntervalwithJitter * 1000 );
}
/*-----------------------------------------------------------*/
static void prvNetworkDisconnectCallback( void * param,
- IotMqttCallbackParam_t * mqttCallbackParams )
+ IotMqttCallbackParam_t * mqttCallbackParams )
{
- ( void ) param;
-
- /* Log the reason for MQTT disconnect.*/
- switch( mqttCallbackParams->u.disconnectReason )
- {
- case IOT_MQTT_DISCONNECT_CALLED:
- configPRINTF( ( "Mqtt disconnected due to invoking diconnect function.\r\n" ) );
- break;
-
- case IOT_MQTT_BAD_PACKET_RECEIVED:
- configPRINTF( ( "Mqtt disconnected due to invalid packet received from the network.\r\n" ) );
- break;
-
- case IOT_MQTT_KEEP_ALIVE_TIMEOUT:
- configPRINTF( ( "Mqtt disconnected due to Keep-alive response not received.\r\n" ) );
- break;
-
- default:
- configPRINTF( ( "Mqtt disconnected due to unknown reason." ) );
- break;
- }
-
- /* Clear the flag for network connection status.*/
- _networkConnected = false;
+ ( void ) param;
+
+ /* Log the reason for MQTT disconnect.*/
+ switch( mqttCallbackParams->u.disconnectReason )
+ {
+ case IOT_MQTT_DISCONNECT_CALLED:
+ configPRINTF( ( "Mqtt disconnected due to invoking diconnect function.\r\n" ) );
+ break;
+
+ case IOT_MQTT_BAD_PACKET_RECEIVED:
+ configPRINTF( ( "Mqtt disconnected due to invalid packet received from the network.\r\n" ) );
+ break;
+
+ case IOT_MQTT_KEEP_ALIVE_TIMEOUT:
+ configPRINTF( ( "Mqtt disconnected due to Keep-alive response not received.\r\n" ) );
+ break;
+
+ default:
+ configPRINTF( ( "Mqtt disconnected due to unknown reason." ) );
+ break;
+ }
+
+ /* Clear the flag for network connection status.*/
+ _networkConnected = false;
}
/*-----------------------------------------------------------*/
static IotMqttError_t _establishMqttConnection( bool awsIotMqttMode,
- IotMqttConnection_t * pMqttConnection )
+ IotMqttConnection_t * pMqttConnection )
{
-IotMqttError_t connectStatus = IOT_MQTT_STATUS_PENDING;
-
- /* Set the members of the connection info not set by the initializer. */
- memset( &xConnectInfo, 0, sizeof( xConnectInfo ) );
- xConnectInfo.awsIotMqttMode = awsIotMqttMode;
- xConnectInfo.cleanSession = true;
- xConnectInfo.keepAliveSeconds = otaDemoKEEPALIVE_SECONDS;
- xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( awsiotdemoprofileCLIENT_IDENTIFIER );
- xConnectInfo.pClientIdentifier = awsiotdemoprofileCLIENT_IDENTIFIER;
-
- /* Establish the MQTT connection. */
- configPRINTF( ( "MQTT demo client identifier is %.*s (length %hu).",
- xConnectInfo.clientIdentifierLength,
- xConnectInfo.pClientIdentifier,
- xConnectInfo.clientIdentifierLength ) );
-
- connectStatus = IotMqtt_Connect( &xNetworkInfo,
- &xConnectInfo,
- otaDemoCONN_TIMEOUT_MS,
- pMqttConnection );
-
- if( connectStatus != IOT_MQTT_SUCCESS )
- {
- configPRINTF( ( "MQTT CONNECT returned error %s.",
- IotMqtt_strerror( connectStatus ) ) );
- }
-
- return connectStatus;
+ IotMqttError_t connectStatus = IOT_MQTT_STATUS_PENDING;
+
+ /* Set the members of the connection info not set by the initializer. */
+ memset( &xConnectInfo, 0, sizeof( xConnectInfo ) );
+ xConnectInfo.awsIotMqttMode = awsIotMqttMode;
+ xConnectInfo.cleanSession = true;
+ xConnectInfo.keepAliveSeconds = otaDemoKEEPALIVE_SECONDS;
+ xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( awsiotdemoprofileCLIENT_IDENTIFIER );
+ xConnectInfo.pClientIdentifier = awsiotdemoprofileCLIENT_IDENTIFIER;
+
+ /* Establish the MQTT connection. */
+ configPRINTF( ( "MQTT demo client identifier is %.*s (length %hu).",
+ xConnectInfo.clientIdentifierLength,
+ xConnectInfo.pClientIdentifier,
+ xConnectInfo.clientIdentifierLength ) );
+
+ connectStatus = IotMqtt_Connect( &xNetworkInfo,
+ &xConnectInfo,
+ otaDemoCONN_TIMEOUT_MS,
+ pMqttConnection );
+
+ if( connectStatus != IOT_MQTT_SUCCESS )
+ {
+ configPRINTF( ( "MQTT CONNECT returned error %s.",
+ IotMqtt_strerror( connectStatus ) ) );
+ }
+
+ return connectStatus;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_application_version.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_application_version.h
index afc9ae3a2..03a1740eb 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_application_version.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_application_version.h
@@ -29,8 +29,8 @@
#include "iot_appversion32.h"
extern const AppVersion32_t xAppFirmwareVersion;
-#define APP_VERSION_MAJOR 0
-#define APP_VERSION_MINOR 9
-#define APP_VERSION_BUILD 2
+#define APP_VERSION_MAJOR 0
+#define APP_VERSION_MINOR 9
+#define APP_VERSION_BUILD 2
#endif
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_demo_version.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_demo_version.c
index 215a4b67e..e05964025 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_demo_version.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_demo_version.c
@@ -29,7 +29,7 @@
/* Declare the firmware version structure for all to see. */
const AppVersion32_t xAppFirmwareVersion =
{
- .u.x.ucMajor = APP_VERSION_MAJOR,
- .u.x.ucMinor = APP_VERSION_MINOR,
- .u.x.usBuild = APP_VERSION_BUILD,
+ .u.x.ucMajor = APP_VERSION_MAJOR,
+ .u.x.ucMinor = APP_VERSION_MINOR,
+ .u.x.usBuild = APP_VERSION_BUILD,
};
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c
index 2ff302c55..281f2e0d9 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c
@@ -41,64 +41,64 @@ const char cOTA_JSON_FileSignatureKey[ OTA_FILE_SIG_KEY_STR_MAX_LENGTH ] = "sig-
static OTA_Err_t prvPAL_CheckFileSignature( OTA_FileContext_t * const C );
static uint8_t * prvPAL_ReadAndAssumeCertificate( const uint8_t * const pucCertName,
- uint32_t * const ulSignerCertSize );
+ uint32_t * const ulSignerCertSize );
/*-----------------------------------------------------------*/
static inline BaseType_t prvContextValidate( OTA_FileContext_t * C )
{
- return( ( C != NULL ) &&
- ( C->pxFile != NULL ) ); /*lint !e9034 Comparison is correct for file pointer type. */
+ return( ( C != NULL ) &&
+ ( C->pxFile != NULL ) ); /*lint !e9034 Comparison is correct for file pointer type. */
}
/* Used to set the high bit of Windows error codes for a negative return value. */
-#define OTA_PAL_INT16_NEGATIVE_MASK ( 1 << 15 )
+#define OTA_PAL_INT16_NEGATIVE_MASK ( 1 << 15 )
/* Size of buffer used in file operations on this platform (Windows). */
-#define OTA_PAL_WIN_BUF_SIZE ( ( size_t ) 4096UL )
+#define OTA_PAL_WIN_BUF_SIZE ( ( size_t ) 4096UL )
/* Attempt to create a new receive file for the file chunks as they come in. */
OTA_Err_t prvPAL_CreateFileForRx( OTA_FileContext_t * const C )
{
- DEFINE_OTA_METHOD_NAME( "prvPAL_CreateFileForRx" );
-
- OTA_Err_t eResult = kOTA_Err_Uninitialized; /* For MISRA mandatory. */
-
- if( C != NULL )
- {
- if( C->pucFilePath != NULL )
- {
- C->pxFile = fopen( ( const char * ) C->pucFilePath, "w+b" ); /*lint !e586
- * C standard library call is being used for portability. */
-
- if( C->pxFile != NULL )
- {
- eResult = kOTA_Err_None;
- OTA_LOG_L1( "[%s] Receive file created.\r\n", OTA_METHOD_NAME );
- }
- else
- {
- eResult = ( kOTA_Err_RxFileCreateFailed | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
- * Errno is being used in accordance with host API documentation.
- * Bitmasking is being used to preserve host API error with library status code. */
- OTA_LOG_L1( "[%s] ERROR - Failed to start operation: already active!\r\n", OTA_METHOD_NAME );
- }
- }
- else
- {
- eResult = kOTA_Err_RxFileCreateFailed;
- OTA_LOG_L1( "[%s] ERROR - Invalid context provided.\r\n", OTA_METHOD_NAME );
- }
- }
- else
- {
- eResult = kOTA_Err_RxFileCreateFailed;
- OTA_LOG_L1( "[%s] ERROR - Invalid context provided.\r\n", OTA_METHOD_NAME );
- }
-
- return eResult; /*lint !e480 !e481 Exiting function without calling fclose.
- * Context file handle state is managed by this API. */
+ DEFINE_OTA_METHOD_NAME( "prvPAL_CreateFileForRx" );
+
+ OTA_Err_t eResult = kOTA_Err_Uninitialized; /* For MISRA mandatory. */
+
+ if( C != NULL )
+ {
+ if( C->pucFilePath != NULL )
+ {
+ C->pxFile = fopen( ( const char * ) C->pucFilePath, "w+b" ); /*lint !e586
+ * C standard library call is being used for portability. */
+
+ if( C->pxFile != NULL )
+ {
+ eResult = kOTA_Err_None;
+ OTA_LOG_L1( "[%s] Receive file created.\r\n", OTA_METHOD_NAME );
+ }
+ else
+ {
+ eResult = ( kOTA_Err_RxFileCreateFailed | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
+ * Errno is being used in accordance with host API documentation.
+ * Bitmasking is being used to preserve host API error with library status code. */
+ OTA_LOG_L1( "[%s] ERROR - Failed to start operation: already active!\r\n", OTA_METHOD_NAME );
+ }
+ }
+ else
+ {
+ eResult = kOTA_Err_RxFileCreateFailed;
+ OTA_LOG_L1( "[%s] ERROR - Invalid context provided.\r\n", OTA_METHOD_NAME );
+ }
+ }
+ else
+ {
+ eResult = kOTA_Err_RxFileCreateFailed;
+ OTA_LOG_L1( "[%s] ERROR - Invalid context provided.\r\n", OTA_METHOD_NAME );
+ }
+
+ return eResult; /*lint !e480 !e481 Exiting function without calling fclose.
+ * Context file handle state is managed by this API. */
}
@@ -106,152 +106,152 @@ OTA_Err_t prvPAL_CreateFileForRx( OTA_FileContext_t * const C )
OTA_Err_t prvPAL_Abort( OTA_FileContext_t * const C )
{
- DEFINE_OTA_METHOD_NAME( "prvPAL_Abort" );
-
- /* Set default return status to uninitialized. */
- OTA_Err_t eResult = kOTA_Err_Uninitialized;
- int32_t lFileCloseResult;
-
- if( NULL != C )
- {
- /* Close the OTA update file if it's open. */
- if( NULL != C->pxFile )
- {
- lFileCloseResult = fclose( C->pxFile ); /*lint !e482 !e586
- * Context file handle state is managed by this API. */
- C->pxFile = NULL;
-
- if( 0 == lFileCloseResult )
- {
- OTA_LOG_L1( "[%s] OK\r\n", OTA_METHOD_NAME );
- eResult = kOTA_Err_None;
- }
- else /* Failed to close file. */
- {
- OTA_LOG_L1( "[%s] ERROR - Closing file failed.\r\n", OTA_METHOD_NAME );
- eResult = ( kOTA_Err_FileAbort | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
- * Errno is being used in accordance with host API documentation.
- * Bitmasking is being used to preserve host API error with library status code. */
- }
- }
- else
- {
- /* Nothing to do. No open file associated with this context. */
- eResult = kOTA_Err_None;
- }
- }
- else /* Context was not valid. */
- {
- OTA_LOG_L1( "[%s] ERROR - Invalid context.\r\n", OTA_METHOD_NAME );
- eResult = kOTA_Err_FileAbort;
- }
-
- return eResult;
+ DEFINE_OTA_METHOD_NAME( "prvPAL_Abort" );
+
+ /* Set default return status to uninitialized. */
+ OTA_Err_t eResult = kOTA_Err_Uninitialized;
+ int32_t lFileCloseResult;
+
+ if( NULL != C )
+ {
+ /* Close the OTA update file if it's open. */
+ if( NULL != C->pxFile )
+ {
+ lFileCloseResult = fclose( C->pxFile ); /*lint !e482 !e586
+ * Context file handle state is managed by this API. */
+ C->pxFile = NULL;
+
+ if( 0 == lFileCloseResult )
+ {
+ OTA_LOG_L1( "[%s] OK\r\n", OTA_METHOD_NAME );
+ eResult = kOTA_Err_None;
+ }
+ else /* Failed to close file. */
+ {
+ OTA_LOG_L1( "[%s] ERROR - Closing file failed.\r\n", OTA_METHOD_NAME );
+ eResult = ( kOTA_Err_FileAbort | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
+ * Errno is being used in accordance with host API documentation.
+ * Bitmasking is being used to preserve host API error with library status code. */
+ }
+ }
+ else
+ {
+ /* Nothing to do. No open file associated with this context. */
+ eResult = kOTA_Err_None;
+ }
+ }
+ else /* Context was not valid. */
+ {
+ OTA_LOG_L1( "[%s] ERROR - Invalid context.\r\n", OTA_METHOD_NAME );
+ eResult = kOTA_Err_FileAbort;
+ }
+
+ return eResult;
}
/* Write a block of data to the specified file. */
int16_t prvPAL_WriteBlock( OTA_FileContext_t * const C,
- uint32_t ulOffset,
- uint8_t * const pacData,
- uint32_t ulBlockSize )
+ uint32_t ulOffset,
+ uint8_t * const pacData,
+ uint32_t ulBlockSize )
{
- DEFINE_OTA_METHOD_NAME( "prvPAL_WriteBlock" );
-
- int32_t lResult = 0;
-
- if( prvContextValidate( C ) == pdTRUE )
- {
- lResult = fseek( C->pxFile, ulOffset, SEEK_SET ); /*lint !e586 !e713 !e9034
- * C standard library call is being used for portability. */
-
- if( 0 == lResult )
- {
- lResult = fwrite( pacData, 1, ulBlockSize, C->pxFile ); /*lint !e586 !e713 !e9034
- * C standard library call is being used for portability. */
-
- if( lResult < 0 )
- {
- OTA_LOG_L1( "[%s] ERROR - fwrite failed\r\n", OTA_METHOD_NAME );
- /* Mask to return a negative value. */
- lResult = OTA_PAL_INT16_NEGATIVE_MASK | errno; /*lint !e40 !e9027
- * Errno is being used in accordance with host API documentation.
- * Bitmasking is being used to preserve host API error with library status code. */
- }
- }
- else
- {
- OTA_LOG_L1( "[%s] ERROR - fseek failed\r\n", OTA_METHOD_NAME );
- /* Mask to return a negative value. */
- lResult = OTA_PAL_INT16_NEGATIVE_MASK | errno; /*lint !e40 !e9027
- * Errno is being used in accordance with host API documentation.
- * Bitmasking is being used to preserve host API error with library status code. */
- }
- }
- else /* Invalid context or file pointer provided. */
- {
- OTA_LOG_L1( "[%s] ERROR - Invalid context.\r\n", OTA_METHOD_NAME );
- lResult = -1; /*TODO: Need a negative error code from the PAL here. */
- }
-
- return ( int16_t ) lResult;
+ DEFINE_OTA_METHOD_NAME( "prvPAL_WriteBlock" );
+
+ int32_t lResult = 0;
+
+ if( prvContextValidate( C ) == pdTRUE )
+ {
+ lResult = fseek( C->pxFile, ulOffset, SEEK_SET ); /*lint !e586 !e713 !e9034
+ * C standard library call is being used for portability. */
+
+ if( 0 == lResult )
+ {
+ lResult = fwrite( pacData, 1, ulBlockSize, C->pxFile ); /*lint !e586 !e713 !e9034
+ * C standard library call is being used for portability. */
+
+ if( lResult < 0 )
+ {
+ OTA_LOG_L1( "[%s] ERROR - fwrite failed\r\n", OTA_METHOD_NAME );
+ /* Mask to return a negative value. */
+ lResult = OTA_PAL_INT16_NEGATIVE_MASK | errno; /*lint !e40 !e9027
+ * Errno is being used in accordance with host API documentation.
+ * Bitmasking is being used to preserve host API error with library status code. */
+ }
+ }
+ else
+ {
+ OTA_LOG_L1( "[%s] ERROR - fseek failed\r\n", OTA_METHOD_NAME );
+ /* Mask to return a negative value. */
+ lResult = OTA_PAL_INT16_NEGATIVE_MASK | errno; /*lint !e40 !e9027
+ * Errno is being used in accordance with host API documentation.
+ * Bitmasking is being used to preserve host API error with library status code. */
+ }
+ }
+ else /* Invalid context or file pointer provided. */
+ {
+ OTA_LOG_L1( "[%s] ERROR - Invalid context.\r\n", OTA_METHOD_NAME );
+ lResult = -1; /*TODO: Need a negative error code from the PAL here. */
+ }
+
+ return ( int16_t ) lResult;
}
/* Close the specified file. This shall authenticate the file if it is marked as secure. */
OTA_Err_t prvPAL_CloseFile( OTA_FileContext_t * const C )
{
- DEFINE_OTA_METHOD_NAME( "prvPAL_CloseFile" );
-
- OTA_Err_t eResult = kOTA_Err_None;
- int32_t lWindowsError = 0;
-
- if( prvContextValidate( C ) == pdTRUE )
- {
- #if ( configOTA_ENABLE_CODE_SIGNATURE_VERIFICATION )
- /* Verify the file signature, close the file and return the signature verification result. */
- eResult = prvPAL_CheckFileSignature( C );
- #else
- /* Code signature verification is disabled so return no error. */
-
- OTA_LOG_L1( "[%s] Warning: Code signature verification is disabled in OTA config , see configOTA_ENABLE_CODE_SIGNATURE_VERIFICATION .\r\n", OTA_METHOD_NAME );
-
- eResult = kOTA_Err_None;
- #endif
-
- /* Close the file. */
- lWindowsError = fclose( C->pxFile ); /*lint !e482 !e586
- * C standard library call is being used for portability. */
- C->pxFile = NULL;
-
- if( lWindowsError != 0 )
- {
- OTA_LOG_L1( "[%s] ERROR - Failed to close OTA update file.\r\n", OTA_METHOD_NAME );
- eResult = ( kOTA_Err_FileClose | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
- * Errno is being used in accordance with host API documentation.
- * Bitmasking is being used to preserve host API error with library status code. */
- }
-
- if( eResult == kOTA_Err_None )
- {
- OTA_LOG_L1( "[%s] %s signature verification passed.\r\n", OTA_METHOD_NAME, cOTA_JSON_FileSignatureKey );
- }
- else
- {
- OTA_LOG_L1( "[%s] ERROR - Failed to pass %s signature verification: %d.\r\n", OTA_METHOD_NAME,
- cOTA_JSON_FileSignatureKey, eResult );
-
- /* If we fail to verify the file signature that means the image is not valid. We need to set the image state to aborted. */
- prvPAL_SetPlatformImageState( eOTA_ImageState_Aborted );
- }
- }
- else /* Invalid OTA Context. */
- {
- /* FIXME: Invalid error code for a null file context and file handle. */
- OTA_LOG_L1( "[%s] ERROR - Invalid context.\r\n", OTA_METHOD_NAME );
- eResult = kOTA_Err_FileClose;
- }
-
- return eResult;
+ DEFINE_OTA_METHOD_NAME( "prvPAL_CloseFile" );
+
+ OTA_Err_t eResult = kOTA_Err_None;
+ int32_t lWindowsError = 0;
+
+ if( prvContextValidate( C ) == pdTRUE )
+ {
+ #if ( configOTA_ENABLE_CODE_SIGNATURE_VERIFICATION )
+ /* Verify the file signature, close the file and return the signature verification result. */
+ eResult = prvPAL_CheckFileSignature( C );
+ #else
+ /* Code signature verification is disabled so return no error. */
+
+ OTA_LOG_L1( "[%s] Warning: Code signature verification is disabled in OTA config , see configOTA_ENABLE_CODE_SIGNATURE_VERIFICATION .\r\n", OTA_METHOD_NAME );
+
+ eResult = kOTA_Err_None;
+ #endif
+
+ /* Close the file. */
+ lWindowsError = fclose( C->pxFile ); /*lint !e482 !e586
+ * C standard library call is being used for portability. */
+ C->pxFile = NULL;
+
+ if( lWindowsError != 0 )
+ {
+ OTA_LOG_L1( "[%s] ERROR - Failed to close OTA update file.\r\n", OTA_METHOD_NAME );
+ eResult = ( kOTA_Err_FileClose | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
+ * Errno is being used in accordance with host API documentation.
+ * Bitmasking is being used to preserve host API error with library status code. */
+ }
+
+ if( eResult == kOTA_Err_None )
+ {
+ OTA_LOG_L1( "[%s] %s signature verification passed.\r\n", OTA_METHOD_NAME, cOTA_JSON_FileSignatureKey );
+ }
+ else
+ {
+ OTA_LOG_L1( "[%s] ERROR - Failed to pass %s signature verification: %d.\r\n", OTA_METHOD_NAME,
+ cOTA_JSON_FileSignatureKey, eResult );
+
+ /* If we fail to verify the file signature that means the image is not valid. We need to set the image state to aborted. */
+ prvPAL_SetPlatformImageState( eOTA_ImageState_Aborted );
+ }
+ }
+ else /* Invalid OTA Context. */
+ {
+ /* FIXME: Invalid error code for a null file context and file handle. */
+ OTA_LOG_L1( "[%s] ERROR - Invalid context.\r\n", OTA_METHOD_NAME );
+ eResult = kOTA_Err_FileClose;
+ }
+
+ return eResult;
}
@@ -259,88 +259,88 @@ OTA_Err_t prvPAL_CloseFile( OTA_FileContext_t * const C )
static OTA_Err_t prvPAL_CheckFileSignature( OTA_FileContext_t * const C )
{
- DEFINE_OTA_METHOD_NAME( "prvPAL_CheckFileSignature" );
-
- OTA_Err_t eResult = kOTA_Err_None;
- uint32_t ulBytesRead;
- uint32_t ulSignerCertSize;
- uint8_t * pucBuf, * pucSignerCert;
- void * pvSigVerifyContext;
-
- if( prvContextValidate( C ) == pdTRUE )
- {
- /* Verify an ECDSA-SHA256 signature. */
- if( pdFALSE == CRYPTO_SignatureVerificationStart( &pvSigVerifyContext, cryptoASYMMETRIC_ALGORITHM_ECDSA, cryptoHASH_ALGORITHM_SHA256 ) )
- {
- eResult = kOTA_Err_SignatureCheckFailed;
- }
- else
- {
- OTA_LOG_L1( "[%s] Started %s signature verification, file: %s\r\n", OTA_METHOD_NAME,
- cOTA_JSON_FileSignatureKey, ( const char * ) C->pucCertFilepath );
- pucSignerCert = prvPAL_ReadAndAssumeCertificate( ( const uint8_t * const ) C->pucCertFilepath, &ulSignerCertSize );
-
- if( pucSignerCert != NULL )
- {
- pucBuf = pvPortMalloc( OTA_PAL_WIN_BUF_SIZE ); /*lint !e9079 Allow conversion. */
-
- if( pucBuf != NULL )
- {
- /* Rewind the received file to the beginning. */
- if( fseek( C->pxFile, 0L, SEEK_SET ) == 0 ) /*lint !e586
- * C standard library call is being used for portability. */
- {
- do
- {
- ulBytesRead = fread( pucBuf, 1, OTA_PAL_WIN_BUF_SIZE, C->pxFile ); /*lint !e586
- * C standard library call is being used for portability. */
- /* Include the file chunk in the signature validation. Zero size is OK. */
- CRYPTO_SignatureVerificationUpdate( pvSigVerifyContext, pucBuf, ulBytesRead );
- } while( ulBytesRead > 0UL );
-
- if( pdFALSE == CRYPTO_SignatureVerificationFinal( pvSigVerifyContext,
- ( char * ) pucSignerCert,
- ( size_t ) ulSignerCertSize,
- C->pxSignature->ucData,
- C->pxSignature->usSize ) ) /*lint !e732 !e9034 Allow comparison in this context. */
- {
- eResult = kOTA_Err_SignatureCheckFailed;
- }
-
- pvSigVerifyContext = NULL; /* The context has been freed by CRYPTO_SignatureVerificationFinal(). */
- }
- else
- {
- /* Nothing special to do. */
- }
-
- /* Free the temporary file page buffer. */
- vPortFree( pucBuf );
- }
- else
- {
- OTA_LOG_L1( "[%s] ERROR - Failed to allocate buffer memory.\r\n", OTA_METHOD_NAME );
- eResult = kOTA_Err_OutOfMemory;
- }
-
- /* Free the signer certificate that we now own after prvReadAndAssumeCertificate(). */
- vPortFree( pucSignerCert );
- }
- else
- {
- eResult = kOTA_Err_BadSignerCert;
- }
- }
- }
- else
- {
- /* FIXME: Invalid error code for a NULL file context. */
- OTA_LOG_L1( "[%s] ERROR - Invalid OTA file context.\r\n", OTA_METHOD_NAME );
- /* Invalid OTA context or file pointer. */
- eResult = kOTA_Err_NullFilePtr;
- }
-
- return eResult;
+ DEFINE_OTA_METHOD_NAME( "prvPAL_CheckFileSignature" );
+
+ OTA_Err_t eResult = kOTA_Err_None;
+ uint32_t ulBytesRead;
+ uint32_t ulSignerCertSize;
+ uint8_t * pucBuf, * pucSignerCert;
+ void * pvSigVerifyContext;
+
+ if( prvContextValidate( C ) == pdTRUE )
+ {
+ /* Verify an ECDSA-SHA256 signature. */
+ if( pdFALSE == CRYPTO_SignatureVerificationStart( &pvSigVerifyContext, cryptoASYMMETRIC_ALGORITHM_ECDSA, cryptoHASH_ALGORITHM_SHA256 ) )
+ {
+ eResult = kOTA_Err_SignatureCheckFailed;
+ }
+ else
+ {
+ OTA_LOG_L1( "[%s] Started %s signature verification, file: %s\r\n", OTA_METHOD_NAME,
+ cOTA_JSON_FileSignatureKey, ( const char * ) C->pucCertFilepath );
+ pucSignerCert = prvPAL_ReadAndAssumeCertificate( ( const uint8_t * const ) C->pucCertFilepath, &ulSignerCertSize );
+
+ if( pucSignerCert != NULL )
+ {
+ pucBuf = pvPortMalloc( OTA_PAL_WIN_BUF_SIZE ); /*lint !e9079 Allow conversion. */
+
+ if( pucBuf != NULL )
+ {
+ /* Rewind the received file to the beginning. */
+ if( fseek( C->pxFile, 0L, SEEK_SET ) == 0 ) /*lint !e586
+ * C standard library call is being used for portability. */
+ {
+ do
+ {
+ ulBytesRead = fread( pucBuf, 1, OTA_PAL_WIN_BUF_SIZE, C->pxFile ); /*lint !e586
+ * C standard library call is being used for portability. */
+ /* Include the file chunk in the signature validation. Zero size is OK. */
+ CRYPTO_SignatureVerificationUpdate( pvSigVerifyContext, pucBuf, ulBytesRead );
+ } while( ulBytesRead > 0UL );
+
+ if( pdFALSE == CRYPTO_SignatureVerificationFinal( pvSigVerifyContext,
+ ( char * ) pucSignerCert,
+ ( size_t ) ulSignerCertSize,
+ C->pxSignature->ucData,
+ C->pxSignature->usSize ) ) /*lint !e732 !e9034 Allow comparison in this context. */
+ {
+ eResult = kOTA_Err_SignatureCheckFailed;
+ }
+
+ pvSigVerifyContext = NULL; /* The context has been freed by CRYPTO_SignatureVerificationFinal(). */
+ }
+ else
+ {
+ /* Nothing special to do. */
+ }
+
+ /* Free the temporary file page buffer. */
+ vPortFree( pucBuf );
+ }
+ else
+ {
+ OTA_LOG_L1( "[%s] ERROR - Failed to allocate buffer memory.\r\n", OTA_METHOD_NAME );
+ eResult = kOTA_Err_OutOfMemory;
+ }
+
+ /* Free the signer certificate that we now own after prvReadAndAssumeCertificate(). */
+ vPortFree( pucSignerCert );
+ }
+ else
+ {
+ eResult = kOTA_Err_BadSignerCert;
+ }
+ }
+ }
+ else
+ {
+ /* FIXME: Invalid error code for a NULL file context. */
+ OTA_LOG_L1( "[%s] ERROR - Invalid OTA file context.\r\n", OTA_METHOD_NAME );
+ /* Invalid OTA context or file pointer. */
+ eResult = kOTA_Err_NullFilePtr;
+ }
+
+ return eResult;
}
@@ -349,114 +349,114 @@ static OTA_Err_t prvPAL_CheckFileSignature( OTA_FileContext_t * const C )
*/
static uint8_t * prvPAL_ReadAndAssumeCertificate( const uint8_t * const pucCertName,
- uint32_t * const ulSignerCertSize )
+ uint32_t * const ulSignerCertSize )
{
- DEFINE_OTA_METHOD_NAME( "prvPAL_ReadAndAssumeCertificate" );
-
- FILE * pxFile;
- uint8_t * pucSignerCert = NULL;
- uint8_t * pucCertData = NULL;
- int32_t lSize = 0; /* For MISRA mandatory. */
- int32_t lWindowsError;
-
- pxFile = fopen( ( const char * ) pucCertName, "rb" ); /*lint !e586
- * C standard library call is being used for portability. */
-
- if( pxFile != NULL )
- {
- lWindowsError = fseek( pxFile, 0, SEEK_END ); /*lint !e586
- * C standard library call is being used for portability. */
-
- if( lWindowsError == 0 ) /* fseek returns a non-zero value on error. */
- {
- lSize = ( s32 ) ftell( pxFile ); /*lint !e586 Allow call in this context. */
-
- if( lSize != -1L ) /* ftell returns -1 on error. */
- {
- lWindowsError = fseek( pxFile, 0, SEEK_SET ); /*lint !e586
- * C standard library call is being used for portability. */
- }
- else /* ftell returned an error, pucSignerCert remains NULL. */
- {
- lWindowsError = -1L;
- }
- } /* else fseek returned an error, pucSignerCert remains NULL. */
-
- if( lWindowsError == 0 )
- {
- /* Allocate memory for the signer certificate plus a terminating zero so we can load and return it to the caller. */
- pucSignerCert = pvPortMalloc( lSize + 1 ); /*lint !e732 !e9034 !e9079 Allow conversion. */
- }
-
- if( pucSignerCert != NULL )
- {
- if( fread( pucSignerCert, 1, lSize, pxFile ) == ( size_t ) lSize ) /*lint !e586 !e732 !e9034
- * C standard library call is being used for portability. */
- {
- /* The crypto code requires the terminating zero to be part of the length so add 1 to the size. */
- *ulSignerCertSize = lSize + 1;
- pucSignerCert[ lSize ] = 0;
- }
- else
- { /* There was a problem reading the certificate file so free the memory and abort. */
- vPortFree( pucSignerCert );
- pucSignerCert = NULL;
- }
- }
- else
- {
- OTA_LOG_L1( "[%s] ERROR - Failed to allocate memory for signer cert contents.\r\n", OTA_METHOD_NAME );
- /* Nothing special to do. */
- }
-
- lWindowsError = fclose( pxFile ); /*lint !e586
- * C standard library call is being used for portability. */
-
- if( lWindowsError != 0 )
- {
- OTA_LOG_L1( "[%s] ERROR - File pointer operation failed.\r\n", OTA_METHOD_NAME );
- pucSignerCert = NULL;
- }
- }
- else
- {
- OTA_LOG_L1( "[%s] No such certificate file: %s. Using aws_ota_codesigner_certificate.h.\r\n", OTA_METHOD_NAME,
- ( const char * ) pucCertName );
-
- /* Allocate memory for the signer certificate plus a terminating zero so we can copy it and return to the caller. */
- lSize = sizeof( signingcredentialSIGNING_CERTIFICATE_PEM );
- pucSignerCert = pvPortMalloc( lSize ); /*lint !e9029 !e9079 !e838 malloc proto requires void*. */
- pucCertData = ( uint8_t * ) signingcredentialSIGNING_CERTIFICATE_PEM; /*lint !e9005 we don't modify the cert but it could be set by PKCS11 so it's not const. */
-
- if( pucSignerCert != NULL )
- {
- memcpy( pucSignerCert, pucCertData, lSize );
- *ulSignerCertSize = lSize;
- }
- else
- {
- OTA_LOG_L1( "[%s] Error: No memory for certificate of size %d!\r\n", OTA_METHOD_NAME, lSize );
- }
- }
-
- return pucSignerCert; /*lint !e480 !e481 fopen and fclose are being used by-design. */
+ DEFINE_OTA_METHOD_NAME( "prvPAL_ReadAndAssumeCertificate" );
+
+ FILE * pxFile;
+ uint8_t * pucSignerCert = NULL;
+ uint8_t * pucCertData = NULL;
+ int32_t lSize = 0; /* For MISRA mandatory. */
+ int32_t lWindowsError;
+
+ pxFile = fopen( ( const char * ) pucCertName, "rb" ); /*lint !e586
+ * C standard library call is being used for portability. */
+
+ if( pxFile != NULL )
+ {
+ lWindowsError = fseek( pxFile, 0, SEEK_END ); /*lint !e586
+ * C standard library call is being used for portability. */
+
+ if( lWindowsError == 0 ) /* fseek returns a non-zero value on error. */
+ {
+ lSize = ( s32 ) ftell( pxFile ); /*lint !e586 Allow call in this context. */
+
+ if( lSize != -1L ) /* ftell returns -1 on error. */
+ {
+ lWindowsError = fseek( pxFile, 0, SEEK_SET ); /*lint !e586
+ * C standard library call is being used for portability. */
+ }
+ else /* ftell returned an error, pucSignerCert remains NULL. */
+ {
+ lWindowsError = -1L;
+ }
+ } /* else fseek returned an error, pucSignerCert remains NULL. */
+
+ if( lWindowsError == 0 )
+ {
+ /* Allocate memory for the signer certificate plus a terminating zero so we can load and return it to the caller. */
+ pucSignerCert = pvPortMalloc( lSize + 1 ); /*lint !e732 !e9034 !e9079 Allow conversion. */
+ }
+
+ if( pucSignerCert != NULL )
+ {
+ if( fread( pucSignerCert, 1, lSize, pxFile ) == ( size_t ) lSize ) /*lint !e586 !e732 !e9034
+ * C standard library call is being used for portability. */
+ {
+ /* The crypto code requires the terminating zero to be part of the length so add 1 to the size. */
+ *ulSignerCertSize = lSize + 1;
+ pucSignerCert[ lSize ] = 0;
+ }
+ else
+ { /* There was a problem reading the certificate file so free the memory and abort. */
+ vPortFree( pucSignerCert );
+ pucSignerCert = NULL;
+ }
+ }
+ else
+ {
+ OTA_LOG_L1( "[%s] ERROR - Failed to allocate memory for signer cert contents.\r\n", OTA_METHOD_NAME );
+ /* Nothing special to do. */
+ }
+
+ lWindowsError = fclose( pxFile ); /*lint !e586
+ * C standard library call is being used for portability. */
+
+ if( lWindowsError != 0 )
+ {
+ OTA_LOG_L1( "[%s] ERROR - File pointer operation failed.\r\n", OTA_METHOD_NAME );
+ pucSignerCert = NULL;
+ }
+ }
+ else
+ {
+ OTA_LOG_L1( "[%s] No such certificate file: %s. Using aws_ota_codesigner_certificate.h.\r\n", OTA_METHOD_NAME,
+ ( const char * ) pucCertName );
+
+ /* Allocate memory for the signer certificate plus a terminating zero so we can copy it and return to the caller. */
+ lSize = sizeof( signingcredentialSIGNING_CERTIFICATE_PEM );
+ pucSignerCert = pvPortMalloc( lSize ); /*lint !e9029 !e9079 !e838 malloc proto requires void*. */
+ pucCertData = ( uint8_t * ) signingcredentialSIGNING_CERTIFICATE_PEM; /*lint !e9005 we don't modify the cert but it could be set by PKCS11 so it's not const. */
+
+ if( pucSignerCert != NULL )
+ {
+ memcpy( pucSignerCert, pucCertData, lSize );
+ *ulSignerCertSize = lSize;
+ }
+ else
+ {
+ OTA_LOG_L1( "[%s] Error: No memory for certificate of size %d!\r\n", OTA_METHOD_NAME, lSize );
+ }
+ }
+
+ return pucSignerCert; /*lint !e480 !e481 fopen and fclose are being used by-design. */
}
/*-----------------------------------------------------------*/
OTA_Err_t prvPAL_ResetDevice( void )
{
- /* Return no error. Windows implementation does not reset device. */
- return kOTA_Err_None;
+ /* Return no error. Windows implementation does not reset device. */
+ return kOTA_Err_None;
}
/*-----------------------------------------------------------*/
OTA_Err_t prvPAL_ActivateNewImage( void )
{
- /* Return no error. Windows implementation simply does nothing on activate.
- * To run the new firmware image, double click the newly downloaded exe */
- return kOTA_Err_None;
+ /* Return no error. Windows implementation simply does nothing on activate.
+ * To run the new firmware image, double click the newly downloaded exe */
+ return kOTA_Err_None;
}
@@ -467,52 +467,52 @@ OTA_Err_t prvPAL_ActivateNewImage( void )
OTA_Err_t prvPAL_SetPlatformImageState( OTA_ImageState_t eState )
{
- DEFINE_OTA_METHOD_NAME( "prvPAL_SetPlatformImageState" );
-
- OTA_Err_t eResult = kOTA_Err_None;
- FILE * pstPlatformImageState;
-
- if( ( eState != eOTA_ImageState_Unknown ) && ( eState <= eOTA_LastImageState ) )
- {
- pstPlatformImageState = fopen( "PlatformImageState.txt", "w+b" ); /*lint !e586
- * C standard library call is being used for portability. */
-
- if( pstPlatformImageState != NULL )
- {
- /* Write the image state to PlatformImageState.txt. */
- if( 1 != fwrite( &eState, sizeof( OTA_ImageState_t ), 1, pstPlatformImageState ) ) /*lint !e586 !e9029
- * C standard library call is being used for portability. */
- {
- OTA_LOG_L1( "[%s] ERROR - Unable to write to image state file.\r\n", OTA_METHOD_NAME );
- eResult = ( kOTA_Err_BadImageState | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
- * Errno is being used in accordance with host API documentation.
- * Bitmasking is being used to preserve host API error with library status code. */
- }
-
- /* Close PlatformImageState.txt. */
- if( 0 != fclose( pstPlatformImageState ) ) /*lint !e586 Allow call in this context. */
- {
- OTA_LOG_L1( "[%s] ERROR - Unable to close image state file.\r\n", OTA_METHOD_NAME );
- eResult = ( kOTA_Err_BadImageState | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
- * Errno is being used in accordance with host API documentation.
- * Bitmasking is being used to preserve host API error with library status code. */
- }
- }
- else
- {
- OTA_LOG_L1( "[%s] ERROR - Unable to open image state file.\r\n", OTA_METHOD_NAME );
- eResult = ( kOTA_Err_BadImageState | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
- * Errno is being used in accordance with host API documentation.
- * Bitmasking is being used to preserve host API error with library status code. */
- }
- } /*lint !e481 Allow fopen and fclose calls in this context. */
- else /* Image state invalid. */
- {
- OTA_LOG_L1( "[%s] ERROR - Invalid image state provided.\r\n", OTA_METHOD_NAME );
- eResult = kOTA_Err_BadImageState;
- }
-
- return eResult; /*lint !e480 !e481 Allow calls to fopen and fclose in this context. */
+ DEFINE_OTA_METHOD_NAME( "prvPAL_SetPlatformImageState" );
+
+ OTA_Err_t eResult = kOTA_Err_None;
+ FILE * pstPlatformImageState;
+
+ if( ( eState != eOTA_ImageState_Unknown ) && ( eState <= eOTA_LastImageState ) )
+ {
+ pstPlatformImageState = fopen( "PlatformImageState.txt", "w+b" ); /*lint !e586
+ * C standard library call is being used for portability. */
+
+ if( pstPlatformImageState != NULL )
+ {
+ /* Write the image state to PlatformImageState.txt. */
+ if( 1 != fwrite( &eState, sizeof( OTA_ImageState_t ), 1, pstPlatformImageState ) ) /*lint !e586 !e9029
+ * C standard library call is being used for portability. */
+ {
+ OTA_LOG_L1( "[%s] ERROR - Unable to write to image state file.\r\n", OTA_METHOD_NAME );
+ eResult = ( kOTA_Err_BadImageState | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
+ * Errno is being used in accordance with host API documentation.
+ * Bitmasking is being used to preserve host API error with library status code. */
+ }
+
+ /* Close PlatformImageState.txt. */
+ if( 0 != fclose( pstPlatformImageState ) ) /*lint !e586 Allow call in this context. */
+ {
+ OTA_LOG_L1( "[%s] ERROR - Unable to close image state file.\r\n", OTA_METHOD_NAME );
+ eResult = ( kOTA_Err_BadImageState | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
+ * Errno is being used in accordance with host API documentation.
+ * Bitmasking is being used to preserve host API error with library status code. */
+ }
+ }
+ else
+ {
+ OTA_LOG_L1( "[%s] ERROR - Unable to open image state file.\r\n", OTA_METHOD_NAME );
+ eResult = ( kOTA_Err_BadImageState | ( errno & kOTA_PAL_ErrMask ) ); /*lint !e40 !e737 !e9027 !e9029
+ * Errno is being used in accordance with host API documentation.
+ * Bitmasking is being used to preserve host API error with library status code. */
+ }
+ } /*lint !e481 Allow fopen and fclose calls in this context. */
+ else /* Image state invalid. */
+ {
+ OTA_LOG_L1( "[%s] ERROR - Invalid image state provided.\r\n", OTA_METHOD_NAME );
+ eResult = kOTA_Err_BadImageState;
+ }
+
+ return eResult; /*lint !e480 !e481 Allow calls to fopen and fclose in this context. */
}
/* Get the state of the currently running image.
@@ -529,64 +529,64 @@ OTA_Err_t prvPAL_SetPlatformImageState( OTA_ImageState_t eState )
*/
OTA_PAL_ImageState_t prvPAL_GetPlatformImageState( void )
{
- /* FIXME: This function should return OTA_PAL_ImageState_t, but it doesn't. */
- DEFINE_OTA_METHOD_NAME( "prvPAL_GetPlatformImageState" );
-
- FILE * pstPlatformImageState;
- OTA_ImageState_t eSavedAgentState = eOTA_ImageState_Unknown;
- OTA_PAL_ImageState_t ePalState = eOTA_PAL_ImageState_Unknown;
-
- pstPlatformImageState = fopen( "PlatformImageState.txt", "r+b" ); /*lint !e586
- * C standard library call is being used for portability. */
-
- if( pstPlatformImageState != NULL )
- {
- if( 1 != fread( &eSavedAgentState, sizeof( OTA_ImageState_t ), 1, pstPlatformImageState ) ) /*lint !e586 !e9029
- * C standard library call is being used for portability. */
- {
- /* If an error occured reading the file, mark the state as aborted. */
- OTA_LOG_L1( "[%s] ERROR - Unable to read image state file.\r\n", OTA_METHOD_NAME );
- ePalState = ( eOTA_PAL_ImageState_Invalid | ( errno & kOTA_PAL_ErrMask ) );
- }
- else
- {
- switch( eSavedAgentState )
- {
- case eOTA_ImageState_Testing:
- ePalState = eOTA_PAL_ImageState_PendingCommit;
- break;
-
- case eOTA_ImageState_Accepted:
- ePalState = eOTA_PAL_ImageState_Valid;
- break;
-
- case eOTA_ImageState_Rejected:
- case eOTA_ImageState_Aborted:
- default:
- ePalState = eOTA_PAL_ImageState_Invalid;
- break;
- }
- }
-
- if( 0 != fclose( pstPlatformImageState ) ) /*lint !e586
- * C standard library call is being used for portability. */
- {
- OTA_LOG_L1( "[%s] ERROR - Unable to close image state file.\r\n", OTA_METHOD_NAME );
- ePalState = ( eOTA_PAL_ImageState_Invalid | ( errno & kOTA_PAL_ErrMask ) );
- }
- }
- else
- {
- /* If no image state file exists, assume a factory image. */
- ePalState = eOTA_PAL_ImageState_Valid; /*lint !e64 Allow assignment. */
- }
-
- return ePalState; /*lint !e64 !e480 !e481 I/O calls and return type are used per design. */
+ /* FIXME: This function should return OTA_PAL_ImageState_t, but it doesn't. */
+ DEFINE_OTA_METHOD_NAME( "prvPAL_GetPlatformImageState" );
+
+ FILE * pstPlatformImageState;
+ OTA_ImageState_t eSavedAgentState = eOTA_ImageState_Unknown;
+ OTA_PAL_ImageState_t ePalState = eOTA_PAL_ImageState_Unknown;
+
+ pstPlatformImageState = fopen( "PlatformImageState.txt", "r+b" ); /*lint !e586
+ * C standard library call is being used for portability. */
+
+ if( pstPlatformImageState != NULL )
+ {
+ if( 1 != fread( &eSavedAgentState, sizeof( OTA_ImageState_t ), 1, pstPlatformImageState ) ) /*lint !e586 !e9029
+ * C standard library call is being used for portability. */
+ {
+ /* If an error occured reading the file, mark the state as aborted. */
+ OTA_LOG_L1( "[%s] ERROR - Unable to read image state file.\r\n", OTA_METHOD_NAME );
+ ePalState = ( eOTA_PAL_ImageState_Invalid | ( errno & kOTA_PAL_ErrMask ) );
+ }
+ else
+ {
+ switch( eSavedAgentState )
+ {
+ case eOTA_ImageState_Testing:
+ ePalState = eOTA_PAL_ImageState_PendingCommit;
+ break;
+
+ case eOTA_ImageState_Accepted:
+ ePalState = eOTA_PAL_ImageState_Valid;
+ break;
+
+ case eOTA_ImageState_Rejected:
+ case eOTA_ImageState_Aborted:
+ default:
+ ePalState = eOTA_PAL_ImageState_Invalid;
+ break;
+ }
+ }
+
+ if( 0 != fclose( pstPlatformImageState ) ) /*lint !e586
+ * C standard library call is being used for portability. */
+ {
+ OTA_LOG_L1( "[%s] ERROR - Unable to close image state file.\r\n", OTA_METHOD_NAME );
+ ePalState = ( eOTA_PAL_ImageState_Invalid | ( errno & kOTA_PAL_ErrMask ) );
+ }
+ }
+ else
+ {
+ /* If no image state file exists, assume a factory image. */
+ ePalState = eOTA_PAL_ImageState_Valid; /*lint !e64 Allow assignment. */
+ }
+
+ return ePalState; /*lint !e64 !e480 !e481 I/O calls and return type are used per design. */
}
/*-----------------------------------------------------------*/
/* Provide access to private members for testing. */
#if IOT_BUILD_TESTS == 1
- #include "aws_ota_pal_test_access_define.h"
+ #include "aws_ota_pal_test_access_define.h"
#endif
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c
index 3c46ff835..e6aa16c3e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c
@@ -57,19 +57,19 @@
/*-----------------------------------------------------------*/
/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
+ * to .ful. */
+#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
+#define dlMAX_PRINT_STRING_LENGTH 255
/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
+ * the Win32 thread that is responsible for making any Win32 system calls that are
+ * necessary for the selected logging method. */
+#define dlLOGGING_STREAM_BUFFER_SIZE 32768
/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
+#define dlDONT_BLOCK 0
/*-----------------------------------------------------------*/
@@ -81,7 +81,8 @@ static void prvFileLoggingInit( void );
/*
* Attempt to write a message to the file.
*/
-static void prvLogToFile( const char *pcMessage, size_t xLength );
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength );
/*
* Simply close the logging file, if it is open.
@@ -102,7 +103,7 @@ static void prvLoggingFlushBuffer( void );
* Win32 system calls. Only the windows thread can make system calls so as not
* to disrupt the simulation by making Windows calls from FreeRTOS tasks.
*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
+static DWORD WINAPI prvWin32LoggingThread( void * pvParam );
/*
* Creates the socket to which UDP messages are sent. This function is not
@@ -110,417 +111,426 @@ static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
* task - which could result in a deadlock. Instead the function call is
* deferred to run in the RTOS daemon task - hence it prototype.
*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 );
/*-----------------------------------------------------------*/
/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
+ * needs Win32 system calls. */
+static void * pvLoggingThreadEvent = NULL;
/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
+ * vLoggingInit() function. */
+BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
+ * thread that is responsible for making Win32 calls (when stdout or a disk log is
+ * used). */
+static StreamBuffer_t * xLogStreamBuffer = NULL;
/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
+ * messages waiting to be logged, then closed again in between logs. */
+static FILE * pxLoggingFileHandle = NULL;
/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
+ * to pdFALSE - at which time prints that require Win32 system calls are done by
+ * the Win32 thread responsible for logging. */
+BaseType_t xDirectPrint = pdTRUE;
/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
+static const char * pcLogFileName = "RTOSDemo.log";
+static const char * pcFullLogFileName = "RTOSDemo.ful";
/* As an optimization, the current file size is kept in a variable. */
-static size_t ulSizeOfLoggingFile = 0ul;
+static size_t ulSizeOfLoggingFile = 0ul;
/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
+Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
struct freertos_sockaddr xPrintUDPAddress;
/*-----------------------------------------------------------*/
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort )
{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialize it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialized. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
+ /* Can only be called before the scheduler has started. */
+ configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
+
+ #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
+ {
+ HANDLE Win32Thread;
+
+ /* Record which output methods are to be used. */
+ xStdoutLoggingUsed = xLogToStdout;
+ xDiskFileLoggingUsed = xLogToFile;
+ xUDPLoggingUsed = xLogToUDP;
+
+ /* If a disk file is used then initialize it now. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvFileLoggingInit();
+ }
+
+ /* If UDP logging is used then store the address to which the log data
+ * will be sent - but don't create the socket yet because the network is
+ * not initialized. */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ /* Set the address to which the print messages are sent. */
+ xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
+ xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
+ }
+
+ /* If a disk file or stdout are to be used then Win32 system calls will
+ * have to be made. Such system calls cannot be made from FreeRTOS tasks
+ * so create a stream buffer to pass the messages to a Win32 thread, then
+ * create the thread itself, along with a Win32 event that can be used to
+ * unblock the thread. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ /* Create the buffer. */
+ xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
+ configASSERT( xLogStreamBuffer );
+ memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
+ xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
+
+ /* Create the Windows event. */
+ pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
+
+ /* Create the thread itself. */
+ Win32Thread = CreateThread(
+ NULL, /* Pointer to thread security attributes. */
+ 0, /* Initial thread stack size, in bytes. */
+ prvWin32LoggingThread, /* Pointer to thread function. */
+ NULL, /* Argument for new thread. */
+ 0, /* Creation flags. */
+ NULL );
+
+ /* Use the cores that are not used by the FreeRTOS tasks. */
+ SetThreadAffinityMask( Win32Thread, ~0x01u );
+ SetThreadPriorityBoost( Win32Thread, TRUE );
+ SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
+ }
+ }
+ #else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */
+ {
+ /* FreeRTOSIPConfig is set such that no print messages will be output.
+ * Avoid compiler warnings about unused parameters. */
+ ( void ) xLogToStdout;
+ ( void ) xLogToFile;
+ ( void ) xLogToUDP;
+ ( void ) usRemotePort;
+ ( void ) ulRemoteIPAddress;
+ }
+ #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
}
/*-----------------------------------------------------------*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 )
{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
+ static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
+ Socket_t xSocket;
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
+ /* The function prototype is that of a deferred function, but the parameters
+ * are not actually used. */
+ ( void ) pvParameter1;
+ ( void ) ulParameter2;
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
+ if( xSocket != FREERTOS_INVALID_SOCKET )
+ {
+ /* FreeRTOS+TCP decides which port to bind to. */
+ FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
+ FreeRTOS_bind( xSocket, NULL, 0 );
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
+ /* Now the socket is bound it can be assigned to the print socket. */
+ xPrintSocket = xSocket;
+ }
}
/*-----------------------------------------------------------*/
-void vLoggingPrintf( const char *pcFormat, ... )
+void vLoggingPrintf( const char * pcFormat,
+ ... )
{
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
-char *pcSource, *pcTarget, *pcBegin;
-size_t xLength, xLength2, rc;
-static BaseType_t xMessageNumber = 0;
-va_list args;
-uint32_t ulIPAddress;
-const char *pcTaskName;
-const char *pcNoTask = "None";
-int iOriginalPriority;
-HANDLE xCurrentTask;
-
-
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
- {
- /* There are a variable number of parameters. */
- va_start( args, pcFormat );
-
- /* Additional info to place at the start of the log. */
- if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
- {
- pcTaskName = pcTaskGetName( NULL );
- }
- else
- {
- pcTaskName = pcNoTask;
- }
-
- if( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
-
- if( xLength2 < 0 )
- {
- /* Clean up. */
- xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
- cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
- }
-
- xLength += xLength2;
- va_end( args );
-
- /* For ease of viewing, copy the string into another buffer, converting
- IP addresses to dot notation on the way. */
- pcSource = cPrintString;
- pcTarget = cOutputString;
-
- while( ( *pcSource ) != '\0' )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- pcSource++;
-
- /* Look forward for an IP address denoted by 'ip'. */
- if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- *pcTarget = '\0';
- pcBegin = pcTarget - 8;
-
- while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
- {
- pcTarget--;
- }
-
- sscanf( pcTarget, "%8X", &ulIPAddress );
- rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
- ( unsigned long ) ( ulIPAddress >> 24UL ),
- ( unsigned long ) ( (ulIPAddress >> 16UL) & 0xffUL ),
- ( unsigned long ) ( (ulIPAddress >> 8UL) & 0xffUL ),
- ( unsigned long ) ( ulIPAddress & 0xffUL ) );
- pcTarget += rc;
- pcSource += 3; /* skip "<n>ip" */
- }
- }
-
- /* How far through the buffer was written? */
- xLength = ( BaseType_t ) ( pcTarget - cOutputString );
-
- /* If the message is to be logged to a UDP port then it can be sent directly
- because it only uses FreeRTOS function (not Win32 functions). */
- if( xUDPLoggingUsed != pdFALSE )
- {
- if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
- {
- /* Create and bind the socket to which print messages are sent. The
- xTimerPendFunctionCall() function is used even though this is
- not an interrupt because this function is called from the IP task
- and the IP task cannot itself wait for a socket to bind. The
- parameters to prvCreatePrintSocket() are not required so set to
- NULL or 0. */
- xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* If logging is also to go to either stdout or a disk file then it cannot
- be output here - so instead write the message to the stream buffer and wake
- the Win32 thread which will read it from the stream buffer and perform the
- actual output. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- configASSERT( xLogStreamBuffer );
-
- /* How much space is in the buffer? */
- xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
-
- /* There must be enough space to write both the string and the length of
- the string. */
- if( xLength2 >= ( xLength + sizeof( xLength ) ) )
- {
- /* First write in the length of the data, then write in the data
- itself. Raising the thread priority is used as a critical section
- as there are potentially multiple writers. The stream buffer is
- only thread safe when there is a single writer (likewise for
- reading from the buffer). */
- xCurrentTask = GetCurrentThread();
- iOriginalPriority = GetThreadPriority( xCurrentTask );
- SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
- SetThreadPriority( GetCurrentThread(), iOriginalPriority );
- }
-
- /* xDirectPrint is initialized to pdTRUE, and while it remains true the
- logging output function is called directly. When the system is running
- the output function cannot be called directly because it would get
- called from both FreeRTOS tasks and Win32 threads - so instead wake the
- Win32 thread responsible for the actual output. */
- if( xDirectPrint != pdFALSE )
- {
- /* While starting up, the thread which calls prvWin32LoggingThread()
- is not running yet and xDirectPrint will be pdTRUE. */
- prvLoggingFlushBuffer();
- }
- else if( pvLoggingThreadEvent != NULL )
- {
- /* While running, wake up prvWin32LoggingThread() to send the
- logging data. */
- SetEvent( pvLoggingThreadEvent );
- }
- }
- }
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+ char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
+ char * pcSource, * pcTarget, * pcBegin;
+ size_t xLength, xLength2, rc;
+ static BaseType_t xMessageNumber = 0;
+ va_list args;
+ uint32_t ulIPAddress;
+ const char * pcTaskName;
+ const char * pcNoTask = "None";
+ int iOriginalPriority;
+ HANDLE xCurrentTask;
+
+
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
+ {
+ /* There are a variable number of parameters. */
+ va_start( args, pcFormat );
+
+ /* Additional info to place at the start of the log. */
+ if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
+ {
+ pcTaskName = pcTaskGetName( NULL );
+ }
+ else
+ {
+ pcTaskName = pcNoTask;
+ }
+
+ if( strcmp( pcFormat, "\n" ) != 0 )
+ {
+ xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
+ xMessageNumber++,
+ ( unsigned long ) xTaskGetTickCount(),
+ pcTaskName );
+ }
+ else
+ {
+ xLength = 0;
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ }
+
+ xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
+
+ if( xLength2 < 0 )
+ {
+ /* Clean up. */
+ xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
+ cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
+ }
+
+ xLength += xLength2;
+ va_end( args );
+
+ /* For ease of viewing, copy the string into another buffer, converting
+ * IP addresses to dot notation on the way. */
+ pcSource = cPrintString;
+ pcTarget = cOutputString;
+
+ while( ( *pcSource ) != '\0' )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ pcSource++;
+
+ /* Look forward for an IP address denoted by 'ip'. */
+ if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ *pcTarget = '\0';
+ pcBegin = pcTarget - 8;
+
+ while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
+ {
+ pcTarget--;
+ }
+
+ sscanf( pcTarget, "%8X", &ulIPAddress );
+ rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
+ ( unsigned long ) ( ulIPAddress >> 24UL ),
+ ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ),
+ ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ),
+ ( unsigned long ) ( ulIPAddress & 0xffUL ) );
+ pcTarget += rc;
+ pcSource += 3; /* skip "<n>ip" */
+ }
+ }
+
+ /* How far through the buffer was written? */
+ xLength = ( BaseType_t ) ( pcTarget - cOutputString );
+
+ /* If the message is to be logged to a UDP port then it can be sent directly
+ * because it only uses FreeRTOS function (not Win32 functions). */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
+ {
+ /* Create and bind the socket to which print messages are sent. The
+ * xTimerPendFunctionCall() function is used even though this is
+ * not an interrupt because this function is called from the IP task
+ * and the IP task cannot itself wait for a socket to bind. The
+ * parameters to prvCreatePrintSocket() are not required so set to
+ * NULL or 0. */
+ xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
+ }
+
+ if( xPrintSocket != FREERTOS_INVALID_SOCKET )
+ {
+ FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+
+ /* Just because the UDP data logger I'm using is dumb. */
+ FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+ }
+ }
+
+ /* If logging is also to go to either stdout or a disk file then it cannot
+ * be output here - so instead write the message to the stream buffer and wake
+ * the Win32 thread which will read it from the stream buffer and perform the
+ * actual output. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ configASSERT( xLogStreamBuffer );
+
+ /* How much space is in the buffer? */
+ xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
+
+ /* There must be enough space to write both the string and the length of
+ * the string. */
+ if( xLength2 >= ( xLength + sizeof( xLength ) ) )
+ {
+ /* First write in the length of the data, then write in the data
+ * itself. Raising the thread priority is used as a critical section
+ * as there are potentially multiple writers. The stream buffer is
+ * only thread safe when there is a single writer (likewise for
+ * reading from the buffer). */
+ xCurrentTask = GetCurrentThread();
+ iOriginalPriority = GetThreadPriority( xCurrentTask );
+ SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
+ SetThreadPriority( GetCurrentThread(), iOriginalPriority );
+ }
+
+ /* xDirectPrint is initialized to pdTRUE, and while it remains true the
+ * logging output function is called directly. When the system is running
+ * the output function cannot be called directly because it would get
+ * called from both FreeRTOS tasks and Win32 threads - so instead wake the
+ * Win32 thread responsible for the actual output. */
+ if( xDirectPrint != pdFALSE )
+ {
+ /* While starting up, the thread which calls prvWin32LoggingThread()
+ * is not running yet and xDirectPrint will be pdTRUE. */
+ prvLoggingFlushBuffer();
+ }
+ else if( pvLoggingThreadEvent != NULL )
+ {
+ /* While running, wake up prvWin32LoggingThread() to send the
+ * logging data. */
+ SetEvent( pvLoggingThreadEvent );
+ }
+ }
+ }
}
/*-----------------------------------------------------------*/
static void prvLoggingFlushBuffer( void )
{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- _write( _fileno(stdout), cPrintString, strlen( cPrintString ) );
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
+ size_t xLength;
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+
+ /* Is there more than the length value stored in the circular buffer
+ * used to pass data from the FreeRTOS simulator into this Win32 thread? */
+ while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
+ {
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
+
+ /* Write the message to standard out if requested to do so when
+ * vLoggingInit() was called, or if the network is not yet up. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
+ {
+ /* Write the message to stdout. */
+ _write( _fileno( stdout ), cPrintString, strlen( cPrintString ) );
+ }
+
+ /* Write the message to a file if requested to do so when
+ * vLoggingInit() was called. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvLogToFile( cPrintString, xLength );
+ }
+ }
+
+ prvFileClose();
}
/*-----------------------------------------------------------*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
+static DWORD WINAPI prvWin32LoggingThread( void * pvParameter )
{
-const DWORD xMaxWait = 1000;
+ const DWORD xMaxWait = 1000;
- ( void ) pvParameter;
+ ( void ) pvParameter;
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
+ /* From now on, prvLoggingFlushBuffer() will only be called from this
+ * Windows thread */
+ xDirectPrint = pdFALSE;
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
+ for( ; ; )
+ {
+ /* Wait to be told there are message waiting to be logged. */
+ WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
+ /* Write out all waiting messages. */
+ prvLoggingFlushBuffer();
+ }
}
/*-----------------------------------------------------------*/
static void prvFileLoggingInit( void )
{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
+ FILE * pxHandle = fopen( pcLogFileName, "a" );
+
+ if( pxHandle != NULL )
+ {
+ fseek( pxHandle, SEEK_END, 0ul );
+ ulSizeOfLoggingFile = ftell( pxHandle );
+ fclose( pxHandle );
+ }
+ else
+ {
+ ulSizeOfLoggingFile = 0ul;
+ }
}
/*-----------------------------------------------------------*/
static void prvFileClose( void )
{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
+ if( pxLoggingFileHandle != NULL )
+ {
+ fclose( pxLoggingFileHandle );
+ pxLoggingFileHandle = NULL;
+ }
}
/*-----------------------------------------------------------*/
-static void prvLogToFile( const char *pcMessage, size_t xLength )
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength )
{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
+ if( pxLoggingFileHandle == NULL )
+ {
+ pxLoggingFileHandle = fopen( pcLogFileName, "a" );
+ }
+
+ if( pxLoggingFileHandle != NULL )
+ {
+ fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
+ ulSizeOfLoggingFile += xLength;
+
+ /* If the file has grown to its maximum permissible size then close and
+ * rename it - then start with a new file. */
+ if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
+ {
+ prvFileClose();
+
+ if( _access( pcFullLogFileName, 00 ) == 0 )
+ {
+ remove( pcFullLogFileName );
+ }
+
+ rename( pcLogFileName, pcFullLogFileName );
+ ulSizeOfLoggingFile = 0;
+ }
+ }
}
/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.h
index 2cc068ce9..773cc0d75 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.h
@@ -38,11 +38,10 @@
* If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
* to the IP address and port number to which UDP log messages will be sent.
*/
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort );
#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_appversion32.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_appversion32.h
index 26408d0ef..c8bc79045 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_appversion32.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_appversion32.h
@@ -31,28 +31,28 @@
/* Application version structure. */
typedef struct
{
- union
- {
- #if ( defined( __BYTE_ORDER__ ) && defined( __ORDER_LITTLE_ENDIAN__ ) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) || ( __little_endian__ == 1 ) || WIN32 || ( __BYTE_ORDER == __LITTLE_ENDIAN )
- struct version
- {
- uint16_t usBuild;
- uint8_t ucMinor;
- uint8_t ucMajor;
- } x;
- #elif ( defined( __BYTE_ORDER__ ) && defined( __ORDER_BIG_ENDIAN__ ) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ) || ( __big_endian__ == 1 ) || ( __BYTE_ORDER == __BIG_ENDIAN )
- struct version
- {
- uint8_t ucMajor;
- uint8_t ucMinor;
- uint16_t usBuild;
- } x;
- #else /* if ( defined( __BYTE_ORDER__ ) && defined( __ORDER_LITTLE_ENDIAN__ ) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) || ( __little_endian__ == 1 ) || WIN32 || ( __BYTE_ORDER == __LITTLE_ENDIAN ) */
- #error "Unable to determine byte order!"
- #endif /* if ( defined( __BYTE_ORDER__ ) && defined( __ORDER_LITTLE_ENDIAN__ ) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) || ( __little_endian__ == 1 ) || WIN32 || ( __BYTE_ORDER == __LITTLE_ENDIAN ) */
- uint32_t ulVersion32;
- int32_t lVersion32;
- } u;
+ union
+ {
+ #if ( defined( __BYTE_ORDER__ ) && defined( __ORDER_LITTLE_ENDIAN__ ) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) || ( __little_endian__ == 1 ) || WIN32 || ( __BYTE_ORDER == __LITTLE_ENDIAN )
+ struct version
+ {
+ uint16_t usBuild;
+ uint8_t ucMinor;
+ uint8_t ucMajor;
+ } x;
+ #elif ( defined( __BYTE_ORDER__ ) && defined( __ORDER_BIG_ENDIAN__ ) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ) || ( __big_endian__ == 1 ) || ( __BYTE_ORDER == __BIG_ENDIAN )
+ struct version
+ {
+ uint8_t ucMajor;
+ uint8_t ucMinor;
+ uint16_t usBuild;
+ } x;
+ #else /* if ( defined( __BYTE_ORDER__ ) && defined( __ORDER_LITTLE_ENDIAN__ ) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) || ( __little_endian__ == 1 ) || WIN32 || ( __BYTE_ORDER == __LITTLE_ENDIAN ) */
+ #error "Unable to determine byte order!"
+ #endif /* if ( defined( __BYTE_ORDER__ ) && defined( __ORDER_LITTLE_ENDIAN__ ) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) || ( __little_endian__ == 1 ) || WIN32 || ( __BYTE_ORDER == __LITTLE_ENDIAN ) */
+ uint32_t ulVersion32;
+ int32_t lVersion32;
+ } u;
} AppVersion32_t;
#endif /* ifndef _IOT_APPVERSION32_H_ */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c
index 53f6830cf..474092664 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c
@@ -31,9 +31,9 @@
/* mbedTLS includes. */
#if !defined( MBEDTLS_CONFIG_FILE )
- #include "mbedtls/config.h"
+ #include "mbedtls/config.h"
#else
- #include MBEDTLS_CONFIG_FILE
+ #include MBEDTLS_CONFIG_FILE
#endif
#include "mbedtls/platform.h"
@@ -57,10 +57,10 @@
*/
typedef struct SignatureVerificationState
{
-BaseType_t xAsymmetricAlgorithm;
-BaseType_t xHashAlgorithm;
-mbedtls_sha1_context xSHA1Context;
-mbedtls_sha256_context xSHA256Context;
+ BaseType_t xAsymmetricAlgorithm;
+ BaseType_t xHashAlgorithm;
+ mbedtls_sha1_context xSHA1Context;
+ mbedtls_sha256_context xSHA256Context;
} SignatureVerificationState_t, * SignatureVerificationStatePtr_t;
/*-----------------------------------------------------------*/
@@ -70,62 +70,62 @@ mbedtls_sha256_context xSHA256Context;
* certificate, hash algorithm, and the data that was signed.
*/
static BaseType_t prvVerifySignature( char * pcSignerCertificate,
- size_t xSignerCertificateLength,
- BaseType_t xHashAlgorithm,
- uint8_t * pucHash,
- size_t xHashLength,
- uint8_t * pucSignature,
- size_t xSignatureLength )
+ size_t xSignerCertificateLength,
+ BaseType_t xHashAlgorithm,
+ uint8_t * pucHash,
+ size_t xHashLength,
+ uint8_t * pucSignature,
+ size_t xSignatureLength )
{
-BaseType_t xResult = pdTRUE;
-mbedtls_x509_crt xCertCtx;
-mbedtls_md_type_t xMbedHashAlg = MBEDTLS_MD_SHA256;
-
-
- memset( &xCertCtx, 0, sizeof( mbedtls_x509_crt ) );
-
- /*
- * Map the hash algorithm
- */
- if( cryptoHASH_ALGORITHM_SHA1 == xHashAlgorithm )
- {
- xMbedHashAlg = MBEDTLS_MD_SHA1;
- }
-
- /*
- * Decode and create a certificate context
- */
- mbedtls_x509_crt_init( &xCertCtx );
-
- if( 0 != mbedtls_x509_crt_parse(
- &xCertCtx, ( const unsigned char * ) pcSignerCertificate, xSignerCertificateLength ) )
- {
- xResult = pdFALSE;
- }
-
- /*
- * Verify the signature using the public key from the decoded certificate
- */
- if( pdTRUE == xResult )
- {
- if( 0 != mbedtls_pk_verify(
- &xCertCtx.pk,
- xMbedHashAlg,
- pucHash,
- xHashLength,
- pucSignature,
- xSignatureLength ) )
- {
- xResult = pdFALSE;
- }
- }
-
- /*
- * Clean-up
- */
- mbedtls_x509_crt_free( &xCertCtx );
-
- return xResult;
+ BaseType_t xResult = pdTRUE;
+ mbedtls_x509_crt xCertCtx;
+ mbedtls_md_type_t xMbedHashAlg = MBEDTLS_MD_SHA256;
+
+
+ memset( &xCertCtx, 0, sizeof( mbedtls_x509_crt ) );
+
+ /*
+ * Map the hash algorithm
+ */
+ if( cryptoHASH_ALGORITHM_SHA1 == xHashAlgorithm )
+ {
+ xMbedHashAlg = MBEDTLS_MD_SHA1;
+ }
+
+ /*
+ * Decode and create a certificate context
+ */
+ mbedtls_x509_crt_init( &xCertCtx );
+
+ if( 0 != mbedtls_x509_crt_parse(
+ &xCertCtx, ( const unsigned char * ) pcSignerCertificate, xSignerCertificateLength ) )
+ {
+ xResult = pdFALSE;
+ }
+
+ /*
+ * Verify the signature using the public key from the decoded certificate
+ */
+ if( pdTRUE == xResult )
+ {
+ if( 0 != mbedtls_pk_verify(
+ &xCertCtx.pk,
+ xMbedHashAlg,
+ pucHash,
+ xHashLength,
+ pucSignature,
+ xSignatureLength ) )
+ {
+ xResult = pdFALSE;
+ }
+ }
+
+ /*
+ * Clean-up
+ */
+ mbedtls_x509_crt_free( &xCertCtx );
+
+ return xResult;
}
/*
@@ -136,47 +136,47 @@ mbedtls_md_type_t xMbedHashAlg = MBEDTLS_MD_SHA256;
* @brief Creates signature verification context.
*/
BaseType_t CRYPTO_SignatureVerificationStart( void ** ppvContext,
- BaseType_t xAsymmetricAlgorithm,
- BaseType_t xHashAlgorithm )
+ BaseType_t xAsymmetricAlgorithm,
+ BaseType_t xHashAlgorithm )
{
-BaseType_t xResult = pdTRUE;
-SignatureVerificationState_t * pxCtx = NULL;
-
- /*
- * Allocate the context
- */
- if( NULL == ( pxCtx = ( SignatureVerificationStatePtr_t ) pvPortMalloc(
- sizeof( *pxCtx ) ) ) ) /*lint !e9087 Allow casting void* to other types. */
- {
- xResult = pdFALSE;
- }
-
- if( pdTRUE == xResult )
- {
- *ppvContext = pxCtx;
-
- /*
- * Store the algorithm identifiers
- */
- pxCtx->xAsymmetricAlgorithm = xAsymmetricAlgorithm;
- pxCtx->xHashAlgorithm = xHashAlgorithm;
-
- /*
- * Initialize the requested hash type
- */
- if( cryptoHASH_ALGORITHM_SHA1 == pxCtx->xHashAlgorithm )
- {
- mbedtls_sha1_init( &pxCtx->xSHA1Context );
- ( void ) mbedtls_sha1_starts_ret( &pxCtx->xSHA1Context );
- }
- else
- {
- mbedtls_sha256_init( &pxCtx->xSHA256Context );
- ( void ) mbedtls_sha256_starts_ret( &pxCtx->xSHA256Context, 0 );
- }
- }
-
- return xResult;
+ BaseType_t xResult = pdTRUE;
+ SignatureVerificationState_t * pxCtx = NULL;
+
+ /*
+ * Allocate the context
+ */
+ if( NULL == ( pxCtx = ( SignatureVerificationStatePtr_t ) pvPortMalloc(
+ sizeof( *pxCtx ) ) ) ) /*lint !e9087 Allow casting void* to other types. */
+ {
+ xResult = pdFALSE;
+ }
+
+ if( pdTRUE == xResult )
+ {
+ *ppvContext = pxCtx;
+
+ /*
+ * Store the algorithm identifiers
+ */
+ pxCtx->xAsymmetricAlgorithm = xAsymmetricAlgorithm;
+ pxCtx->xHashAlgorithm = xHashAlgorithm;
+
+ /*
+ * Initialize the requested hash type
+ */
+ if( cryptoHASH_ALGORITHM_SHA1 == pxCtx->xHashAlgorithm )
+ {
+ mbedtls_sha1_init( &pxCtx->xSHA1Context );
+ ( void ) mbedtls_sha1_starts_ret( &pxCtx->xSHA1Context );
+ }
+ else
+ {
+ mbedtls_sha256_init( &pxCtx->xSHA256Context );
+ ( void ) mbedtls_sha256_starts_ret( &pxCtx->xSHA256Context, 0 );
+ }
+ }
+
+ return xResult;
}
/**
@@ -184,84 +184,84 @@ SignatureVerificationState_t * pxCtx = NULL;
* verification.
*/
void CRYPTO_SignatureVerificationUpdate( void * pvContext,
- const uint8_t * pucData,
- size_t xDataLength )
+ const uint8_t * pucData,
+ size_t xDataLength )
{
-SignatureVerificationState_t * pxCtx = ( SignatureVerificationStatePtr_t ) pvContext; /*lint !e9087 Allow casting void* to other types. */
-
- /*
- * Add the data to the hash of the requested type
- */
- if( cryptoHASH_ALGORITHM_SHA1 == pxCtx->xHashAlgorithm )
- {
- ( void ) mbedtls_sha1_update_ret( &pxCtx->xSHA1Context, pucData, xDataLength );
- }
- else
- {
- ( void ) mbedtls_sha256_update_ret( &pxCtx->xSHA256Context, pucData, xDataLength );
- }
+ SignatureVerificationState_t * pxCtx = ( SignatureVerificationStatePtr_t ) pvContext; /*lint !e9087 Allow casting void* to other types. */
+
+ /*
+ * Add the data to the hash of the requested type
+ */
+ if( cryptoHASH_ALGORITHM_SHA1 == pxCtx->xHashAlgorithm )
+ {
+ ( void ) mbedtls_sha1_update_ret( &pxCtx->xSHA1Context, pucData, xDataLength );
+ }
+ else
+ {
+ ( void ) mbedtls_sha256_update_ret( &pxCtx->xSHA256Context, pucData, xDataLength );
+ }
}
/**
* @brief Performs signature verification on a cryptographic hash.
*/
BaseType_t CRYPTO_SignatureVerificationFinal( void * pvContext,
- char * pcSignerCertificate,
- size_t xSignerCertificateLength,
- uint8_t * pucSignature,
- size_t xSignatureLength )
+ char * pcSignerCertificate,
+ size_t xSignerCertificateLength,
+ uint8_t * pucSignature,
+ size_t xSignatureLength )
{
-BaseType_t xResult = pdFALSE;
-
- if( pvContext != NULL )
- {
- SignatureVerificationStatePtr_t pxCtx = ( SignatureVerificationStatePtr_t ) pvContext; /*lint !e9087 Allow casting void* to other types. */
- uint8_t ucSHA1or256[ cryptoSHA256_DIGEST_BYTES ]; /* Reserve enough space for the larger of SHA1 or SHA256 results. */
- uint8_t * pucHash = NULL;
- size_t xHashLength = 0;
-
- if( ( pcSignerCertificate != NULL ) &&
- ( pucSignature != NULL ) &&
- ( xSignerCertificateLength > 0UL ) &&
- ( xSignatureLength > 0UL ) )
- {
- /*
- * Finish the hash
- */
- if( cryptoHASH_ALGORITHM_SHA1 == pxCtx->xHashAlgorithm )
- {
- ( void ) mbedtls_sha1_finish_ret( &pxCtx->xSHA1Context, ucSHA1or256 );
- pucHash = ucSHA1or256;
- xHashLength = cryptoSHA1_DIGEST_BYTES;
- }
- else
- {
- ( void ) mbedtls_sha256_finish_ret( &pxCtx->xSHA256Context, ucSHA1or256 );
- pucHash = ucSHA1or256;
- xHashLength = cryptoSHA256_DIGEST_BYTES;
- }
-
- /*
- * Verify the signature
- */
- xResult = prvVerifySignature( pcSignerCertificate,
- xSignerCertificateLength,
- pxCtx->xHashAlgorithm,
- pucHash,
- xHashLength,
- pucSignature,
- xSignatureLength );
- }
- else
- {
- /* Allow function to be called with only the context pointer for cleanup after a failure. */
- }
-
- /*
- * Clean-up
- */
- vPortFree( pxCtx );
- }
-
- return xResult;
+ BaseType_t xResult = pdFALSE;
+
+ if( pvContext != NULL )
+ {
+ SignatureVerificationStatePtr_t pxCtx = ( SignatureVerificationStatePtr_t ) pvContext; /*lint !e9087 Allow casting void* to other types. */
+ uint8_t ucSHA1or256[ cryptoSHA256_DIGEST_BYTES ]; /* Reserve enough space for the larger of SHA1 or SHA256 results. */
+ uint8_t * pucHash = NULL;
+ size_t xHashLength = 0;
+
+ if( ( pcSignerCertificate != NULL ) &&
+ ( pucSignature != NULL ) &&
+ ( xSignerCertificateLength > 0UL ) &&
+ ( xSignatureLength > 0UL ) )
+ {
+ /*
+ * Finish the hash
+ */
+ if( cryptoHASH_ALGORITHM_SHA1 == pxCtx->xHashAlgorithm )
+ {
+ ( void ) mbedtls_sha1_finish_ret( &pxCtx->xSHA1Context, ucSHA1or256 );
+ pucHash = ucSHA1or256;
+ xHashLength = cryptoSHA1_DIGEST_BYTES;
+ }
+ else
+ {
+ ( void ) mbedtls_sha256_finish_ret( &pxCtx->xSHA256Context, ucSHA1or256 );
+ pucHash = ucSHA1or256;
+ xHashLength = cryptoSHA256_DIGEST_BYTES;
+ }
+
+ /*
+ * Verify the signature
+ */
+ xResult = prvVerifySignature( pcSignerCertificate,
+ xSignerCertificateLength,
+ pxCtx->xHashAlgorithm,
+ pucHash,
+ xHashLength,
+ pucSignature,
+ xSignatureLength );
+ }
+ else
+ {
+ /* Allow function to be called with only the context pointer for cleanup after a failure. */
+ }
+
+ /*
+ * Clean-up
+ */
+ vPortFree( pxCtx );
+ }
+
+ return xResult;
}
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.h
index 0d866c079..b81afe9fb 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.h
@@ -32,8 +32,8 @@
* @brief Commonly used buffer sizes for storing cryptographic hash computation
* results.
*/
-#define cryptoSHA1_DIGEST_BYTES 20
-#define cryptoSHA256_DIGEST_BYTES 32
+#define cryptoSHA1_DIGEST_BYTES 20
+#define cryptoSHA256_DIGEST_BYTES 32
/**
* @brief Initializes the heap and threading functions for cryptography libraries.
@@ -59,10 +59,10 @@ void CRYPTO_ConfigureHeap( void );
/**
* @brief Library-independent cryptographic algorithm identifiers.
*/
-#define cryptoHASH_ALGORITHM_SHA1 1
-#define cryptoHASH_ALGORITHM_SHA256 2
-#define cryptoASYMMETRIC_ALGORITHM_RSA 1
-#define cryptoASYMMETRIC_ALGORITHM_ECDSA 2
+#define cryptoHASH_ALGORITHM_SHA1 1
+#define cryptoHASH_ALGORITHM_SHA256 2
+#define cryptoASYMMETRIC_ALGORITHM_RSA 1
+#define cryptoASYMMETRIC_ALGORITHM_ECDSA 2
/**
* @brief Initializes digital signature verification.
@@ -74,8 +74,8 @@ void CRYPTO_ConfigureHeap( void );
* @return pdTRUE if initialization succeeds, or pdFALSE otherwise.
*/
BaseType_t CRYPTO_SignatureVerificationStart( void ** ppvContext,
- BaseType_t xAsymmetricAlgorithm,
- BaseType_t xHashAlgorithm );
+ BaseType_t xAsymmetricAlgorithm,
+ BaseType_t xHashAlgorithm );
/**
* @brief Updates a cryptographic hash computation with the specified byte array.
@@ -85,8 +85,8 @@ BaseType_t CRYPTO_SignatureVerificationStart( void ** ppvContext,
* @param[in] xDataLength Length in bytes of data that was signed.
*/
void CRYPTO_SignatureVerificationUpdate( void * pvContext,
- const uint8_t * pucData,
- size_t xDataLength );
+ const uint8_t * pucData,
+ size_t xDataLength );
/**
* @brief Verifies a digital signature computation using the public key from the
@@ -102,9 +102,9 @@ void CRYPTO_SignatureVerificationUpdate( void * pvContext,
* @return pdTRUE if the signature is correct or pdFALSE if the signature is invalid.
*/
BaseType_t CRYPTO_SignatureVerificationFinal( void * pvContext,
- char * pcSignerCertificate,
- size_t xSignerCertificateLength,
- uint8_t * pucSignature,
- size_t xSignatureLength );
+ char * pcSignerCertificate,
+ size_t xSignerCertificateLength,
+ uint8_t * pucSignature,
+ size_t xSignatureLength );
#endif /* ifndef __AWS_CRYPTO__H__ */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c
index ddde0132a..df799191f 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c
@@ -94,7 +94,7 @@ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALS
* to and from a real network connection on the host PC. See the
* configNETWORK_INTERFACE_TO_USE definition for information on how to configure
* the real network connection to use. */
-const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
+const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
/* Use by the pseudo random number generator. */
static UBaseType_t ulNextRand;
@@ -102,36 +102,36 @@ static UBaseType_t ulNextRand;
int main( void )
{
- /***
- * See https://www.FreeRTOS.org/https/index.html for configuration and usage instructions.
- ***/
-
- /* Miscellaneous initialization including preparing the logging and seeding
- * the random number generator. */
- prvMiscInitialisation();
-
- /* Initialize the network interface.
- *
- ***NOTE*** Tasks that use the network are created in the network event hook
- * when the network is connected and ready for use (see the implementation of
- * vApplicationIPNetworkEventHook() below). The address values passed in here
- * are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
- * but a DHCP server cannot be contacted. */
- FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
-
- /* Start the RTOS scheduler. */
- vTaskStartScheduler();
-
- /* If all is well, the scheduler will now be running, and the following
- * line will never be reached. If the following line does execute, then
- * there was insufficient FreeRTOS heap memory available for the idle and/or
- * timer tasks to be created. See the memory management section on the
- * FreeRTOS web site for more details (this is standard text that is not
- * really applicable to the Win32 simulator port). */
- for( ; ; )
- {
- __debugbreak();
- }
+ /***
+ * See https://www.FreeRTOS.org/https/index.html for configuration and usage instructions.
+ ***/
+
+ /* Miscellaneous initialization including preparing the logging and seeding
+ * the random number generator. */
+ prvMiscInitialisation();
+
+ /* Initialize the network interface.
+ *
+ ***NOTE*** Tasks that use the network are created in the network event hook
+ * when the network is connected and ready for use (see the implementation of
+ * vApplicationIPNetworkEventHook() below). The address values passed in here
+ * are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
+ * but a DHCP server cannot be contacted. */
+ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
+
+ /* Start the RTOS scheduler. */
+ vTaskStartScheduler();
+
+ /* If all is well, the scheduler will now be running, and the following
+ * line will never be reached. If the following line does execute, then
+ * there was insufficient FreeRTOS heap memory available for the idle and/or
+ * timer tasks to be created. See the memory management section on the
+ * FreeRTOS web site for more details (this is standard text that is not
+ * really applicable to the Win32 simulator port). */
+ for( ; ; )
+ {
+ __debugbreak();
+ }
}
/*-----------------------------------------------------------*/
@@ -139,156 +139,157 @@ int main( void )
* events are only received if implemented in the MAC driver. */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
-uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
-char cBuffer[ 16 ];
-static BaseType_t xTasksAlreadyCreated = pdFALSE;
-
- /* If the network has just come up...*/
- if( eNetworkEvent == eNetworkUp )
- {
- /* Create the tasks that use the IP stack if they have not already been
- * created. */
- if( xTasksAlreadyCreated == pdFALSE )
- {
- /* Demos that use the network are created after the network is
- * up. */
- configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
- vStartOTAUpdateDemo();
- xTasksAlreadyCreated = pdTRUE;
- }
-
- /* Print out the network configuration, which may have come from a DHCP
- * server. */
- FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
- FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
- FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) ); /*_RB_ Should use IoT libraries logging. */
-
- FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
- FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
- FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
- FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
- }
+ uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
+ char cBuffer[ 16 ];
+ static BaseType_t xTasksAlreadyCreated = pdFALSE;
+
+ /* If the network has just come up...*/
+ if( eNetworkEvent == eNetworkUp )
+ {
+ /* Create the tasks that use the IP stack if they have not already been
+ * created. */
+ if( xTasksAlreadyCreated == pdFALSE )
+ {
+ /* Demos that use the network are created after the network is
+ * up. */
+ configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
+ vStartOTAUpdateDemo();
+ xTasksAlreadyCreated = pdTRUE;
+ }
+
+ /* Print out the network configuration, which may have come from a DHCP
+ * server. */
+ FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
+ FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
+ FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) ); /*_RB_ Should use IoT libraries logging. */
+
+ FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
+ FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
+ FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
+ FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
+ }
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void )
{
- const uint32_t ulMSToSleep = 1;
- Sleep( ulMSToSleep );
+ const uint32_t ulMSToSleep = 1;
+
+ Sleep( ulMSToSleep );
}
/*-----------------------------------------------------------*/
void vAssertCalled( const char * pcFile,
- uint32_t ulLine )
+ uint32_t ulLine )
{
-volatile uint32_t ulBlockVariable = 0UL;
-volatile char * pcFileName = ( volatile char * ) pcFile;
-volatile uint32_t ulLineNumber = ulLine;
-
- ( void ) pcFileName;
- ( void ) ulLineNumber;
-
- printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
-
- /* Setting ulBlockVariable to a non-zero value in the debugger will allow
- * this function to be exited. */
- taskDISABLE_INTERRUPTS();
- {
- while( ulBlockVariable == 0UL )
- {
- __debugbreak();
- }
- }
- taskENABLE_INTERRUPTS();
+ volatile uint32_t ulBlockVariable = 0UL;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
+ volatile uint32_t ulLineNumber = ulLine;
+
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
+
+ printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
+
+ /* Setting ulBlockVariable to a non-zero value in the debugger will allow
+ * this function to be exited. */
+ taskDISABLE_INTERRUPTS();
+ {
+ while( ulBlockVariable == 0UL )
+ {
+ __debugbreak();
+ }
+ }
+ taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
UBaseType_t uxRand( void )
{
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
-
- /*
- * Utility function to generate a pseudo random number.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
- return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
+ const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
+
+ /*
+ * Utility function to generate a pseudo random number.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
}
/*-----------------------------------------------------------*/
static void prvSRand( UBaseType_t ulSeed )
{
- /* Utility function to seed the pseudo random number generator. */
- ulNextRand = ulSeed;
+ /* Utility function to seed the pseudo random number generator. */
+ ulNextRand = ulSeed;
}
/*-----------------------------------------------------------*/
static void prvMiscInitialisation( void )
{
-time_t xTimeNow;
-uint32_t ulLoggingIPAddress;
-
- ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
- vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
-
- /*
- * Seed random number generator.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- time( &xTimeNow );
- FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
- prvSRand( ( uint32_t ) xTimeNow );
- FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
+ time_t xTimeNow;
+ uint32_t ulLoggingIPAddress;
+
+ ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
+ vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
+
+ /*
+ * Seed random number generator.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ time( &xTimeNow );
+ FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
+ prvSRand( ( uint32_t ) xTimeNow );
+ FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
}
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
- const char * pcApplicationHostnameHook( void )
- {
- /* Assign the name "FreeRTOS" to this network node. This function will
- * be called during the DHCP: the machine will be registered with an IP
- * address plus this name. */
- return mainHOST_NAME;
- }
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* Assign the name "FreeRTOS" to this network node. This function will
+ * be called during the DHCP: the machine will be registered with an IP
+ * address plus this name. */
+ return mainHOST_NAME;
+ }
#endif
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
- BaseType_t xApplicationDNSQueryHook( const char * pcName )
- {
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- * to this node: that returned by pcApplicationHostnameHook() and that set
- * by mainDEVICE_NICK_NAME. */
- if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
- {
- xReturn = pdPASS;
- }
- else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
- {
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
-
- return xReturn;
- }
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
+ {
+ BaseType_t xReturn;
+
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*-----------------------------------------------------------*/
@@ -300,32 +301,32 @@ uint32_t ulLoggingIPAddress;
* SYSTEMS.
*/
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort )
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- ( void ) ulSourceAddress;
- ( void ) usSourcePort;
- ( void ) ulDestinationAddress;
- ( void ) usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
- return uxRand();
+ return uxRand();
}
/*-----------------------------------------------------------*/
/*
-* Set *pulNumber to a random number, and return pdTRUE. When the random number
-* generator is broken, it shall return pdFALSE.
-* The macros ipconfigRAND32() and configRAND32() are not in use
-* anymore in FreeRTOS+TCP.
-*
-* THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS
-* NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.
-*/
+ * Set *pulNumber to a random number, and return pdTRUE. When the random number
+ * generator is broken, it shall return pdFALSE.
+ * The macros ipconfigRAND32() and configRAND32() are not in use
+ * anymore in FreeRTOS+TCP.
+ *
+ * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS
+ * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.
+ */
BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
{
- *pulNumber = uxRand();
- return pdTRUE;
+ *pulNumber = uxRand();
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
@@ -333,26 +334,26 @@ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
* implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
* used by the Idle task. */
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
- StackType_t ** ppxIdleTaskStackBuffer,
- uint32_t * pulIdleTaskStackSize )
+ StackType_t ** ppxIdleTaskStackBuffer,
+ uint32_t * pulIdleTaskStackSize )
{
- /* If the buffers to be provided to the Idle task are declared inside this
- * function then they must be declared static - otherwise they will be allocated on
- * the stack and so not exists after this function exits. */
- static StaticTask_t xIdleTaskTCB;
- static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
- * state will be stored. */
- *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
-
- /* Pass out the array that will be used as the Idle task's stack. */
- *ppxIdleTaskStackBuffer = uxIdleTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
- * Note that, as the array is necessarily of type StackType_t,
- * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+ /* If the buffers to be provided to the Idle task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xIdleTaskTCB;
+ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
+ * state will be stored. */
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+
+ /* Pass out the array that will be used as the Idle task's stack. */
+ *ppxIdleTaskStackBuffer = uxIdleTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*/
@@ -360,25 +361,25 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
* application must provide an implementation of vApplicationGetTimerTaskMemory()
* to provide the memory that is used by the Timer service task. */
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
- StackType_t ** ppxTimerTaskStackBuffer,
- uint32_t * pulTimerTaskStackSize )
+ StackType_t ** ppxTimerTaskStackBuffer,
+ uint32_t * pulTimerTaskStackSize )
{
- /* If the buffers to be provided to the Timer task are declared inside this
- * function then they must be declared static - otherwise they will be allocated on
- * the stack and so not exists after this function exits. */
- static StaticTask_t xTimerTaskTCB;
- static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Timer
- * task's state will be stored. */
- *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
-
- /* Pass out the array that will be used as the Timer task's stack. */
- *ppxTimerTaskStackBuffer = uxTimerTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
- * Note that, as the array is necessarily of type StackType_t,
- * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+ /* If the buffers to be provided to the Timer task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xTimerTaskTCB;
+ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Timer
+ * task's state will be stored. */
+ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+
+ /* Pass out the array that will be used as the Timer task's stack. */
+ *ppxTimerTaskStackBuffer = uxTimerTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/mbedtls_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/mbedtls_config.h
index f8a43cb64..0b2d27a0c 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/mbedtls_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/mbedtls_config.h
@@ -99,25 +99,25 @@
/* Set the memory allocation functions on FreeRTOS. */
void * mbedtls_platform_calloc( size_t nmemb,
- size_t size );
+ size_t size );
void mbedtls_platform_free( void * ptr );
#define MBEDTLS_PLATFORM_MEMORY
-#define MBEDTLS_PLATFORM_CALLOC_MACRO mbedtls_platform_calloc
-#define MBEDTLS_PLATFORM_FREE_MACRO mbedtls_platform_free
+#define MBEDTLS_PLATFORM_CALLOC_MACRO mbedtls_platform_calloc
+#define MBEDTLS_PLATFORM_FREE_MACRO mbedtls_platform_free
/* The network send and receive functions on FreeRTOS. */
int mbedtls_platform_send( void * ctx,
- const unsigned char * buf,
- size_t len );
+ const unsigned char * buf,
+ size_t len );
int mbedtls_platform_recv( void * ctx,
- unsigned char * buf,
- size_t len );
+ unsigned char * buf,
+ size_t len );
/* The entropy poll function. */
int mbedtls_platform_entropy_poll( void * data,
- unsigned char * output,
- size_t len,
- size_t * olen );
+ unsigned char * output,
+ size_t len,
+ size_t * olen );
#include "mbedtls/check_config.h"
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSConfig.h
index fcef78a98..6cdc78e2d 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSConfig.h
@@ -29,95 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 1
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 1
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile,
- uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -125,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demo of the HTTP library. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString,
- ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSIPConfig.h
index 7ce865d71..68e49bacc 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/FreeRTOSIPConfig.h
@@ -27,285 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString,
- ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
#define ipconfigHAS_DEBUG_PRINTF 0
#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
#define ipconfigHAS_PRINTF 1
#if ( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf( X ) vLoggingPrintf X
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
-#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
+#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
+ * real program memory (RAM or flash) or just has a random non-zero value. */
#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/aws_ota_agent_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/aws_ota_agent_config.h
index c08c203c3..287a797c1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/aws_ota_agent_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/aws_ota_agent_config.h
@@ -34,19 +34,19 @@
/**
* @brief The number of words allocated to the stack for the OTA agent.
*/
-#define otaconfigSTACK_SIZE 630U
+#define otaconfigSTACK_SIZE 630U
/**
* @brief Log base 2 of the size of the file data block message (excluding the header).
*
* 10 bits yields a data block size of 1KB.
*/
-#define otaconfigLOG2_FILE_BLOCK_SIZE 12UL
+#define otaconfigLOG2_FILE_BLOCK_SIZE 12UL
/**
* @brief Milliseconds to wait for the self test phase to succeed before we force reset.
*/
-#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 16000U
+#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 16000U
/**
* @brief Milliseconds to wait before requesting data blocks from the OTA service if nothing is happening.
@@ -54,12 +54,12 @@
* The wait timer is reset whenever a data block is received from the OTA service so we will only send
* the request message after being idle for this amount of time.
*/
-#define otaconfigFILE_REQUEST_WAIT_MS 10000U
+#define otaconfigFILE_REQUEST_WAIT_MS 10000U
/**
* @brief The OTA agents task priority. Normally it runs at a low priority.
*/
-#define otaconfigAGENT_PRIORITY tskIDLE_PRIORITY
+#define otaconfigAGENT_PRIORITY tskIDLE_PRIORITY
/**
* @brief The maximum allowed length of the thing name used by the OTA agent.
@@ -69,7 +69,7 @@
* initializing the OTA agent. The agent uses this size to allocate static storage for the
* Thing name used in all OTA base topics. Namely $aws/things/<thingName>
*/
-#define otaconfigMAX_THINGNAME_LEN 64U
+#define otaconfigMAX_THINGNAME_LEN 64U
/**
@@ -84,7 +84,7 @@
* Please note that this must be set larger than zero.
*
*/
-#define otaconfigMAX_NUM_BLOCKS_REQUEST 1U
+#define otaconfigMAX_NUM_BLOCKS_REQUEST 1U
/**
* @brief The maximum number of requests allowed to send without a response before we abort.
@@ -93,7 +93,7 @@
* the selected communication channel before aborting and returning error.
*
*/
-#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U
+#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U
/**
* @brief The number of data buffers reserved by the OTA agent.
@@ -101,7 +101,7 @@
* This configurations parameter sets the maximum number of static data buffers used by
* the OTA agent for job and file data blocks received.
*/
-#define otaconfigMAX_NUM_OTA_DATA_BUFFERS 4U
+#define otaconfigMAX_NUM_OTA_DATA_BUFFERS 4U
/**
* @brief Allow update to same or lower version.
@@ -121,7 +121,7 @@
*
* Note - Only MQTT is supported at this time for control operations.
*/
-#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT )
+#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT )
/**
* @brief The protocol selected for OTA data operations.
@@ -135,7 +135,7 @@
* Enable data over HTTP - ( OTA_DATA_OVER_HTTP)
* Enable data over both MQTT & HTTP ( OTA_DATA_OVER_MQTT | OTA_DATA_OVER_HTTP )
*/
-#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT )
+#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT )
/**
* @brief The preferred protocol selected for OTA data operations.
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/iot_config.h
index 8ed948a49..dd013989e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/*
* @brief Set the log level of the task pool library.
@@ -76,7 +76,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_WARN
+#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_WARN
/**
* @brief Set the log level of the MQTT library.
@@ -87,7 +87,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
+#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
/**
* @brief Set the log level of the HTTPS Client library.
@@ -98,14 +98,14 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
+#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
/**
* @brief Enable TLS in the network abstraction.
*
* The TLS implementation requires the mbed TLS library.
*/
-#define IOT_NETWORK_ENABLE_TLS 1
+#define IOT_NETWORK_ENABLE_TLS 1
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -119,7 +119,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
@@ -128,16 +128,16 @@
#define IotLogging_Puts( str ) configPRINTF( ( "%s\r\n", str ) )
/* Assert functions on FreeRTOS. */
-#define Iot_DefaultAssert configASSERT
+#define Iot_DefaultAssert configASSERT
/* Memory allocation functions on FreeRTOS. */
-#define Iot_DefaultMalloc pvPortMalloc
-#define Iot_DefaultFree vPortFree
+#define Iot_DefaultMalloc pvPortMalloc
+#define Iot_DefaultFree vPortFree
-#define IotThreads_Malloc pvPortMalloc
-#define IotThreads_Free vPortFree
+#define IotThreads_Malloc pvPortMalloc
+#define IotThreads_Free vPortFree
-#define IotLogging_Malloc pvPortMalloc
-#define IotLogging_Free vPortFree
+#define IotLogging_Malloc pvPortMalloc
+#define IotLogging_Free vPortFree
#endif /* ifndef IOT_CONFIG_H_ */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSConfig.h
index fcef78a98..6cdc78e2d 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSConfig.h
@@ -29,95 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 1
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 1
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile,
- uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -125,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demo of the HTTP library. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString,
- ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSIPConfig.h
index 7ce865d71..68e49bacc 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/FreeRTOSIPConfig.h
@@ -27,285 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString,
- ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
#define ipconfigHAS_DEBUG_PRINTF 0
#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
#define ipconfigHAS_PRINTF 1
#if ( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf( X ) vLoggingPrintf X
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
-#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
+#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
+ * real program memory (RAM or flash) or just has a random non-zero value. */
#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/aws_ota_agent_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/aws_ota_agent_config.h
index 85e7bae3d..2791cca7a 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/aws_ota_agent_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/aws_ota_agent_config.h
@@ -34,19 +34,19 @@
/**
* @brief The number of words allocated to the stack for the OTA agent.
*/
-#define otaconfigSTACK_SIZE 630U
+#define otaconfigSTACK_SIZE 630U
/**
* @brief Log base 2 of the size of the file data block message (excluding the header).
*
* 10 bits yields a data block size of 1KB.
*/
-#define otaconfigLOG2_FILE_BLOCK_SIZE 12UL
+#define otaconfigLOG2_FILE_BLOCK_SIZE 12UL
/**
* @brief Milliseconds to wait for the self test phase to succeed before we force reset.
*/
-#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 16000U
+#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 16000U
/**
* @brief Milliseconds to wait before requesting data blocks from the OTA service if nothing is happening.
@@ -54,12 +54,12 @@
* The wait timer is reset whenever a data block is received from the OTA service so we will only send
* the request message after being idle for this amount of time.
*/
-#define otaconfigFILE_REQUEST_WAIT_MS 10000U
+#define otaconfigFILE_REQUEST_WAIT_MS 10000U
/**
* @brief The OTA agents task priority. Normally it runs at a low priority.
*/
-#define otaconfigAGENT_PRIORITY tskIDLE_PRIORITY
+#define otaconfigAGENT_PRIORITY tskIDLE_PRIORITY
/**
* @brief The maximum allowed length of the thing name used by the OTA agent.
@@ -69,7 +69,7 @@
* initializing the OTA agent. The agent uses this size to allocate static storage for the
* Thing name used in all OTA base topics. Namely $aws/things/<thingName>
*/
-#define otaconfigMAX_THINGNAME_LEN 64U
+#define otaconfigMAX_THINGNAME_LEN 64U
/**
@@ -84,7 +84,7 @@
* Please note that this must be set larger than zero.
*
*/
-#define otaconfigMAX_NUM_BLOCKS_REQUEST 1U
+#define otaconfigMAX_NUM_BLOCKS_REQUEST 1U
/**
* @brief The maximum number of requests allowed to send without a response before we abort.
@@ -93,7 +93,7 @@
* the selected communication channel before aborting and returning error.
*
*/
-#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U
+#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U
/**
* @brief The number of data buffers reserved by the OTA agent.
@@ -101,7 +101,7 @@
* This configurations parameter sets the maximum number of static data buffers used by
* the OTA agent for job and file data blocks received.
*/
-#define otaconfigMAX_NUM_OTA_DATA_BUFFERS 4U
+#define otaconfigMAX_NUM_OTA_DATA_BUFFERS 4U
/**
* @brief Allow update to same or lower version.
@@ -121,7 +121,7 @@
*
* Note - Only MQTT is supported at this time for control operations.
*/
-#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT )
+#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT )
/**
* @brief The protocol selected for OTA data operations.
@@ -135,7 +135,7 @@
* Enable data over HTTP - ( OTA_DATA_OVER_HTTP)
* Enable data over both MQTT & HTTP ( OTA_DATA_OVER_MQTT | OTA_DATA_OVER_HTTP )
*/
-#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT | OTA_DATA_OVER_HTTP )
+#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT | OTA_DATA_OVER_HTTP )
/**
* @brief The preferred protocol selected for OTA data operations.
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/iot_config.h
index 8ed948a49..dd013989e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_code_signing_http/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/*
* @brief Set the log level of the task pool library.
@@ -76,7 +76,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_WARN
+#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_WARN
/**
* @brief Set the log level of the MQTT library.
@@ -87,7 +87,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
+#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
/**
* @brief Set the log level of the HTTPS Client library.
@@ -98,14 +98,14 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
+#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
/**
* @brief Enable TLS in the network abstraction.
*
* The TLS implementation requires the mbed TLS library.
*/
-#define IOT_NETWORK_ENABLE_TLS 1
+#define IOT_NETWORK_ENABLE_TLS 1
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -119,7 +119,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
@@ -128,16 +128,16 @@
#define IotLogging_Puts( str ) configPRINTF( ( "%s\r\n", str ) )
/* Assert functions on FreeRTOS. */
-#define Iot_DefaultAssert configASSERT
+#define Iot_DefaultAssert configASSERT
/* Memory allocation functions on FreeRTOS. */
-#define Iot_DefaultMalloc pvPortMalloc
-#define Iot_DefaultFree vPortFree
+#define Iot_DefaultMalloc pvPortMalloc
+#define Iot_DefaultFree vPortFree
-#define IotThreads_Malloc pvPortMalloc
-#define IotThreads_Free vPortFree
+#define IotThreads_Malloc pvPortMalloc
+#define IotThreads_Free vPortFree
-#define IotLogging_Malloc pvPortMalloc
-#define IotLogging_Free vPortFree
+#define IotLogging_Malloc pvPortMalloc
+#define IotLogging_Free vPortFree
#endif /* ifndef IOT_CONFIG_H_ */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSConfig.h
index fcef78a98..6cdc78e2d 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSConfig.h
@@ -29,95 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 1
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 1
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile,
- uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -125,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demo of the HTTP library. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString,
- ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSIPConfig.h
index 7ce865d71..68e49bacc 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/FreeRTOSIPConfig.h
@@ -27,285 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString,
- ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
#define ipconfigHAS_DEBUG_PRINTF 0
#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
#define ipconfigHAS_PRINTF 1
#if ( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf( X ) vLoggingPrintf X
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 2000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
-#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
+#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
+ * real program memory (RAM or flash) or just has a random non-zero value. */
#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/aws_ota_agent_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/aws_ota_agent_config.h
index 2039ebea0..a1f1ab9df 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/aws_ota_agent_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/aws_ota_agent_config.h
@@ -34,19 +34,19 @@
/**
* @brief The number of words allocated to the stack for the OTA agent.
*/
-#define otaconfigSTACK_SIZE 630U
+#define otaconfigSTACK_SIZE 630U
/**
* @brief Log base 2 of the size of the file data block message (excluding the header).
*
* 10 bits yields a data block size of 1KB.
*/
-#define otaconfigLOG2_FILE_BLOCK_SIZE 12UL
+#define otaconfigLOG2_FILE_BLOCK_SIZE 12UL
/**
* @brief Milliseconds to wait for the self test phase to succeed before we force reset.
*/
-#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 16000U
+#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 16000U
/**
* @brief Milliseconds to wait before requesting data blocks from the OTA service if nothing is happening.
@@ -54,12 +54,12 @@
* The wait timer is reset whenever a data block is received from the OTA service so we will only send
* the request message after being idle for this amount of time.
*/
-#define otaconfigFILE_REQUEST_WAIT_MS 10000U
+#define otaconfigFILE_REQUEST_WAIT_MS 10000U
/**
* @brief The OTA agents task priority. Normally it runs at a low priority.
*/
-#define otaconfigAGENT_PRIORITY tskIDLE_PRIORITY
+#define otaconfigAGENT_PRIORITY tskIDLE_PRIORITY
/**
* @brief The maximum allowed length of the thing name used by the OTA agent.
@@ -69,7 +69,7 @@
* initializing the OTA agent. The agent uses this size to allocate static storage for the
* Thing name used in all OTA base topics. Namely $aws/things/<thingName>
*/
-#define otaconfigMAX_THINGNAME_LEN 64U
+#define otaconfigMAX_THINGNAME_LEN 64U
/**
@@ -84,7 +84,7 @@
* Please note that this must be set larger than zero.
*
*/
-#define otaconfigMAX_NUM_BLOCKS_REQUEST 1U
+#define otaconfigMAX_NUM_BLOCKS_REQUEST 1U
/**
* @brief The maximum number of requests allowed to send without a response before we abort.
@@ -93,7 +93,7 @@
* the selected communication channel before aborting and returning error.
*
*/
-#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U
+#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U
/**
* @brief The number of data buffers reserved by the OTA agent.
@@ -101,7 +101,7 @@
* This configurations parameter sets the maximum number of static data buffers used by
* the OTA agent for job and file data blocks received.
*/
-#define otaconfigMAX_NUM_OTA_DATA_BUFFERS 4U
+#define otaconfigMAX_NUM_OTA_DATA_BUFFERS 4U
/**
* @brief Allow update to same or lower version.
@@ -121,7 +121,7 @@
*
* Note - Only MQTT is supported at this time for control operations.
*/
-#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT )
+#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT )
/**
* @brief The protocol selected for OTA data operations.
@@ -135,7 +135,7 @@
* Enable data over HTTP - ( OTA_DATA_OVER_HTTP)
* Enable data over both MQTT & HTTP ( OTA_DATA_OVER_MQTT | OTA_DATA_OVER_HTTP )
*/
-#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT )
+#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT )
/**
* @brief The preferred protocol selected for OTA data operations.
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/iot_config.h
index 8ed948a49..dd013989e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/ota_no_code_signing/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/*
* @brief Set the log level of the task pool library.
@@ -76,7 +76,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_WARN
+#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_WARN
/**
* @brief Set the log level of the MQTT library.
@@ -87,7 +87,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
+#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
/**
* @brief Set the log level of the HTTPS Client library.
@@ -98,14 +98,14 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
+#define IOT_LOG_LEVEL_HTTPS IOT_LOG_WARN
/**
* @brief Enable TLS in the network abstraction.
*
* The TLS implementation requires the mbed TLS library.
*/
-#define IOT_NETWORK_ENABLE_TLS 1
+#define IOT_NETWORK_ENABLE_TLS 1
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -119,7 +119,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
@@ -128,16 +128,16 @@
#define IotLogging_Puts( str ) configPRINTF( ( "%s\r\n", str ) )
/* Assert functions on FreeRTOS. */
-#define Iot_DefaultAssert configASSERT
+#define Iot_DefaultAssert configASSERT
/* Memory allocation functions on FreeRTOS. */
-#define Iot_DefaultMalloc pvPortMalloc
-#define Iot_DefaultFree vPortFree
+#define Iot_DefaultMalloc pvPortMalloc
+#define Iot_DefaultFree vPortFree
-#define IotThreads_Malloc pvPortMalloc
-#define IotThreads_Free vPortFree
+#define IotThreads_Malloc pvPortMalloc
+#define IotThreads_Free vPortFree
-#define IotLogging_Malloc pvPortMalloc
-#define IotLogging_Free vPortFree
+#define IotLogging_Malloc pvPortMalloc
+#define IotLogging_Free vPortFree
#endif /* ifndef IOT_CONFIG_H_ */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c
index 85c9118ec..8977f975b 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c
@@ -184,17 +184,17 @@ static void prvInitialiseLibraries( void );
/**
* @brief The MQTT connection handle used in this example.
*/
-static IotMqttConnection_t xMQTTConnection = NULL;
+static IotMqttConnection_t xMQTTConnection = NULL;
/*-----------------------------------------------------------*/
-static const struct IotNetworkServerInfo xMQTTBrokerInfo =
+static const struct IotNetworkServerInfo xMQTTBrokerInfo =
{
.pHostName = mqttexampleBROKER_ENDPOINT,
.port = mqttexampleBROKER_PORT
};
-static struct IotNetworkCredentials xNetworkSecurityCredentials =
+static struct IotNetworkCredentials xNetworkSecurityCredentials =
{
/* Optional TLS extensions. For this demo, they are disabled. */
.pAlpnProtos = NULL,
@@ -209,7 +209,7 @@ static struct IotNetworkCredentials xNetworkSecurityCredentials =
.rootCaSize = mqttexampleBROKER_CERTIFICATE_PEM_SIZE,
};
-static IotMqttNetworkInfo_t xNetworkInfo =
+static IotMqttNetworkInfo_t xNetworkInfo =
{
/* No connection to the MQTT broker has been established yet and we want to
* establish a new connection. */
@@ -227,7 +227,7 @@ static IotMqttNetworkInfo_t xNetworkInfo =
.disconnectCallback.function = prvExample_OnDisconnect
};
-static const IotMqttConnectInfo_t xConnectInfo =
+static const IotMqttConnectInfo_t xConnectInfo =
{
/* Set this flag to true if connecting to the AWS IoT MQTT broker. */
.awsIotMqttMode = true,
@@ -288,9 +288,9 @@ void vStartPKCSMutualAuthDemo( void )
static void prvMQTTDemoTask( void * pvParameters )
{
- uint32_t ulNotificationValue = 0, ulPublishCount;
- const uint32_t ulMaxPublishCount = 5UL;
- const TickType_t xNoDelay = ( TickType_t ) 0;
+ uint32_t ulNotificationValue = 0, ulPublishCount;
+ const uint32_t ulMaxPublishCount = 5UL;
+ const TickType_t xNoDelay = ( TickType_t ) 0;
/* Remove compiler warnings about unused parameters. */
( void ) pvParameters;
@@ -464,86 +464,86 @@ static void prvMQTTDisconnect( void )
static void prvMQTTSubscribe( void )
{
- IotMqttError_t xResult;
+ IotMqttError_t xResult;
IotMqttSubscription_t xMQTTSubscription;
/* Subscribe to the mqttexampleTOPIC topic filter. The task handle is passed
* as the callback context, which is then used by the callback to send a task
* notification to this task.*/
- xMQTTSubscription.qos = IOT_MQTT_QOS_1;
- xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
- xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
+ xMQTTSubscription.qos = IOT_MQTT_QOS_1;
+ xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
+ xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
xMQTTSubscription.callback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();
- xMQTTSubscription.callback.function = prvExample_OnMessageReceived;
+ xMQTTSubscription.callback.function = prvExample_OnMessageReceived;
/* Use the synchronous API to subscribe - It is a blocking call and only
* returns when the subscribe operation is complete or a timeout occurs. */
- xResult = IotMqtt_SubscribeSync( xMQTTConnection,
- &( xMQTTSubscription ),
- 1, /* We are subscribing to one topic filter. */
- 0, /* flags - currently ignored. */
- mqttexampleMQTT_TIMEOUT_MS );
+ xResult = IotMqtt_SubscribeSync( xMQTTConnection,
+ &( xMQTTSubscription ),
+ 1, /* We are subscribing to one topic filter. */
+ 0, /* flags - currently ignored. */
+ mqttexampleMQTT_TIMEOUT_MS );
configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvMQTTPublish( void )
{
- IotMqttError_t xResult;
+ IotMqttError_t xResult;
IotMqttPublishInfo_t xMQTTPublishInfo;
/* Publish a message with QoS1 on the mqttexampleTOPIC topic. Since we are
* subscribed to the same topic, the MQTT broker will send the same message
* back to us. It is verified in the publish callback. */
- xMQTTPublishInfo.qos = IOT_MQTT_QOS_1;
- xMQTTPublishInfo.retain = false;
- xMQTTPublishInfo.pTopicName = mqttexampleTOPIC;
+ xMQTTPublishInfo.qos = IOT_MQTT_QOS_1;
+ xMQTTPublishInfo.retain = false;
+ xMQTTPublishInfo.pTopicName = mqttexampleTOPIC;
xMQTTPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC );
- xMQTTPublishInfo.pPayload = mqttexampleMESSAGE;
- xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE );
- xMQTTPublishInfo.retryMs = mqttexamplePUBLISH_RETRY_MS;
- xMQTTPublishInfo.retryLimit = mqttexamplePUBLISH_RETRY_LIMIT;
+ xMQTTPublishInfo.pPayload = mqttexampleMESSAGE;
+ xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE );
+ xMQTTPublishInfo.retryMs = mqttexamplePUBLISH_RETRY_MS;
+ xMQTTPublishInfo.retryLimit = mqttexamplePUBLISH_RETRY_LIMIT;
/* Use the synchronous API to publish - It is a blocking call and only
* returns when the publish operation is complete or a timeout occurs. */
- xResult = IotMqtt_PublishSync( xMQTTConnection,
- &( xMQTTPublishInfo ),
- 0, /* flags - currently ignored. */
- mqttexampleMQTT_TIMEOUT_MS );
+ xResult = IotMqtt_PublishSync( xMQTTConnection,
+ &( xMQTTPublishInfo ),
+ 0, /* flags - currently ignored. */
+ mqttexampleMQTT_TIMEOUT_MS );
configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvMQTTUnsubscribe( void )
{
- IotMqttError_t xResult;
+ IotMqttError_t xResult;
IotMqttSubscription_t xMQTTSubscription;
/* Unsubscribe from the mqttexampleTOPIC topic filter. */
- xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
- xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
+ xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
+ xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
/* The following members of the IotMqttSubscription_t are ignored by the
* unsubscribe operation. Just initialize them to avoid "use of uninitialized
* variable" warnings. */
- xMQTTSubscription.qos = IOT_MQTT_QOS_1;
+ xMQTTSubscription.qos = IOT_MQTT_QOS_1;
xMQTTSubscription.callback.pCallbackContext = NULL;
- xMQTTSubscription.callback.function = NULL;
+ xMQTTSubscription.callback.function = NULL;
/* Use the synchronous API to unsubscribe - It is a blocking call and only
* returns when the unsubscribe operation is complete or a timeout occurs. */
- xResult = IotMqtt_UnsubscribeSync( xMQTTConnection,
- &( xMQTTSubscription ),
- 1, /* We are unsubscribing from one topic filter. */
- 0, /* flags - currently ignored. */
- mqttexampleMQTT_TIMEOUT_MS );
+ xResult = IotMqtt_UnsubscribeSync( xMQTTConnection,
+ &( xMQTTSubscription ),
+ 1, /* We are unsubscribing from one topic filter. */
+ 0, /* flags - currently ignored. */
+ mqttexampleMQTT_TIMEOUT_MS );
configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvInitialiseLibraries( void )
{
- IotMqttError_t xResult;
+ IotMqttError_t xResult;
IotNetworkError_t xNetworkResult; /*_RB_ Are three types necessary, one for each lib? */
/* Initialize the network stack abstraction for FreeRTOS. */
@@ -552,7 +552,7 @@ static void prvInitialiseLibraries( void )
/* MQTT library must be initialized before it can be used. This is just one
* time initialization. */
- xResult = IotMqtt_Init();
+ xResult = IotMqtt_Init();
configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSConfig.h
index 4c4246b71..04980a2b5 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSConfig.h
@@ -30,195 +30,197 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES (7)
-#define configTICK_RATE_HZ \
- (1000) /* In this non-real time simulated environment the tick frequency \
- has to be at least a multiple of the Win32 tick frequency, and \
- therefore very slow. */
-#define configMINIMAL_STACK_SIZE \
- ((unsigned short)60) /* In this simulated case, the stack only has to hold \
- one small structure as the real stack is part of \
- the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ((size_t)(2048U * 1024U))
-#define configMAX_TASK_NAME_LEN (15)
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ \
+ ( 1000 ) /* In this non-real time simulated environment the tick frequency \
+ * has to be at least a multiple of the Win32 tick frequency, and \
+ * therefore very slow. */
+#define configMINIMAL_STACK_SIZE \
+ ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold \
+ * one small structure as the real stack is part of \
+ * the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
/* Not applicable to the Win32 port. */
-#define configCHECK_FOR_STACK_OVERFLOW 0
+#define configCHECK_FOR_STACK_OVERFLOW 0
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES (2)
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
-extern void vAssertCalled(const char* pcFile, uint32_t ulLine);
-#define configASSERT(x) \
- if ((x) == 0) \
- vAssertCalled(__FILE__, __LINE__)
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) \
+ if( ( x ) == 0 ) \
+ vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY (configMAX_PRIORITIES - 1)
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 1L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 1L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT (15000)
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demo which uses MQTT (MQTT depends on task pool). */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-#if (defined(_MSC_VER) && (_MSC_VER <= 1600) && !defined(snprintf))
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
/* Map to Windows names. */
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf(const char* pcFormatString, ...);
-#define configPRINTF(X) vLoggingPrintf X
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
+#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSIPConfig.h
index 4f17259b4..b27ce64d1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/FreeRTOSIPConfig.h
@@ -28,285 +28,286 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf(const char* pcFormatString, ...);
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if (ipconfigHAS_DEBUG_PRINTF == 1)
-#define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if (ipconfigHAS_PRINTF == 1)
-#define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP
-checksums) then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the
-software stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * checksums) then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the
+ * software stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME (5000)
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME (5000)
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR (0)
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS (0)
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE (1)
-#define ipconfigDNS_CACHE_NAME_LENGTH (64)
-#define ipconfigDNS_CACHE_ENTRIES (4)
-#define ipconfigDNS_REQUEST_ATTEMPTS (2)
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API).
-ipconfigUDP_TASK_PRIORITY sets the priority of the task that executes the IP
-stack. The priority is a standard FreeRTOS task priority so can take any value
-from 0 (the lowest priority) to (configMAX_PRIORITIES - 1) (the highest
-priority). configMAX_PRIORITIES is a standard FreeRTOS configuration parameter
-defined in FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be
-given as to the priority assigned to the task executing the IP stack relative to
-the priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY (configMAX_PRIORITIES - 2)
+ * use of its services through the published sockets API).
+ * ipconfigUDP_TASK_PRIORITY sets the priority of the task that executes the IP
+ * stack. The priority is a standard FreeRTOS task priority so can take any value
+ * from 0 (the lowest priority) to (configMAX_PRIORITIES - 1) (the highest
+ * priority). configMAX_PRIORITIES is a standard FreeRTOS configuration parameter
+ * defined in FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be
+ * given as to the priority assigned to the task executing the IP stack relative to
+ * the priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS (configMINIMAL_STACK_SIZE * 5)
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time
-expires then the send operation is aborted. The maximum allowable send block
-time is capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping
-the maximum allowable send block time prevents prevents a deadlock occurring
-when all the network buffers are in use and the tasks that process (and
-subsequently free) the network buffers are themselves blocked waiting for a
-network buffer. ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A
-time in milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS (5000 / portTICK_PERIOD_MS)
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time
+ * expires then the send operation is aborted. The maximum allowable send block
+ * time is capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping
+ * the maximum allowable send block time prevents prevents a deadlock occurring
+ * when all the network buffers are in use and the tasks that process (and
+ * subsequently free) the network buffers are themselves blocked waiting for a
+ * network buffer. ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A
+ * time in milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD (120000 / portTICK_PERIOD_MS)
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS (5)
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is
-stale. New ARP requests are sent for ARP cache entries that are nearing their
-maximum age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of
-150 is equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is
+ * stale. New ARP requests are sent for ARP cache entries that are nearing their
+ * maximum age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of
+ * 150 is equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network
-buffer that are available to the IP stack. The total number of network buffers
-is limited to ensure the total amount of RAM that can be consumed by the IP
-stack is capped to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * buffer that are available to the IP stack. The total number of network buffers
+ * is limited to ensure the total amount of RAM that can be consumed by the IP
+ * stack is capped to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH (ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5)
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the
-send operation being aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the
+ * send operation being aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE \
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE \
128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP (1)
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
-#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT (1)
+#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN (1)
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 0
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 0
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY (20 / portTICK_PERIOD_MS)
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus
-16-bits. This has to do with the contents of the IP-packets: all 32-bit fields
-are 32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus
+ * 16-bits. This has to do with the contents of the IP-packets: all 32-bit fields
+ * are 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 20
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 20
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH (1000)
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH (1000)
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ((x) != NULL)
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION (1)
-#define ipconfigTCP_HANG_PROTECTION_TIME (30)
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE (1)
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL (20) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c
index 0b2388f93..61a68dc82 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c
@@ -35,65 +35,65 @@
*
* Also note that it is assumed this demo is going to be used for short periods
* of time only, and therefore timer overflows are not handled.
-*/
+ */
/* FreeRTOS includes. */
#include <FreeRTOS.h>
/* Variables used in the creation of the run time stats time base. Run time
-stats record how much time each task spends in the Running state. */
+ * stats record how much time each task spends in the Running state. */
static long long llInitialRunTimeCounterValue = 0LL, llTicksPerHundedthMillisecond = 0LL;
/*-----------------------------------------------------------*/
void vConfigureTimerForRunTimeStats( void )
{
-LARGE_INTEGER liPerformanceCounterFrequency, liInitialRunTimeValue;
+ LARGE_INTEGER liPerformanceCounterFrequency, liInitialRunTimeValue;
- /* Initialise the variables used to create the run time stats time base.
- Run time stats record how much time each task spends in the Running
- state. */
+ /* Initialise the variables used to create the run time stats time base.
+ * Run time stats record how much time each task spends in the Running
+ * state. */
- if( QueryPerformanceFrequency( &liPerformanceCounterFrequency ) == 0 )
- {
- llTicksPerHundedthMillisecond = 1;
- }
- else
- {
- /* How many times does the performance counter increment in 1/100th
- millisecond. */
- llTicksPerHundedthMillisecond = liPerformanceCounterFrequency.QuadPart / 100000LL;
+ if( QueryPerformanceFrequency( &liPerformanceCounterFrequency ) == 0 )
+ {
+ llTicksPerHundedthMillisecond = 1;
+ }
+ else
+ {
+ /* How many times does the performance counter increment in 1/100th
+ * millisecond. */
+ llTicksPerHundedthMillisecond = liPerformanceCounterFrequency.QuadPart / 100000LL;
- /* What is the performance counter value now, this will be subtracted
- from readings taken at run time. */
- QueryPerformanceCounter( &liInitialRunTimeValue );
- llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart;
- }
+ /* What is the performance counter value now, this will be subtracted
+ * from readings taken at run time. */
+ QueryPerformanceCounter( &liInitialRunTimeValue );
+ llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart;
+ }
}
/*-----------------------------------------------------------*/
unsigned long ulGetRunTimeCounterValue( void )
{
-LARGE_INTEGER liCurrentCount;
-unsigned long ulReturn;
+ LARGE_INTEGER liCurrentCount;
+ unsigned long ulReturn;
- /* What is the performance counter value now? */
- QueryPerformanceCounter( &liCurrentCount );
+ /* What is the performance counter value now? */
+ QueryPerformanceCounter( &liCurrentCount );
- /* Subtract the performance counter value reading taken when the
- application started to get a count from that reference point, then
- scale to (simulated) 1/100ths of a millisecond. */
- if( llTicksPerHundedthMillisecond == 0 )
- {
- /* The trace macros are probably calling this function before the
- scheduler has been started. */
- ulReturn = 0;
- }
- else
- {
- ulReturn = ( unsigned long ) ( ( liCurrentCount.QuadPart - llInitialRunTimeCounterValue ) / llTicksPerHundedthMillisecond );
- }
+ /* Subtract the performance counter value reading taken when the
+ * application started to get a count from that reference point, then
+ * scale to (simulated) 1/100ths of a millisecond. */
+ if( llTicksPerHundedthMillisecond == 0 )
+ {
+ /* The trace macros are probably calling this function before the
+ * scheduler has been started. */
+ ulReturn = 0;
+ }
+ else
+ {
+ ulReturn = ( unsigned long ) ( ( liCurrentCount.QuadPart - llInitialRunTimeCounterValue ) / llTicksPerHundedthMillisecond );
+ }
- return ulReturn;
+ return ulReturn;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h
index 7ea61a153..522773bcd 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h
@@ -47,68 +47,68 @@
*/
#ifndef ATOMIC_H
-#define ATOMIC_H
+ #define ATOMIC_H
-#ifndef INC_FREERTOS_H
- #error "include FreeRTOS.h must appear in source files before include atomic.h"
-#endif
+ #ifndef INC_FREERTOS_H
+ #error "include FreeRTOS.h must appear in source files before include atomic.h"
+ #endif
/* Standard includes. */
-#include <stdint.h>
+ #include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- /* Needed for __atomic_compare_exchange() weak=false. */
- #include <stdbool.h>
+/* Needed for __atomic_compare_exchange() weak=false. */
+ #include <stdbool.h>
- /* This branch is for GCC compiler and GCC compiler only. */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE inline __attribute__((always_inline))
- #endif
+/* This branch is for GCC compiler and GCC compiler only. */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE inline __attribute__( ( always_inline ) )
+ #endif
-#else
+ #else
- /* Port specific definitions -- entering/exiting critical section.
- * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
- *
- * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
- * ATOMIC_ENTER_CRITICAL().
- */
- #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
+/* Port specific definitions -- entering/exiting critical section.
+ * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
+ *
+ * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
+ * ATOMIC_ENTER_CRITICAL().
+ */
+ #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
- /* Nested interrupt scheme is supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() \
- UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
+/* Nested interrupt scheme is supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() \
+ UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
- #define ATOMIC_EXIT_CRITICAL() \
- portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
+ #define ATOMIC_EXIT_CRITICAL() \
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
- #else
+ #else
- /* Nested interrupt scheme is NOT supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
- #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
+/* Nested interrupt scheme is NOT supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
+ #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
- #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
+ #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
- /* Port specific definition -- "always inline".
- * Inline is compiler specific, and may not always get inlined depending on your optimization level.
- * Also, inline is considerred as performance optimization for atomic.
- * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
- * simply define it.
- */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE
- #endif
+/* Port specific definition -- "always inline".
+ * Inline is compiler specific, and may not always get inlined depending on your optimization level.
+ * Also, inline is considerred as performance optimization for atomic.
+ * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
+ * simply define it.
+ */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE
+ #endif
-#endif /* configUSE_GCC_BUILTIN_ATOMICS */
+ #endif /* configUSE_GCC_BUILTIN_ATOMICS */
-#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
-#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
+ #define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
+ #define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
/*----------------------------- Swap && CAS ------------------------------*/
@@ -127,44 +127,36 @@ extern "C" {
* @note This function only swaps *pDestination with ulExchange, if previous
* *pDestination value equals ulComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
- uint32_t volatile * pDestination,
- uint32_t ulExchange,
- uint32_t ulComparand )
-{
-
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- if ( __atomic_compare_exchange( pDestination,
- &ulComparand,
- &ulExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pDestination,
+ uint32_t ulExchange,
+ uint32_t ulComparand )
{
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( pDestination,
+ &ulComparand,
+ &ulExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *pDestination == ulComparand )
+ {
+ *pDestination = ulExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *pDestination == ulComparand )
- {
- *pDestination = ulExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-
-}
-
/**
* Atomic swap (pointers)
*
@@ -177,30 +169,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
*
* @return The initial value of *ppDestination.
*/
-static portFORCE_INLINE void * Atomic_SwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange )
-{
- void * pReturnValue;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange )
+ {
+ void * pReturnValue;
- pReturnValue = *ppDestination;
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
+ #else
+ ATOMIC_ENTER_CRITICAL();
- *ppDestination = pExchange;
+ pReturnValue = *ppDestination;
- ATOMIC_EXIT_CRITICAL();
+ *ppDestination = pExchange;
-#endif
+ ATOMIC_EXIT_CRITICAL();
+ #endif
- return pReturnValue;
-}
+ return pReturnValue;
+ }
/**
* Atomic compare-and-swap (pointers)
@@ -218,40 +205,36 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32(
* @note This function only swaps *ppDestination with pExchange, if previous
* *ppDestination value equals pComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange, void * pComparand )
-{
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- if ( __atomic_compare_exchange( ppDestination,
- &pComparand,
- &pExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
- {
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *ppDestination == pComparand )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange,
+ void * pComparand )
{
- *ppDestination = pExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( ppDestination,
+ &pComparand,
+ &pExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *ppDestination == pComparand )
+ {
+ *ppDestination = pExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-}
-
/*----------------------------- Arithmetic ------------------------------*/
@@ -266,30 +249,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Add_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic subtract
@@ -303,30 +281,25 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic increment
@@ -338,28 +311,24 @@ static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
*
* @return *pAddend value before increment.
*/
-static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic decrement
@@ -371,28 +340,24 @@ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAdde
*
* @return *pAddend value before decrement.
*/
-static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/*----------------------------- Bitwise Logical ------------------------------*/
@@ -407,30 +372,25 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_OR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_or(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_or( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination |= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination |= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic AND
@@ -443,30 +403,25 @@ static portFORCE_INLINE uint32_t Atomic_OR_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_AND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_and(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_and( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination &= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination &= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic NAND
@@ -479,30 +434,25 @@ static portFORCE_INLINE uint32_t Atomic_AND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_NAND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_nand(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_nand( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination = ~(ulCurrent & ulValue);
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination = ~( ulCurrent & ulValue );
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic XOR
@@ -515,33 +465,28 @@ static portFORCE_INLINE uint32_t Atomic_NAND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_XOR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_xor(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_xor( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination ^= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination ^= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
-#ifdef __cplusplus
-}
-#endif
+ #ifdef __cplusplus
+ }
+ #endif
#endif /* ATOMIC_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c
index b723bcd87..cd8116018 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c
@@ -57,19 +57,19 @@
/*-----------------------------------------------------------*/
/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
+ * to .ful. */
+#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
+#define dlMAX_PRINT_STRING_LENGTH 255
/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
+ * the Win32 thread that is responsible for making any Win32 system calls that are
+ * necessary for the selected logging method. */
+#define dlLOGGING_STREAM_BUFFER_SIZE 32768
/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
+#define dlDONT_BLOCK 0
/*-----------------------------------------------------------*/
@@ -81,7 +81,8 @@ static void prvFileLoggingInit( void );
/*
* Attempt to write a message to the file.
*/
-static void prvLogToFile( const char *pcMessage, size_t xLength );
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength );
/*
* Simply close the logging file, if it is open.
@@ -102,7 +103,7 @@ static void prvLoggingFlushBuffer( void );
* Win32 system calls. Only the windows thread can make system calls so as not
* to disrupt the simulation by making Windows calls from FreeRTOS tasks.
*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
+static DWORD WINAPI prvWin32LoggingThread( void * pvParam );
/*
* Creates the socket to which UDP messages are sent. This function is not
@@ -110,417 +111,426 @@ static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
* task - which could result in a deadlock. Instead the function call is
* deferred to run in the RTOS daemon task - hence it prototype.
*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 );
/*-----------------------------------------------------------*/
/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
+ * needs Win32 system calls. */
+static void * pvLoggingThreadEvent = NULL;
/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
+ * vLoggingInit() function. */
+BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
+ * thread that is responsible for making Win32 calls (when stdout or a disk log is
+ * used). */
+static StreamBuffer_t * xLogStreamBuffer = NULL;
/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
+ * messages waiting to be logged, then closed again in between logs. */
+static FILE * pxLoggingFileHandle = NULL;
/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
+ * to pdFALSE - at which time prints that require Win32 system calls are done by
+ * the Win32 thread responsible for logging. */
+BaseType_t xDirectPrint = pdTRUE;
/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
+static const char * pcLogFileName = "RTOSDemo.log";
+static const char * pcFullLogFileName = "RTOSDemo.ful";
/* Keep the current file size in a variable, as an optimisation. */
-static size_t ulSizeOfLoggingFile = 0ul;
+static size_t ulSizeOfLoggingFile = 0ul;
/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
+Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
struct freertos_sockaddr xPrintUDPAddress;
/*-----------------------------------------------------------*/
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort )
{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialise it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialised. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
+ /* Can only be called before the scheduler has started. */
+ configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
+
+ #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
+ {
+ HANDLE Win32Thread;
+
+ /* Record which output methods are to be used. */
+ xStdoutLoggingUsed = xLogToStdout;
+ xDiskFileLoggingUsed = xLogToFile;
+ xUDPLoggingUsed = xLogToUDP;
+
+ /* If a disk file is used then initialise it now. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvFileLoggingInit();
+ }
+
+ /* If UDP logging is used then store the address to which the log data
+ * will be sent - but don't create the socket yet because the network is
+ * not initialised. */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ /* Set the address to which the print messages are sent. */
+ xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
+ xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
+ }
+
+ /* If a disk file or stdout are to be used then Win32 system calls will
+ * have to be made. Such system calls cannot be made from FreeRTOS tasks
+ * so create a stream buffer to pass the messages to a Win32 thread, then
+ * create the thread itself, along with a Win32 event that can be used to
+ * unblock the thread. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ /* Create the buffer. */
+ xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
+ configASSERT( xLogStreamBuffer );
+ memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
+ xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
+
+ /* Create the Windows event. */
+ pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
+
+ /* Create the thread itself. */
+ Win32Thread = CreateThread(
+ NULL, /* Pointer to thread security attributes. */
+ 0, /* Initial thread stack size, in bytes. */
+ prvWin32LoggingThread, /* Pointer to thread function. */
+ NULL, /* Argument for new thread. */
+ 0, /* Creation flags. */
+ NULL );
+
+ /* Use the cores that are not used by the FreeRTOS tasks. */
+ SetThreadAffinityMask( Win32Thread, ~0x01u );
+ SetThreadPriorityBoost( Win32Thread, TRUE );
+ SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
+ }
+ }
+ #else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */
+ {
+ /* FreeRTOSIPConfig is set such that no print messages will be output.
+ * Avoid compiler warnings about unused parameters. */
+ ( void ) xLogToStdout;
+ ( void ) xLogToFile;
+ ( void ) xLogToUDP;
+ ( void ) usRemotePort;
+ ( void ) ulRemoteIPAddress;
+ }
+ #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
}
/*-----------------------------------------------------------*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 )
{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
+ static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
+ Socket_t xSocket;
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
+ /* The function prototype is that of a deferred function, but the parameters
+ * are not actually used. */
+ ( void ) pvParameter1;
+ ( void ) ulParameter2;
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
+ if( xSocket != FREERTOS_INVALID_SOCKET )
+ {
+ /* FreeRTOS+TCP decides which port to bind to. */
+ FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
+ FreeRTOS_bind( xSocket, NULL, 0 );
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
+ /* Now the socket is bound it can be assigned to the print socket. */
+ xPrintSocket = xSocket;
+ }
}
/*-----------------------------------------------------------*/
-void vLoggingPrintf( const char *pcFormat, ... )
+void vLoggingPrintf( const char * pcFormat,
+ ... )
{
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
-char *pcSource, *pcTarget, *pcBegin;
-size_t xLength, xLength2, rc;
-static BaseType_t xMessageNumber = 0;
-va_list args;
-uint32_t ulIPAddress;
-const char *pcTaskName;
-const char *pcNoTask = "None";
-int iOriginalPriority;
-HANDLE xCurrentTask;
-
-
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
- {
- /* There are a variable number of parameters. */
- va_start( args, pcFormat );
-
- /* Additional info to place at the start of the log. */
- if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
- {
- pcTaskName = pcTaskGetName( NULL );
- }
- else
- {
- pcTaskName = pcNoTask;
- }
-
- if( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
-
- if( xLength2 < 0 )
- {
- /* Clean up. */
- xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
- cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
- }
-
- xLength += xLength2;
- va_end( args );
-
- /* For ease of viewing, copy the string into another buffer, converting
- IP addresses to dot notation on the way. */
- pcSource = cPrintString;
- pcTarget = cOutputString;
-
- while( ( *pcSource ) != '\0' )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- pcSource++;
-
- /* Look forward for an IP address denoted by 'ip'. */
- if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- *pcTarget = '\0';
- pcBegin = pcTarget - 8;
-
- while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
- {
- pcTarget--;
- }
-
- sscanf( pcTarget, "%8X", &ulIPAddress );
- rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
- ( unsigned long ) ( ulIPAddress >> 24UL ),
- ( unsigned long ) ( (ulIPAddress >> 16UL) & 0xffUL ),
- ( unsigned long ) ( (ulIPAddress >> 8UL) & 0xffUL ),
- ( unsigned long ) ( ulIPAddress & 0xffUL ) );
- pcTarget += rc;
- pcSource += 3; /* skip "<n>ip" */
- }
- }
-
- /* How far through the buffer was written? */
- xLength = ( BaseType_t ) ( pcTarget - cOutputString );
-
- /* If the message is to be logged to a UDP port then it can be sent directly
- because it only uses FreeRTOS function (not Win32 functions). */
- if( xUDPLoggingUsed != pdFALSE )
- {
- if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
- {
- /* Create and bind the socket to which print messages are sent. The
- xTimerPendFunctionCall() function is used even though this is
- not an interrupt because this function is called from the IP task
- and the IP task cannot itself wait for a socket to bind. The
- parameters to prvCreatePrintSocket() are not required so set to
- NULL or 0. */
- xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* If logging is also to go to either stdout or a disk file then it cannot
- be output here - so instead write the message to the stream buffer and wake
- the Win32 thread which will read it from the stream buffer and perform the
- actual output. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- configASSERT( xLogStreamBuffer );
-
- /* How much space is in the buffer? */
- xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
-
- /* There must be enough space to write both the string and the length of
- the string. */
- if( xLength2 >= ( xLength + sizeof( xLength ) ) )
- {
- /* First write in the length of the data, then write in the data
- itself. Raising the thread priority is used as a critical section
- as there are potentially multiple writers. The stream buffer is
- only thread safe when there is a single writer (likewise for
- reading from the buffer). */
- xCurrentTask = GetCurrentThread();
- iOriginalPriority = GetThreadPriority( xCurrentTask );
- SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
- SetThreadPriority( GetCurrentThread(), iOriginalPriority );
- }
-
- /* xDirectPrint is initialised to pdTRUE, and while it remains true the
- logging output function is called directly. When the system is running
- the output function cannot be called directly because it would get
- called from both FreeRTOS tasks and Win32 threads - so instead wake the
- Win32 thread responsible for the actual output. */
- if( xDirectPrint != pdFALSE )
- {
- /* While starting up, the thread which calls prvWin32LoggingThread()
- is not running yet and xDirectPrint will be pdTRUE. */
- prvLoggingFlushBuffer();
- }
- else if( pvLoggingThreadEvent != NULL )
- {
- /* While running, wake up prvWin32LoggingThread() to send the
- logging data. */
- SetEvent( pvLoggingThreadEvent );
- }
- }
- }
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+ char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
+ char * pcSource, * pcTarget, * pcBegin;
+ size_t xLength, xLength2, rc;
+ static BaseType_t xMessageNumber = 0;
+ va_list args;
+ uint32_t ulIPAddress;
+ const char * pcTaskName;
+ const char * pcNoTask = "None";
+ int iOriginalPriority;
+ HANDLE xCurrentTask;
+
+
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
+ {
+ /* There are a variable number of parameters. */
+ va_start( args, pcFormat );
+
+ /* Additional info to place at the start of the log. */
+ if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
+ {
+ pcTaskName = pcTaskGetName( NULL );
+ }
+ else
+ {
+ pcTaskName = pcNoTask;
+ }
+
+ if( strcmp( pcFormat, "\n" ) != 0 )
+ {
+ xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
+ xMessageNumber++,
+ ( unsigned long ) xTaskGetTickCount(),
+ pcTaskName );
+ }
+ else
+ {
+ xLength = 0;
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ }
+
+ xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
+
+ if( xLength2 < 0 )
+ {
+ /* Clean up. */
+ xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
+ cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
+ }
+
+ xLength += xLength2;
+ va_end( args );
+
+ /* For ease of viewing, copy the string into another buffer, converting
+ * IP addresses to dot notation on the way. */
+ pcSource = cPrintString;
+ pcTarget = cOutputString;
+
+ while( ( *pcSource ) != '\0' )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ pcSource++;
+
+ /* Look forward for an IP address denoted by 'ip'. */
+ if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ *pcTarget = '\0';
+ pcBegin = pcTarget - 8;
+
+ while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
+ {
+ pcTarget--;
+ }
+
+ sscanf( pcTarget, "%8X", &ulIPAddress );
+ rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
+ ( unsigned long ) ( ulIPAddress >> 24UL ),
+ ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ),
+ ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ),
+ ( unsigned long ) ( ulIPAddress & 0xffUL ) );
+ pcTarget += rc;
+ pcSource += 3; /* skip "<n>ip" */
+ }
+ }
+
+ /* How far through the buffer was written? */
+ xLength = ( BaseType_t ) ( pcTarget - cOutputString );
+
+ /* If the message is to be logged to a UDP port then it can be sent directly
+ * because it only uses FreeRTOS function (not Win32 functions). */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
+ {
+ /* Create and bind the socket to which print messages are sent. The
+ * xTimerPendFunctionCall() function is used even though this is
+ * not an interrupt because this function is called from the IP task
+ * and the IP task cannot itself wait for a socket to bind. The
+ * parameters to prvCreatePrintSocket() are not required so set to
+ * NULL or 0. */
+ xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
+ }
+
+ if( xPrintSocket != FREERTOS_INVALID_SOCKET )
+ {
+ FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+
+ /* Just because the UDP data logger I'm using is dumb. */
+ FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+ }
+ }
+
+ /* If logging is also to go to either stdout or a disk file then it cannot
+ * be output here - so instead write the message to the stream buffer and wake
+ * the Win32 thread which will read it from the stream buffer and perform the
+ * actual output. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ configASSERT( xLogStreamBuffer );
+
+ /* How much space is in the buffer? */
+ xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
+
+ /* There must be enough space to write both the string and the length of
+ * the string. */
+ if( xLength2 >= ( xLength + sizeof( xLength ) ) )
+ {
+ /* First write in the length of the data, then write in the data
+ * itself. Raising the thread priority is used as a critical section
+ * as there are potentially multiple writers. The stream buffer is
+ * only thread safe when there is a single writer (likewise for
+ * reading from the buffer). */
+ xCurrentTask = GetCurrentThread();
+ iOriginalPriority = GetThreadPriority( xCurrentTask );
+ SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
+ SetThreadPriority( GetCurrentThread(), iOriginalPriority );
+ }
+
+ /* xDirectPrint is initialised to pdTRUE, and while it remains true the
+ * logging output function is called directly. When the system is running
+ * the output function cannot be called directly because it would get
+ * called from both FreeRTOS tasks and Win32 threads - so instead wake the
+ * Win32 thread responsible for the actual output. */
+ if( xDirectPrint != pdFALSE )
+ {
+ /* While starting up, the thread which calls prvWin32LoggingThread()
+ * is not running yet and xDirectPrint will be pdTRUE. */
+ prvLoggingFlushBuffer();
+ }
+ else if( pvLoggingThreadEvent != NULL )
+ {
+ /* While running, wake up prvWin32LoggingThread() to send the
+ * logging data. */
+ SetEvent( pvLoggingThreadEvent );
+ }
+ }
+ }
}
/*-----------------------------------------------------------*/
static void prvLoggingFlushBuffer( void )
{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- _write( _fileno(stdout), cPrintString, strlen( cPrintString ) );
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
+ size_t xLength;
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+
+ /* Is there more than the length value stored in the circular buffer
+ * used to pass data from the FreeRTOS simulator into this Win32 thread? */
+ while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
+ {
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
+
+ /* Write the message to standard out if requested to do so when
+ * vLoggingInit() was called, or if the network is not yet up. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
+ {
+ /* Write the message to stdout. */
+ _write( _fileno( stdout ), cPrintString, strlen( cPrintString ) );
+ }
+
+ /* Write the message to a file if requested to do so when
+ * vLoggingInit() was called. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvLogToFile( cPrintString, xLength );
+ }
+ }
+
+ prvFileClose();
}
/*-----------------------------------------------------------*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
+static DWORD WINAPI prvWin32LoggingThread( void * pvParameter )
{
-const DWORD xMaxWait = 1000;
+ const DWORD xMaxWait = 1000;
- ( void ) pvParameter;
+ ( void ) pvParameter;
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
+ /* From now on, prvLoggingFlushBuffer() will only be called from this
+ * Windows thread */
+ xDirectPrint = pdFALSE;
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
+ for( ; ; )
+ {
+ /* Wait to be told there are message waiting to be logged. */
+ WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
+ /* Write out all waiting messages. */
+ prvLoggingFlushBuffer();
+ }
}
/*-----------------------------------------------------------*/
static void prvFileLoggingInit( void )
{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
+ FILE * pxHandle = fopen( pcLogFileName, "a" );
+
+ if( pxHandle != NULL )
+ {
+ fseek( pxHandle, SEEK_END, 0ul );
+ ulSizeOfLoggingFile = ftell( pxHandle );
+ fclose( pxHandle );
+ }
+ else
+ {
+ ulSizeOfLoggingFile = 0ul;
+ }
}
/*-----------------------------------------------------------*/
static void prvFileClose( void )
{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
+ if( pxLoggingFileHandle != NULL )
+ {
+ fclose( pxLoggingFileHandle );
+ pxLoggingFileHandle = NULL;
+ }
}
/*-----------------------------------------------------------*/
-static void prvLogToFile( const char *pcMessage, size_t xLength )
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength )
{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
+ if( pxLoggingFileHandle == NULL )
+ {
+ pxLoggingFileHandle = fopen( pcLogFileName, "a" );
+ }
+
+ if( pxLoggingFileHandle != NULL )
+ {
+ fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
+ ulSizeOfLoggingFile += xLength;
+
+ /* If the file has grown to its maximum permissible size then close and
+ * rename it - then start with a new file. */
+ if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
+ {
+ prvFileClose();
+
+ if( _access( pcFullLogFileName, 00 ) == 0 )
+ {
+ remove( pcFullLogFileName );
+ }
+
+ rename( pcLogFileName, pcFullLogFileName );
+ ulSizeOfLoggingFile = 0;
+ }
+ }
}
/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.h
index f1d7315a8..a997f5ba7 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.h
@@ -38,11 +38,10 @@
* If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
* to the IP address and port number to which UDP log messages will be sent.
*/
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort );
#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_config.h
index e127a408c..1845c513c 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_config.h
@@ -38,7 +38,7 @@
* Possible values: One of the Log levels.
* Default value (if undefined): IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
+#define IOT_LOG_LEVEL_GLOBAL IOT_LOG_NONE
/**
* @brief Set the log level of the platform libraries except the network
@@ -52,7 +52,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
+#define IOT_LOG_LEVEL_PLATFORM IOT_LOG_NONE
/**
* @brief Set the log level of the platform network library.
@@ -64,7 +64,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
+#define IOT_LOG_LEVEL_NETWORK IOT_LOG_WARN
/**
* @brief Set the log level of the MQTT library.
@@ -75,7 +75,7 @@
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
* then IOT_LOG_NONE.
*/
-#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
+#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
/**
* @brief Enable/Disable asserts for the linear containers library.
@@ -89,7 +89,7 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_CONTAINERS_ENABLE_ASSERTS 1
+#define IOT_CONTAINERS_ENABLE_ASSERTS 1
/**
* @brief Enable/Disable asserts for the MQTT library.
@@ -103,12 +103,12 @@
* Recommended values: 1 when debugging; 0 in production code.
* Default value (if undefined): 0
*/
-#define IOT_MQTT_ENABLE_ASSERTS 1
+#define IOT_MQTT_ENABLE_ASSERTS 1
/**
* @brief Enable/Disable anonymous metrics collection when using AWS IoT.
*/
-#define AWS_IOT_MQTT_ENABLE_METRICS 0
+#define AWS_IOT_MQTT_ENABLE_METRICS 0
/* Common settings for FreeRTOS; settings below this line generally do not need
* to be changed. */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_pkcs11_config.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_pkcs11_config.h
index 97337d7ea..03eacf8fd 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_pkcs11_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/iot_pkcs11_config.h
@@ -33,30 +33,30 @@
#define _AWS_PKCS11_CONFIG_H_
/**
-* @brief PKCS #11 default user PIN.
-*
-* The PKCS #11 standard specifies the presence of a user PIN. That feature is
-* sensible for applications that have an interactive user interface and memory
-* protections. However, since typical microcontroller applications lack one or
-* both of those, the user PIN is assumed to be used herein for interoperability
-* purposes only, and not as a security feature.
-*
+ * @brief PKCS #11 default user PIN.
+ *
+ * The PKCS #11 standard specifies the presence of a user PIN. That feature is
+ * sensible for applications that have an interactive user interface and memory
+ * protections. However, since typical microcontroller applications lack one or
+ * both of those, the user PIN is assumed to be used herein for interoperability
+ * purposes only, and not as a security feature.
+ *
* Note: Do not cast this to a pointer! The library calls sizeof to get the length
* of this string.
-*/
-#define configPKCS11_DEFAULT_USER_PIN "0000"
+ */
+#define configPKCS11_DEFAULT_USER_PIN "0000"
/**
-* @brief Maximum length (in characters) for a PKCS #11 CKA_LABEL
-* attribute.
-*/
-#define pkcs11configMAX_LABEL_LENGTH 32
+ * @brief Maximum length (in characters) for a PKCS #11 CKA_LABEL
+ * attribute.
+ */
+#define pkcs11configMAX_LABEL_LENGTH 32
/**
-* @brief Maximum number of token objects that can be stored
-* by the PKCS #11 module.
-*/
-#define pkcs11configMAX_NUM_OBJECTS 6
+ * @brief Maximum number of token objects that can be stored
+ * by the PKCS #11 module.
+ */
+#define pkcs11configMAX_NUM_OBJECTS 6
/**
* @brief Maximum number of sessions that can be stored
@@ -65,73 +65,73 @@
#define pkcs11configMAX_SESSIONS 10
/**
-* @brief Set to 1 if a PAL destroy object is implemented.
-*
-* If set to 0, no PAL destroy object is implemented, and this functionality
-* is implemented in the common PKCS #11 layer.
-*/
+ * @brief Set to 1 if a PAL destroy object is implemented.
+ *
+ * If set to 0, no PAL destroy object is implemented, and this functionality
+ * is implemented in the common PKCS #11 layer.
+ */
#define pkcs11configPAL_DESTROY_SUPPORTED 0
/**
-* @brief Set to 1 if OTA image verification via PKCS #11 module is supported.
-*
-* If set to 0, OTA code signing certificate is built in via
-* aws_ota_codesigner_certificate.h.
-*/
+ * @brief Set to 1 if OTA image verification via PKCS #11 module is supported.
+ *
+ * If set to 0, OTA code signing certificate is built in via
+ * aws_ota_codesigner_certificate.h.
+ */
#define pkcs11configOTA_SUPPORTED 0
/**
-* @brief Set to 1 if PAL supports storage for JITP certificate,
-* code verify certificate, and trusted server root certificate.
-*
-* If set to 0, PAL does not support storage mechanism for these, and
-* they are accessed via headers compiled into the code.
-*/
+ * @brief Set to 1 if PAL supports storage for JITP certificate,
+ * code verify certificate, and trusted server root certificate.
+ *
+ * If set to 0, PAL does not support storage mechanism for these, and
+ * they are accessed via headers compiled into the code.
+ */
#define pkcs11configJITP_CODEVERIFY_ROOT_CERT_SUPPORTED 0
/**
-* @brief The PKCS #11 label for device private key.
-*
-* Private key for connection to AWS IoT endpoint. The corresponding
-* public key should be registered with the AWS IoT endpoint.
-*/
+ * @brief The PKCS #11 label for device private key.
+ *
+ * Private key for connection to AWS IoT endpoint. The corresponding
+ * public key should be registered with the AWS IoT endpoint.
+ */
#define pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS "Device Priv TLS Key"
/**
-* @brief The PKCS #11 label for device public key.
-*
-* The public key corresponding to pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS.
-*/
+ * @brief The PKCS #11 label for device public key.
+ *
+ * The public key corresponding to pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS.
+ */
#define pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS "Device Pub TLS Key"
/**
-* @brief The PKCS #11 label for the device certificate.
-*
-* Device certificate corresponding to pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS.
-*/
+ * @brief The PKCS #11 label for the device certificate.
+ *
+ * Device certificate corresponding to pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS.
+ */
#define pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS "Device Cert"
/**
-* @brief The PKCS #11 label for the object to be used for code verification.
-*
-* Used by over-the-air update code to verify an incoming signed image.
-*/
+ * @brief The PKCS #11 label for the object to be used for code verification.
+ *
+ * Used by over-the-air update code to verify an incoming signed image.
+ */
#define pkcs11configLABEL_CODE_VERIFICATION_KEY "Code Verify Key"
/**
-* @brief The PKCS #11 label for Just-In-Time-Provisioning.
-*
-* The certificate corresponding to the issuer of the device certificate
-* (pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS) when using the JITR or
-* JITP flow.
-*/
+ * @brief The PKCS #11 label for Just-In-Time-Provisioning.
+ *
+ * The certificate corresponding to the issuer of the device certificate
+ * (pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS) when using the JITR or
+ * JITP flow.
+ */
#define pkcs11configLABEL_JITP_CERTIFICATE "JITP Cert"
/**
-* @brief The PKCS #11 label for the AWS Trusted Root Certificate.
-*
-* @see aws_default_root_certificates.h
-*/
+ * @brief The PKCS #11 label for the AWS Trusted Root Certificate.
+ *
+ * @see aws_default_root_certificates.h
+ */
#define pkcs11configLABEL_ROOT_CERTIFICATE "Root Cert"
#endif /* _AWS_PKCS11_CONFIG_H_ include guard. */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c
index 67e61dcb8..793f6a4a8 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c
@@ -28,7 +28,7 @@
/***
* See https://www.FreeRTOS.org/pkcs11/index.html for configuration and usage
- *instructions.
+ * instructions.
***/
/* Standard includes. */
@@ -61,28 +61,38 @@
* vStartPKCSMutualAuthDemo() is called from inside
* vApplicationIPNetworkEventHook().
*/
-extern void vStartPKCSMutualAuthDemo(void);
+extern void vStartPKCSMutualAuthDemo( void );
/*
* Miscellaneous initialisation including preparing the logging and seeding the
* random number generator.
*/
-static void prvMiscInitialisation(void);
+static void prvMiscInitialisation( void );
/* The default IP and MAC address used by the demo. The address configuration
* defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
* 1 but a DHCP server could not be contacted. See the online documentation for
* more information. */
-static const uint8_t ucIPAddress[4] = {configIP_ADDR0, configIP_ADDR1,
- configIP_ADDR2, configIP_ADDR3};
-static const uint8_t ucNetMask[4] = {configNET_MASK0, configNET_MASK1,
- configNET_MASK2, configNET_MASK3};
-static const uint8_t ucGatewayAddress[4] = {
+static const uint8_t ucIPAddress[ 4 ] =
+{
+ configIP_ADDR0, configIP_ADDR1,
+ configIP_ADDR2, configIP_ADDR3
+};
+static const uint8_t ucNetMask[ 4 ] =
+{
+ configNET_MASK0, configNET_MASK1,
+ configNET_MASK2, configNET_MASK3
+};
+static const uint8_t ucGatewayAddress[ 4 ] =
+{
configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2,
- configGATEWAY_ADDR3};
-static const uint8_t ucDNSServerAddress[4] = {
+ configGATEWAY_ADDR3
+};
+static const uint8_t ucDNSServerAddress[ 4 ] =
+{
configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2,
- configDNS_SERVER_ADDR3};
+ configDNS_SERVER_ADDR3
+};
/* Set the following constant to pdTRUE to log using the method indicated by the
* name of the constant, or pdFALSE to not log using the method indicated by the
@@ -93,24 +103,27 @@ static const uint8_t ucDNSServerAddress[4] = {
* FreeRTOSConfig.h) and the port number set by configPRINT_PORT in
* FreeRTOSConfig.h. */
const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE,
- xLogToUDP = pdFALSE;
+ xLogToUDP = pdFALSE;
/* Default MAC address configuration. The demo creates a virtual network
* connection that uses this MAC address by accessing the raw Ethernet data
* to and from a real network connection on the host PC. See the
* configNETWORK_INTERFACE_TO_USE definition for information on how to configure
* the real network connection to use. */
-const uint8_t ucMACAddress[6] = {configMAC_ADDR0, configMAC_ADDR1,
- configMAC_ADDR2, configMAC_ADDR3,
- configMAC_ADDR4, configMAC_ADDR5};
+const uint8_t ucMACAddress[ 6 ] =
+{
+ configMAC_ADDR0, configMAC_ADDR1,
+ configMAC_ADDR2, configMAC_ADDR3,
+ configMAC_ADDR4, configMAC_ADDR5
+};
/*-----------------------------------------------------------*/
-int main(void)
+int main( void )
{
/***
* See https://www.FreeRTOS.org/pkcs11/index.html for configuration and usage
- *instructions.
+ * instructions.
***/
/* Miscellaneous initialisation including preparing the logging and seeding
@@ -121,12 +134,12 @@ int main(void)
*
***NOTE*** Tasks that use the network are created in the network event hook
* when the network is connected and ready for use (see the implementation
- *of vApplicationIPNetworkEventHook() below). The address values passed in
- *here are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is
- *set to 1 but a DHCP server cannot be contacted. */
+ * of vApplicationIPNetworkEventHook() below). The address values passed in
+ * here are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is
+ * set to 1 but a DHCP server cannot be contacted. */
FreeRTOS_IPInit(
ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress,
- ucMACAddress);
+ ucMACAddress );
/* Start the RTOS scheduler. */
vTaskStartScheduler();
@@ -137,7 +150,8 @@ int main(void)
* timer tasks to be created. See the memory management section on the
* FreeRTOS web site for more details (this is standard text that is not not
* really applicable to the Win32 simulator port). */
- for (;;) {
+ for( ; ; )
+ {
__debugbreak();
}
}
@@ -145,20 +159,22 @@ int main(void)
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
* events are only received if implemented in the MAC driver. */
-void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)
+void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
- uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
- char cBuffer[16];
+ uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
+ char cBuffer[ 16 ];
static BaseType_t xTasksAlreadyCreated = pdFALSE;
/* If the network has just come up...*/
- if (eNetworkEvent == eNetworkUp) {
+ if( eNetworkEvent == eNetworkUp )
+ {
/* Create the tasks that use the IP stack if they have not already been
* created. */
- if (xTasksAlreadyCreated == pdFALSE) {
+ if( xTasksAlreadyCreated == pdFALSE )
+ {
/* Demos that use the network are created after the network is
* up. */
- configPRINTF(("---------STARTING DEMO---------\r\n"));
+ configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
vStartPKCSMutualAuthDemo();
xTasksAlreadyCreated = pdTRUE;
}
@@ -166,36 +182,37 @@ void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)
/* Print out the network configuration, which may have come from a DHCP
* server. */
FreeRTOS_GetAddressConfiguration(
- &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress);
- FreeRTOS_inet_ntoa(ulIPAddress, cBuffer);
+ &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
+ FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
FreeRTOS_printf(
- ("\r\n\r\nIP Address: %s\r\n",
- cBuffer));
+ ( "\r\n\r\nIP Address: %s\r\n",
+ cBuffer ) );
- FreeRTOS_inet_ntoa(ulNetMask, cBuffer);
- FreeRTOS_printf(("Subnet Mask: %s\r\n", cBuffer));
+ FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
+ FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
- FreeRTOS_inet_ntoa(ulGatewayAddress, cBuffer);
- FreeRTOS_printf(("Gateway Address: %s\r\n", cBuffer));
+ FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
+ FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
- FreeRTOS_inet_ntoa(ulDNSServerAddress, cBuffer);
- FreeRTOS_printf(("DNS Server Address: %s\r\n\r\n\r\n", cBuffer));
+ FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
+ FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
}
}
/*-----------------------------------------------------------*/
-void vAssertCalled(const char* pcFile, uint32_t ulLine)
+void vAssertCalled( const char * pcFile,
+ uint32_t ulLine )
{
volatile uint32_t ulBlockVariable = 0UL;
- volatile char* pcFileName = (volatile char*)pcFile;
- volatile uint32_t ulLineNumber = ulLine;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
+ volatile uint32_t ulLineNumber = ulLine;
- (void)pcFileName;
- (void)ulLineNumber;
- (void)ulBlockVariable;
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
+ ( void ) ulBlockVariable;
- printf("vAssertCalled( %s, %u\n", pcFile, ulLine);
+ printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
/* Setting ulBlockVariable to a non-zero value in the debugger will allow
* this function to be exited. */
@@ -206,24 +223,27 @@ void vAssertCalled(const char* pcFile, uint32_t ulLine)
taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
-UBaseType_t uxRand(void)
+UBaseType_t uxRand( void )
{
- uint8_t ulNextRand = 0;
- CK_RV xResult = CKR_OK;
- static CK_SESSION_HANDLE xSession = CK_INVALID_HANDLE;
- CK_FUNCTION_LIST_PTR pxFunctionList;
- xResult = C_GetFunctionList(&pxFunctionList);
-
- if (xSession == CK_INVALID_HANDLE)
- {
+ uint8_t ulNextRand = 0;
+ CK_RV xResult = CKR_OK;
+ static CK_SESSION_HANDLE xSession = CK_INVALID_HANDLE;
+ CK_FUNCTION_LIST_PTR pxFunctionList;
+
+ xResult = C_GetFunctionList( &pxFunctionList );
+
+ if( xSession == CK_INVALID_HANDLE )
+ {
xResult = xInitializePkcs11Session( &xSession );
}
- if (xResult == CKR_OK)
+
+ if( xResult == CKR_OK )
{
- xResult = pxFunctionList->C_GenerateRandom(xSession, &ulNextRand, sizeof(ulNextRand));
+ xResult = pxFunctionList->C_GenerateRandom( xSession, &ulNextRand, sizeof( ulNextRand ) );
}
- if (xResult != CKR_OK) {
+ if( xResult != CKR_OK )
+ {
ulNextRand = 0;
}
@@ -234,76 +254,81 @@ UBaseType_t uxRand(void)
/*-----------------------------------------------------------*/
-static void prvMiscInitialisation(void)
+static void prvMiscInitialisation( void )
{
uint32_t ulLoggingIPAddress;
ulLoggingIPAddress = FreeRTOS_inet_addr_quick(
configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1,
- configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3);
+ configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
vLoggingInit(
xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress,
- configPRINT_PORT);
+ configPRINT_PORT );
- CK_RV xResult;
+ CK_RV xResult;
uint32_t xRandom = 0;
/* Set the mutex functions for mbed TLS thread safety. */
mbedtls_threading_set_alt(
mbedtls_platform_mutex_init, mbedtls_platform_mutex_free,
- mbedtls_platform_mutex_lock, mbedtls_platform_mutex_unlock);
+ mbedtls_platform_mutex_lock, mbedtls_platform_mutex_unlock );
/*
* Initialize the PKCS #11 module and token.
*/
- xResult = xInitializePkcs11Token();
- configASSERT(xResult == CKR_OK);
+ xResult = xInitializePkcs11Token();
+ configASSERT( xResult == CKR_OK );
/* Call for a random number. The first time this is called, it will
* create a PKCS #11 session which is shared by all callers to
* xGetRandomNumber. Make this call now since randomness session
* initialization isn't threadsafe. */
- xRandom = uxRand();
+ xRandom = uxRand();
configPRINTF(
- ("Successfully Generated Random numbers: %08X %08X %08X %08X\n",
- ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(),
- ipconfigRAND32()));
+ ( "Successfully Generated Random numbers: %08X %08X %08X %08X\n",
+ ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(),
+ ipconfigRAND32() ) );
}
/*-----------------------------------------------------------*/
-#if (ipconfigUSE_LLMNR != 0) || (ipconfigUSE_NBNS != 0) \
- || (ipconfigDHCP_REGISTER_HOSTNAME == 1)
+#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) \
+ || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
-const char* pcApplicationHostnameHook(void)
-{
- /* Assign the name "FreeRTOS" to this network node. This function will
- * be called during the DHCP: the machine will be registered with an IP
- * address plus this name. */
- return mainHOST_NAME;
-}
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* Assign the name "FreeRTOS" to this network node. This function will
+ * be called during the DHCP: the machine will be registered with an IP
+ * address plus this name. */
+ return mainHOST_NAME;
+ }
#endif
/*-----------------------------------------------------------*/
-#if (ipconfigUSE_LLMNR != 0) || (ipconfigUSE_NBNS != 0)
+#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
-BaseType_t xApplicationDNSQueryHook(const char* pcName)
-{
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- * to this node: that returned by pcApplicationHostnameHook() and that set
- * by mainDEVICE_NICK_NAME. */
- if (_stricmp(pcName, pcApplicationHostnameHook()) == 0) {
- xReturn = pdPASS;
- } else if (_stricmp(pcName, mainDEVICE_NICK_NAME) == 0) {
- xReturn = pdPASS;
- } else {
- xReturn = pdFAIL;
- }
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
+ {
+ BaseType_t xReturn;
+
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
- return xReturn;
-}
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*-----------------------------------------------------------*/
@@ -312,14 +337,15 @@ BaseType_t xApplicationDNSQueryHook(const char* pcName)
* Callback that provides the inputs necessary to generate a randomized TCP
* Initial Sequence Number per RFC 6528.
*/
-extern uint32_t ulApplicationGetNextSequenceNumber(
- uint32_t ulSourceAddress, uint16_t usSourcePort,
- uint32_t ulDestinationAddress, uint16_t usDestinationPort)
+extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- (void)ulSourceAddress;
- (void)usSourcePort;
- (void)ulDestinationAddress;
- (void)usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
return uxRand();
}
@@ -328,9 +354,9 @@ extern uint32_t ulApplicationGetNextSequenceNumber(
/*
* Set *pulNumber to a random number, and return pdTRUE. When the random number
* generator is broken, it shall return pdFALSE.
- * The macros ipconfigRAND32() and configRAND32() are not in use
+ * The macros ipconfigRAND32() and configRAND32() are not in use
* anymore in FreeRTOS+TCP.
- *
+ *
* THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS
* NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.
*/
@@ -342,21 +368,21 @@ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
-implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
-used by the Idle task. */
-void vApplicationGetIdleTaskMemory(
- StaticTask_t** ppxIdleTaskTCBBuffer, StackType_t** ppxIdleTaskStackBuffer,
- uint32_t* pulIdleTaskStackSize)
+ * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
+ * used by the Idle task. */
+void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
+ StackType_t ** ppxIdleTaskStackBuffer,
+ uint32_t * pulIdleTaskStackSize )
{
/* If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be
* allocated on the stack and so not exists after this function exits. */
static StaticTask_t xIdleTaskTCB;
- static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE];
+ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
/* Pass out a pointer to the StaticTask_t structure in which the Idle task's
* state will be stored. */
- *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
/* Pass out the array that will be used as the Idle task's stack. */
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
@@ -364,26 +390,26 @@ void vApplicationGetIdleTaskMemory(
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
* Note that, as the array is necessarily of type StackType_t,
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
-application must provide an implementation of vApplicationGetTimerTaskMemory()
-to provide the memory that is used by the Timer service task. */
-void vApplicationGetTimerTaskMemory(
- StaticTask_t** ppxTimerTaskTCBBuffer, StackType_t** ppxTimerTaskStackBuffer,
- uint32_t* pulTimerTaskStackSize)
+ * application must provide an implementation of vApplicationGetTimerTaskMemory()
+ * to provide the memory that is used by the Timer service task. */
+void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
+ StackType_t ** ppxTimerTaskStackBuffer,
+ uint32_t * pulTimerTaskStackSize )
{
/* If the buffers to be provided to the Timer task are declared inside this
* function then they must be declared static - otherwise they will be
* allocated on the stack and so not exists after this function exits. */
static StaticTask_t xTimerTaskTCB;
- static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
+ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
/* Pass out a pointer to the StaticTask_t structure in which the Timer
* task's state will be stored. */
- *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
/* Pass out the array that will be used as the Timer task's stack. */
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
@@ -391,6 +417,6 @@ void vApplicationGetTimerTaskMemory(
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
* Note that, as the array is necessarily of type StackType_t,
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c
index 84b87b2a4..f9bc5b5b1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c
@@ -1,21 +1,21 @@
/*
- Copyright 2001, 2002 Georges Menie (www.menie.org)
- stdarg version contributed by Christian Ettinger
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Changes for the FreeRTOS ports:
-
- - The dot in "%-8.8s"
- - The specifiers 'l' (long) and 'L' (long long)
- - The specifier 'u' for unsigned
- - Dot notation for IP addresses:
- sprintf("IP = %xip\n", 0xC0A80164);
- will produce "IP = 192.168.1.100\n"
-*/
+ * Copyright 2001, 2002 Georges Menie (www.menie.org)
+ * stdarg version contributed by Christian Ettinger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Changes for the FreeRTOS ports:
+ *
+ * - The dot in "%-8.8s"
+ * - The specifiers 'l' (long) and 'L' (long long)
+ * - The specifier 'u' for unsigned
+ * - Dot notation for IP addresses:
+ * sprintf("IP = %xip\n", 0xC0A80164);
+ * will produce "IP = 192.168.1.100\n"
+ */
#include <stdarg.h>
#include <stdio.h>
@@ -24,8 +24,8 @@
#include "FreeRTOS.h"
-#define PAD_RIGHT 1
-#define PAD_ZERO 2
+#define PAD_RIGHT 1
+#define PAD_ZERO 2
/*
* Return 1 for readable, 2 for writeable, 3 for both.
@@ -33,635 +33,721 @@
*/
extern BaseType_t xApplicationMemoryPermissions( uint32_t aAddress );
-extern void vOutputChar( const char cChar, const TickType_t xTicksToWait );
+extern void vOutputChar( const char cChar,
+ const TickType_t xTicksToWait );
static const TickType_t xTicksToWait = pdMS_TO_TICKS( 20 );
struct xPrintFlags
{
- int base;
- int width;
- int printLimit;
- unsigned
- pad : 8,
- letBase : 8,
- isSigned : 1,
- isNumber : 1,
- long32 : 1,
- long64 : 1;
+ int base;
+ int width;
+ int printLimit;
+ unsigned
+ pad : 8,
+ letBase : 8,
+ isSigned : 1,
+ isNumber : 1,
+ long32 : 1,
+ long64 : 1;
};
struct SStringBuf
{
- char *str;
- const char *orgStr;
- const char *nulPos;
- int curLen;
- struct xPrintFlags flags;
+ char * str;
+ const char * orgStr;
+ const char * nulPos;
+ int curLen;
+ struct xPrintFlags flags;
};
-static void strbuf_init( struct SStringBuf *apStr, char *apBuf, const char *apMaxStr )
+static void strbuf_init( struct SStringBuf * apStr,
+ char * apBuf,
+ const char * apMaxStr )
{
- apStr->str = apBuf;
- apStr->orgStr = apBuf;
- apStr->nulPos = apMaxStr-1;
- apStr->curLen = 0;
+ apStr->str = apBuf;
+ apStr->orgStr = apBuf;
+ apStr->nulPos = apMaxStr - 1;
+ apStr->curLen = 0;
- memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
+ memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
}
/*-----------------------------------------------------------*/
-static BaseType_t strbuf_printchar( struct SStringBuf *apStr, int c )
+static BaseType_t strbuf_printchar( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *( apStr->str++ ) = c;
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
-static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf *apStr, int c )
+static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *(apStr->str++) = c;
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
static portINLINE int i2hex( int aCh )
{
-int iResult;
-
- if( aCh < 10 )
- {
- iResult = '0' + aCh;
- }
- else
- {
- iResult = 'A' + aCh - 10;
- }
-
- return iResult;
+ int iResult;
+
+ if( aCh < 10 )
+ {
+ iResult = '0' + aCh;
+ }
+ else
+ {
+ iResult = 'A' + aCh - 10;
+ }
+
+ return iResult;
}
/*-----------------------------------------------------------*/
-static BaseType_t prints(struct SStringBuf *apBuf, const char *apString )
+static BaseType_t prints( struct SStringBuf * apBuf,
+ const char * apString )
{
- register int padchar = ' ';
- int i,len;
-
- if( xApplicationMemoryPermissions( ( uint32_t )apString ) == 0 )
- {
- /* The user has probably made a mistake with the parameter
- for '%s', the memory is not readbale. */
- apString = "INV_MEM";
- }
-
- if( apBuf->flags.width > 0 )
- {
- register int len = 0;
- register const char *ptr;
- for( ptr = apString; *ptr; ++ptr )
- {
- ++len;
- }
-
- if( len >= apBuf->flags.width )
- {
- apBuf->flags.width = 0;
- }
- else
- {
- apBuf->flags.width -= len;
- }
-
- if( apBuf->flags.pad & PAD_ZERO )
- {
- padchar = '0';
- }
- }
- if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
- {
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( strbuf_printchar( apBuf, padchar ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
- {
- /* The string to print represents an integer number.
- * In this case, printLimit is the min number of digits to print
- * If the length of the number to print is less than the min nb of i
- * digits to display, we add 0 before printing the number
- */
- len = strlen( apString );
-
- if( len < apBuf->flags.printLimit )
- {
- i = apBuf->flags.printLimit - len;
- for( ; i; i-- )
- {
- if( strbuf_printchar( apBuf, '0' ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- }
- /* The string to print is not the result of a number conversion to ascii.
- * For a string, printLimit is the max number of characters to display
- */
- for( ; apBuf->flags.printLimit && *apString ; ++apString, --apBuf->flags.printLimit )
- {
- if( !strbuf_printchar( apBuf, *apString ) )
- {
- return pdFALSE;
- }
- }
-
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( !strbuf_printchar( apBuf, padchar ) )
- {
- return pdFALSE;
- }
- }
-
- return pdTRUE;
+ register int padchar = ' ';
+ int i, len;
+
+ if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 )
+ {
+ /* The user has probably made a mistake with the parameter
+ * for '%s', the memory is not readbale. */
+ apString = "INV_MEM";
+ }
+
+ if( apBuf->flags.width > 0 )
+ {
+ register int len = 0;
+ register const char * ptr;
+
+ for( ptr = apString; *ptr; ++ptr )
+ {
+ ++len;
+ }
+
+ if( len >= apBuf->flags.width )
+ {
+ apBuf->flags.width = 0;
+ }
+ else
+ {
+ apBuf->flags.width -= len;
+ }
+
+ if( apBuf->flags.pad & PAD_ZERO )
+ {
+ padchar = '0';
+ }
+ }
+
+ if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
+ {
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( strbuf_printchar( apBuf, padchar ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+
+ if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
+ {
+ /* The string to print represents an integer number.
+ * In this case, printLimit is the min number of digits to print
+ * If the length of the number to print is less than the min nb of i
+ * digits to display, we add 0 before printing the number
+ */
+ len = strlen( apString );
+
+ if( len < apBuf->flags.printLimit )
+ {
+ i = apBuf->flags.printLimit - len;
+
+ for( ; i; i-- )
+ {
+ if( strbuf_printchar( apBuf, '0' ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+ }
+
+ /* The string to print is not the result of a number conversion to ascii.
+ * For a string, printLimit is the max number of characters to display
+ */
+ for( ; apBuf->flags.printLimit && *apString; ++apString, --apBuf->flags.printLimit )
+ {
+ if( !strbuf_printchar( apBuf, *apString ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( !strbuf_printchar( apBuf, padchar ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* the following should be enough for 32 bit int */
-#define PRINT_BUF_LEN 12 /* to print 4294967296 */
-
-#if SPRINTF_LONG_LONG
-#warning 64-bit libraries will be included as well
-static BaseType_t printll( struct SStringBuf *apBuf, long long i )
-{
- char print_buf[ 2 * PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned long long u = i;
- lldiv_t lldiv_result;
+#define PRINT_BUF_LEN 12 /* to print 4294967296 */
+
+#if SPRINTF_LONG_LONG
+ #warning 64-bit libraries will be included as well
+ static BaseType_t printll( struct SStringBuf * apBuf,
+ long long i )
+ {
+ char print_buf[ 2 * PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned long long u = i;
+ lldiv_t lldiv_result;
/* typedef struct
* {
- * long long int quot; // quotient
- * long long int rem; // remainder
+ * long long int quot; // quotient
+ * long long int rem; // remainder
* } lldiv_t;
*/
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- if( i == 0LL )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- /* 18446744073709551616 */
- while( u != 0 )
- {
- lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
- t = lldiv_result.rem;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u = lldiv_result.quot;
- }
-
- if( neg != 0 )
- {
- if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
- {
- if( !strbuf_printchar( apBuf, '-' ) )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
-}
-#endif /* SPRINTF_LONG_LONG */
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0LL )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ /* 18446744073709551616 */
+ while( u != 0 )
+ {
+ lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
+ t = lldiv_result.rem;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u = lldiv_result.quot;
+ }
+
+ if( neg != 0 )
+ {
+ if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( !strbuf_printchar( apBuf, '-' ) )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
+ }
+#endif /* SPRINTF_LONG_LONG */
/*-----------------------------------------------------------*/
-static BaseType_t printi( struct SStringBuf *apBuf, int i )
+static BaseType_t printi( struct SStringBuf * apBuf,
+ int i )
{
- char print_buf[ PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned int u = i;
- register unsigned base = apBuf->flags.base;
-
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
-
- if( i == 0 )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- switch( base )
- {
- case 16:
- while( u != 0 )
- {
- t = u & 0xF;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u >>= 4;
- }
- break;
-
- case 8:
- case 10:
- /* GCC compiles very efficient */
- while( u )
- {
- t = u % base;
- *( --s ) = t + '0';
- u /= base;
- }
- break;
+ char print_buf[ PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned int u = i;
+ register unsigned base = apBuf->flags.base;
+
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0 )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ switch( base )
+ {
+ case 16:
+
+ while( u != 0 )
+ {
+ t = u & 0xF;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u >>= 4;
+ }
+
+ break;
+
+ case 8:
+ case 10:
+
+ /* GCC compiles very efficient */
+ while( u )
+ {
+ t = u % base;
+ *( --s ) = t + '0';
+ u /= base;
+ }
+
+ break;
+
/*
- // The generic case, not yet in use
- default:
- while( u )
- {
- t = u % base;
- if( t >= 10)
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u /= base;
- }
- break;
-*/
- }
-
- if( neg != 0 )
- {
- if( apBuf->flags.width && (apBuf->flags.pad & PAD_ZERO ) )
- {
- if( strbuf_printchar( apBuf, '-' ) == 0 )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
+ * // The generic case, not yet in use
+ * default:
+ * while( u )
+ * {
+ * t = u % base;
+ * if( t >= 10)
+ * {
+ * t += apBuf->flags.letBase - '0' - 10;
+ * }
+ *( --s ) = t + '0';
+ * u /= base;
+ * }
+ * break;
+ */
+ }
+
+ if( neg != 0 )
+ {
+ if( apBuf->flags.width && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( strbuf_printchar( apBuf, '-' ) == 0 )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
}
/*-----------------------------------------------------------*/
-static BaseType_t printIp(struct SStringBuf *apBuf, unsigned i )
+static BaseType_t printIp( struct SStringBuf * apBuf,
+ unsigned i )
{
- char print_buf[16];
+ char print_buf[ 16 ];
- sprintf( print_buf, "%u.%u.%u.%u",
- i >> 24,
- ( i >> 16 ) & 0xff,
- ( i >> 8 ) & 0xff,
- i & 0xff );
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- prints( apBuf, print_buf );
+ sprintf( print_buf, "%u.%u.%u.%u",
+ i >> 24,
+ ( i >> 16 ) & 0xff,
+ ( i >> 8 ) & 0xff,
+ i & 0xff );
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+ prints( apBuf, print_buf );
- return pdTRUE;
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
-static void tiny_print( struct SStringBuf *apBuf, const char *format, va_list args )
+static void tiny_print( struct SStringBuf * apBuf,
+ const char * format,
+ va_list args )
{
- char scr[2];
-
- for( ; ; )
- {
- int ch = *( format++ );
-
- if( ch != '%' )
- {
- do
- {
- /* Put the most like flow in a small loop */
- if( strbuf_printchar_inline( apBuf, ch ) == 0 )
- {
- return;
- }
- ch = *( format++ );
- } while( ch != '%' );
- }
- ch = *( format++ );
- /* Now ch has character after '%', format pointing to next */
-
- if( ch == '\0' )
- {
- break;
- }
- if( ch == '%' )
- {
- if( strbuf_printchar( apBuf, ch ) == 0 )
- {
- return;
- }
- continue;
- }
- memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
-
- if( ch == '-' )
- {
- ch = *( format++ );
- apBuf->flags.pad = PAD_RIGHT;
- }
- while( ch == '0' )
- {
- ch = *( format++ );
- apBuf->flags.pad |= PAD_ZERO;
- }
- if( ch == '*' )
- {
- ch = *( format++ );
- apBuf->flags.width = va_arg( args, int );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.width *= 10;
- apBuf->flags.width += ch - '0';
- ch = *( format++ );
- }
- }
- if( ch == '.' )
- {
- ch = *( format++ );
- if( ch == '*' )
- {
- apBuf->flags.printLimit = va_arg( args, int );
- ch = *( format++ );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.printLimit *= 10;
- apBuf->flags.printLimit += ch - '0';
- ch = *( format++ );
- }
- }
- }
- if( apBuf->flags.printLimit == 0 )
- {
- apBuf->flags.printLimit--; /* -1: make it unlimited */
- }
- if( ch == 's' )
- {
- register char *s = ( char * )va_arg( args, int );
- if( prints( apBuf, s ? s : "(null)" ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'c' )
- {
- /* char are converted to int then pushed on the stack */
- scr[0] = ( char ) va_arg( args, int );
-
- if( strbuf_printchar( apBuf, scr[0] ) == 0 )
- {
- return;
- }
-
- continue;
- }
- if( ch == 'l' )
- {
- ch = *( format++ );
- apBuf->flags.long32 = 1;
- /* Makes not difference as u32 == long */
- }
- if( ch == 'L' )
- {
- ch = *( format++ );
- apBuf->flags.long64 = 1;
- /* Does make a difference */
- }
- apBuf->flags.base = 10;
- apBuf->flags.letBase = 'a';
-
- if( ch == 'd' || ch == 'u' )
- {
- apBuf->flags.isSigned = ( ch == 'd' );
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
-
- apBuf->flags.base = 16; /* From here all hexadecimal */
-
- if( ch == 'x' && format[0] == 'i' && format[1] == 'p' )
- {
- format += 2; /* eat the "xi" of "xip" */
- /* Will use base 10 again */
- if( printIp( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'x' || ch == 'X' || ch == 'p' || ch == 'o' )
- {
- if( ch == 'X' )
- {
- apBuf->flags.letBase = 'A';
- }
- else if( ch == 'o' )
- {
- apBuf->flags.base = 8;
- }
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- }
- strbuf_printchar( apBuf, '\0' );
+ char scr[ 2 ];
+
+ for( ; ; )
+ {
+ int ch = *( format++ );
+
+ if( ch != '%' )
+ {
+ do
+ {
+ /* Put the most like flow in a small loop */
+ if( strbuf_printchar_inline( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ ch = *( format++ );
+ } while( ch != '%' );
+ }
+
+ ch = *( format++ );
+ /* Now ch has character after '%', format pointing to next */
+
+ if( ch == '\0' )
+ {
+ break;
+ }
+
+ if( ch == '%' )
+ {
+ if( strbuf_printchar( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
+
+ if( ch == '-' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad = PAD_RIGHT;
+ }
+
+ while( ch == '0' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad |= PAD_ZERO;
+ }
+
+ if( ch == '*' )
+ {
+ ch = *( format++ );
+ apBuf->flags.width = va_arg( args, int );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.width *= 10;
+ apBuf->flags.width += ch - '0';
+ ch = *( format++ );
+ }
+ }
+
+ if( ch == '.' )
+ {
+ ch = *( format++ );
+
+ if( ch == '*' )
+ {
+ apBuf->flags.printLimit = va_arg( args, int );
+ ch = *( format++ );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.printLimit *= 10;
+ apBuf->flags.printLimit += ch - '0';
+ ch = *( format++ );
+ }
+ }
+ }
+
+ if( apBuf->flags.printLimit == 0 )
+ {
+ apBuf->flags.printLimit--; /* -1: make it unlimited */
+ }
+
+ if( ch == 's' )
+ {
+ register char * s = ( char * ) va_arg( args, int );
+
+ if( prints( apBuf, s ? s : "(null)" ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ch == 'c' )
+ {
+ /* char are converted to int then pushed on the stack */
+ scr[ 0 ] = ( char ) va_arg( args, int );
+
+ if( strbuf_printchar( apBuf, scr[ 0 ] ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ if( ch == 'l' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long32 = 1;
+ /* Makes not difference as u32 == long */
+ }
+
+ if( ch == 'L' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long64 = 1;
+ /* Does make a difference */
+ }
+
+ apBuf->flags.base = 10;
+ apBuf->flags.letBase = 'a';
+
+ if( ( ch == 'd' ) || ( ch == 'u' ) )
+ {
+ apBuf->flags.isSigned = ( ch == 'd' );
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ apBuf->flags.base = 16; /* From here all hexadecimal */
+
+ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) )
+ {
+ format += 2; /* eat the "xi" of "xip" */
+
+ /* Will use base 10 again */
+ if( printIp( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ( ch == 'x' ) || ( ch == 'X' ) || ( ch == 'p' ) || ( ch == 'o' ) )
+ {
+ if( ch == 'X' )
+ {
+ apBuf->flags.letBase = 'A';
+ }
+ else if( ch == 'o' )
+ {
+ apBuf->flags.base = 8;
+ }
+
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+ }
+
+ strbuf_printchar( apBuf, '\0' );
}
/*-----------------------------------------------------------*/
-int vsnprintf( char *apBuf, size_t aMaxLen, const char *apFmt, va_list args )
+int vsnprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int snprintf( char *apBuf, size_t aMaxLen, const char *apFmt, ... )
+int snprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int sprintf( char *apBuf, const char *apFmt, ... )
+int sprintf( char * apBuf,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char * )apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int vsprintf( char *apBuf, const char *apFmt, va_list args )
+int vsprintf( char * apBuf,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* ) apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-const char *mkSize (unsigned long long aSize, char *apBuf, int aLen)
+const char * mkSize( unsigned long long aSize,
+ char * apBuf,
+ int aLen )
{
-static char retString[33];
-size_t gb, mb, kb, sb;
-
- if (apBuf == NULL) {
- apBuf = retString;
- aLen = sizeof( retString );
- }
- gb = aSize / (1024*1024*1024);
- aSize -= gb * (1024*1024*1024);
- mb = aSize / (1024*1024);
- aSize -= mb * (1024*1024);
- kb = aSize / (1024);
- aSize -= kb * (1024);
- sb = aSize;
- if( gb )
- {
- snprintf (apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
- }
- else if( mb )
- {
- snprintf (apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb) / 1024ul ) );
- }
- else if( kb != 0ul )
- {
- snprintf (apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb) / 1024ul ) );
- }
- else
- {
- snprintf (apBuf, aLen, "%u bytes", ( unsigned ) sb);
- }
- return apBuf;
+ static char retString[ 33 ];
+ size_t gb, mb, kb, sb;
+
+ if( apBuf == NULL )
+ {
+ apBuf = retString;
+ aLen = sizeof( retString );
+ }
+
+ gb = aSize / ( 1024 * 1024 * 1024 );
+ aSize -= gb * ( 1024 * 1024 * 1024 );
+ mb = aSize / ( 1024 * 1024 );
+ aSize -= mb * ( 1024 * 1024 );
+ kb = aSize / ( 1024 );
+ aSize -= kb * ( 1024 );
+ sb = aSize;
+
+ if( gb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
+ }
+ else if( mb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb ) / 1024ul ) );
+ }
+ else if( kb != 0ul )
+ {
+ snprintf( apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb ) / 1024ul ) );
+ }
+ else
+ {
+ snprintf( apBuf, aLen, "%u bytes", ( unsigned ) sb );
+ }
+
+ return apBuf;
}
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c
index 84a9a8cd1..4093cca64 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c
@@ -115,51 +115,51 @@
* To enable the keep alive feature, set this value
* to the desired interval in seconds.
*/
-#define shadowexampleKEEP_ALIVE_SECONDS ( 0 )
+#define shadowexampleKEEP_ALIVE_SECONDS ( 0 )
/**
* @brief The timeout for MQTT operations in this example.
*/
-#define shadowexampleMQTT_TIMEOUT_MS ( 5000 )
+#define shadowexampleMQTT_TIMEOUT_MS ( 5000 )
/**
* @brief Update count of shadow in a loop in the demo.
*
*/
-#define shadowexampleUPDATE_COUNT ( 5 )
+#define shadowexampleUPDATE_COUNT ( 5 )
/**
* @brief The task wait period between each Shadow update.
*
*/
-#define shadowexampleUPDATE_PERIOD_MS ( 3000 )
+#define shadowexampleUPDATE_PERIOD_MS ( 3000 )
/**
* @brief The task wait period between each demo loop.
*/
-#define shadowexampleLOOP_WAIT_PERIOD_MS ( 5000 )
+#define shadowexampleLOOP_WAIT_PERIOD_MS ( 5000 )
/**
* @brief The timeout period for updates from Shadow Delta Callback before
* attempting next Shadow Update.
*/
-#define shadowexampleWAIT_PERIOD_FOR_DELTA_MS ( 5000 )
+#define shadowexampleWAIT_PERIOD_FOR_DELTA_MS ( 5000 )
/**
* @brief Argument for AwsIotShadow_Init to use the default timeout.
*/
-#define shadowexampleUSE_DEFAULT_MQTT_TIMEOUT ( 0 )
+#define shadowexampleUSE_DEFAULT_MQTT_TIMEOUT ( 0 )
/**
* @brief The bit which is set in the demo task's notification value from the
* disconnect callback to inform the demo task about the MQTT disconnect.
*/
-#define shadowexampleDISCONNECTED_BIT ( 1UL << 0UL )
+#define shadowexampleDISCONNECTED_BIT ( 1UL << 0UL )
/**
* @brief Compile time calculation of shadowexampleCLIENT_IDENTIFIER_LENGTH.
*/
-#define shadowexampleCLIENT_IDENTIFIER_LENGTH sizeof( awsiotdemoprofileCLIENT_IDENTIFIER ) - 1
+#define shadowexampleCLIENT_IDENTIFIER_LENGTH sizeof( awsiotdemoprofileCLIENT_IDENTIFIER ) - 1
/**
* @brief Format string representing a Shadow document with a "desired" state.
@@ -169,14 +169,14 @@
* completed. For this demo, a timestamp is used for a client token.
*/
#define shadowexampleDESIRED_JSON \
- "{" \
- "\"state\":{" \
- "\"desired\":{" \
- "\"powerOn\":%01d" \
- "}" \
- "}," \
- "\"clientToken\":\"%06lu\"" \
- "}"
+ "{" \
+ "\"state\":{" \
+ "\"desired\":{" \
+ "\"powerOn\":%01d" \
+ "}" \
+ "}," \
+ "\"clientToken\":\"%06lu\"" \
+ "}"
/**
* @brief The expected size of #shadowexampleDESIRED_JSON.
@@ -194,14 +194,14 @@
* completed. For this demo, a timestamp is used for a client token.
*/
#define shadowexampleREPORTED_JSON \
- "{" \
- "\"state\":{" \
- "\"reported\":{" \
- "\"powerOn\":%01d" \
- "}" \
- "}," \
- "\"clientToken\":\"%06lu\"" \
- "}"
+ "{" \
+ "\"state\":{" \
+ "\"reported\":{" \
+ "\"powerOn\":%01d" \
+ "}" \
+ "}," \
+ "\"clientToken\":\"%06lu\"" \
+ "}"
/**
* @brief The expected size of #shadowexampleREPORTED_JSON.
@@ -214,13 +214,13 @@
/**
* @brief This is the current state of the shadow used in this demo.
*/
-static int32_t lDevicePowerOnState = 0;
+static int32_t lDevicePowerOnState = 0;
/**
* @brief This is a Semaphore used to synchronize between delta callback and
* Shadow updates.
*/
-iot_sem_internal_t xDeltaSemaphore = { 0 };
+iot_sem_internal_t xDeltaSemaphore = { 0 };
/**
* @brief The task used to demonstrate Shadow.
@@ -241,7 +241,7 @@ static void prvShadowDemoTask( void * pvParameters );
* disconnected.
*/
static void prvExample_OnDisconnect( void * pvCallbackContext,
- IotMqttCallbackParam_t * pxCallbackParams );
+ IotMqttCallbackParam_t * pxCallbackParams );
/**
* @brief The callback invoked by the MQTT library when a message is received on
@@ -253,7 +253,7 @@ static void prvExample_OnDisconnect( void * pvCallbackContext,
* topic on which the message was received, the received message.
*/
static void prvExample_OnMessageReceived( void * pvCallbackContext,
- IotMqttCallbackParam_t * pxCallbackParams );
+ IotMqttCallbackParam_t * pxCallbackParams );
/**
* @brief Connects to the MQTT broker as specified in awsiotdemoprofileAWS_ENDPOINT
@@ -277,7 +277,7 @@ static void prvInitialiseLibraries( void );
/**
* @brief The MQTT connection handle used in this example.
*/
-static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
+static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
/**
* @brief Set the Shadow callback functions used in this demo.
@@ -320,7 +320,7 @@ static void prvSendShadowUpdates( void );
* @param[in] pxCallbackParam The received Shadow delta document.
*/
static void prvShadowDeltaCallback( void * pCallbackContext,
- AwsIotShadowCallbackParam_t * pxCallbackParam );
+ AwsIotShadowCallbackParam_t * pxCallbackParam );
/**
* @brief Shadow updated callback, invoked when the Shadow document changes.
@@ -331,7 +331,7 @@ static void prvShadowDeltaCallback( void * pCallbackContext,
* @param[in] pxCallbackParam The received Shadow updated document.
*/
static void prvShadowUpdatedCallback( void * pCallbackContext,
- AwsIotShadowCallbackParam_t * pxCallbackParam );
+ AwsIotShadowCallbackParam_t * pxCallbackParam );
/**
* @brief Parses a key in the "state" section of a Shadow delta document.
@@ -345,10 +345,10 @@ static void prvShadowUpdatedCallback( void * pCallbackContext,
* @return `true` if the given delta key is found; `false` otherwise.
*/
static BaseType_t prvGetDelta( const char * pcDeltaDocument,
- size_t xDeltaDocumentLength,
- const char * pcDeltaKey,
- const char ** ppcDelta,
- size_t * pxDeltaLength );
+ size_t xDeltaDocumentLength,
+ const char * pcDeltaKey,
+ const char ** ppcDelta,
+ size_t * pxDeltaLength );
/**
* @brief Parses the "state" key from the "previous" or "current" sections of a
@@ -363,666 +363,666 @@ static BaseType_t prvGetDelta( const char * pcDeltaDocument,
* @return pdTRUE if the "state" was found; pdFALSE otherwise.
*/
static BaseType_t prvGetUpdatedState( const char * pcUpdatedDocument,
- size_t xUpdatedDocumentLength,
- const char * pcSectionKey,
- const char ** ppcState,
- size_t * pxStateLength );
+ size_t xUpdatedDocumentLength,
+ const char * pcSectionKey,
+ const char ** ppcState,
+ size_t * pxStateLength );
/*-----------------------------------------------------------*/
-static const struct IotNetworkServerInfo xMQTTBrokerInfo =
+static const struct IotNetworkServerInfo xMQTTBrokerInfo =
{
- .pHostName = awsiotdemoprofileAWS_ENDPOINT,
- .port = awsiotdemoprofileAWS_MQTT_PORT
+ .pHostName = awsiotdemoprofileAWS_ENDPOINT,
+ .port = awsiotdemoprofileAWS_MQTT_PORT
};
-static struct IotNetworkCredentials xNetworkSecurityCredentials =
+static struct IotNetworkCredentials xNetworkSecurityCredentials =
{
- /* Optional TLS extensions. For this demo, they are disabled. */
- .pAlpnProtos = NULL,
- .maxFragmentLength = 0,
-
- /* SNI is enabled by default. */
- .disableSni = false,
-
- /* Provide the certificate for validating the server. Only required for
- * demos using TLS. */
- .pRootCa = awsiotdemoprofileAWS_CERTIFICATE_PEM,
- .rootCaSize = sizeof( awsiotdemoprofileAWS_CERTIFICATE_PEM ),
-
- /* Strong mutual authentication to authenticate both the broker and
- * the client. */
- .pClientCert = awsiotdemoprofileCLIENT_CERTIFICATE_PEM,
- .clientCertSize = sizeof( awsiotdemoprofileCLIENT_CERTIFICATE_PEM ),
- .pPrivateKey = awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM,
- .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM )
+ /* Optional TLS extensions. For this demo, they are disabled. */
+ .pAlpnProtos = NULL,
+ .maxFragmentLength = 0,
+
+ /* SNI is enabled by default. */
+ .disableSni = false,
+
+ /* Provide the certificate for validating the server. Only required for
+ * demos using TLS. */
+ .pRootCa = awsiotdemoprofileAWS_CERTIFICATE_PEM,
+ .rootCaSize = sizeof( awsiotdemoprofileAWS_CERTIFICATE_PEM ),
+
+ /* Strong mutual authentication to authenticate both the broker and
+ * the client. */
+ .pClientCert = awsiotdemoprofileCLIENT_CERTIFICATE_PEM,
+ .clientCertSize = sizeof( awsiotdemoprofileCLIENT_CERTIFICATE_PEM ),
+ .pPrivateKey = awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM,
+ .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM )
};
-static IotMqttNetworkInfo_t xNetworkInfo =
+static IotMqttNetworkInfo_t xNetworkInfo =
{
- /* No connection to the MQTT broker has been established yet and we want to
- * establish a new connection. */
- .createNetworkConnection = true,
- .u.setup.pNetworkServerInfo = &( xMQTTBrokerInfo ),
-
- /* Set the TLS credentials for the new MQTT connection. This member is NULL
- * for the plain text MQTT demo. */
- .u.setup.pNetworkCredentialInfo = &xNetworkSecurityCredentials,
-
- /* Use FreeRTOS+TCP network interface. */
- .pNetworkInterface = IOT_NETWORK_INTERFACE_FREERTOS,
-
- /* Setup the callback which is called when the MQTT connection is
- * disconnected. The task handle is passed as the callback context which
- * is used by the callback to send a task notification to this task.*/
- .disconnectCallback.function = prvExample_OnDisconnect
+ /* No connection to the MQTT broker has been established yet and we want to
+ * establish a new connection. */
+ .createNetworkConnection = true,
+ .u.setup.pNetworkServerInfo = &( xMQTTBrokerInfo ),
+
+ /* Set the TLS credentials for the new MQTT connection. This member is NULL
+ * for the plain text MQTT demo. */
+ .u.setup.pNetworkCredentialInfo = &xNetworkSecurityCredentials,
+
+ /* Use FreeRTOS+TCP network interface. */
+ .pNetworkInterface = IOT_NETWORK_INTERFACE_FREERTOS,
+
+ /* Setup the callback which is called when the MQTT connection is
+ * disconnected. The task handle is passed as the callback context which
+ * is used by the callback to send a task notification to this task.*/
+ .disconnectCallback.function = prvExample_OnDisconnect
};
-static const IotMqttConnectInfo_t xConnectInfo =
+static const IotMqttConnectInfo_t xConnectInfo =
{
- /* Set this flag to true if connecting to the AWS IoT MQTT broker. */
- .awsIotMqttMode = true,
-
- /* Start with a clean session i.e. direct the MQTT broker to discard any
- * previous session data. Also, establishing a connection with clean session
- * will ensure that the broker does not store any data when this client
- * gets disconnected. */
- .cleanSession = true,
-
- /* Since we are starting with a clean session, there are no previous
- * subscriptions to be restored. */
- .pPreviousSubscriptions = NULL,
- .previousSubscriptionCount = 0,
-
- /* We do not want to publish Last Will and Testament (LWT) message if the
- * client gets disconnected. */
- .pWillInfo = NULL,
-
- /* Send an MQTT PING request every minute to keep the connection open if
- * there is no other MQTT traffic. */
- .keepAliveSeconds = shadowexampleKEEP_ALIVE_SECONDS,
-
- /* The client identifier is used to uniquely identify this MQTT client to
- * the MQTT broker. In a production device the identifier can be something
- * unique, such as a device serial number. */
- .pClientIdentifier = awsiotdemoprofileCLIENT_IDENTIFIER,
- .clientIdentifierLength = ( uint16_t ) sizeof( awsiotdemoprofileCLIENT_IDENTIFIER ) - 1,
-
- /* This example does not authenticate the client and therefore username and
- * password fields are not used. */
- .pUserName = NULL,
- .userNameLength = 0,
- .pPassword = NULL,
- .passwordLength = 0
+ /* Set this flag to true if connecting to the AWS IoT MQTT broker. */
+ .awsIotMqttMode = true,
+
+ /* Start with a clean session i.e. direct the MQTT broker to discard any
+ * previous session data. Also, establishing a connection with clean session
+ * will ensure that the broker does not store any data when this client
+ * gets disconnected. */
+ .cleanSession = true,
+
+ /* Since we are starting with a clean session, there are no previous
+ * subscriptions to be restored. */
+ .pPreviousSubscriptions = NULL,
+ .previousSubscriptionCount = 0,
+
+ /* We do not want to publish Last Will and Testament (LWT) message if the
+ * client gets disconnected. */
+ .pWillInfo = NULL,
+
+ /* Send an MQTT PING request every minute to keep the connection open if
+ * there is no other MQTT traffic. */
+ .keepAliveSeconds = shadowexampleKEEP_ALIVE_SECONDS,
+
+ /* The client identifier is used to uniquely identify this MQTT client to
+ * the MQTT broker. In a production device the identifier can be something
+ * unique, such as a device serial number. */
+ .pClientIdentifier = awsiotdemoprofileCLIENT_IDENTIFIER,
+ .clientIdentifierLength = ( uint16_t ) sizeof( awsiotdemoprofileCLIENT_IDENTIFIER ) - 1,
+
+ /* This example does not authenticate the client and therefore username and
+ * password fields are not used. */
+ .pUserName = NULL,
+ .userNameLength = 0,
+ .pPassword = NULL,
+ .passwordLength = 0
};
/*-----------------------------------------------------------*/
void vStartShadowDeviceOperationsDemo( void )
{
-TickType_t xShortDelay = ( TickType_t ) pdMS_TO_TICKS( ( TickType_t ) 500 );
-
- /* Wait a short time to allow receipt of the ARP replies. */
- vTaskDelay( xShortDelay );
-
- /* This example uses a single application task, which in turn is used to
- * connect, subscribe, publish, unsubscribe and disconnect from the MQTT
- * broker. */
- xTaskCreate( prvShadowDemoTask, /* Function that implements the task. */
- "ShadowDemo", /* Text name for the task - only used for debugging. */
- democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
- NULL, /* Task parameter - not used in this case. */
- tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */
- NULL ); /* Used to pass out a handle to the created task - not used in this case. */
+ TickType_t xShortDelay = ( TickType_t ) pdMS_TO_TICKS( ( TickType_t ) 500 );
+
+ /* Wait a short time to allow receipt of the ARP replies. */
+ vTaskDelay( xShortDelay );
+
+ /* This example uses a single application task, which in turn is used to
+ * connect, subscribe, publish, unsubscribe and disconnect from the MQTT
+ * broker. */
+ xTaskCreate( prvShadowDemoTask, /* Function that implements the task. */
+ "ShadowDemo", /* Text name for the task - only used for debugging. */
+ democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
+ NULL, /* Task parameter - not used in this case. */
+ tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */
+ NULL ); /* Used to pass out a handle to the created task - not used in this case. */
}
/*-----------------------------------------------------------*/
static void prvShadowDemoTask( void * pvParameters )
{
-uint32_t ulNotificationValue = 0;
-const TickType_t xNoDelay = ( TickType_t ) 0;
-
- /* Remove compiler warnings about unused parameters. */
- ( void ) pvParameters;
-
- /* One time initialization of the libraries used by this demo. */
- prvInitialiseLibraries();
-
- for( ; ; )
- {
- /* Don't expect any notifications to be pending yet. */
- configASSERT( ulTaskNotifyTake( pdTRUE, xNoDelay ) == 0 );
-
- /****************************** Connect. ******************************/
-
- /* Establish a connection to the AWS IoT MQTT broker. This example connects to
- * the MQTT broker as specified in awsiotdemoprofileAWS_ENDPOINT and
- * awsiotdemoprofileAWS_MQTT_PORT at the top of this file.
- */
- configPRINTF( ( "Attempt to connect to %s\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
- prvMQTTConnect();
- configPRINTF( ( "Connected to %s\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
-
- /************************ Create a semaphore **************************/
-
- /* Creates a semaphore to synchronize between delta callback and
- * Shadow updates.
- */
- configPRINTF( ( "Creating delta semaphore\r\n" ) );
- configASSERT( xSemaphoreCreateCountingStatic( 1, 0, &xDeltaSemaphore.xSemaphore ) != NULL );
-
- /************************ Set shadow callbacks ************************/
-
- /* Sets the updated callback and delta callback */
- configPRINTF( ( "Setting the updated callback and delta callback\r\n" ) );
- prvSetShadowCallbacks();
-
- /************************ Clear shadow document ***********************/
-
- /* Clears the Shadow document if it exists already */
- configPRINTF( ( "Clearing the Shadow document if it already exits\r\n" ) );
- prvClearShadowDocument();
-
- /*********************** Send Shadow updates **************************/
-
- /* Send Shadow updates for shadowexampleUPDATE_COUNT times.
- * For each Shadow update, it waits on xDeltaSemaphore. xDeltaSemaphore
- * will be posted by the delta callback.
- */
- configPRINTF( ( "Sending Shadow updates\r\n" ) );
- prvSendShadowUpdates();
-
- /************************ Clear shadow document ***********************/
-
- /* Clears the Shadow document at the end of the demo */
- configPRINTF( ( "Clearing the Shadow document\r\n" ) );
- prvClearShadowDocument();
-
- /************** Clear callbacks and Disconnect MQTT. ******************/
-
- /* Clear updated callback and delta callback */
- configPRINTF( ( "Clearing the Shadow updated callback and delta callback\r\n" ) );
- prvClearShadowCallbacks();
-
- /* Disconnect MQTT gracefully. */
- prvMQTTDisconnect();
- configPRINTF( ( "Disconnected from %s\r\n\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
-
- /* Wait for the disconnect operation to complete which is informed to us
- * by the disconnect callback (prvExample_OnDisconnect)by setting
- * the shadowexampleDISCONNECTED_BIT in this task's notification value.
- * Note that the bit is cleared in the task's notification value to
- * ensure that it is ready for the next run. */
- xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
- shadowexampleDISCONNECTED_BIT, /* Clear bit on exit. */
- &( ulNotificationValue ), /* Obtain the notification value. */
- pdMS_TO_TICKS( shadowexampleMQTT_TIMEOUT_MS ) );
- configASSERT( ( ulNotificationValue & shadowexampleDISCONNECTED_BIT ) == shadowexampleDISCONNECTED_BIT );
-
- /* Destroy the delta semaphore*/
- vSemaphoreDelete( ( SemaphoreHandle_t ) &xDeltaSemaphore.xSemaphore );
-
- /* Clear the current reported shadow state to toggle the reported state. */
- lDevicePowerOnState = 0;
-
- /* Wait for some time between two iterations to ensure that we do not
- * bombard the broker. */
- configPRINTF( ( "prvShadowDemoTask() completed an iteration successfully. Total free heap is %u\r\n", xPortGetFreeHeapSize() ) );
- configPRINTF( ( "Demo completed successfully.\r\n" ) );
- configPRINTF( ( "Short delay before starting the next iteration... \r\n\r\n" ) );
- vTaskDelay( pdMS_TO_TICKS( shadowexampleLOOP_WAIT_PERIOD_MS ) );
- }
+ uint32_t ulNotificationValue = 0;
+ const TickType_t xNoDelay = ( TickType_t ) 0;
+
+ /* Remove compiler warnings about unused parameters. */
+ ( void ) pvParameters;
+
+ /* One time initialization of the libraries used by this demo. */
+ prvInitialiseLibraries();
+
+ for( ; ; )
+ {
+ /* Don't expect any notifications to be pending yet. */
+ configASSERT( ulTaskNotifyTake( pdTRUE, xNoDelay ) == 0 );
+
+ /****************************** Connect. ******************************/
+
+ /* Establish a connection to the AWS IoT MQTT broker. This example connects to
+ * the MQTT broker as specified in awsiotdemoprofileAWS_ENDPOINT and
+ * awsiotdemoprofileAWS_MQTT_PORT at the top of this file.
+ */
+ configPRINTF( ( "Attempt to connect to %s\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
+ prvMQTTConnect();
+ configPRINTF( ( "Connected to %s\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
+
+ /************************ Create a semaphore **************************/
+
+ /* Creates a semaphore to synchronize between delta callback and
+ * Shadow updates.
+ */
+ configPRINTF( ( "Creating delta semaphore\r\n" ) );
+ configASSERT( xSemaphoreCreateCountingStatic( 1, 0, &xDeltaSemaphore.xSemaphore ) != NULL );
+
+ /************************ Set shadow callbacks ************************/
+
+ /* Sets the updated callback and delta callback */
+ configPRINTF( ( "Setting the updated callback and delta callback\r\n" ) );
+ prvSetShadowCallbacks();
+
+ /************************ Clear shadow document ***********************/
+
+ /* Clears the Shadow document if it exists already */
+ configPRINTF( ( "Clearing the Shadow document if it already exits\r\n" ) );
+ prvClearShadowDocument();
+
+ /*********************** Send Shadow updates **************************/
+
+ /* Send Shadow updates for shadowexampleUPDATE_COUNT times.
+ * For each Shadow update, it waits on xDeltaSemaphore. xDeltaSemaphore
+ * will be posted by the delta callback.
+ */
+ configPRINTF( ( "Sending Shadow updates\r\n" ) );
+ prvSendShadowUpdates();
+
+ /************************ Clear shadow document ***********************/
+
+ /* Clears the Shadow document at the end of the demo */
+ configPRINTF( ( "Clearing the Shadow document\r\n" ) );
+ prvClearShadowDocument();
+
+ /************** Clear callbacks and Disconnect MQTT. ******************/
+
+ /* Clear updated callback and delta callback */
+ configPRINTF( ( "Clearing the Shadow updated callback and delta callback\r\n" ) );
+ prvClearShadowCallbacks();
+
+ /* Disconnect MQTT gracefully. */
+ prvMQTTDisconnect();
+ configPRINTF( ( "Disconnected from %s\r\n\r\n", awsiotdemoprofileAWS_ENDPOINT ) );
+
+ /* Wait for the disconnect operation to complete which is informed to us
+ * by the disconnect callback (prvExample_OnDisconnect)by setting
+ * the shadowexampleDISCONNECTED_BIT in this task's notification value.
+ * Note that the bit is cleared in the task's notification value to
+ * ensure that it is ready for the next run. */
+ xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
+ shadowexampleDISCONNECTED_BIT, /* Clear bit on exit. */
+ &( ulNotificationValue ), /* Obtain the notification value. */
+ pdMS_TO_TICKS( shadowexampleMQTT_TIMEOUT_MS ) );
+ configASSERT( ( ulNotificationValue & shadowexampleDISCONNECTED_BIT ) == shadowexampleDISCONNECTED_BIT );
+
+ /* Destroy the delta semaphore*/
+ vSemaphoreDelete( ( SemaphoreHandle_t ) &xDeltaSemaphore.xSemaphore );
+
+ /* Clear the current reported shadow state to toggle the reported state. */
+ lDevicePowerOnState = 0;
+
+ /* Wait for some time between two iterations to ensure that we do not
+ * bombard the broker. */
+ configPRINTF( ( "prvShadowDemoTask() completed an iteration successfully. Total free heap is %u\r\n", xPortGetFreeHeapSize() ) );
+ configPRINTF( ( "Demo completed successfully.\r\n" ) );
+ configPRINTF( ( "Short delay before starting the next iteration... \r\n\r\n" ) );
+ vTaskDelay( pdMS_TO_TICKS( shadowexampleLOOP_WAIT_PERIOD_MS ) );
+ }
}
/*-----------------------------------------------------------*/
static void prvExample_OnDisconnect( void * pvCallbackContext,
- IotMqttCallbackParam_t * pxCallbackParams )
+ IotMqttCallbackParam_t * pxCallbackParams )
{
-TaskHandle_t xDemoTaskHandle = ( TaskHandle_t ) pvCallbackContext;
+ TaskHandle_t xDemoTaskHandle = ( TaskHandle_t ) pvCallbackContext;
- /* Ensure that we initiated the disconnect. */
- configASSERT( pxCallbackParams->u.disconnectReason == IOT_MQTT_DISCONNECT_CALLED );
+ /* Ensure that we initiated the disconnect. */
+ configASSERT( pxCallbackParams->u.disconnectReason == IOT_MQTT_DISCONNECT_CALLED );
- /* Inform the demo task about the disconnect. */
- xTaskNotify( xDemoTaskHandle,
- shadowexampleDISCONNECTED_BIT,
- eSetBits /* Set the shadowexampleDISCONNECTED_BIT in the demo task's notification value. */
- );
+ /* Inform the demo task about the disconnect. */
+ xTaskNotify( xDemoTaskHandle,
+ shadowexampleDISCONNECTED_BIT,
+ eSetBits /* Set the shadowexampleDISCONNECTED_BIT in the demo task's notification value. */
+ );
}
/*-----------------------------------------------------------*/
static void prvMQTTConnect( void )
{
-IotMqttError_t xResult;
-
- /* Set the context to pass into the disconnect callback function. */
- xNetworkInfo.disconnectCallback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();
-
- /* Establish the connection to the MQTT broker - It is a blocking call and
- * will return only when connection is complete or a timeout occurs. */
- xResult = IotMqtt_Connect( &( xNetworkInfo ),
- &( xConnectInfo ),
- shadowexampleMQTT_TIMEOUT_MS,
- &( xMQTTConnection ) );
- configASSERT( xResult == IOT_MQTT_SUCCESS );
+ IotMqttError_t xResult;
+
+ /* Set the context to pass into the disconnect callback function. */
+ xNetworkInfo.disconnectCallback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();
+
+ /* Establish the connection to the MQTT broker - It is a blocking call and
+ * will return only when connection is complete or a timeout occurs. */
+ xResult = IotMqtt_Connect( &( xNetworkInfo ),
+ &( xConnectInfo ),
+ shadowexampleMQTT_TIMEOUT_MS,
+ &( xMQTTConnection ) );
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvMQTTDisconnect( void )
{
- /* Send a MQTT DISCONNECT packet to the MQTT broker to do a graceful
- * disconnect. */
- IotMqtt_Disconnect( xMQTTConnection,
- 0 /* flags - 0 means a graceful disconnect by sending MQTT DISCONNECT. */
- );
+ /* Send a MQTT DISCONNECT packet to the MQTT broker to do a graceful
+ * disconnect. */
+ IotMqtt_Disconnect( xMQTTConnection,
+ 0 /* flags - 0 means a graceful disconnect by sending MQTT DISCONNECT. */
+ );
}
/*-----------------------------------------------------------*/
static void prvSetShadowCallbacks( void )
{
-AwsIotShadowError_t xCallbackStatus = AWS_IOT_SHADOW_STATUS_PENDING;
-AwsIotShadowCallbackInfo_t xDeltaCallback = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER,
- xUpdatedCallback = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER;
-
- /* Set the functions for callbacks. */
- xDeltaCallback.pCallbackContext = &xDeltaSemaphore;
- xDeltaCallback.function = prvShadowDeltaCallback;
- xUpdatedCallback.function = prvShadowUpdatedCallback;
-
- /************************ Set delta callbacks ****************************/
-
- /* Set the delta callback, which notifies of different desired and reported
- * Shadow states. */
- xCallbackStatus = AwsIotShadow_SetDeltaCallback( xMQTTConnection,
- awsiotdemoprofileCLIENT_IDENTIFIER,
- shadowexampleCLIENT_IDENTIFIER_LENGTH,
- 0, &xDeltaCallback );
- configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS );
-
- /************************ Set updated callbacks **************************/
-
- /* Set the updated callback, which notifies when a Shadow document is
- * changed. */
- xCallbackStatus = AwsIotShadow_SetUpdatedCallback( xMQTTConnection,
- awsiotdemoprofileCLIENT_IDENTIFIER,
- shadowexampleCLIENT_IDENTIFIER_LENGTH,
- 0, &xUpdatedCallback );
-
- configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS );
+ AwsIotShadowError_t xCallbackStatus = AWS_IOT_SHADOW_STATUS_PENDING;
+ AwsIotShadowCallbackInfo_t xDeltaCallback = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER,
+ xUpdatedCallback = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER;
+
+ /* Set the functions for callbacks. */
+ xDeltaCallback.pCallbackContext = &xDeltaSemaphore;
+ xDeltaCallback.function = prvShadowDeltaCallback;
+ xUpdatedCallback.function = prvShadowUpdatedCallback;
+
+ /************************ Set delta callbacks ****************************/
+
+ /* Set the delta callback, which notifies of different desired and reported
+ * Shadow states. */
+ xCallbackStatus = AwsIotShadow_SetDeltaCallback( xMQTTConnection,
+ awsiotdemoprofileCLIENT_IDENTIFIER,
+ shadowexampleCLIENT_IDENTIFIER_LENGTH,
+ 0, &xDeltaCallback );
+ configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS );
+
+ /************************ Set updated callbacks **************************/
+
+ /* Set the updated callback, which notifies when a Shadow document is
+ * changed. */
+ xCallbackStatus = AwsIotShadow_SetUpdatedCallback( xMQTTConnection,
+ awsiotdemoprofileCLIENT_IDENTIFIER,
+ shadowexampleCLIENT_IDENTIFIER_LENGTH,
+ 0, &xUpdatedCallback );
+
+ configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvClearShadowCallbacks( void )
{
-AwsIotShadowError_t xCallbackStatus = AWS_IOT_SHADOW_STATUS_PENDING;
-
- /************************ Clear delta callbacks **************************/
- xCallbackStatus = AwsIotShadow_SetDeltaCallback( xMQTTConnection,
- awsiotdemoprofileCLIENT_IDENTIFIER,
- shadowexampleCLIENT_IDENTIFIER_LENGTH,
- 0, NULL );
- configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS );
-
- /************************ Clear updated callbacks ************************/
- xCallbackStatus = AwsIotShadow_SetUpdatedCallback( xMQTTConnection,
- awsiotdemoprofileCLIENT_IDENTIFIER,
- shadowexampleCLIENT_IDENTIFIER_LENGTH,
- 0, NULL );
- configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS );
+ AwsIotShadowError_t xCallbackStatus = AWS_IOT_SHADOW_STATUS_PENDING;
+
+ /************************ Clear delta callbacks **************************/
+ xCallbackStatus = AwsIotShadow_SetDeltaCallback( xMQTTConnection,
+ awsiotdemoprofileCLIENT_IDENTIFIER,
+ shadowexampleCLIENT_IDENTIFIER_LENGTH,
+ 0, NULL );
+ configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS );
+
+ /************************ Clear updated callbacks ************************/
+ xCallbackStatus = AwsIotShadow_SetUpdatedCallback( xMQTTConnection,
+ awsiotdemoprofileCLIENT_IDENTIFIER,
+ shadowexampleCLIENT_IDENTIFIER_LENGTH,
+ 0, NULL );
+ configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvShadowDeltaCallback( void * pCallbackContext,
- AwsIotShadowCallbackParam_t * pxCallbackParam )
+ AwsIotShadowCallbackParam_t * pxCallbackParam )
{
-BaseType_t xDeltaFound = pdFALSE;
-const char * pcDelta = NULL;
-size_t xDeltaLength = 0;
-IotSemaphore_t * pxDeltaSemaphore = pCallbackContext;
-uint32_t ulUpdateDocumentLength = 0;
-AwsIotShadowError_t xShadowStatus = AWS_IOT_SHADOW_STATUS_PENDING;
-AwsIotShadowDocumentInfo_t xUpdateDocument = AWS_IOT_SHADOW_DOCUMENT_INFO_INITIALIZER;
-uint8_t ucNewState = 0;
-
- configASSERT( pxDeltaSemaphore != NULL );
- configASSERT( pxCallbackParam != NULL );
-
- /* A buffer containing the update document. It has static duration to prevent
- * it from being placed on the call stack.This is only safe because there
- * is only one task in the task pool so this function cannot be called from
- * two tasks simultaneously. */
- static char cUpdateDocument[ shadowexampleREPORTED_JSON_SIZE + 1 ] = { 0 };
-
- /****************** Get delta state from Shadow document *****************/
- /* Check if there is a different "powerOn" state in the Shadow. */
- xDeltaFound = prvGetDelta( pxCallbackParam->u.callback.pDocument,
- pxCallbackParam->u.callback.documentLength,
- "powerOn",
- &pcDelta,
- &xDeltaLength );
-
- configASSERT( xDeltaFound == pdTRUE );
-
- /* Change the current state based on the value in the delta document. */
- if( *pcDelta == '0' )
- {
- ucNewState = 0;
- }
- else if( *pcDelta == '1' )
- {
- ucNewState = 1;
- }
- else
- {
- configPRINTF( ( "Unknown powerOn state parsed from delta document.\r\n" ) );
-
- /* Set new state to current state to ignore the delta document. */
- ucNewState = lDevicePowerOnState;
- }
-
- if( ucNewState != lDevicePowerOnState )
- {
- /* Toggle state. */
- configPRINTF( ( "%.*s changing state from %d to %d.\r\n",
- pxCallbackParam->thingNameLength,
- pxCallbackParam->pThingName,
- lDevicePowerOnState,
- ucNewState ) );
-
- lDevicePowerOnState = ucNewState;
-
- /* Set the common members to report the new state. */
- xUpdateDocument.pThingName = pxCallbackParam->pThingName;
- xUpdateDocument.thingNameLength = pxCallbackParam->thingNameLength;
- xUpdateDocument.u.update.pUpdateDocument = cUpdateDocument;
- xUpdateDocument.u.update.updateDocumentLength = shadowexampleREPORTED_JSON_SIZE;
-
- /* Generate a Shadow document for the reported state. To keep the client
- * token within 6 characters, it is modded by 1000000. */
- ulUpdateDocumentLength = snprintf( cUpdateDocument,
- shadowexampleREPORTED_JSON_SIZE + 1,
- shadowexampleREPORTED_JSON,
- ( int ) lDevicePowerOnState,
- ( long unsigned ) ( IotClock_GetTimeMs() % 1000000 ) );
-
- /* Check if the reported state document is generated for Shadow update*/
- configASSERT( ( size_t ) ulUpdateDocumentLength == shadowexampleREPORTED_JSON_SIZE );
-
- /* Send the Shadow update. Its result is not checked by waiting for the
- * callback, as the Shadow updated callback will report if the Shadow
- * was successfully updated. As the Shadow is constantly updated
- * in this demo, the "Keep Subscriptions" flag is passed to this
- * function. */
- xShadowStatus = AwsIotShadow_UpdateAsync( pxCallbackParam->mqttConnection,
- &xUpdateDocument,
- AWS_IOT_SHADOW_FLAG_KEEP_SUBSCRIPTIONS,
- NULL,
- NULL );
-
- configASSERT( xShadowStatus == AWS_IOT_SHADOW_STATUS_PENDING );
- configPRINTF( ( "%.*s sent new state report: %.*s\r\n",
- pxCallbackParam->thingNameLength,
- pxCallbackParam->pThingName,
- shadowexampleREPORTED_JSON_SIZE,
- cUpdateDocument ) );
-
- /* Post to the delta semaphore to unblock the thread sending Shadow updates. */
- xSemaphoreGive( ( SemaphoreHandle_t ) &pxDeltaSemaphore->xSemaphore );
- }
+ BaseType_t xDeltaFound = pdFALSE;
+ const char * pcDelta = NULL;
+ size_t xDeltaLength = 0;
+ IotSemaphore_t * pxDeltaSemaphore = pCallbackContext;
+ uint32_t ulUpdateDocumentLength = 0;
+ AwsIotShadowError_t xShadowStatus = AWS_IOT_SHADOW_STATUS_PENDING;
+ AwsIotShadowDocumentInfo_t xUpdateDocument = AWS_IOT_SHADOW_DOCUMENT_INFO_INITIALIZER;
+ uint8_t ucNewState = 0;
+
+ configASSERT( pxDeltaSemaphore != NULL );
+ configASSERT( pxCallbackParam != NULL );
+
+ /* A buffer containing the update document. It has static duration to prevent
+ * it from being placed on the call stack.This is only safe because there
+ * is only one task in the task pool so this function cannot be called from
+ * two tasks simultaneously. */
+ static char cUpdateDocument[ shadowexampleREPORTED_JSON_SIZE + 1 ] = { 0 };
+
+ /****************** Get delta state from Shadow document *****************/
+ /* Check if there is a different "powerOn" state in the Shadow. */
+ xDeltaFound = prvGetDelta( pxCallbackParam->u.callback.pDocument,
+ pxCallbackParam->u.callback.documentLength,
+ "powerOn",
+ &pcDelta,
+ &xDeltaLength );
+
+ configASSERT( xDeltaFound == pdTRUE );
+
+ /* Change the current state based on the value in the delta document. */
+ if( *pcDelta == '0' )
+ {
+ ucNewState = 0;
+ }
+ else if( *pcDelta == '1' )
+ {
+ ucNewState = 1;
+ }
+ else
+ {
+ configPRINTF( ( "Unknown powerOn state parsed from delta document.\r\n" ) );
+
+ /* Set new state to current state to ignore the delta document. */
+ ucNewState = lDevicePowerOnState;
+ }
+
+ if( ucNewState != lDevicePowerOnState )
+ {
+ /* Toggle state. */
+ configPRINTF( ( "%.*s changing state from %d to %d.\r\n",
+ pxCallbackParam->thingNameLength,
+ pxCallbackParam->pThingName,
+ lDevicePowerOnState,
+ ucNewState ) );
+
+ lDevicePowerOnState = ucNewState;
+
+ /* Set the common members to report the new state. */
+ xUpdateDocument.pThingName = pxCallbackParam->pThingName;
+ xUpdateDocument.thingNameLength = pxCallbackParam->thingNameLength;
+ xUpdateDocument.u.update.pUpdateDocument = cUpdateDocument;
+ xUpdateDocument.u.update.updateDocumentLength = shadowexampleREPORTED_JSON_SIZE;
+
+ /* Generate a Shadow document for the reported state. To keep the client
+ * token within 6 characters, it is modded by 1000000. */
+ ulUpdateDocumentLength = snprintf( cUpdateDocument,
+ shadowexampleREPORTED_JSON_SIZE + 1,
+ shadowexampleREPORTED_JSON,
+ ( int ) lDevicePowerOnState,
+ ( long unsigned ) ( IotClock_GetTimeMs() % 1000000 ) );
+
+ /* Check if the reported state document is generated for Shadow update*/
+ configASSERT( ( size_t ) ulUpdateDocumentLength == shadowexampleREPORTED_JSON_SIZE );
+
+ /* Send the Shadow update. Its result is not checked by waiting for the
+ * callback, as the Shadow updated callback will report if the Shadow
+ * was successfully updated. As the Shadow is constantly updated
+ * in this demo, the "Keep Subscriptions" flag is passed to this
+ * function. */
+ xShadowStatus = AwsIotShadow_UpdateAsync( pxCallbackParam->mqttConnection,
+ &xUpdateDocument,
+ AWS_IOT_SHADOW_FLAG_KEEP_SUBSCRIPTIONS,
+ NULL,
+ NULL );
+
+ configASSERT( xShadowStatus == AWS_IOT_SHADOW_STATUS_PENDING );
+ configPRINTF( ( "%.*s sent new state report: %.*s\r\n",
+ pxCallbackParam->thingNameLength,
+ pxCallbackParam->pThingName,
+ shadowexampleREPORTED_JSON_SIZE,
+ cUpdateDocument ) );
+
+ /* Post to the delta semaphore to unblock the thread sending Shadow updates. */
+ xSemaphoreGive( ( SemaphoreHandle_t ) &pxDeltaSemaphore->xSemaphore );
+ }
}
/*-----------------------------------------------------------*/
static void prvShadowUpdatedCallback( void * pCallbackContext,
- AwsIotShadowCallbackParam_t * pxCallbackParam )
+ AwsIotShadowCallbackParam_t * pxCallbackParam )
{
-BaseType_t xPreviousFound = pdFALSE, xCurrentFound = pdFALSE;
-const char * pcPrevious = NULL, * pcCurrent = NULL;
-size_t xPreviousLength = 0, xCurrentLength = 0;
-
- /* Silence warnings about unused parameters. */
- ( void ) pCallbackContext;
-
- configASSERT( pxCallbackParam != NULL );
-
- /****************** Get previous state from Shadow document **************/
- /* Find the previous Shadow document. */
- xPreviousFound = prvGetUpdatedState( pxCallbackParam->u.callback.pDocument,
- pxCallbackParam->u.callback.documentLength,
- "previous",
- &pcPrevious,
- &xPreviousLength );
-
- /****************** Get current state from Shadow document **************/
- /* Find the current Shadow document. */
- xCurrentFound = prvGetUpdatedState( pxCallbackParam->u.callback.pDocument,
- pxCallbackParam->u.callback.documentLength,
- "current",
- &pcCurrent,
- &xCurrentLength );
-
- configASSERT( ( xPreviousFound == pdTRUE ) || ( xCurrentFound == pdTRUE ) );
-
- /* Log the previous and current states. */
- configPRINTF( ( "Shadow was updated!\r\n"
- "Previous: {\"state\":%.*s}\r\n"
- "Current: {\"state\":%.*s}\r\n",
- xPreviousLength,
- pcPrevious,
- xCurrentLength,
- pcCurrent ) );
+ BaseType_t xPreviousFound = pdFALSE, xCurrentFound = pdFALSE;
+ const char * pcPrevious = NULL, * pcCurrent = NULL;
+ size_t xPreviousLength = 0, xCurrentLength = 0;
+
+ /* Silence warnings about unused parameters. */
+ ( void ) pCallbackContext;
+
+ configASSERT( pxCallbackParam != NULL );
+
+ /****************** Get previous state from Shadow document **************/
+ /* Find the previous Shadow document. */
+ xPreviousFound = prvGetUpdatedState( pxCallbackParam->u.callback.pDocument,
+ pxCallbackParam->u.callback.documentLength,
+ "previous",
+ &pcPrevious,
+ &xPreviousLength );
+
+ /****************** Get current state from Shadow document **************/
+ /* Find the current Shadow document. */
+ xCurrentFound = prvGetUpdatedState( pxCallbackParam->u.callback.pDocument,
+ pxCallbackParam->u.callback.documentLength,
+ "current",
+ &pcCurrent,
+ &xCurrentLength );
+
+ configASSERT( ( xPreviousFound == pdTRUE ) || ( xCurrentFound == pdTRUE ) );
+
+ /* Log the previous and current states. */
+ configPRINTF( ( "Shadow was updated!\r\n"
+ "Previous: {\"state\":%.*s}\r\n"
+ "Current: {\"state\":%.*s}\r\n",
+ xPreviousLength,
+ pcPrevious,
+ xCurrentLength,
+ pcCurrent ) );
}
/*-----------------------------------------------------------*/
static BaseType_t prvGetDelta( const char * pcDeltaDocument,
- size_t xDeltaDocumentLength,
- const char * pcDeltaKey,
- const char ** pcDelta,
- size_t * pcDeltaLength )
+ size_t xDeltaDocumentLength,
+ const char * pcDeltaKey,
+ const char ** pcDelta,
+ size_t * pcDeltaLength )
{
-BaseType_t xStateFound = pdFALSE, xDeltaFound = pdFALSE;
-const size_t xDeltaKeyLength = strlen( pcDeltaKey );
-const char * pcState = NULL;
-size_t xStateLength = 0;
-
- configASSERT( pcDeltaDocument != NULL );
- configASSERT( pcDeltaKey != NULL );
- /****************** Get state from Shadow document ***********************/
-
- /* Note: This parser used is specific for parsing AWS IoT document received
- * through a mutually authenticated connection. This parser will not check
- * for the correctness of the document as it is designed for low memory
- * footprint rather than checking for correctness of the document. This
- * parser is not meant to be used as a general purpose JSON parser.
- */
- xStateFound = ( BaseType_t ) AwsIotDocParser_FindValue(
- pcDeltaDocument,
- xDeltaDocumentLength,
- "state",
- 5,
- &pcState,
- &xStateLength );
-
- configASSERT( xStateFound == pdTRUE );
-
- /********** Get delta key from state section of Shadow document **********/
-
- /* Note: This parser used is specific for parsing AWS IoT document received
- * through a mutually authenticated connection. This parser will not check
- * for the correctness of the document as it is designed for low memory
- * footprint rather than checking for correctness of the document. This
- * parser is not meant to be used as a general purpose JSON parser.
- */
- xDeltaFound = ( BaseType_t ) AwsIotDocParser_FindValue(
- pcState,
- xStateLength,
- pcDeltaKey,
- xDeltaKeyLength,
- pcDelta,
- pcDeltaLength );
-
- return xDeltaFound;
+ BaseType_t xStateFound = pdFALSE, xDeltaFound = pdFALSE;
+ const size_t xDeltaKeyLength = strlen( pcDeltaKey );
+ const char * pcState = NULL;
+ size_t xStateLength = 0;
+
+ configASSERT( pcDeltaDocument != NULL );
+ configASSERT( pcDeltaKey != NULL );
+ /****************** Get state from Shadow document ***********************/
+
+ /* Note: This parser used is specific for parsing AWS IoT document received
+ * through a mutually authenticated connection. This parser will not check
+ * for the correctness of the document as it is designed for low memory
+ * footprint rather than checking for correctness of the document. This
+ * parser is not meant to be used as a general purpose JSON parser.
+ */
+ xStateFound = ( BaseType_t ) AwsIotDocParser_FindValue(
+ pcDeltaDocument,
+ xDeltaDocumentLength,
+ "state",
+ 5,
+ &pcState,
+ &xStateLength );
+
+ configASSERT( xStateFound == pdTRUE );
+
+ /********** Get delta key from state section of Shadow document **********/
+
+ /* Note: This parser used is specific for parsing AWS IoT document received
+ * through a mutually authenticated connection. This parser will not check
+ * for the correctness of the document as it is designed for low memory
+ * footprint rather than checking for correctness of the document. This
+ * parser is not meant to be used as a general purpose JSON parser.
+ */
+ xDeltaFound = ( BaseType_t ) AwsIotDocParser_FindValue(
+ pcState,
+ xStateLength,
+ pcDeltaKey,
+ xDeltaKeyLength,
+ pcDelta,
+ pcDeltaLength );
+
+ return xDeltaFound;
}
/*-----------------------------------------------------------*/
static BaseType_t prvGetUpdatedState( const char * pcUpdatedDocument,
- size_t xUpdatedDocumentLength,
- const char * pcSectionKey,
- const char ** ppcState,
- size_t * ppcStateLength )
+ size_t xUpdatedDocumentLength,
+ const char * pcSectionKey,
+ const char ** ppcState,
+ size_t * ppcStateLength )
{
-BaseType_t xSectionFound = pdFALSE, xStateFound = pdFALSE;
-const size_t xSectionKeyLength = strlen( pcSectionKey );
-const char * pcSection = NULL;
-size_t xSectionLength = 0;
-
- configASSERT( pcUpdatedDocument != NULL );
- configASSERT( pcSectionKey != NULL );
-
- /*********** Find the given section in the updated document. *************/
-
- /* Note: This parser used is specific for parsing AWS IoT document received
- * through a mutually authenticated connection. This parser will not check
- * for the correctness of the document as it is designed for low memory
- * footprint rather than checking for correctness of the document. This
- * parser is not meant to be used as a general purpose JSON parser.
- */
- xSectionFound = ( BaseType_t ) AwsIotDocParser_FindValue(
- pcUpdatedDocument,
- xUpdatedDocumentLength,
- pcSectionKey,
- xSectionKeyLength,
- &pcSection,
- &xSectionLength );
-
- configASSERT( xSectionFound == pdTRUE );
-
- /*********** Find the state key within the section found *****************/
-
- /* Find the "state" key within the "previous" or "current" section.
- *
- * Note: This parser used is specific for parsing AWS IoT document received
- * through a mutually authenticated connection. This parser will not check
- * for the correctness of the document as it is designed for low memory
- * footprint rather than checking for correctness of the document. This
- * parser is not meant to be used as a general purpose JSON parser.
- */
- xStateFound = ( BaseType_t ) AwsIotDocParser_FindValue(
- pcSection,
- xSectionLength,
- "state",
- 5,
- ppcState,
- ppcStateLength );
-
- return xStateFound;
+ BaseType_t xSectionFound = pdFALSE, xStateFound = pdFALSE;
+ const size_t xSectionKeyLength = strlen( pcSectionKey );
+ const char * pcSection = NULL;
+ size_t xSectionLength = 0;
+
+ configASSERT( pcUpdatedDocument != NULL );
+ configASSERT( pcSectionKey != NULL );
+
+ /*********** Find the given section in the updated document. *************/
+
+ /* Note: This parser used is specific for parsing AWS IoT document received
+ * through a mutually authenticated connection. This parser will not check
+ * for the correctness of the document as it is designed for low memory
+ * footprint rather than checking for correctness of the document. This
+ * parser is not meant to be used as a general purpose JSON parser.
+ */
+ xSectionFound = ( BaseType_t ) AwsIotDocParser_FindValue(
+ pcUpdatedDocument,
+ xUpdatedDocumentLength,
+ pcSectionKey,
+ xSectionKeyLength,
+ &pcSection,
+ &xSectionLength );
+
+ configASSERT( xSectionFound == pdTRUE );
+
+ /*********** Find the state key within the section found *****************/
+
+ /* Find the "state" key within the "previous" or "current" section.
+ *
+ * Note: This parser used is specific for parsing AWS IoT document received
+ * through a mutually authenticated connection. This parser will not check
+ * for the correctness of the document as it is designed for low memory
+ * footprint rather than checking for correctness of the document. This
+ * parser is not meant to be used as a general purpose JSON parser.
+ */
+ xStateFound = ( BaseType_t ) AwsIotDocParser_FindValue(
+ pcSection,
+ xSectionLength,
+ "state",
+ 5,
+ ppcState,
+ ppcStateLength );
+
+ return xStateFound;
}
/*-----------------------------------------------------------*/
static void prvClearShadowDocument( void )
{
-AwsIotShadowError_t xDeleteStatus = AWS_IOT_SHADOW_STATUS_PENDING;
-
- /************************* Delete Shadow document ************************/
- xDeleteStatus = AwsIotShadow_DeleteSync( xMQTTConnection,
- awsiotdemoprofileCLIENT_IDENTIFIER,
- shadowexampleCLIENT_IDENTIFIER_LENGTH,
- 0, shadowexampleMQTT_TIMEOUT_MS );
- configASSERT( ( xDeleteStatus == AWS_IOT_SHADOW_SUCCESS ) || ( xDeleteStatus == AWS_IOT_SHADOW_NOT_FOUND ) );
-
- configPRINTF( ( "Successfully cleared Shadow of %.*s.\r\n",
- shadowexampleCLIENT_IDENTIFIER_LENGTH,
- awsiotdemoprofileCLIENT_IDENTIFIER ) );
+ AwsIotShadowError_t xDeleteStatus = AWS_IOT_SHADOW_STATUS_PENDING;
+
+ /************************* Delete Shadow document ************************/
+ xDeleteStatus = AwsIotShadow_DeleteSync( xMQTTConnection,
+ awsiotdemoprofileCLIENT_IDENTIFIER,
+ shadowexampleCLIENT_IDENTIFIER_LENGTH,
+ 0, shadowexampleMQTT_TIMEOUT_MS );
+ configASSERT( ( xDeleteStatus == AWS_IOT_SHADOW_SUCCESS ) || ( xDeleteStatus == AWS_IOT_SHADOW_NOT_FOUND ) );
+
+ configPRINTF( ( "Successfully cleared Shadow of %.*s.\r\n",
+ shadowexampleCLIENT_IDENTIFIER_LENGTH,
+ awsiotdemoprofileCLIENT_IDENTIFIER ) );
}
/*-----------------------------------------------------------*/
static void prvSendShadowUpdates( void )
{
-int32_t lIndex = 0, lDesiredState = 0, lStatus = 0;
-AwsIotShadowError_t xShadowStatus = AWS_IOT_SHADOW_STATUS_PENDING;
-AwsIotShadowDocumentInfo_t xUpdateDocument = AWS_IOT_SHADOW_DOCUMENT_INFO_INITIALIZER;
-
- /* A buffer containing the update document. It has static duration to prevent
- * it from being placed on the call stack. */
- static char cUpdateDocument[ shadowexampleDESIRED_JSON_SIZE + 1 ] = { 0 };
-
- /********** Set the common members of Shadow update document *************/
- xUpdateDocument.pThingName = awsiotdemoprofileCLIENT_IDENTIFIER;
- xUpdateDocument.thingNameLength = shadowexampleCLIENT_IDENTIFIER_LENGTH;
- xUpdateDocument.u.update.pUpdateDocument = cUpdateDocument;
- xUpdateDocument.u.update.updateDocumentLength = shadowexampleDESIRED_JSON_SIZE;
-
- /*************** Publish Shadow updates at a set period. *****************/
- for( lIndex = 1; lIndex <= shadowexampleUPDATE_COUNT; lIndex++ )
- {
- /* Toggle the desired state. */
- lDesiredState = !( lDesiredState );
-
- /* Generate a Shadow desired state document, using a timestamp for the client
- * token. To keep the client token within 6 characters, it is modded by 1000000. */
- lStatus = snprintf( cUpdateDocument,
- shadowexampleDESIRED_JSON_SIZE + 1,
- shadowexampleDESIRED_JSON,
- ( int ) lDesiredState,
- ( long unsigned ) ( IotClock_GetTimeMs() % 1000000 ) );
-
- /* Check for errors from snprintf. The expected value is the length of
- * the desired JSON document less the format specifier for the state. */
- configASSERT( lStatus == shadowexampleDESIRED_JSON_SIZE );
-
- configPRINTF( ( "Sending Shadow update %d of %d: %s\r\n",
- lIndex,
- shadowexampleUPDATE_COUNT,
- cUpdateDocument ) );
-
- /* Send the Shadow update. Because the Shadow is constantly updated in
- * this demo, the "Keep Subscriptions" flag is passed to this function.
- * Note that this flag only needs to be passed on the first call, but
- * passing it for subsequent calls is fine.
- */
- xShadowStatus = AwsIotShadow_UpdateSync( xMQTTConnection,
- &xUpdateDocument,
- AWS_IOT_SHADOW_FLAG_KEEP_SUBSCRIPTIONS,
- shadowexampleMQTT_TIMEOUT_MS );
-
- configASSERT( xShadowStatus == AWS_IOT_SHADOW_SUCCESS );
-
- configPRINTF( ( "Successfully sent Shadow update %d of %d.\r\n",
- lIndex,
- shadowexampleUPDATE_COUNT ) );
-
- /* Wait for the delta callback to change its state before continuing. */
- configASSERT( xSemaphoreTake( ( SemaphoreHandle_t ) &xDeltaSemaphore.xSemaphore,
- pdMS_TO_TICKS( shadowexampleWAIT_PERIOD_FOR_DELTA_MS ) ) == pdTRUE );
-
- IotClock_SleepMs( shadowexampleUPDATE_PERIOD_MS );
- }
-
- /* Remove persistent subscriptions. In the AwsIotShadow_UpdateSync call, we have used the */
- xShadowStatus = AwsIotShadow_RemovePersistentSubscriptions( xMQTTConnection,
- awsiotdemoprofileCLIENT_IDENTIFIER,
- shadowexampleCLIENT_IDENTIFIER_LENGTH,
- AWS_IOT_SHADOW_FLAG_REMOVE_UPDATE_SUBSCRIPTIONS );
-
- configASSERT( xShadowStatus == AWS_IOT_SHADOW_SUCCESS );
+ int32_t lIndex = 0, lDesiredState = 0, lStatus = 0;
+ AwsIotShadowError_t xShadowStatus = AWS_IOT_SHADOW_STATUS_PENDING;
+ AwsIotShadowDocumentInfo_t xUpdateDocument = AWS_IOT_SHADOW_DOCUMENT_INFO_INITIALIZER;
+
+ /* A buffer containing the update document. It has static duration to prevent
+ * it from being placed on the call stack. */
+ static char cUpdateDocument[ shadowexampleDESIRED_JSON_SIZE + 1 ] = { 0 };
+
+ /********** Set the common members of Shadow update document *************/
+ xUpdateDocument.pThingName = awsiotdemoprofileCLIENT_IDENTIFIER;
+ xUpdateDocument.thingNameLength = shadowexampleCLIENT_IDENTIFIER_LENGTH;
+ xUpdateDocument.u.update.pUpdateDocument = cUpdateDocument;
+ xUpdateDocument.u.update.updateDocumentLength = shadowexampleDESIRED_JSON_SIZE;
+
+ /*************** Publish Shadow updates at a set period. *****************/
+ for( lIndex = 1; lIndex <= shadowexampleUPDATE_COUNT; lIndex++ )
+ {
+ /* Toggle the desired state. */
+ lDesiredState = !( lDesiredState );
+
+ /* Generate a Shadow desired state document, using a timestamp for the client
+ * token. To keep the client token within 6 characters, it is modded by 1000000. */
+ lStatus = snprintf( cUpdateDocument,
+ shadowexampleDESIRED_JSON_SIZE + 1,
+ shadowexampleDESIRED_JSON,
+ ( int ) lDesiredState,
+ ( long unsigned ) ( IotClock_GetTimeMs() % 1000000 ) );
+
+ /* Check for errors from snprintf. The expected value is the length of
+ * the desired JSON document less the format specifier for the state. */
+ configASSERT( lStatus == shadowexampleDESIRED_JSON_SIZE );
+
+ configPRINTF( ( "Sending Shadow update %d of %d: %s\r\n",
+ lIndex,
+ shadowexampleUPDATE_COUNT,
+ cUpdateDocument ) );
+
+ /* Send the Shadow update. Because the Shadow is constantly updated in
+ * this demo, the "Keep Subscriptions" flag is passed to this function.
+ * Note that this flag only needs to be passed on the first call, but
+ * passing it for subsequent calls is fine.
+ */
+ xShadowStatus = AwsIotShadow_UpdateSync( xMQTTConnection,
+ &xUpdateDocument,
+ AWS_IOT_SHADOW_FLAG_KEEP_SUBSCRIPTIONS,
+ shadowexampleMQTT_TIMEOUT_MS );
+
+ configASSERT( xShadowStatus == AWS_IOT_SHADOW_SUCCESS );
+
+ configPRINTF( ( "Successfully sent Shadow update %d of %d.\r\n",
+ lIndex,
+ shadowexampleUPDATE_COUNT ) );
+
+ /* Wait for the delta callback to change its state before continuing. */
+ configASSERT( xSemaphoreTake( ( SemaphoreHandle_t ) &xDeltaSemaphore.xSemaphore,
+ pdMS_TO_TICKS( shadowexampleWAIT_PERIOD_FOR_DELTA_MS ) ) == pdTRUE );
+
+ IotClock_SleepMs( shadowexampleUPDATE_PERIOD_MS );
+ }
+
+ /* Remove persistent subscriptions. In the AwsIotShadow_UpdateSync call, we have used the */
+ xShadowStatus = AwsIotShadow_RemovePersistentSubscriptions( xMQTTConnection,
+ awsiotdemoprofileCLIENT_IDENTIFIER,
+ shadowexampleCLIENT_IDENTIFIER_LENGTH,
+ AWS_IOT_SHADOW_FLAG_REMOVE_UPDATE_SUBSCRIPTIONS );
+
+ configASSERT( xShadowStatus == AWS_IOT_SHADOW_SUCCESS );
}
/*-----------------------------------------------------------*/
static void prvInitialiseLibraries( void )
{
-IotMqttError_t xResult;
-IotNetworkError_t xNetworkResult;
+ IotMqttError_t xResult;
+ IotNetworkError_t xNetworkResult;
- /* Initialize the network stack abstraction for FreeRTOS. */
- xNetworkResult = IotNetworkFreeRTOS_Init();
- configASSERT( xNetworkResult == IOT_NETWORK_SUCCESS );
+ /* Initialize the network stack abstraction for FreeRTOS. */
+ xNetworkResult = IotNetworkFreeRTOS_Init();
+ configASSERT( xNetworkResult == IOT_NETWORK_SUCCESS );
- /* MQTT library must be initialized before it can be used. This is just one
- * time initialization. */
- xResult = IotMqtt_Init();
- configASSERT( xResult == IOT_MQTT_SUCCESS );
+ /* MQTT library must be initialized before it can be used. This is just one
+ * time initialization. */
+ xResult = IotMqtt_Init();
+ configASSERT( xResult == IOT_MQTT_SUCCESS );
- /* Initialize Shadow library*/
- xResult = AwsIotShadow_Init( shadowexampleUSE_DEFAULT_MQTT_TIMEOUT );
- configASSERT( xResult == AWS_IOT_SHADOW_SUCCESS );
+ /* Initialize Shadow library*/
+ xResult = AwsIotShadow_Init( shadowexampleUSE_DEFAULT_MQTT_TIMEOUT );
+ configASSERT( xResult == AWS_IOT_SHADOW_SUCCESS );
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSConfig.h
index 2d17e44e7..e677d79c1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSConfig.h
@@ -29,94 +29,95 @@
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
- * Application specific definitions.
- *
- * These definitions should be adjusted for your particular hardware and
- * application requirements.
- *
- * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
- * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
- * http://www.freertos.org/a00110.html
- *
- * The bottom of this file contains some constants specific to running the UDP
- * stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
- * the demo) are contained in FreeRTOSIPConfig.h.
- *----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configMAX_PRIORITIES ( 7 )
-#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
-#define configMAX_TASK_NAME_LEN ( 15 )
-#define configUSE_TRACE_FACILITY 1
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_CO_ROUTINES 0
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configUSE_ALTERNATIVE_API 0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configENABLE_BACKWARD_COMPATIBILITY 1
-#define configSUPPORT_STATIC_ALLOCATION 1
+* Application specific definitions.
+*
+* These definitions should be adjusted for your particular hardware and
+* application requirements.
+*
+* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+* http://www.freertos.org/a00110.html
+*
+* The bottom of this file contains some constants specific to running the UDP
+* stack in this demo. Constants specific to FreeRTOS+TCP itself (rather than
+* the demo) are contained in FreeRTOSIPConfig.h.
+*----------------------------------------------------------*/
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configMAX_PRIORITIES ( 7 )
+#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 60 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the Win32 thread. */
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048U * 1024U ) )
+#define configMAX_TASK_NAME_LEN ( 15 )
+#define configUSE_TRACE_FACILITY 1
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_CO_ROUTINES 0
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configUSE_ALTERNATIVE_API 0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSUPPORT_STATIC_ALLOCATION 1
/* Hook function related definitions. */
-#define configUSE_TICK_HOOK 0
-#define configUSE_IDLE_HOOK 0
-#define configUSE_MALLOC_FAILED_HOOK 0
-#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
+#define configUSE_TICK_HOOK 0
+#define configUSE_IDLE_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0
+#define configCHECK_FOR_STACK_OVERFLOW 0 /* Not applicable to the Win32 port. */
/* Software timer related definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
/* Event group related definitions. */
-#define configUSE_EVENT_GROUPS 1
+#define configUSE_EVENT_GROUPS 1
/* Run time stats gathering definitions. */
-#define configGENERATE_RUN_TIME_STATS 0
+#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0
-#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
-to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 0
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
-#define INCLUDE_uxTaskGetStackHighWaterMark 1
-#define INCLUDE_xTaskGetSchedulerState 1
-#define INCLUDE_xTimerGetTimerTaskHandle 0
-#define INCLUDE_xTaskGetIdleTaskHandle 0
-#define INCLUDE_xQueueGetMutexHolder 1
-#define INCLUDE_eTaskGetState 1
-#define INCLUDE_xEventGroupSetBitsFromISR 1
-#define INCLUDE_xTimerPendFunctionCall 1
-#define INCLUDE_pcTaskGetTaskName 1
+ * to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 1
+#define INCLUDE_xTaskGetSchedulerState 1
+#define INCLUDE_xTimerGetTimerTaskHandle 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xQueueGetMutexHolder 1
+#define INCLUDE_eTaskGetState 1
+#define INCLUDE_xEventGroupSetBitsFromISR 1
+#define INCLUDE_xTimerPendFunctionCall 1
+#define INCLUDE_pcTaskGetTaskName 1
/* This demo makes use of one or more example stats formatting functions. These
-format the raw data provided by the uxTaskGetSystemState() function in to human
-readable ASCII form. See the notes in the implementation of vTaskList() within
-FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
-is set to 2 so the formatting functions are included without the stdio.h being
-included in tasks.c. That is because this project defines its own sprintf()
-functions. */
-#define configUSE_STATS_FORMATTING_FUNCTIONS 1
+ * format the raw data provided by the uxTaskGetSystemState() function in to human
+ * readable ASCII form. See the notes in the implementation of vTaskList() within
+ * FreeRTOS/Source/tasks.c for limitations. configUSE_STATS_FORMATTING_FUNCTIONS
+ * is set to 2 so the formatting functions are included without the stdio.h being
+ * included in tasks.c. That is because this project defines its own sprintf()
+ * functions. */
+#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Assert call defined for debug builds. */
#ifdef _DEBUG
- extern void vAssertCalled( const char *pcFile, uint32_t ulLine );
- #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
+ extern void vAssertCalled( const char * pcFile,
+ uint32_t ulLine );
+ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
#endif /* _DEBUG */
@@ -124,93 +125,93 @@ functions. */
/* Application specific definitions follow. **********************************/
/* Only used when running in the FreeRTOS Windows simulator. Defines the
-priority of the task used to simulate Ethernet interrupts. */
-#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
+ * priority of the task used to simulate Ethernet interrupts. */
+#define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 1 )
/* This demo creates a virtual network connection by accessing the raw Ethernet
-or WiFi data to and from a real network connection. Many computers have more
-than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
-the demo which real port should be used to create the virtual port. The ports
-available are displayed on the console when the application is executed. For
-example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
-results in the wired network being used, while setting
-configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
-used. */
-#define configNETWORK_INTERFACE_TO_USE 4L
+ * or WiFi data to and from a real network connection. Many computers have more
+ * than one real network port, and configNETWORK_INTERFACE_TO_USE is used to tell
+ * the demo which real port should be used to create the virtual port. The ports
+ * available are displayed on the console when the application is executed. For
+ * example, on my development laptop setting configNETWORK_INTERFACE_TO_USE to 4
+ * results in the wired network being used, while setting
+ * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
+ * used. */
+#define configNETWORK_INTERFACE_TO_USE 4L
/* The address of an echo server is only left in this project as it doubles as
-the address to which logging is sent should UDP logging be enabled. */
-#define configECHO_SERVER_ADDR0 192
-#define configECHO_SERVER_ADDR1 168
-#define configECHO_SERVER_ADDR2 0
-#define configECHO_SERVER_ADDR3 11
+ * the address to which logging is sent should UDP logging be enabled. */
+#define configECHO_SERVER_ADDR0 192
+#define configECHO_SERVER_ADDR1 168
+#define configECHO_SERVER_ADDR2 0
+#define configECHO_SERVER_ADDR3 11
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet/WiFi data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition above for information on how to
-configure the real network connection to use. */
-#define configMAC_ADDR0 0x00
-#define configMAC_ADDR1 0x11
-#define configMAC_ADDR2 0x11
-#define configMAC_ADDR3 0x11
-#define configMAC_ADDR4 0x11
-#define configMAC_ADDR5 0x41
+ * connection that uses this MAC address by accessing the raw Ethernet/WiFi data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition above for information on how to
+ * configure the real network connection to use. */
+#define configMAC_ADDR0 0x00
+#define configMAC_ADDR1 0x11
+#define configMAC_ADDR2 0x11
+#define configMAC_ADDR3 0x11
+#define configMAC_ADDR4 0x11
+#define configMAC_ADDR5 0x41
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configIP_ADDR0 10
-#define configIP_ADDR1 10
-#define configIP_ADDR2 10
-#define configIP_ADDR3 200
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0 10
+#define configIP_ADDR1 10
+#define configIP_ADDR2 10
+#define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
-0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configGATEWAY_ADDR0 10
-#define configGATEWAY_ADDR1 10
-#define configGATEWAY_ADDR2 10
-#define configGATEWAY_ADDR3 1
+ * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0 10
+#define configGATEWAY_ADDR1 10
+#define configGATEWAY_ADDR2 10
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
-208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
-to 1 but a DNS server cannot be contacted.*/
-#define configDNS_SERVER_ADDR0 208
-#define configDNS_SERVER_ADDR1 67
-#define configDNS_SERVER_ADDR2 222
-#define configDNS_SERVER_ADDR3 222
+ * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set
+ * to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0 208
+#define configDNS_SERVER_ADDR1 67
+#define configDNS_SERVER_ADDR2 222
+#define configDNS_SERVER_ADDR3 222
/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or
-ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
-#define configNET_MASK0 255
-#define configNET_MASK1 0
-#define configNET_MASK2 0
-#define configNET_MASK3 0
+ * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0 255
+#define configNET_MASK1 0
+#define configNET_MASK2 0
+#define configNET_MASK3 0
/* The UDP port to which print messages are sent. */
-#define configPRINT_PORT ( 15000 )
+#define configPRINT_PORT ( 15000 )
/* Task pool definitions for the demos of IoT Libraries. */
-#define configTASKPOOL_ENABLE_ASSERTS 1
-#define configTASKPOOL_NUMBER_OF_WORKERS 1
-#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
-#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
-
-#if( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
- /* Map to Windows names. */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
+#define configTASKPOOL_ENABLE_ASSERTS 1
+#define configTASKPOOL_NUMBER_OF_WORKERS 1
+#define configTASKPOOL_WORKER_PRIORITY tskIDLE_PRIORITY
+#define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048
+
+#if ( defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) && !defined( snprintf ) )
+ /* Map to Windows names. */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
#endif
/* Visual studio does not have an implementation of strcasecmp(). */
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#define strcmpi _strcmpi
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strcmpi _strcmpi
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
#define configPRINTF( X ) vLoggingPrintf X
#endif /* FREERTOS_CONFIG_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSIPConfig.h
index 39a61856b..0375594c1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSIPConfig.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/FreeRTOSIPConfig.h
@@ -27,284 +27,285 @@
/*****************************************************************************
- *
- * See the following URL for configuration information.
- * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
- *
- *****************************************************************************/
+*
+* See the following URL for configuration information.
+* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html
+*
+*****************************************************************************/
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
/* Prototype for the function used to print out. In this case it prints to the
-console before the network is connected then a UDP port after the network has
-connected. */
-extern void vLoggingPrintf( const char *pcFormatString, ... );
+ * console before the network is connected then a UDP port after the network has
+ * connected. */
+extern void vLoggingPrintf( const char * pcFormatString,
+ ... );
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
-1 then FreeRTOS_debug_printf should be defined to the function used to print
-out the debugging messages. */
-#define ipconfigHAS_DEBUG_PRINTF 0
-#if( ipconfigHAS_DEBUG_PRINTF == 1 )
- #define FreeRTOS_debug_printf(X) vLoggingPrintf X
+ * 1 then FreeRTOS_debug_printf should be defined to the function used to print
+ * out the debugging messages. */
+#define ipconfigHAS_DEBUG_PRINTF 0
+#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
+ #define FreeRTOS_debug_printf( X ) vLoggingPrintf X
#endif
/* Set to 1 to print out non debugging messages, for example the output of the
-FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
-then FreeRTOS_printf should be set to the function used to print out the
-messages. */
-#define ipconfigHAS_PRINTF 1
-#if( ipconfigHAS_PRINTF == 1 )
- #define FreeRTOS_printf(X) vLoggingPrintf X
+ * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1
+ * then FreeRTOS_printf should be set to the function used to print out the
+ * messages. */
+#define ipconfigHAS_PRINTF 1
+#if ( ipconfigHAS_PRINTF == 1 )
+ #define FreeRTOS_printf( X ) vLoggingPrintf X
#endif
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
-on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
-#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
+ * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
+#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
-then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
-stack repeating the checksum calculations. */
-#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
+ * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
+ * stack repeating the checksum calculations. */
+#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
-performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
-set per socket, using setsockopt(). If not set, the times below will be
-used as defaults. */
-#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
-#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
+ * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
+ * set per socket, using setsockopt(). If not set, the times below will be
+ * used as defaults. */
+#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
+#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
-(non-Microsoft) */
-#define ipconfigUSE_LLMNR ( 0 )
+ * (non-Microsoft) */
+#define ipconfigUSE_LLMNR ( 0 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
-#define ipconfigUSE_NBNS ( 0 )
+#define ipconfigUSE_NBNS ( 0 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
-useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
-and also DNS may use small timeouts. If a DNS reply comes in after the DNS
-socket has been destroyed, the result will be stored into the cache. The next
-call to FreeRTOS_gethostbyname() will return immediately, without even creating
-a socket. */
-#define ipconfigUSE_DNS_CACHE ( 1 )
-#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
-#define ipconfigDNS_CACHE_ENTRIES ( 4 )
-#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
+ * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
+ * and also DNS may use small timeouts. If a DNS reply comes in after the DNS
+ * socket has been destroyed, the result will be stored into the cache. The next
+ * call to FreeRTOS_gethostbyname() will return immediately, without even creating
+ * a socket. */
+#define ipconfigUSE_DNS_CACHE ( 1 )
+#define ipconfigDNS_CACHE_NAME_LENGTH ( 64 )
+#define ipconfigDNS_CACHE_ENTRIES ( 4 )
+#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* The IP stack executes it its own task (although any application task can make
-use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
-sets the priority of the task that executes the IP stack. The priority is a
-standard FreeRTOS task priority so can take any value from 0 (the lowest
-priority) to (configMAX_PRIORITIES - 1) (the highest priority).
-configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
-FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
-the priority assigned to the task executing the IP stack relative to the
-priority assigned to tasks that use the IP stack. */
-#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
+ * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
+ * sets the priority of the task that executes the IP stack. The priority is a
+ * standard FreeRTOS task priority so can take any value from 0 (the lowest
+ * priority) to (configMAX_PRIORITIES - 1) (the highest priority).
+ * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
+ * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
+ * the priority assigned to the task executing the IP stack relative to the
+ * priority assigned to tasks that use the IP stack. */
+#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
-task. This setting is less important when the FreeRTOS Win32 simulator is used
-as the Win32 simulator only stores a fixed amount of information on the task
-stack. FreeRTOS includes optional stack overflow detection, see:
-http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
-#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
+ * task. This setting is less important when the FreeRTOS Win32 simulator is used
+ * as the Win32 simulator only stores a fixed amount of information on the task
+ * stack. FreeRTOS includes optional stack overflow detection, see:
+ * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
+#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
-things such as a DHCP transaction number or initial sequence number. Random
-number generation is performed via this macro to allow applications to use their
-own random number generation method. For example, it might be possible to
-generate a random number by sampling noise on an analogue input. */
+ * things such as a DHCP transaction number or initial sequence number. Random
+ * number generation is performed via this macro to allow applications to use their
+ * own random number generation method. For example, it might be possible to
+ * generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
-#define ipconfigRAND32() uxRand()
+#define ipconfigRAND32() uxRand()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
-network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
-is not set to 1 then the network event hook will never be called. See
-http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
-*/
-#define ipconfigUSE_NETWORK_EVENT_HOOK 1
+ * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK
+ * is not set to 1 then the network event hook will never be called. See
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml
+ */
+#define ipconfigUSE_NETWORK_EVENT_HOOK 1
/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but
-a network buffer cannot be obtained then the calling task is held in the Blocked
-state (so other tasks can continue to executed) until either a network buffer
-becomes available or the send block time expires. If the send block time expires
-then the send operation is aborted. The maximum allowable send block time is
-capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
-maximum allowable send block time prevents prevents a deadlock occurring when
-all the network buffers are in use and the tasks that process (and subsequently
-free) the network buffers are themselves blocked waiting for a network buffer.
-ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
-milliseconds can be converted to a time in ticks by dividing the time in
-milliseconds by portTICK_PERIOD_MS. */
-#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
+ * a network buffer cannot be obtained then the calling task is held in the Blocked
+ * state (so other tasks can continue to executed) until either a network buffer
+ * becomes available or the send block time expires. If the send block time expires
+ * then the send operation is aborted. The maximum allowable send block time is
+ * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the
+ * maximum allowable send block time prevents prevents a deadlock occurring when
+ * all the network buffers are in use and the tasks that process (and subsequently
+ * free) the network buffers are themselves blocked waiting for a network buffer.
+ * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in
+ * milliseconds can be converted to a time in ticks by dividing the time in
+ * milliseconds by portTICK_PERIOD_MS. */
+#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000 / portTICK_PERIOD_MS )
/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP
-address, netmask, DNS server address and gateway address from a DHCP server. If
-ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
-stack will revert to using the static IP address even when ipconfigUSE_DHCP is
-set to 1 if a valid configuration cannot be obtained from a DHCP server for any
-reason. The static configuration used is that passed into the stack by the
-FreeRTOS_IPInit() function call. */
-#define ipconfigUSE_DHCP 1
+ * address, netmask, DNS server address and gateway address from a DHCP server. If
+ * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The
+ * stack will revert to using the static IP address even when ipconfigUSE_DHCP is
+ * set to 1 if a valid configuration cannot be obtained from a DHCP server for any
+ * reason. The static configuration used is that passed into the stack by the
+ * FreeRTOS_IPInit() function call. */
+#define ipconfigUSE_DHCP 1
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at
-increasing time intervals until either a reply is received from a DHCP server
-and accepted, or the interval between transmissions reaches
-ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
-static IP address passed as a parameter to FreeRTOS_IPInit() if the
-re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
-a DHCP reply being received. */
-#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
+ * increasing time intervals until either a reply is received from a DHCP server
+ * and accepted, or the interval between transmissions reaches
+ * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
+ * static IP address passed as a parameter to FreeRTOS_IPInit() if the
+ * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
+ * a DHCP reply being received. */
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_PERIOD_MS )
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
-stack can only send a UDP message to a remove IP address if it knowns the MAC
-address associated with the IP address, or the MAC address of the router used to
-contact the remote IP address. When a UDP message is received from a remote IP
-address the MAC address and IP address are added to the ARP cache. When a UDP
-message is sent to a remote IP address that does not already appear in the ARP
-cache then the UDP message is replaced by a ARP message that solicits the
-required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
-number of entries that can exist in the ARP table at any one time. */
-#define ipconfigARP_CACHE_ENTRIES 6
+ * stack can only send a UDP message to a remove IP address if it knowns the MAC
+ * address associated with the IP address, or the MAC address of the router used to
+ * contact the remote IP address. When a UDP message is received from a remote IP
+ * address the MAC address and IP address are added to the ARP cache. When a UDP
+ * message is sent to a remote IP address that does not already appear in the ARP
+ * cache then the UDP message is replaced by a ARP message that solicits the
+ * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum
+ * number of entries that can exist in the ARP table at any one time. */
+#define ipconfigARP_CACHE_ENTRIES 6
/* ARP requests that do not result in an ARP response will be re-transmitted a
-maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
-aborted. */
-#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
+ * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is
+ * aborted. */
+#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )
/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP
-table being created or refreshed and the entry being removed because it is stale.
-New ARP requests are sent for ARP cache entries that are nearing their maximum
-age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
-equal to 1500 seconds (or 25 minutes). */
-#define ipconfigMAX_ARP_AGE 150
+ * table being created or refreshed and the entry being removed because it is stale.
+ * New ARP requests are sent for ARP cache entries that are nearing their maximum
+ * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is
+ * equal to 1500 seconds (or 25 minutes). */
+#define ipconfigMAX_ARP_AGE 150
/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling
-routines, which are relatively large. To save code space the full
-FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
-alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
-takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
-FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
-(for example, 192, 168, 0, 1) as its parameters. If
-ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
-FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
-not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
-#define ipconfigINCLUDE_FULL_INET_ADDR 1
+ * routines, which are relatively large. To save code space the full
+ * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster
+ * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr()
+ * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.
+ * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets
+ * (for example, 192, 168, 0, 1) as its parameters. If
+ * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and
+ * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is
+ * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
+#define ipconfigINCLUDE_FULL_INET_ADDR 1
/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that
-are available to the IP stack. The total number of network buffers is limited
-to ensure the total amount of RAM that can be consumed by the IP stack is capped
-to a pre-determinable value. */
-#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
+ * are available to the IP stack. The total number of network buffers is limited
+ * to ensure the total amount of RAM that can be consumed by the IP stack is capped
+ * to a pre-determinable value. */
+#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60
/* A FreeRTOS queue is used to send events from application tasks to the IP
-stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
-be queued for processing at any one time. The event queue must be a minimum of
-5 greater than the total number of network buffers. */
-#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
+ * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can
+ * be queued for processing at any one time. The event queue must be a minimum of
+ * 5 greater than the total number of network buffers. */
+#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
/* The address of a socket is the combination of its IP address and its port
-number. FreeRTOS_bind() is used to manually allocate a port number to a socket
-(to 'bind' the socket to a port), but manual binding is not normally necessary
-for client sockets (those sockets that initiate outgoing connections rather than
-wait for incoming connections on a known port number). If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
-FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
-stack automatically binding the socket to a port number from the range
-socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
-ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
-on a socket that has not yet been bound will result in the send operation being
-aborted. */
-#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
+ * number. FreeRTOS_bind() is used to manually allocate a port number to a socket
+ * (to 'bind' the socket to a port), but manual binding is not normally necessary
+ * for client sockets (those sockets that initiate outgoing connections rather than
+ * wait for incoming connections on a known port number). If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling
+ * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP
+ * stack automatically binding the socket to a port number from the range
+ * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If
+ * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()
+ * on a socket that has not yet been bound will result in the send operation being
+ * aborted. */
+#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */
-#define ipconfigUDP_TIME_TO_LIVE 128
-#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
+#define ipconfigUDP_TIME_TO_LIVE 128
+#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */
/* USE_TCP: Use TCP and all its features */
-#define ipconfigUSE_TCP ( 1 )
+#define ipconfigUSE_TCP ( 1 )
/* Use the TCP socket wake context with a callback. */
#define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT ( 1 )
/* USE_WIN: Let TCP use windowing mechanism. */
-#define ipconfigUSE_TCP_WIN ( 1 )
+#define ipconfigUSE_TCP_WIN ( 1 )
/* The MTU is the maximum number of bytes the payload of a network frame can
-contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
-lower value can save RAM, depending on the buffer management scheme used. If
-ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
-be divisible by 8. */
-#define ipconfigNETWORK_MTU 1200
+ * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a
+ * lower value can save RAM, depending on the buffer management scheme used. If
+ * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must
+ * be divisible by 8. */
+#define ipconfigNETWORK_MTU 1200
/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used
-through the FreeRTOS_gethostbyname() API function. */
-#define ipconfigUSE_DNS 1
+ * through the FreeRTOS_gethostbyname() API function. */
+#define ipconfigUSE_DNS 1
/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will
-generate replies to incoming ICMP echo (ping) requests. */
-#define ipconfigREPLY_TO_INCOMING_PINGS 1
+ * generate replies to incoming ICMP echo (ping) requests. */
+#define ipconfigREPLY_TO_INCOMING_PINGS 1
/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the
-FreeRTOS_SendPingRequest() API function is available. */
-#define ipconfigSUPPORT_OUTGOING_PINGS 0
+ * FreeRTOS_SendPingRequest() API function is available. */
+#define ipconfigSUPPORT_OUTGOING_PINGS 0
/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()
-(and associated) API function is available. */
-#define ipconfigSUPPORT_SELECT_FUNCTION 1
+ * (and associated) API function is available. */
+#define ipconfigSUPPORT_SELECT_FUNCTION 1
/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames
-that are not in Ethernet II format will be dropped. This option is included for
-potential future IP stack developments. */
-#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
+ * that are not in Ethernet II format will be dropped. This option is included for
+ * potential future IP stack developments. */
+#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the
-responsibility of the Ethernet interface to filter out packets that are of no
-interest. If the Ethernet interface does not implement this functionality, then
-set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
-perform the filtering instead (it is much less efficient for the stack to do it
-because the packet will already have been passed into the stack). If the
-Ethernet driver does all the necessary filtering in hardware then software
-filtering can be removed by using a value other than 1 or 0. */
-#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
+ * responsibility of the Ethernet interface to filter out packets that are of no
+ * interest. If the Ethernet interface does not implement this functionality, then
+ * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack
+ * perform the filtering instead (it is much less efficient for the stack to do it
+ * because the packet will already have been passed into the stack). If the
+ * Ethernet driver does all the necessary filtering in hardware then software
+ * filtering can be removed by using a value other than 1 or 0. */
+#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
/* The windows simulator cannot really simulate MAC interrupts, and needs to
-block occasionally to allow other tasks to run. */
-#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
+ * block occasionally to allow other tasks to run. */
+#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS )
/* Advanced only: in order to access 32-bit fields in the IP packets with
-32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
-This has to do with the contents of the IP-packets: all 32-bit fields are
-32-bit-aligned, plus 16-bit(!) */
-#define ipconfigPACKET_FILLER_SIZE 2
+ * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits.
+ * This has to do with the contents of the IP-packets: all 32-bit fields are
+ * 32-bit-aligned, plus 16-bit(!) */
+#define ipconfigPACKET_FILLER_SIZE 2
/* Define the size of the pool of TCP window descriptors. On the average, each
-TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
-outstanding packets (for Rx and Tx). When using up to 10 TP sockets
-simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
-#define ipconfigTCP_WIN_SEG_COUNT 240
+ * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6
+ * outstanding packets (for Rx and Tx). When using up to 10 TP sockets
+ * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */
+#define ipconfigTCP_WIN_SEG_COUNT 240
/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed
-maximum size. Define the size of Rx buffer for TCP sockets. */
-#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
+ * maximum size. Define the size of Rx buffer for TCP sockets. */
+#define ipconfigTCP_RX_BUFFER_LENGTH ( 1000 )
/* Define the size of Tx buffer for TCP sockets. */
-#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
+#define ipconfigTCP_TX_BUFFER_LENGTH ( 1000 )
/* When using call-back handlers, the driver may check if the handler points to
-real program memory (RAM or flash) or just has a random non-zero value. */
-#define ipconfigIS_VALID_PROG_ADDRESS(x) ( (x) != NULL )
+ * real program memory (RAM or flash) or just has a random non-zero value. */
+#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL )
/* Include support for TCP hang protection. All sockets in a connecting or
-disconnecting stage will timeout after a period of non-activity. */
-#define ipconfigTCP_HANG_PROTECTION ( 1 )
-#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
+ * disconnecting stage will timeout after a period of non-activity. */
+#define ipconfigTCP_HANG_PROTECTION ( 1 )
+#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 )
/* Include support for TCP keep-alive messages. */
-#define ipconfigTCP_KEEP_ALIVE ( 1 )
-#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
+#define ipconfigTCP_KEEP_ALIVE ( 1 )
+#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */
-#define portINLINE __inline
+#define portINLINE __inline
#endif /* FREERTOS_IP_CONFIG_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h
index d9b063bf8..ee2402255 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h
@@ -47,68 +47,68 @@
*/
#ifndef ATOMIC_H
-#define ATOMIC_H
+ #define ATOMIC_H
-#ifndef INC_FREERTOS_H
- #error "include FreeRTOS.h must appear in source files before include atomic.h"
-#endif
+ #ifndef INC_FREERTOS_H
+ #error "include FreeRTOS.h must appear in source files before include atomic.h"
+ #endif
/* Standard includes. */
-#include <stdint.h>
+ #include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- /* Needed for __atomic_compare_exchange() weak=false. */
- #include <stdbool.h>
+/* Needed for __atomic_compare_exchange() weak=false. */
+ #include <stdbool.h>
- /* This branch is for GCC compiler and GCC compiler only. */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE inline __attribute__((always_inline))
- #endif
+/* This branch is for GCC compiler and GCC compiler only. */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE inline __attribute__( ( always_inline ) )
+ #endif
-#else
+ #else
- /* Port specific definitions -- entering/exiting critical section.
- * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
- *
- * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
- * ATOMIC_ENTER_CRITICAL().
- */
- #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
+/* Port specific definitions -- entering/exiting critical section.
+ * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
+ *
+ * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
+ * ATOMIC_ENTER_CRITICAL().
+ */
+ #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
- /* Nested interrupt scheme is supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() \
- UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
+/* Nested interrupt scheme is supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() \
+ UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
- #define ATOMIC_EXIT_CRITICAL() \
- portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
+ #define ATOMIC_EXIT_CRITICAL() \
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
- #else
+ #else
- /* Nested interrupt scheme is NOT supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
- #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
+/* Nested interrupt scheme is NOT supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
+ #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
- #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
+ #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
- /* Port specific definition -- "always inline".
- * Inline is compiler specific, and may not always get inlined depending on your optimization level.
- * For atomic operations, inline is considered a performance optimization.
- * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
- * simply define it.
- */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE
- #endif
+/* Port specific definition -- "always inline".
+ * Inline is compiler specific, and may not always get inlined depending on your optimization level.
+ * For atomic operations, inline is considered a performance optimization.
+ * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
+ * simply define it.
+ */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE
+ #endif
-#endif /* configUSE_GCC_BUILTIN_ATOMICS */
+ #endif /* configUSE_GCC_BUILTIN_ATOMICS */
-#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
-#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
+ #define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
+ #define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
/*----------------------------- Swap && CAS ------------------------------*/
@@ -127,44 +127,36 @@ extern "C" {
* @note This function only swaps *pDestination with ulExchange, if previous
* *pDestination value equals ulComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
- uint32_t volatile * pDestination,
- uint32_t ulExchange,
- uint32_t ulComparand )
-{
-
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- if ( __atomic_compare_exchange( pDestination,
- &ulComparand,
- &ulExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pDestination,
+ uint32_t ulExchange,
+ uint32_t ulComparand )
{
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( pDestination,
+ &ulComparand,
+ &ulExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *pDestination == ulComparand )
+ {
+ *pDestination = ulExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *pDestination == ulComparand )
- {
- *pDestination = ulExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-
-}
-
/**
* Atomic swap (pointers)
*
@@ -177,30 +169,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
*
* @return The initial value of *ppDestination.
*/
-static portFORCE_INLINE void * Atomic_SwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange )
-{
- void * pReturnValue;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange )
+ {
+ void * pReturnValue;
- pReturnValue = *ppDestination;
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
+ #else
+ ATOMIC_ENTER_CRITICAL();
- *ppDestination = pExchange;
+ pReturnValue = *ppDestination;
- ATOMIC_EXIT_CRITICAL();
+ *ppDestination = pExchange;
-#endif
+ ATOMIC_EXIT_CRITICAL();
+ #endif
- return pReturnValue;
-}
+ return pReturnValue;
+ }
/**
* Atomic compare-and-swap (pointers)
@@ -218,40 +205,36 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32(
* @note This function only swaps *ppDestination with pExchange, if previous
* *ppDestination value equals pComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange, void * pComparand )
-{
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- if ( __atomic_compare_exchange( ppDestination,
- &pComparand,
- &pExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
- {
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *ppDestination == pComparand )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange,
+ void * pComparand )
{
- *ppDestination = pExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( ppDestination,
+ &pComparand,
+ &pExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *ppDestination == pComparand )
+ {
+ *ppDestination = pExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-}
-
/*----------------------------- Arithmetic ------------------------------*/
@@ -266,30 +249,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Add_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic subtract
@@ -303,30 +281,25 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic increment
@@ -338,28 +311,24 @@ static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
*
* @return *pAddend value before increment.
*/
-static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic decrement
@@ -371,28 +340,24 @@ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAdde
*
* @return *pAddend value before decrement.
*/
-static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/*----------------------------- Bitwise Logical ------------------------------*/
@@ -407,30 +372,25 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_OR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_or(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_or( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination |= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination |= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic AND
@@ -443,30 +403,25 @@ static portFORCE_INLINE uint32_t Atomic_OR_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_AND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_and(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_and( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination &= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination &= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic NAND
@@ -479,30 +434,25 @@ static portFORCE_INLINE uint32_t Atomic_AND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_NAND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_nand(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_nand( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination = ~(ulCurrent & ulValue);
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination = ~( ulCurrent & ulValue );
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic XOR
@@ -515,33 +465,28 @@ static portFORCE_INLINE uint32_t Atomic_NAND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_XOR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_xor(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_xor( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination ^= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination ^= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
-#ifdef __cplusplus
-}
-#endif
+ #ifdef __cplusplus
+ }
+ #endif
#endif /* ATOMIC_H */
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c
index 3c46ff835..e6aa16c3e 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c
@@ -57,19 +57,19 @@
/*-----------------------------------------------------------*/
/* The maximum size to which the log file may grow, before being renamed
-to .ful. */
-#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
+ * to .ful. */
+#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
/* Dimensions the arrays into which print messages are created. */
-#define dlMAX_PRINT_STRING_LENGTH 255
+#define dlMAX_PRINT_STRING_LENGTH 255
/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
-the Win32 thread that is responsible for making any Win32 system calls that are
-necessary for the selected logging method. */
-#define dlLOGGING_STREAM_BUFFER_SIZE 32768
+ * the Win32 thread that is responsible for making any Win32 system calls that are
+ * necessary for the selected logging method. */
+#define dlLOGGING_STREAM_BUFFER_SIZE 32768
/* A block time of zero simply means don't block. */
-#define dlDONT_BLOCK 0
+#define dlDONT_BLOCK 0
/*-----------------------------------------------------------*/
@@ -81,7 +81,8 @@ static void prvFileLoggingInit( void );
/*
* Attempt to write a message to the file.
*/
-static void prvLogToFile( const char *pcMessage, size_t xLength );
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength );
/*
* Simply close the logging file, if it is open.
@@ -102,7 +103,7 @@ static void prvLoggingFlushBuffer( void );
* Win32 system calls. Only the windows thread can make system calls so as not
* to disrupt the simulation by making Windows calls from FreeRTOS tasks.
*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
+static DWORD WINAPI prvWin32LoggingThread( void * pvParam );
/*
* Creates the socket to which UDP messages are sent. This function is not
@@ -110,417 +111,426 @@ static DWORD WINAPI prvWin32LoggingThread( void *pvParam );
* task - which could result in a deadlock. Instead the function call is
* deferred to run in the RTOS daemon task - hence it prototype.
*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 );
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 );
/*-----------------------------------------------------------*/
/* Windows event used to wake the Win32 thread which performs any logging that
-needs Win32 system calls. */
-static void *pvLoggingThreadEvent = NULL;
+ * needs Win32 system calls. */
+static void * pvLoggingThreadEvent = NULL;
/* Stores the selected logging targets passed in as parameters to the
-vLoggingInit() function. */
-BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
+ * vLoggingInit() function. */
+BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
-thread that is responsible for making Win32 calls (when stdout or a disk log is
-used). */
-static StreamBuffer_t *xLogStreamBuffer = NULL;
+ * thread that is responsible for making Win32 calls (when stdout or a disk log is
+ * used). */
+static StreamBuffer_t * xLogStreamBuffer = NULL;
/* Handle to the file used for logging. This is left open while there are
-messages waiting to be logged, then closed again in between logs. */
-static FILE *pxLoggingFileHandle = NULL;
+ * messages waiting to be logged, then closed again in between logs. */
+static FILE * pxLoggingFileHandle = NULL;
/* When true prints are performed directly. After start up xDirectPrint is set
-to pdFALSE - at which time prints that require Win32 system calls are done by
-the Win32 thread responsible for logging. */
-BaseType_t xDirectPrint = pdTRUE;
+ * to pdFALSE - at which time prints that require Win32 system calls are done by
+ * the Win32 thread responsible for logging. */
+BaseType_t xDirectPrint = pdTRUE;
/* File names for the in use and complete (full) log files. */
-static const char *pcLogFileName = "RTOSDemo.log";
-static const char *pcFullLogFileName = "RTOSDemo.ful";
+static const char * pcLogFileName = "RTOSDemo.log";
+static const char * pcFullLogFileName = "RTOSDemo.ful";
/* As an optimization, the current file size is kept in a variable. */
-static size_t ulSizeOfLoggingFile = 0ul;
+static size_t ulSizeOfLoggingFile = 0ul;
/* The UDP socket and address on/to which print messages are sent. */
-Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
+Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
struct freertos_sockaddr xPrintUDPAddress;
/*-----------------------------------------------------------*/
-void vLoggingInit( BaseType_t xLogToStdout, BaseType_t xLogToFile, BaseType_t xLogToUDP, uint32_t ulRemoteIPAddress, uint16_t usRemotePort )
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort )
{
- /* Can only be called before the scheduler has started. */
- configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
-
- #if( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
- {
- HANDLE Win32Thread;
-
- /* Record which output methods are to be used. */
- xStdoutLoggingUsed = xLogToStdout;
- xDiskFileLoggingUsed = xLogToFile;
- xUDPLoggingUsed = xLogToUDP;
-
- /* If a disk file is used then initialize it now. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvFileLoggingInit();
- }
-
- /* If UDP logging is used then store the address to which the log data
- will be sent - but don't create the socket yet because the network is
- not initialized. */
- if( xUDPLoggingUsed != pdFALSE )
- {
- /* Set the address to which the print messages are sent. */
- xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
- xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
- }
-
- /* If a disk file or stdout are to be used then Win32 system calls will
- have to be made. Such system calls cannot be made from FreeRTOS tasks
- so create a stream buffer to pass the messages to a Win32 thread, then
- create the thread itself, along with a Win32 event that can be used to
- unblock the thread. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- /* Create the buffer. */
- xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
- configASSERT( xLogStreamBuffer );
- memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
- xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
-
- /* Create the Windows event. */
- pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
-
- /* Create the thread itself. */
- Win32Thread = CreateThread(
- NULL, /* Pointer to thread security attributes. */
- 0, /* Initial thread stack size, in bytes. */
- prvWin32LoggingThread, /* Pointer to thread function. */
- NULL, /* Argument for new thread. */
- 0, /* Creation flags. */
- NULL );
-
- /* Use the cores that are not used by the FreeRTOS tasks. */
- SetThreadAffinityMask( Win32Thread, ~0x01u );
- SetThreadPriorityBoost( Win32Thread, TRUE );
- SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
- }
- }
- #else
- {
- /* FreeRTOSIPConfig is set such that no print messages will be output.
- Avoid compiler warnings about unused parameters. */
- ( void ) xLogToStdout;
- ( void ) xLogToFile;
- ( void ) xLogToUDP;
- ( void ) usRemotePort;
- ( void ) ulRemoteIPAddress;
- }
- #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
+ /* Can only be called before the scheduler has started. */
+ configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
+
+ #if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
+ {
+ HANDLE Win32Thread;
+
+ /* Record which output methods are to be used. */
+ xStdoutLoggingUsed = xLogToStdout;
+ xDiskFileLoggingUsed = xLogToFile;
+ xUDPLoggingUsed = xLogToUDP;
+
+ /* If a disk file is used then initialize it now. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvFileLoggingInit();
+ }
+
+ /* If UDP logging is used then store the address to which the log data
+ * will be sent - but don't create the socket yet because the network is
+ * not initialized. */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ /* Set the address to which the print messages are sent. */
+ xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
+ xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
+ }
+
+ /* If a disk file or stdout are to be used then Win32 system calls will
+ * have to be made. Such system calls cannot be made from FreeRTOS tasks
+ * so create a stream buffer to pass the messages to a Win32 thread, then
+ * create the thread itself, along with a Win32 event that can be used to
+ * unblock the thread. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ /* Create the buffer. */
+ xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
+ configASSERT( xLogStreamBuffer );
+ memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
+ xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
+
+ /* Create the Windows event. */
+ pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
+
+ /* Create the thread itself. */
+ Win32Thread = CreateThread(
+ NULL, /* Pointer to thread security attributes. */
+ 0, /* Initial thread stack size, in bytes. */
+ prvWin32LoggingThread, /* Pointer to thread function. */
+ NULL, /* Argument for new thread. */
+ 0, /* Creation flags. */
+ NULL );
+
+ /* Use the cores that are not used by the FreeRTOS tasks. */
+ SetThreadAffinityMask( Win32Thread, ~0x01u );
+ SetThreadPriorityBoost( Win32Thread, TRUE );
+ SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
+ }
+ }
+ #else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */
+ {
+ /* FreeRTOSIPConfig is set such that no print messages will be output.
+ * Avoid compiler warnings about unused parameters. */
+ ( void ) xLogToStdout;
+ ( void ) xLogToFile;
+ ( void ) xLogToUDP;
+ ( void ) usRemotePort;
+ ( void ) ulRemoteIPAddress;
+ }
+ #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
}
/*-----------------------------------------------------------*/
-static void prvCreatePrintSocket( void *pvParameter1, uint32_t ulParameter2 )
+static void prvCreatePrintSocket( void * pvParameter1,
+ uint32_t ulParameter2 )
{
-static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
-Socket_t xSocket;
+ static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
+ Socket_t xSocket;
- /* The function prototype is that of a deferred function, but the parameters
- are not actually used. */
- ( void ) pvParameter1;
- ( void ) ulParameter2;
+ /* The function prototype is that of a deferred function, but the parameters
+ * are not actually used. */
+ ( void ) pvParameter1;
+ ( void ) ulParameter2;
- xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
+ xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
- if( xSocket != FREERTOS_INVALID_SOCKET )
- {
- /* FreeRTOS+TCP decides which port to bind to. */
- FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
- FreeRTOS_bind( xSocket, NULL, 0 );
+ if( xSocket != FREERTOS_INVALID_SOCKET )
+ {
+ /* FreeRTOS+TCP decides which port to bind to. */
+ FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
+ FreeRTOS_bind( xSocket, NULL, 0 );
- /* Now the socket is bound it can be assigned to the print socket. */
- xPrintSocket = xSocket;
- }
+ /* Now the socket is bound it can be assigned to the print socket. */
+ xPrintSocket = xSocket;
+ }
}
/*-----------------------------------------------------------*/
-void vLoggingPrintf( const char *pcFormat, ... )
+void vLoggingPrintf( const char * pcFormat,
+ ... )
{
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
-char *pcSource, *pcTarget, *pcBegin;
-size_t xLength, xLength2, rc;
-static BaseType_t xMessageNumber = 0;
-va_list args;
-uint32_t ulIPAddress;
-const char *pcTaskName;
-const char *pcNoTask = "None";
-int iOriginalPriority;
-HANDLE xCurrentTask;
-
-
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
- {
- /* There are a variable number of parameters. */
- va_start( args, pcFormat );
-
- /* Additional info to place at the start of the log. */
- if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
- {
- pcTaskName = pcTaskGetName( NULL );
- }
- else
- {
- pcTaskName = pcNoTask;
- }
-
- if( strcmp( pcFormat, "\n" ) != 0 )
- {
- xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
- xMessageNumber++,
- ( unsigned long ) xTaskGetTickCount(),
- pcTaskName );
- }
- else
- {
- xLength = 0;
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- }
-
- xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
-
- if( xLength2 < 0 )
- {
- /* Clean up. */
- xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
- cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
- }
-
- xLength += xLength2;
- va_end( args );
-
- /* For ease of viewing, copy the string into another buffer, converting
- IP addresses to dot notation on the way. */
- pcSource = cPrintString;
- pcTarget = cOutputString;
-
- while( ( *pcSource ) != '\0' )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- pcSource++;
-
- /* Look forward for an IP address denoted by 'ip'. */
- if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
- {
- *pcTarget = *pcSource;
- pcTarget++;
- *pcTarget = '\0';
- pcBegin = pcTarget - 8;
-
- while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
- {
- pcTarget--;
- }
-
- sscanf( pcTarget, "%8X", &ulIPAddress );
- rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
- ( unsigned long ) ( ulIPAddress >> 24UL ),
- ( unsigned long ) ( (ulIPAddress >> 16UL) & 0xffUL ),
- ( unsigned long ) ( (ulIPAddress >> 8UL) & 0xffUL ),
- ( unsigned long ) ( ulIPAddress & 0xffUL ) );
- pcTarget += rc;
- pcSource += 3; /* skip "<n>ip" */
- }
- }
-
- /* How far through the buffer was written? */
- xLength = ( BaseType_t ) ( pcTarget - cOutputString );
-
- /* If the message is to be logged to a UDP port then it can be sent directly
- because it only uses FreeRTOS function (not Win32 functions). */
- if( xUDPLoggingUsed != pdFALSE )
- {
- if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
- {
- /* Create and bind the socket to which print messages are sent. The
- xTimerPendFunctionCall() function is used even though this is
- not an interrupt because this function is called from the IP task
- and the IP task cannot itself wait for a socket to bind. The
- parameters to prvCreatePrintSocket() are not required so set to
- NULL or 0. */
- xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
- }
-
- if( xPrintSocket != FREERTOS_INVALID_SOCKET )
- {
- FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
-
- /* Just because the UDP data logger I'm using is dumb. */
- FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
- }
- }
-
- /* If logging is also to go to either stdout or a disk file then it cannot
- be output here - so instead write the message to the stream buffer and wake
- the Win32 thread which will read it from the stream buffer and perform the
- actual output. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
- {
- configASSERT( xLogStreamBuffer );
-
- /* How much space is in the buffer? */
- xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
-
- /* There must be enough space to write both the string and the length of
- the string. */
- if( xLength2 >= ( xLength + sizeof( xLength ) ) )
- {
- /* First write in the length of the data, then write in the data
- itself. Raising the thread priority is used as a critical section
- as there are potentially multiple writers. The stream buffer is
- only thread safe when there is a single writer (likewise for
- reading from the buffer). */
- xCurrentTask = GetCurrentThread();
- iOriginalPriority = GetThreadPriority( xCurrentTask );
- SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
- uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
- SetThreadPriority( GetCurrentThread(), iOriginalPriority );
- }
-
- /* xDirectPrint is initialized to pdTRUE, and while it remains true the
- logging output function is called directly. When the system is running
- the output function cannot be called directly because it would get
- called from both FreeRTOS tasks and Win32 threads - so instead wake the
- Win32 thread responsible for the actual output. */
- if( xDirectPrint != pdFALSE )
- {
- /* While starting up, the thread which calls prvWin32LoggingThread()
- is not running yet and xDirectPrint will be pdTRUE. */
- prvLoggingFlushBuffer();
- }
- else if( pvLoggingThreadEvent != NULL )
- {
- /* While running, wake up prvWin32LoggingThread() to send the
- logging data. */
- SetEvent( pvLoggingThreadEvent );
- }
- }
- }
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+ char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
+ char * pcSource, * pcTarget, * pcBegin;
+ size_t xLength, xLength2, rc;
+ static BaseType_t xMessageNumber = 0;
+ va_list args;
+ uint32_t ulIPAddress;
+ const char * pcTaskName;
+ const char * pcNoTask = "None";
+ int iOriginalPriority;
+ HANDLE xCurrentTask;
+
+
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
+ {
+ /* There are a variable number of parameters. */
+ va_start( args, pcFormat );
+
+ /* Additional info to place at the start of the log. */
+ if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
+ {
+ pcTaskName = pcTaskGetName( NULL );
+ }
+ else
+ {
+ pcTaskName = pcNoTask;
+ }
+
+ if( strcmp( pcFormat, "\n" ) != 0 )
+ {
+ xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
+ xMessageNumber++,
+ ( unsigned long ) xTaskGetTickCount(),
+ pcTaskName );
+ }
+ else
+ {
+ xLength = 0;
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ }
+
+ xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
+
+ if( xLength2 < 0 )
+ {
+ /* Clean up. */
+ xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
+ cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
+ }
+
+ xLength += xLength2;
+ va_end( args );
+
+ /* For ease of viewing, copy the string into another buffer, converting
+ * IP addresses to dot notation on the way. */
+ pcSource = cPrintString;
+ pcTarget = cOutputString;
+
+ while( ( *pcSource ) != '\0' )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ pcSource++;
+
+ /* Look forward for an IP address denoted by 'ip'. */
+ if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
+ {
+ *pcTarget = *pcSource;
+ pcTarget++;
+ *pcTarget = '\0';
+ pcBegin = pcTarget - 8;
+
+ while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
+ {
+ pcTarget--;
+ }
+
+ sscanf( pcTarget, "%8X", &ulIPAddress );
+ rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
+ ( unsigned long ) ( ulIPAddress >> 24UL ),
+ ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ),
+ ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ),
+ ( unsigned long ) ( ulIPAddress & 0xffUL ) );
+ pcTarget += rc;
+ pcSource += 3; /* skip "<n>ip" */
+ }
+ }
+
+ /* How far through the buffer was written? */
+ xLength = ( BaseType_t ) ( pcTarget - cOutputString );
+
+ /* If the message is to be logged to a UDP port then it can be sent directly
+ * because it only uses FreeRTOS function (not Win32 functions). */
+ if( xUDPLoggingUsed != pdFALSE )
+ {
+ if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
+ {
+ /* Create and bind the socket to which print messages are sent. The
+ * xTimerPendFunctionCall() function is used even though this is
+ * not an interrupt because this function is called from the IP task
+ * and the IP task cannot itself wait for a socket to bind. The
+ * parameters to prvCreatePrintSocket() are not required so set to
+ * NULL or 0. */
+ xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
+ }
+
+ if( xPrintSocket != FREERTOS_INVALID_SOCKET )
+ {
+ FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+
+ /* Just because the UDP data logger I'm using is dumb. */
+ FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
+ }
+ }
+
+ /* If logging is also to go to either stdout or a disk file then it cannot
+ * be output here - so instead write the message to the stream buffer and wake
+ * the Win32 thread which will read it from the stream buffer and perform the
+ * actual output. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
+ {
+ configASSERT( xLogStreamBuffer );
+
+ /* How much space is in the buffer? */
+ xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
+
+ /* There must be enough space to write both the string and the length of
+ * the string. */
+ if( xLength2 >= ( xLength + sizeof( xLength ) ) )
+ {
+ /* First write in the length of the data, then write in the data
+ * itself. Raising the thread priority is used as a critical section
+ * as there are potentially multiple writers. The stream buffer is
+ * only thread safe when there is a single writer (likewise for
+ * reading from the buffer). */
+ xCurrentTask = GetCurrentThread();
+ iOriginalPriority = GetThreadPriority( xCurrentTask );
+ SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
+ uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
+ SetThreadPriority( GetCurrentThread(), iOriginalPriority );
+ }
+
+ /* xDirectPrint is initialized to pdTRUE, and while it remains true the
+ * logging output function is called directly. When the system is running
+ * the output function cannot be called directly because it would get
+ * called from both FreeRTOS tasks and Win32 threads - so instead wake the
+ * Win32 thread responsible for the actual output. */
+ if( xDirectPrint != pdFALSE )
+ {
+ /* While starting up, the thread which calls prvWin32LoggingThread()
+ * is not running yet and xDirectPrint will be pdTRUE. */
+ prvLoggingFlushBuffer();
+ }
+ else if( pvLoggingThreadEvent != NULL )
+ {
+ /* While running, wake up prvWin32LoggingThread() to send the
+ * logging data. */
+ SetEvent( pvLoggingThreadEvent );
+ }
+ }
+ }
}
/*-----------------------------------------------------------*/
static void prvLoggingFlushBuffer( void )
{
-size_t xLength;
-char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
-
- /* Is there more than the length value stored in the circular buffer
- used to pass data from the FreeRTOS simulator into this Win32 thread? */
- while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
- {
- memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
- uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
-
- /* Write the message to standard out if requested to do so when
- vLoggingInit() was called, or if the network is not yet up. */
- if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
- {
- /* Write the message to stdout. */
- _write( _fileno(stdout), cPrintString, strlen( cPrintString ) );
- }
-
- /* Write the message to a file if requested to do so when
- vLoggingInit() was called. */
- if( xDiskFileLoggingUsed != pdFALSE )
- {
- prvLogToFile( cPrintString, xLength );
- }
- }
-
- prvFileClose();
+ size_t xLength;
+ char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
+
+ /* Is there more than the length value stored in the circular buffer
+ * used to pass data from the FreeRTOS simulator into this Win32 thread? */
+ while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
+ {
+ memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
+ uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
+
+ /* Write the message to standard out if requested to do so when
+ * vLoggingInit() was called, or if the network is not yet up. */
+ if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
+ {
+ /* Write the message to stdout. */
+ _write( _fileno( stdout ), cPrintString, strlen( cPrintString ) );
+ }
+
+ /* Write the message to a file if requested to do so when
+ * vLoggingInit() was called. */
+ if( xDiskFileLoggingUsed != pdFALSE )
+ {
+ prvLogToFile( cPrintString, xLength );
+ }
+ }
+
+ prvFileClose();
}
/*-----------------------------------------------------------*/
-static DWORD WINAPI prvWin32LoggingThread( void *pvParameter )
+static DWORD WINAPI prvWin32LoggingThread( void * pvParameter )
{
-const DWORD xMaxWait = 1000;
+ const DWORD xMaxWait = 1000;
- ( void ) pvParameter;
+ ( void ) pvParameter;
- /* From now on, prvLoggingFlushBuffer() will only be called from this
- Windows thread */
- xDirectPrint = pdFALSE;
+ /* From now on, prvLoggingFlushBuffer() will only be called from this
+ * Windows thread */
+ xDirectPrint = pdFALSE;
- for( ;; )
- {
- /* Wait to be told there are message waiting to be logged. */
- WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
+ for( ; ; )
+ {
+ /* Wait to be told there are message waiting to be logged. */
+ WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
- /* Write out all waiting messages. */
- prvLoggingFlushBuffer();
- }
+ /* Write out all waiting messages. */
+ prvLoggingFlushBuffer();
+ }
}
/*-----------------------------------------------------------*/
static void prvFileLoggingInit( void )
{
-FILE *pxHandle = fopen( pcLogFileName, "a" );
-
- if( pxHandle != NULL )
- {
- fseek( pxHandle, SEEK_END, 0ul );
- ulSizeOfLoggingFile = ftell( pxHandle );
- fclose( pxHandle );
- }
- else
- {
- ulSizeOfLoggingFile = 0ul;
- }
+ FILE * pxHandle = fopen( pcLogFileName, "a" );
+
+ if( pxHandle != NULL )
+ {
+ fseek( pxHandle, SEEK_END, 0ul );
+ ulSizeOfLoggingFile = ftell( pxHandle );
+ fclose( pxHandle );
+ }
+ else
+ {
+ ulSizeOfLoggingFile = 0ul;
+ }
}
/*-----------------------------------------------------------*/
static void prvFileClose( void )
{
- if( pxLoggingFileHandle != NULL )
- {
- fclose( pxLoggingFileHandle );
- pxLoggingFileHandle = NULL;
- }
+ if( pxLoggingFileHandle != NULL )
+ {
+ fclose( pxLoggingFileHandle );
+ pxLoggingFileHandle = NULL;
+ }
}
/*-----------------------------------------------------------*/
-static void prvLogToFile( const char *pcMessage, size_t xLength )
+static void prvLogToFile( const char * pcMessage,
+ size_t xLength )
{
- if( pxLoggingFileHandle == NULL )
- {
- pxLoggingFileHandle = fopen( pcLogFileName, "a" );
- }
-
- if( pxLoggingFileHandle != NULL )
- {
- fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
- ulSizeOfLoggingFile += xLength;
-
- /* If the file has grown to its maximum permissible size then close and
- rename it - then start with a new file. */
- if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
- {
- prvFileClose();
- if( _access( pcFullLogFileName, 00 ) == 0 )
- {
- remove( pcFullLogFileName );
- }
- rename( pcLogFileName, pcFullLogFileName );
- ulSizeOfLoggingFile = 0;
- }
- }
+ if( pxLoggingFileHandle == NULL )
+ {
+ pxLoggingFileHandle = fopen( pcLogFileName, "a" );
+ }
+
+ if( pxLoggingFileHandle != NULL )
+ {
+ fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
+ ulSizeOfLoggingFile += xLength;
+
+ /* If the file has grown to its maximum permissible size then close and
+ * rename it - then start with a new file. */
+ if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
+ {
+ prvFileClose();
+
+ if( _access( pcFullLogFileName, 00 ) == 0 )
+ {
+ remove( pcFullLogFileName );
+ }
+
+ rename( pcLogFileName, pcFullLogFileName );
+ ulSizeOfLoggingFile = 0;
+ }
+ }
}
/*-----------------------------------------------------------*/
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.h
index 2cc068ce9..773cc0d75 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.h
@@ -38,11 +38,10 @@
* If xLogToUDP is pdTRUE then ulRemoteIPAddress and usRemotePort must be set
* to the IP address and port number to which UDP log messages will be sent.
*/
-void vLoggingInit( BaseType_t xLogToStdout,
- BaseType_t xLogToFile,
- BaseType_t xLogToUDP,
- uint32_t ulRemoteIPAddress,
- uint16_t usRemotePort );
+void vLoggingInit( BaseType_t xLogToStdout,
+ BaseType_t xLogToFile,
+ BaseType_t xLogToUDP,
+ uint32_t ulRemoteIPAddress,
+ uint16_t usRemotePort );
#endif /* DEMO_LOGGING_H */
-
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c
index b89b1e333..2bf56e74c 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c
@@ -34,7 +34,7 @@
#include <time.h>
/* Visual studio intrinsics used so the __debugbreak() function is available
-should an assert get hit. */
+ * should an assert get hit. */
#include <intrin.h>
/* FreeRTOS includes. */
@@ -73,29 +73,29 @@ static void prvSRand( UBaseType_t ulSeed );
static void prvMiscInitialisation( void );
/* The default IP and MAC address used by the demo. The address configuration
-defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
-1 but a DHCP server could not be contacted. See the online documentation for
-more information. */
+ * defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
+ * 1 but a DHCP server could not be contacted. See the online documentation for
+ * more information. */
static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };
static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };
static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };
/* Set the following constant to pdTRUE to log using the method indicated by the
-name of the constant, or pdFALSE to not log using the method indicated by the
-name of the constant. Options include to standard out (xLogToStdout), to a disk
-file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
-then UDP messages are sent to the IP address configured as the echo server
-address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
-the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
+ * name of the constant, or pdFALSE to not log using the method indicated by the
+ * name of the constant. Options include to standard out (xLogToStdout), to a disk
+ * file (xLogToFile), and to a UDP port (xLogToUDP). If xLogToUDP is set to pdTRUE
+ * then UDP messages are sent to the IP address configured as the echo server
+ * address (see the configECHO_SERVER_ADDR0 definitions in FreeRTOSConfig.h) and
+ * the port number set by configPRINT_PORT in FreeRTOSConfig.h. */
const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALSE;
/* Default MAC address configuration. The demo creates a virtual network
-connection that uses this MAC address by accessing the raw Ethernet data
-to and from a real network connection on the host PC. See the
-configNETWORK_INTERFACE_TO_USE definition for information on how to configure
-the real network connection to use. */
-const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
+ * connection that uses this MAC address by accessing the raw Ethernet data
+ * to and from a real network connection on the host PC. See the
+ * configNETWORK_INTERFACE_TO_USE definition for information on how to configure
+ * the real network connection to use. */
+const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
/* Use by the pseudo random number generator. */
static UBaseType_t ulNextRand;
@@ -103,186 +103,186 @@ static UBaseType_t ulNextRand;
int main( void )
{
- /***
- * See https://www.FreeRTOS.org/shadow/index.html for configuration and usage instructions.
- ***/
-
- /* Miscellaneous initialization including preparing the logging and seeding
- the random number generator. */
- prvMiscInitialisation();
-
- /* Initialize the network interface.
-
- ***NOTE*** Tasks that use the network are created in the network event hook
- when the network is connected and ready for use (see the implementation of
- vApplicationIPNetworkEventHook() below). The address values passed in here
- are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
- but a DHCP server cannot be contacted. */
- FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
-
- /* Start the RTOS scheduler. */
- vTaskStartScheduler();
-
- /* If all is well, the scheduler will now be running, and the following
- line will never be reached. If the following line does execute, then
- there was insufficient FreeRTOS heap memory available for the idle and/or
- timer tasks to be created. See the memory management section on the
- FreeRTOS web site for more details (this is standard text that is not
- really applicable to the Win32 simulator port). */
- for( ; ; )
- {
- __debugbreak();
- }
+ /***
+ * See https://www.FreeRTOS.org/shadow/index.html for configuration and usage instructions.
+ ***/
+
+ /* Miscellaneous initialization including preparing the logging and seeding
+ * the random number generator. */
+ prvMiscInitialisation();
+
+ /* Initialize the network interface.
+ *
+ ***NOTE*** Tasks that use the network are created in the network event hook
+ * when the network is connected and ready for use (see the implementation of
+ * vApplicationIPNetworkEventHook() below). The address values passed in here
+ * are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
+ * but a DHCP server cannot be contacted. */
+ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
+
+ /* Start the RTOS scheduler. */
+ vTaskStartScheduler();
+
+ /* If all is well, the scheduler will now be running, and the following
+ * line will never be reached. If the following line does execute, then
+ * there was insufficient FreeRTOS heap memory available for the idle and/or
+ * timer tasks to be created. See the memory management section on the
+ * FreeRTOS web site for more details (this is standard text that is not
+ * really applicable to the Win32 simulator port). */
+ for( ; ; )
+ {
+ __debugbreak();
+ }
}
/*-----------------------------------------------------------*/
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
-events are only received if implemented in the MAC driver. */
+ * events are only received if implemented in the MAC driver. */
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
-uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
-char cBuffer[ 16 ];
-static BaseType_t xTasksAlreadyCreated = pdFALSE;
-
- /* If the network has just come up...*/
- if( eNetworkEvent == eNetworkUp )
- {
- /* Create the tasks that use the IP stack if they have not already been
- created. */
- if( xTasksAlreadyCreated == pdFALSE )
- {
- /* Demos that use the network are created after the network is
- up. */
- configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
- vStartShadowDeviceOperationsDemo();
- xTasksAlreadyCreated = pdTRUE;
- }
-
- /* Print out the network configuration, which may have come from a DHCP
- server. */
- FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
- FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
- FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
- FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
- FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
-
- FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
- FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
- }
+ uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
+ char cBuffer[ 16 ];
+ static BaseType_t xTasksAlreadyCreated = pdFALSE;
+
+ /* If the network has just come up...*/
+ if( eNetworkEvent == eNetworkUp )
+ {
+ /* Create the tasks that use the IP stack if they have not already been
+ * created. */
+ if( xTasksAlreadyCreated == pdFALSE )
+ {
+ /* Demos that use the network are created after the network is
+ * up. */
+ configPRINTF( ( "---------STARTING DEMO---------\r\n" ) );
+ vStartShadowDeviceOperationsDemo();
+ xTasksAlreadyCreated = pdTRUE;
+ }
+
+ /* Print out the network configuration, which may have come from a DHCP
+ * server. */
+ FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
+ FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
+ FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
+ FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
+ FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
+
+ FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
+ FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
+ }
}
/*-----------------------------------------------------------*/
-void vAssertCalled( const char *pcFile,
- uint32_t ulLine )
+void vAssertCalled( const char * pcFile,
+ uint32_t ulLine )
{
-volatile uint32_t ulBlockVariable = 0UL;
-volatile char *pcFileName = ( volatile char * ) pcFile;
-volatile uint32_t ulLineNumber = ulLine;
-
- ( void ) pcFileName;
- ( void ) ulLineNumber;
-
- printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
-
- /* Setting ulBlockVariable to a non-zero value in the debugger will allow
- this function to be exited. */
- taskDISABLE_INTERRUPTS();
- {
- while( ulBlockVariable == 0UL )
- {
- __debugbreak();
- }
- }
- taskENABLE_INTERRUPTS();
+ volatile uint32_t ulBlockVariable = 0UL;
+ volatile char * pcFileName = ( volatile char * ) pcFile;
+ volatile uint32_t ulLineNumber = ulLine;
+
+ ( void ) pcFileName;
+ ( void ) ulLineNumber;
+
+ printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
+
+ /* Setting ulBlockVariable to a non-zero value in the debugger will allow
+ * this function to be exited. */
+ taskDISABLE_INTERRUPTS();
+ {
+ while( ulBlockVariable == 0UL )
+ {
+ __debugbreak();
+ }
+ }
+ taskENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/
UBaseType_t uxRand( void )
{
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
-
- /*
- * Utility function to generate a pseudo random number.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
- return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
+ const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
+
+ /*
+ * Utility function to generate a pseudo random number.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
+ return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
}
/*-----------------------------------------------------------*/
static void prvSRand( UBaseType_t ulSeed )
{
- /* Utility function to seed the pseudo random number generator. */
- ulNextRand = ulSeed;
+ /* Utility function to seed the pseudo random number generator. */
+ ulNextRand = ulSeed;
}
/*-----------------------------------------------------------*/
static void prvMiscInitialisation( void )
{
-time_t xTimeNow;
-uint32_t ulLoggingIPAddress;
-
- ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
- vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
-
- /*
- * Seed random number generator.
- *
- * !!!NOTE!!!
- * This is not a secure method of generating a random number. Production
- * devices should use a True Random Number Generator (TRNG).
- */
- time( &xTimeNow );
- FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
- prvSRand( ( uint32_t ) xTimeNow );
- FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
+ time_t xTimeNow;
+ uint32_t ulLoggingIPAddress;
+
+ ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
+ vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
+
+ /*
+ * Seed random number generator.
+ *
+ * !!!NOTE!!!
+ * This is not a secure method of generating a random number. Production
+ * devices should use a True Random Number Generator (TRNG).
+ */
+ time( &xTimeNow );
+ FreeRTOS_debug_printf( ( "Seed for randomizer: %lu\n", xTimeNow ) );
+ prvSRand( ( uint32_t ) xTimeNow );
+ FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
}
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
- const char * pcApplicationHostnameHook( void )
- {
- /* Assign the name "FreeRTOS" to this network node. This function will
- be called during the DHCP: the machine will be registered with an IP
- address plus this name. */
- return mainHOST_NAME;
- }
+ const char * pcApplicationHostnameHook( void )
+ {
+ /* Assign the name "FreeRTOS" to this network node. This function will
+ * be called during the DHCP: the machine will be registered with an IP
+ * address plus this name. */
+ return mainHOST_NAME;
+ }
#endif
/*-----------------------------------------------------------*/
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 )
- BaseType_t xApplicationDNSQueryHook( const char *pcName )
- {
- BaseType_t xReturn;
-
- /* Determine if a name lookup is for this node. Two names are given
- to this node: that returned by pcApplicationHostnameHook() and that set
- by mainDEVICE_NICK_NAME. */
- if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
- {
- xReturn = pdPASS;
- }
- else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
- {
- xReturn = pdPASS;
- }
- else
- {
- xReturn = pdFAIL;
- }
-
- return xReturn;
- }
+ BaseType_t xApplicationDNSQueryHook( const char * pcName )
+ {
+ BaseType_t xReturn;
+
+ /* Determine if a name lookup is for this node. Two names are given
+ * to this node: that returned by pcApplicationHostnameHook() and that set
+ * by mainDEVICE_NICK_NAME. */
+ if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 )
+ {
+ xReturn = pdPASS;
+ }
+ else
+ {
+ xReturn = pdFAIL;
+ }
+
+ return xReturn;
+ }
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
/*-----------------------------------------------------------*/
@@ -294,85 +294,85 @@ uint32_t ulLoggingIPAddress;
* SYSTEMS.
*/
extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
- uint16_t usSourcePort,
- uint32_t ulDestinationAddress,
- uint16_t usDestinationPort )
+ uint16_t usSourcePort,
+ uint32_t ulDestinationAddress,
+ uint16_t usDestinationPort )
{
- ( void ) ulSourceAddress;
- ( void ) usSourcePort;
- ( void ) ulDestinationAddress;
- ( void ) usDestinationPort;
+ ( void ) ulSourceAddress;
+ ( void ) usSourcePort;
+ ( void ) ulDestinationAddress;
+ ( void ) usDestinationPort;
- return uxRand();
+ return uxRand();
}
/*-----------------------------------------------------------*/
/*
* Set *pulNumber to a random number, and return pdTRUE. When the random number
* generator is broken, it shall return pdFALSE.
- * The macros ipconfigRAND32() and configRAND32() are not in use
+ * The macros ipconfigRAND32() and configRAND32() are not in use
* anymore in FreeRTOS+TCP.
- *
+ *
* THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS
* NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.
*/
BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
{
- *pulNumber = uxRand();
- return pdTRUE;
+ *pulNumber = uxRand();
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
-implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
-used by the Idle task. */
+ * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
+ * used by the Idle task. */
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
- StackType_t ** ppxIdleTaskStackBuffer,
- uint32_t * pulIdleTaskStackSize )
+ StackType_t ** ppxIdleTaskStackBuffer,
+ uint32_t * pulIdleTaskStackSize )
{
- /* If the buffers to be provided to the Idle task are declared inside this
- function then they must be declared static - otherwise they will be allocated on
- the stack and so not exists after this function exits. */
- static StaticTask_t xIdleTaskTCB;
- static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
- state will be stored. */
- *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
-
- /* Pass out the array that will be used as the Idle task's stack. */
- *ppxIdleTaskStackBuffer = uxIdleTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
- Note that, as the array is necessarily of type StackType_t,
- configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+ /* If the buffers to be provided to the Idle task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xIdleTaskTCB;
+ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
+ * state will be stored. */
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+
+ /* Pass out the array that will be used as the Idle task's stack. */
+ *ppxIdleTaskStackBuffer = uxIdleTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
-application must provide an implementation of vApplicationGetTimerTaskMemory()
-to provide the memory that is used by the Timer service task. */
+ * application must provide an implementation of vApplicationGetTimerTaskMemory()
+ * to provide the memory that is used by the Timer service task. */
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
- StackType_t ** ppxTimerTaskStackBuffer,
- uint32_t * pulTimerTaskStackSize )
+ StackType_t ** ppxTimerTaskStackBuffer,
+ uint32_t * pulTimerTaskStackSize )
{
- /* If the buffers to be provided to the Timer task are declared inside this
- function then they must be declared static - otherwise they will be allocated on
- the stack and so not exists after this function exits. */
- static StaticTask_t xTimerTaskTCB;
- static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
-
- /* Pass out a pointer to the StaticTask_t structure in which the Timer
- task's state will be stored. */
- *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
-
- /* Pass out the array that will be used as the Timer task's stack. */
- *ppxTimerTaskStackBuffer = uxTimerTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
- Note that, as the array is necessarily of type StackType_t,
- configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+ /* If the buffers to be provided to the Timer task are declared inside this
+ * function then they must be declared static - otherwise they will be allocated on
+ * the stack and so not exists after this function exits. */
+ static StaticTask_t xTimerTaskTCB;
+ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
+
+ /* Pass out a pointer to the StaticTask_t structure in which the Timer
+ * task's state will be stored. */
+ *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+
+ /* Pass out the array that will be used as the Timer task's stack. */
+ *ppxTimerTaskStackBuffer = uxTimerTaskStack;
+
+ /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
+ * Note that, as the array is necessarily of type StackType_t,
+ * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+ *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c
index 84b87b2a4..f9bc5b5b1 100755..100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c
@@ -1,21 +1,21 @@
/*
- Copyright 2001, 2002 Georges Menie (www.menie.org)
- stdarg version contributed by Christian Ettinger
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Changes for the FreeRTOS ports:
-
- - The dot in "%-8.8s"
- - The specifiers 'l' (long) and 'L' (long long)
- - The specifier 'u' for unsigned
- - Dot notation for IP addresses:
- sprintf("IP = %xip\n", 0xC0A80164);
- will produce "IP = 192.168.1.100\n"
-*/
+ * Copyright 2001, 2002 Georges Menie (www.menie.org)
+ * stdarg version contributed by Christian Ettinger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Changes for the FreeRTOS ports:
+ *
+ * - The dot in "%-8.8s"
+ * - The specifiers 'l' (long) and 'L' (long long)
+ * - The specifier 'u' for unsigned
+ * - Dot notation for IP addresses:
+ * sprintf("IP = %xip\n", 0xC0A80164);
+ * will produce "IP = 192.168.1.100\n"
+ */
#include <stdarg.h>
#include <stdio.h>
@@ -24,8 +24,8 @@
#include "FreeRTOS.h"
-#define PAD_RIGHT 1
-#define PAD_ZERO 2
+#define PAD_RIGHT 1
+#define PAD_ZERO 2
/*
* Return 1 for readable, 2 for writeable, 3 for both.
@@ -33,635 +33,721 @@
*/
extern BaseType_t xApplicationMemoryPermissions( uint32_t aAddress );
-extern void vOutputChar( const char cChar, const TickType_t xTicksToWait );
+extern void vOutputChar( const char cChar,
+ const TickType_t xTicksToWait );
static const TickType_t xTicksToWait = pdMS_TO_TICKS( 20 );
struct xPrintFlags
{
- int base;
- int width;
- int printLimit;
- unsigned
- pad : 8,
- letBase : 8,
- isSigned : 1,
- isNumber : 1,
- long32 : 1,
- long64 : 1;
+ int base;
+ int width;
+ int printLimit;
+ unsigned
+ pad : 8,
+ letBase : 8,
+ isSigned : 1,
+ isNumber : 1,
+ long32 : 1,
+ long64 : 1;
};
struct SStringBuf
{
- char *str;
- const char *orgStr;
- const char *nulPos;
- int curLen;
- struct xPrintFlags flags;
+ char * str;
+ const char * orgStr;
+ const char * nulPos;
+ int curLen;
+ struct xPrintFlags flags;
};
-static void strbuf_init( struct SStringBuf *apStr, char *apBuf, const char *apMaxStr )
+static void strbuf_init( struct SStringBuf * apStr,
+ char * apBuf,
+ const char * apMaxStr )
{
- apStr->str = apBuf;
- apStr->orgStr = apBuf;
- apStr->nulPos = apMaxStr-1;
- apStr->curLen = 0;
+ apStr->str = apBuf;
+ apStr->orgStr = apBuf;
+ apStr->nulPos = apMaxStr - 1;
+ apStr->curLen = 0;
- memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
+ memset( &apStr->flags, '\0', sizeof( apStr->flags ) );
}
/*-----------------------------------------------------------*/
-static BaseType_t strbuf_printchar( struct SStringBuf *apStr, int c )
+static BaseType_t strbuf_printchar( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *( apStr->str++ ) = c;
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
-static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf *apStr, int c )
+static portINLINE BaseType_t strbuf_printchar_inline( struct SStringBuf * apStr,
+ int c )
{
- if( apStr->str == NULL )
- {
- vOutputChar( ( char ) c, xTicksToWait );
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str < apStr->nulPos )
- {
- *(apStr->str++) = c;
- if( c == 0 )
- {
- return pdFALSE;
- }
- apStr->curLen++;
- return pdTRUE;
- }
- if( apStr->str == apStr->nulPos )
- {
- *( apStr->str++ ) = '\0';
- }
- return pdFALSE;
+ if( apStr->str == NULL )
+ {
+ vOutputChar( ( char ) c, xTicksToWait );
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str < apStr->nulPos )
+ {
+ *( apStr->str++ ) = c;
+
+ if( c == 0 )
+ {
+ return pdFALSE;
+ }
+
+ apStr->curLen++;
+ return pdTRUE;
+ }
+
+ if( apStr->str == apStr->nulPos )
+ {
+ *( apStr->str++ ) = '\0';
+ }
+
+ return pdFALSE;
}
/*-----------------------------------------------------------*/
static portINLINE int i2hex( int aCh )
{
-int iResult;
-
- if( aCh < 10 )
- {
- iResult = '0' + aCh;
- }
- else
- {
- iResult = 'A' + aCh - 10;
- }
-
- return iResult;
+ int iResult;
+
+ if( aCh < 10 )
+ {
+ iResult = '0' + aCh;
+ }
+ else
+ {
+ iResult = 'A' + aCh - 10;
+ }
+
+ return iResult;
}
/*-----------------------------------------------------------*/
-static BaseType_t prints(struct SStringBuf *apBuf, const char *apString )
+static BaseType_t prints( struct SStringBuf * apBuf,
+ const char * apString )
{
- register int padchar = ' ';
- int i,len;
-
- if( xApplicationMemoryPermissions( ( uint32_t )apString ) == 0 )
- {
- /* The user has probably made a mistake with the parameter
- for '%s', the memory is not readbale. */
- apString = "INV_MEM";
- }
-
- if( apBuf->flags.width > 0 )
- {
- register int len = 0;
- register const char *ptr;
- for( ptr = apString; *ptr; ++ptr )
- {
- ++len;
- }
-
- if( len >= apBuf->flags.width )
- {
- apBuf->flags.width = 0;
- }
- else
- {
- apBuf->flags.width -= len;
- }
-
- if( apBuf->flags.pad & PAD_ZERO )
- {
- padchar = '0';
- }
- }
- if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
- {
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( strbuf_printchar( apBuf, padchar ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
- {
- /* The string to print represents an integer number.
- * In this case, printLimit is the min number of digits to print
- * If the length of the number to print is less than the min nb of i
- * digits to display, we add 0 before printing the number
- */
- len = strlen( apString );
-
- if( len < apBuf->flags.printLimit )
- {
- i = apBuf->flags.printLimit - len;
- for( ; i; i-- )
- {
- if( strbuf_printchar( apBuf, '0' ) == 0 )
- {
- return pdFALSE;
- }
- }
- }
- }
- /* The string to print is not the result of a number conversion to ascii.
- * For a string, printLimit is the max number of characters to display
- */
- for( ; apBuf->flags.printLimit && *apString ; ++apString, --apBuf->flags.printLimit )
- {
- if( !strbuf_printchar( apBuf, *apString ) )
- {
- return pdFALSE;
- }
- }
-
- for( ; apBuf->flags.width > 0; --apBuf->flags.width )
- {
- if( !strbuf_printchar( apBuf, padchar ) )
- {
- return pdFALSE;
- }
- }
-
- return pdTRUE;
+ register int padchar = ' ';
+ int i, len;
+
+ if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 )
+ {
+ /* The user has probably made a mistake with the parameter
+ * for '%s', the memory is not readbale. */
+ apString = "INV_MEM";
+ }
+
+ if( apBuf->flags.width > 0 )
+ {
+ register int len = 0;
+ register const char * ptr;
+
+ for( ptr = apString; *ptr; ++ptr )
+ {
+ ++len;
+ }
+
+ if( len >= apBuf->flags.width )
+ {
+ apBuf->flags.width = 0;
+ }
+ else
+ {
+ apBuf->flags.width -= len;
+ }
+
+ if( apBuf->flags.pad & PAD_ZERO )
+ {
+ padchar = '0';
+ }
+ }
+
+ if( ( apBuf->flags.pad & PAD_RIGHT ) == 0 )
+ {
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( strbuf_printchar( apBuf, padchar ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+
+ if( ( apBuf->flags.isNumber == pdTRUE ) && ( apBuf->flags.pad == pdTRUE ) )
+ {
+ /* The string to print represents an integer number.
+ * In this case, printLimit is the min number of digits to print
+ * If the length of the number to print is less than the min nb of i
+ * digits to display, we add 0 before printing the number
+ */
+ len = strlen( apString );
+
+ if( len < apBuf->flags.printLimit )
+ {
+ i = apBuf->flags.printLimit - len;
+
+ for( ; i; i-- )
+ {
+ if( strbuf_printchar( apBuf, '0' ) == 0 )
+ {
+ return pdFALSE;
+ }
+ }
+ }
+ }
+
+ /* The string to print is not the result of a number conversion to ascii.
+ * For a string, printLimit is the max number of characters to display
+ */
+ for( ; apBuf->flags.printLimit && *apString; ++apString, --apBuf->flags.printLimit )
+ {
+ if( !strbuf_printchar( apBuf, *apString ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ for( ; apBuf->flags.width > 0; --apBuf->flags.width )
+ {
+ if( !strbuf_printchar( apBuf, padchar ) )
+ {
+ return pdFALSE;
+ }
+ }
+
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
/* the following should be enough for 32 bit int */
-#define PRINT_BUF_LEN 12 /* to print 4294967296 */
-
-#if SPRINTF_LONG_LONG
-#warning 64-bit libraries will be included as well
-static BaseType_t printll( struct SStringBuf *apBuf, long long i )
-{
- char print_buf[ 2 * PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned long long u = i;
- lldiv_t lldiv_result;
+#define PRINT_BUF_LEN 12 /* to print 4294967296 */
+
+#if SPRINTF_LONG_LONG
+ #warning 64-bit libraries will be included as well
+ static BaseType_t printll( struct SStringBuf * apBuf,
+ long long i )
+ {
+ char print_buf[ 2 * PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned long long u = i;
+ lldiv_t lldiv_result;
/* typedef struct
* {
- * long long int quot; // quotient
- * long long int rem; // remainder
+ * long long int quot; // quotient
+ * long long int rem; // remainder
* } lldiv_t;
*/
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- if( i == 0LL )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- /* 18446744073709551616 */
- while( u != 0 )
- {
- lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
- t = lldiv_result.rem;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u = lldiv_result.quot;
- }
-
- if( neg != 0 )
- {
- if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
- {
- if( !strbuf_printchar( apBuf, '-' ) )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
-}
-#endif /* SPRINTF_LONG_LONG */
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0LL )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ /* 18446744073709551616 */
+ while( u != 0 )
+ {
+ lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base );
+ t = lldiv_result.rem;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u = lldiv_result.quot;
+ }
+
+ if( neg != 0 )
+ {
+ if( ( apBuf->flags.width != 0 ) && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( !strbuf_printchar( apBuf, '-' ) )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
+ }
+#endif /* SPRINTF_LONG_LONG */
/*-----------------------------------------------------------*/
-static BaseType_t printi( struct SStringBuf *apBuf, int i )
+static BaseType_t printi( struct SStringBuf * apBuf,
+ int i )
{
- char print_buf[ PRINT_BUF_LEN ];
- register char *s;
- register int t, neg = 0;
- register unsigned int u = i;
- register unsigned base = apBuf->flags.base;
-
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
-
- if( i == 0 )
- {
- print_buf[ 0 ] = '0';
- print_buf[ 1 ] = '\0';
- return prints( apBuf, print_buf );
- }
-
- if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
- {
- neg = 1;
- u = -i;
- }
-
- s = print_buf + sizeof( print_buf ) - 1;
-
- *s = '\0';
- switch( base )
- {
- case 16:
- while( u != 0 )
- {
- t = u & 0xF;
- if( t >= 10 )
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u >>= 4;
- }
- break;
-
- case 8:
- case 10:
- /* GCC compiles very efficient */
- while( u )
- {
- t = u % base;
- *( --s ) = t + '0';
- u /= base;
- }
- break;
+ char print_buf[ PRINT_BUF_LEN ];
+ register char * s;
+ register int t, neg = 0;
+ register unsigned int u = i;
+ register unsigned base = apBuf->flags.base;
+
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+
+ if( i == 0 )
+ {
+ print_buf[ 0 ] = '0';
+ print_buf[ 1 ] = '\0';
+ return prints( apBuf, print_buf );
+ }
+
+ if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) )
+ {
+ neg = 1;
+ u = -i;
+ }
+
+ s = print_buf + sizeof( print_buf ) - 1;
+
+ *s = '\0';
+
+ switch( base )
+ {
+ case 16:
+
+ while( u != 0 )
+ {
+ t = u & 0xF;
+
+ if( t >= 10 )
+ {
+ t += apBuf->flags.letBase - '0' - 10;
+ }
+
+ *( --s ) = t + '0';
+ u >>= 4;
+ }
+
+ break;
+
+ case 8:
+ case 10:
+
+ /* GCC compiles very efficient */
+ while( u )
+ {
+ t = u % base;
+ *( --s ) = t + '0';
+ u /= base;
+ }
+
+ break;
+
/*
- // The generic case, not yet in use
- default:
- while( u )
- {
- t = u % base;
- if( t >= 10)
- {
- t += apBuf->flags.letBase - '0' - 10;
- }
- *( --s ) = t + '0';
- u /= base;
- }
- break;
-*/
- }
-
- if( neg != 0 )
- {
- if( apBuf->flags.width && (apBuf->flags.pad & PAD_ZERO ) )
- {
- if( strbuf_printchar( apBuf, '-' ) == 0 )
- {
- return pdFALSE;
- }
- --apBuf->flags.width;
- }
- else
- {
- *( --s ) = '-';
- }
- }
-
- return prints( apBuf, s );
+ * // The generic case, not yet in use
+ * default:
+ * while( u )
+ * {
+ * t = u % base;
+ * if( t >= 10)
+ * {
+ * t += apBuf->flags.letBase - '0' - 10;
+ * }
+ *( --s ) = t + '0';
+ * u /= base;
+ * }
+ * break;
+ */
+ }
+
+ if( neg != 0 )
+ {
+ if( apBuf->flags.width && ( apBuf->flags.pad & PAD_ZERO ) )
+ {
+ if( strbuf_printchar( apBuf, '-' ) == 0 )
+ {
+ return pdFALSE;
+ }
+
+ --apBuf->flags.width;
+ }
+ else
+ {
+ *( --s ) = '-';
+ }
+ }
+
+ return prints( apBuf, s );
}
/*-----------------------------------------------------------*/
-static BaseType_t printIp(struct SStringBuf *apBuf, unsigned i )
+static BaseType_t printIp( struct SStringBuf * apBuf,
+ unsigned i )
{
- char print_buf[16];
+ char print_buf[ 16 ];
- sprintf( print_buf, "%u.%u.%u.%u",
- i >> 24,
- ( i >> 16 ) & 0xff,
- ( i >> 8 ) & 0xff,
- i & 0xff );
- apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
- prints( apBuf, print_buf );
+ sprintf( print_buf, "%u.%u.%u.%u",
+ i >> 24,
+ ( i >> 16 ) & 0xff,
+ ( i >> 8 ) & 0xff,
+ i & 0xff );
+ apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */
+ prints( apBuf, print_buf );
- return pdTRUE;
+ return pdTRUE;
}
/*-----------------------------------------------------------*/
-static void tiny_print( struct SStringBuf *apBuf, const char *format, va_list args )
+static void tiny_print( struct SStringBuf * apBuf,
+ const char * format,
+ va_list args )
{
- char scr[2];
-
- for( ; ; )
- {
- int ch = *( format++ );
-
- if( ch != '%' )
- {
- do
- {
- /* Put the most like flow in a small loop */
- if( strbuf_printchar_inline( apBuf, ch ) == 0 )
- {
- return;
- }
- ch = *( format++ );
- } while( ch != '%' );
- }
- ch = *( format++ );
- /* Now ch has character after '%', format pointing to next */
-
- if( ch == '\0' )
- {
- break;
- }
- if( ch == '%' )
- {
- if( strbuf_printchar( apBuf, ch ) == 0 )
- {
- return;
- }
- continue;
- }
- memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
-
- if( ch == '-' )
- {
- ch = *( format++ );
- apBuf->flags.pad = PAD_RIGHT;
- }
- while( ch == '0' )
- {
- ch = *( format++ );
- apBuf->flags.pad |= PAD_ZERO;
- }
- if( ch == '*' )
- {
- ch = *( format++ );
- apBuf->flags.width = va_arg( args, int );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.width *= 10;
- apBuf->flags.width += ch - '0';
- ch = *( format++ );
- }
- }
- if( ch == '.' )
- {
- ch = *( format++ );
- if( ch == '*' )
- {
- apBuf->flags.printLimit = va_arg( args, int );
- ch = *( format++ );
- }
- else
- {
- while( ch >= '0' && ch <= '9' )
- {
- apBuf->flags.printLimit *= 10;
- apBuf->flags.printLimit += ch - '0';
- ch = *( format++ );
- }
- }
- }
- if( apBuf->flags.printLimit == 0 )
- {
- apBuf->flags.printLimit--; /* -1: make it unlimited */
- }
- if( ch == 's' )
- {
- register char *s = ( char * )va_arg( args, int );
- if( prints( apBuf, s ? s : "(null)" ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'c' )
- {
- /* char are converted to int then pushed on the stack */
- scr[0] = ( char ) va_arg( args, int );
-
- if( strbuf_printchar( apBuf, scr[0] ) == 0 )
- {
- return;
- }
-
- continue;
- }
- if( ch == 'l' )
- {
- ch = *( format++ );
- apBuf->flags.long32 = 1;
- /* Makes not difference as u32 == long */
- }
- if( ch == 'L' )
- {
- ch = *( format++ );
- apBuf->flags.long64 = 1;
- /* Does make a difference */
- }
- apBuf->flags.base = 10;
- apBuf->flags.letBase = 'a';
-
- if( ch == 'd' || ch == 'u' )
- {
- apBuf->flags.isSigned = ( ch == 'd' );
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
-
- apBuf->flags.base = 16; /* From here all hexadecimal */
-
- if( ch == 'x' && format[0] == 'i' && format[1] == 'p' )
- {
- format += 2; /* eat the "xi" of "xip" */
- /* Will use base 10 again */
- if( printIp( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- if( ch == 'x' || ch == 'X' || ch == 'p' || ch == 'o' )
- {
- if( ch == 'X' )
- {
- apBuf->flags.letBase = 'A';
- }
- else if( ch == 'o' )
- {
- apBuf->flags.base = 8;
- }
-#if SPRINTF_LONG_LONG
- if( apBuf->flags.long64 != pdFALSE )
- {
- if( printll( apBuf, va_arg( args, long long ) ) == 0 )
- {
- break;
- }
- } else
-#endif /* SPRINTF_LONG_LONG */
- if( printi( apBuf, va_arg( args, int ) ) == 0 )
- {
- break;
- }
- continue;
- }
- }
- strbuf_printchar( apBuf, '\0' );
+ char scr[ 2 ];
+
+ for( ; ; )
+ {
+ int ch = *( format++ );
+
+ if( ch != '%' )
+ {
+ do
+ {
+ /* Put the most like flow in a small loop */
+ if( strbuf_printchar_inline( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ ch = *( format++ );
+ } while( ch != '%' );
+ }
+
+ ch = *( format++ );
+ /* Now ch has character after '%', format pointing to next */
+
+ if( ch == '\0' )
+ {
+ break;
+ }
+
+ if( ch == '%' )
+ {
+ if( strbuf_printchar( apBuf, ch ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ memset( &apBuf->flags, '\0', sizeof( apBuf->flags ) );
+
+ if( ch == '-' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad = PAD_RIGHT;
+ }
+
+ while( ch == '0' )
+ {
+ ch = *( format++ );
+ apBuf->flags.pad |= PAD_ZERO;
+ }
+
+ if( ch == '*' )
+ {
+ ch = *( format++ );
+ apBuf->flags.width = va_arg( args, int );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.width *= 10;
+ apBuf->flags.width += ch - '0';
+ ch = *( format++ );
+ }
+ }
+
+ if( ch == '.' )
+ {
+ ch = *( format++ );
+
+ if( ch == '*' )
+ {
+ apBuf->flags.printLimit = va_arg( args, int );
+ ch = *( format++ );
+ }
+ else
+ {
+ while( ch >= '0' && ch <= '9' )
+ {
+ apBuf->flags.printLimit *= 10;
+ apBuf->flags.printLimit += ch - '0';
+ ch = *( format++ );
+ }
+ }
+ }
+
+ if( apBuf->flags.printLimit == 0 )
+ {
+ apBuf->flags.printLimit--; /* -1: make it unlimited */
+ }
+
+ if( ch == 's' )
+ {
+ register char * s = ( char * ) va_arg( args, int );
+
+ if( prints( apBuf, s ? s : "(null)" ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ch == 'c' )
+ {
+ /* char are converted to int then pushed on the stack */
+ scr[ 0 ] = ( char ) va_arg( args, int );
+
+ if( strbuf_printchar( apBuf, scr[ 0 ] ) == 0 )
+ {
+ return;
+ }
+
+ continue;
+ }
+
+ if( ch == 'l' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long32 = 1;
+ /* Makes not difference as u32 == long */
+ }
+
+ if( ch == 'L' )
+ {
+ ch = *( format++ );
+ apBuf->flags.long64 = 1;
+ /* Does make a difference */
+ }
+
+ apBuf->flags.base = 10;
+ apBuf->flags.letBase = 'a';
+
+ if( ( ch == 'd' ) || ( ch == 'u' ) )
+ {
+ apBuf->flags.isSigned = ( ch == 'd' );
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ apBuf->flags.base = 16; /* From here all hexadecimal */
+
+ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) )
+ {
+ format += 2; /* eat the "xi" of "xip" */
+
+ /* Will use base 10 again */
+ if( printIp( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+
+ if( ( ch == 'x' ) || ( ch == 'X' ) || ( ch == 'p' ) || ( ch == 'o' ) )
+ {
+ if( ch == 'X' )
+ {
+ apBuf->flags.letBase = 'A';
+ }
+ else if( ch == 'o' )
+ {
+ apBuf->flags.base = 8;
+ }
+
+ #if SPRINTF_LONG_LONG
+ if( apBuf->flags.long64 != pdFALSE )
+ {
+ if( printll( apBuf, va_arg( args, long long ) ) == 0 )
+ {
+ break;
+ }
+ }
+ else
+ #endif /* SPRINTF_LONG_LONG */
+
+ if( printi( apBuf, va_arg( args, int ) ) == 0 )
+ {
+ break;
+ }
+
+ continue;
+ }
+ }
+
+ strbuf_printchar( apBuf, '\0' );
}
/*-----------------------------------------------------------*/
-int vsnprintf( char *apBuf, size_t aMaxLen, const char *apFmt, va_list args )
+int vsnprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int snprintf( char *apBuf, size_t aMaxLen, const char *apFmt, ... )
+int snprintf( char * apBuf,
+ size_t aMaxLen,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* )apBuf + aMaxLen );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + aMaxLen );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int sprintf( char *apBuf, const char *apFmt, ... )
+int sprintf( char * apBuf,
+ const char * apFmt,
+ ... )
{
- va_list args;
+ va_list args;
- va_start( args, apFmt );
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char * )apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
- va_end( args );
+ va_start( args, apFmt );
+ struct SStringBuf strBuf;
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
+ va_end( args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-int vsprintf( char *apBuf, const char *apFmt, va_list args )
+int vsprintf( char * apBuf,
+ const char * apFmt,
+ va_list args )
{
- struct SStringBuf strBuf;
- strbuf_init( &strBuf, apBuf, ( const char* ) apBuf + 1024 );
- tiny_print( &strBuf, apFmt, args );
+ struct SStringBuf strBuf;
+
+ strbuf_init( &strBuf, apBuf, ( const char * ) apBuf + 1024 );
+ tiny_print( &strBuf, apFmt, args );
- return strBuf.curLen;
+ return strBuf.curLen;
}
/*-----------------------------------------------------------*/
-const char *mkSize (unsigned long long aSize, char *apBuf, int aLen)
+const char * mkSize( unsigned long long aSize,
+ char * apBuf,
+ int aLen )
{
-static char retString[33];
-size_t gb, mb, kb, sb;
-
- if (apBuf == NULL) {
- apBuf = retString;
- aLen = sizeof( retString );
- }
- gb = aSize / (1024*1024*1024);
- aSize -= gb * (1024*1024*1024);
- mb = aSize / (1024*1024);
- aSize -= mb * (1024*1024);
- kb = aSize / (1024);
- aSize -= kb * (1024);
- sb = aSize;
- if( gb )
- {
- snprintf (apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
- }
- else if( mb )
- {
- snprintf (apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb) / 1024ul ) );
- }
- else if( kb != 0ul )
- {
- snprintf (apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb) / 1024ul ) );
- }
- else
- {
- snprintf (apBuf, aLen, "%u bytes", ( unsigned ) sb);
- }
- return apBuf;
+ static char retString[ 33 ];
+ size_t gb, mb, kb, sb;
+
+ if( apBuf == NULL )
+ {
+ apBuf = retString;
+ aLen = sizeof( retString );
+ }
+
+ gb = aSize / ( 1024 * 1024 * 1024 );
+ aSize -= gb * ( 1024 * 1024 * 1024 );
+ mb = aSize / ( 1024 * 1024 );
+ aSize -= mb * ( 1024 * 1024 );
+ kb = aSize / ( 1024 );
+ aSize -= kb * ( 1024 );
+ sb = aSize;
+
+ if( gb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u GB", ( unsigned ) gb, ( unsigned ) ( ( 100 * mb ) / 1024ul ) );
+ }
+ else if( mb )
+ {
+ snprintf( apBuf, aLen, "%u.%02u MB", ( unsigned ) mb, ( unsigned ) ( ( 100 * kb ) / 1024ul ) );
+ }
+ else if( kb != 0ul )
+ {
+ snprintf( apBuf, aLen, "%u.%02u KB", ( unsigned ) kb, ( unsigned ) ( ( 100 * sb ) / 1024ul ) );
+ }
+ else
+ {
+ snprintf( apBuf, aLen, "%u bytes", ( unsigned ) sb );
+ }
+
+ return apBuf;
}
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c
index bdb2e04ba..a10f53250 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c
@@ -36,19 +36,23 @@
/*-----------------------------------------------------------*/
-void* mbedtls_platform_calloc(size_t nmemb, size_t size)
+void * mbedtls_platform_calloc( size_t nmemb,
+ size_t size )
{
size_t totalSize = nmemb * size;
- void* pBuffer = NULL;
+ void * pBuffer = NULL;
/* Check that neither nmemb nor size were 0. */
- if (totalSize > 0) {
+ if( totalSize > 0 )
+ {
/* Overflow check. */
- if (totalSize / size == nmemb) {
- pBuffer = pvPortMalloc(totalSize);
+ if( totalSize / size == nmemb )
+ {
+ pBuffer = pvPortMalloc( totalSize );
- if (pBuffer != NULL) {
- (void)memset(pBuffer, 0x00, totalSize);
+ if( pBuffer != NULL )
+ {
+ ( void ) memset( pBuffer, 0x00, totalSize );
}
}
}
@@ -58,102 +62,111 @@ void* mbedtls_platform_calloc(size_t nmemb, size_t size)
/*-----------------------------------------------------------*/
-void mbedtls_platform_free(void* ptr)
+void mbedtls_platform_free( void * ptr )
{
- vPortFree(ptr);
+ vPortFree( ptr );
}
/*-----------------------------------------------------------*/
-int mbedtls_platform_send(void* ctx, const unsigned char* buf, size_t len)
+int mbedtls_platform_send( void * ctx,
+ const unsigned char * buf,
+ size_t len )
{
Socket_t socket = ctx;
- return (int)FreeRTOS_send(socket, buf, len, 0);
+ return ( int ) FreeRTOS_send( socket, buf, len, 0 );
}
/*-----------------------------------------------------------*/
-int mbedtls_platform_recv(void* ctx, unsigned char* buf, size_t len)
+int mbedtls_platform_recv( void * ctx,
+ unsigned char * buf,
+ size_t len )
{
Socket_t socket = ctx;
- return (int)FreeRTOS_recv(socket, buf, len, 0);
+ return ( int ) FreeRTOS_recv( socket, buf, len, 0 );
}
/*-----------------------------------------------------------*/
-void mbedtls_platform_mutex_init(mbedtls_threading_mutex_t* pMutex)
+void mbedtls_platform_mutex_init( mbedtls_threading_mutex_t * pMutex )
{
/* Create a statically-allocated FreeRTOS mutex. This should never fail as
* storage is provided. */
- pMutex->mutexHandle = xSemaphoreCreateMutexStatic(&(pMutex->mutexStorage));
- configASSERT(pMutex->mutexHandle != NULL);
+ pMutex->mutexHandle = xSemaphoreCreateMutexStatic( &( pMutex->mutexStorage ) );
+ configASSERT( pMutex->mutexHandle != NULL );
}
/*-----------------------------------------------------------*/
-void mbedtls_platform_mutex_free(mbedtls_threading_mutex_t* pMutex)
+void mbedtls_platform_mutex_free( mbedtls_threading_mutex_t * pMutex )
{
/* Nothing needs to be done to free a statically-allocated FreeRTOS mutex.
*/
- (void)pMutex;
+ ( void ) pMutex;
}
/*-----------------------------------------------------------*/
-int mbedtls_platform_mutex_lock(mbedtls_threading_mutex_t* pMutex)
+int mbedtls_platform_mutex_lock( mbedtls_threading_mutex_t * pMutex )
{
BaseType_t mutexStatus = 0;
/* mutexStatus is not used if asserts are disabled. */
- (void)mutexStatus;
+ ( void ) mutexStatus;
/* This function should never fail if the mutex is initialized. */
- mutexStatus = xSemaphoreTake(pMutex->mutexHandle, portMAX_DELAY);
- configASSERT(mutexStatus == pdTRUE);
+ mutexStatus = xSemaphoreTake( pMutex->mutexHandle, portMAX_DELAY );
+ configASSERT( mutexStatus == pdTRUE );
return 0;
}
/*-----------------------------------------------------------*/
-int mbedtls_platform_mutex_unlock(mbedtls_threading_mutex_t* pMutex)
+int mbedtls_platform_mutex_unlock( mbedtls_threading_mutex_t * pMutex )
{
BaseType_t mutexStatus = 0;
/* mutexStatus is not used if asserts are disabled. */
- (void)mutexStatus;
+ ( void ) mutexStatus;
/* This function should never fail if the mutex is initialized. */
- mutexStatus = xSemaphoreGive(pMutex->mutexHandle);
- configASSERT(mutexStatus == pdTRUE);
+ mutexStatus = xSemaphoreGive( pMutex->mutexHandle );
+ configASSERT( mutexStatus == pdTRUE );
return 0;
}
/*-----------------------------------------------------------*/
-int mbedtls_platform_entropy_poll(
- void* data, unsigned char* output, size_t len, size_t* olen)
+int mbedtls_platform_entropy_poll( void * data,
+ unsigned char * output,
+ size_t len,
+ size_t * olen )
{
- int status = 0;
+ int status = 0;
NTSTATUS rngStatus = 0;
/* Context is not used by this function. */
- (void)data;
+ ( void ) data;
/* TLS requires a secure random number generator; use the RNG provided
* by Windows. This function MUST be re-implemented for other platforms. */
rngStatus =
- BCryptGenRandom(NULL, output, len, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
+ BCryptGenRandom( NULL, output, len, BCRYPT_USE_SYSTEM_PREFERRED_RNG );
- if (rngStatus == 0) {
+ if( rngStatus == 0 )
+ {
/* All random bytes generated. */
*olen = len;
- } else {
+ }
+ else
+ {
/* RNG failure. */
- *olen = 0;
+ *olen = 0;
status = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED;
}
@@ -162,10 +175,12 @@ int mbedtls_platform_entropy_poll(
/*-----------------------------------------------------------*/
-int mbedtls_hardware_poll(
- void* data, unsigned char* output, size_t len, size_t* olen)
+int mbedtls_hardware_poll( void * data,
+ unsigned char * output,
+ size_t len,
+ size_t * olen )
{
- return mbedtls_platform_entropy_poll(data, output, len, olen);
+ return mbedtls_platform_entropy_poll( data, output, len, olen );
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/threading_alt.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/threading_alt.h
index c3a980e31..fa009c859 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/threading_alt.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/threading_alt.h
@@ -41,4 +41,4 @@ void mbedtls_platform_mutex_free( mbedtls_threading_mutex_t * pMutex );
int mbedtls_platform_mutex_lock( mbedtls_threading_mutex_t * pMutex );
int mbedtls_platform_mutex_unlock( mbedtls_threading_mutex_t * pMutex );
-#endif
+#endif /* ifndef MBEDTLS_THREADING_ALT_H_ */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/include/platform/iot_platform_types_freertos.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/include/platform/iot_platform_types_freertos.h
index e85e6b396..14f299f06 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/include/platform/iot_platform_types_freertos.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/include/platform/iot_platform_types_freertos.h
@@ -86,7 +86,7 @@ struct IotNetworkCredentials;
struct _networkConnection;
typedef struct IotNetworkServerInfo const * _IotNetworkServerInfo_t;
-typedef struct IotNetworkCredentials * _IotNetworkCredentials_t;
-typedef struct _networkConnection * _IotNetworkConnection_t;
+typedef struct IotNetworkCredentials * _IotNetworkCredentials_t;
+typedef struct _networkConnection * _IotNetworkConnection_t;
#endif /* ifndef _IOT_PLATFORM_TYPES_POSIX_H_ */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c
index e2fee08d3..ae5703321 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c
@@ -25,7 +25,7 @@
/**
* @file iot_clock_freertos.c
- * @brief Implementation of the platform specific functions in iot_clock.h for
+ * @brief Implementation of the platform specific functions in iot_clock.h for
* FreeRTOS.
*/
@@ -89,14 +89,14 @@ bool IotClock_GetTimestring( char * pBuffer,
size_t bufferSize,
size_t * pTimestringLength )
{
- uint64_t milliSeconds = IotClock_GetTimeMs();
- int timestringLength = 0;
+ uint64_t milliSeconds = IotClock_GetTimeMs();
+ int timestringLength = 0;
configASSERT( pBuffer != NULL );
configASSERT( pTimestringLength != NULL );
/* Convert the localTime struct to a string. */
- timestringLength = snprintf( pBuffer, bufferSize, "%llu", milliSeconds );
+ timestringLength = snprintf( pBuffer, bufferSize, "%llu", milliSeconds );
/* Check for error from no string */
if( timestringLength == 0 )
@@ -117,14 +117,14 @@ uint64_t IotClock_GetTimeMs( void )
TimeOut_t xCurrentTime = { 0 };
/* This must be unsigned because the behavior of signed integer overflow is undefined. */
- uint64_t ullTickCount = 0ULL;
+ uint64_t ullTickCount = 0ULL;
/* Get the current tick count and overflow count. vTaskSetTimeOutState()
* is used to get these values because they are both static in tasks.c. */
vTaskSetTimeOutState( &xCurrentTime );
/* Adjust the tick count for the number of times a TickType_t has overflowed. */
- ullTickCount = ( uint64_t ) ( xCurrentTime.xOverflowCount ) << ( sizeof( TickType_t ) * 8 );
+ ullTickCount = ( uint64_t ) ( xCurrentTime.xOverflowCount ) << ( sizeof( TickType_t ) * 8 );
/* Add the current tick count. */
ullTickCount += xCurrentTime.xTimeOnEntering;
@@ -154,18 +154,18 @@ bool IotClock_TimerCreate( IotTimer_t * pNewTimer,
/* Set the timer expiration routine, argument and period */
pxTimer->threadRoutine = expirationRoutine;
- pxTimer->pArgument = pArgument;
- pxTimer->xTimerPeriod = 0;
+ pxTimer->pArgument = pArgument;
+ pxTimer->xTimerPeriod = 0;
/* Create a new FreeRTOS timer. This call will not fail because the
* memory for it has already been allocated, so the output parameter is
* also set. */
- pxTimer->timer = ( TimerHandle_t ) xTimerCreateStatic( "timer", /* Timer name. */
- portMAX_DELAY, /* Initial timer period. Timers are created disarmed. */
- pdFALSE, /* Don't auto-reload timer. */
- ( void * ) pxTimer, /* Timer id. */
- prvTimerCallback, /* Timer expiration callback. */
- &pxTimer->xTimerBuffer ); /* Pre-allocated memory for timer. */
+ pxTimer->timer = ( TimerHandle_t ) xTimerCreateStatic( "timer", /* Timer name. */
+ portMAX_DELAY, /* Initial timer period. Timers are created disarmed. */
+ pdFALSE, /* Don't auto-reload timer. */
+ ( void * ) pxTimer, /* Timer id. */
+ prvTimerCallback, /* Timer expiration callback. */
+ &pxTimer->xTimerBuffer ); /* Pre-allocated memory for timer. */
return true;
}
@@ -202,11 +202,11 @@ bool IotClock_TimerArm( IotTimer_t * pTimer,
uint32_t relativeTimeoutMs,
uint32_t periodMs )
{
- _IotSystemTimer_t * pTimerInfo = ( _IotSystemTimer_t * ) pTimer;
+ _IotSystemTimer_t * pTimerInfo = ( _IotSystemTimer_t * ) pTimer;
configASSERT( pTimerInfo != NULL );
- TimerHandle_t xTimerHandle = pTimerInfo->timer;
+ TimerHandle_t xTimerHandle = pTimerInfo->timer;
IotLogDebug( "Arming timer %p with timeout %llu and period %llu.",
pTimer,
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c
index 9ee3f7769..2f9f83cd0 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c
@@ -255,10 +255,10 @@ const IotNetworkInterface_t IotNetworkFreeRTOS =
/* Initialize the mbed TLS context structures. */
_sslContextInit( pNetworkConnection );
- mbedtlsError = mbedtls_ssl_config_defaults( &( pNetworkConnection->ssl.config ),
- MBEDTLS_SSL_IS_CLIENT,
- MBEDTLS_SSL_TRANSPORT_STREAM,
- MBEDTLS_SSL_PRESET_DEFAULT );
+ mbedtlsError = mbedtls_ssl_config_defaults( &( pNetworkConnection->ssl.config ),
+ MBEDTLS_SSL_IS_CLIENT,
+ MBEDTLS_SSL_TRANSPORT_STREAM,
+ MBEDTLS_SSL_PRESET_DEFAULT );
if( mbedtlsError != 0 )
{
@@ -290,9 +290,9 @@ const IotNetworkInterface_t IotNetworkFreeRTOS =
&( pNetworkConnection->ssl.certProfile ) );
/* Parse the server root CA certificate into the SSL context. */
- mbedtlsError = mbedtls_x509_crt_parse( &( pNetworkConnection->ssl.rootCa ),
- ( const unsigned char * ) pCredentials->pRootCa,
- pCredentials->rootCaSize );
+ mbedtlsError = mbedtls_x509_crt_parse( &( pNetworkConnection->ssl.rootCa ),
+ ( const unsigned char * ) pCredentials->pRootCa,
+ pCredentials->rootCaSize );
if( mbedtlsError != 0 )
{
@@ -342,8 +342,8 @@ const IotNetworkInterface_t IotNetworkFreeRTOS =
}
/* Initialize the mbed TLS secured connection context. */
- mbedtlsError = mbedtls_ssl_setup( &( pNetworkConnection->ssl.context ),
- &( pNetworkConnection->ssl.config ) );
+ mbedtlsError = mbedtls_ssl_setup( &( pNetworkConnection->ssl.context ),
+ &( pNetworkConnection->ssl.config ) );
if( mbedtlsError != 0 )
{
@@ -441,9 +441,9 @@ static BaseType_t _isAnyConnectionActive( void )
static void _networkTask( void * pvParameters )
{
_networkConnection_t * pConnection = NULL;
- BaseType_t socketEvents = 0, i = 0, socketStatus = 0;
- const BaseType_t activeConnectionPresent = 1;
- SocketSet_t socketSet = pvParameters;
+ BaseType_t socketEvents = 0, i = 0, socketStatus = 0;
+ const BaseType_t activeConnectionPresent = 1;
+ SocketSet_t socketSet = pvParameters;
while( true )
{
@@ -528,11 +528,11 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void )
mbedtls_ctr_drbg_init( &_ctrDrgbContext );
/* Add a strong entropy source. At least one is required. */
- mbedtlsError = mbedtls_entropy_add_source( &_entropyContext,
- mbedtls_platform_entropy_poll,
- NULL,
- 32,
- MBEDTLS_ENTROPY_SOURCE_STRONG );
+ mbedtlsError = mbedtls_entropy_add_source( &_entropyContext,
+ mbedtls_platform_entropy_poll,
+ NULL,
+ 32,
+ MBEDTLS_ENTROPY_SOURCE_STRONG );
if( mbedtlsError != 0 )
{
@@ -542,11 +542,11 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void )
}
/* Seed the random number generator. */
- mbedtlsError = mbedtls_ctr_drbg_seed( &_ctrDrgbContext,
- mbedtls_entropy_func,
- &_entropyContext,
- NULL,
- 0 );
+ mbedtlsError = mbedtls_ctr_drbg_seed( &_ctrDrgbContext,
+ mbedtls_entropy_func,
+ &_entropyContext,
+ NULL,
+ 0 );
if( mbedtlsError != 0 )
{
@@ -557,7 +557,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void )
#endif /* if ( IOT_NETWORK_ENABLE_TLS == 1 ) */
/* Create the socket set for the network task. */
- _socketSet = FreeRTOS_CreateSocketSet();
+ _socketSet = FreeRTOS_CreateSocketSet();
if( _socketSet == NULL )
{
@@ -565,10 +565,10 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void )
}
/* Create the socket set mutex. */
- _socketSetMutex = xSemaphoreCreateMutexStatic( &_socketSetMutexStorage );
+ _socketSetMutex = xSemaphoreCreateMutexStatic( &_socketSetMutexStorage );
static StaticTask_t networkTask;
- static StackType_t networkTaskStack[ IOT_NETWORK_TASK_STACK_SIZE ];
+ static StackType_t networkTaskStack[ IOT_NETWORK_TASK_STACK_SIZE ];
/* Create the network task. Since valid parameters are provided, this should
* never fail. */
@@ -609,17 +609,17 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
IotNetworkConnection_t * pConnection )
{
IOT_FUNCTION_ENTRY( IotNetworkError_t, IOT_NETWORK_SUCCESS );
- Socket_t tcpSocket = FREERTOS_INVALID_SOCKET;
- BaseType_t socketStatus = 0;
- struct freertos_sockaddr serverAddress = { 0 };
- const TickType_t receiveTimeout = IOT_NETWORK_SOCKET_TIMEOUT_TICKS;
- _networkConnection_t * pNewNetworkConnection = NULL;
+ Socket_t tcpSocket = FREERTOS_INVALID_SOCKET;
+ BaseType_t socketStatus = 0;
+ struct freertos_sockaddr serverAddress = { 0 };
+ const TickType_t receiveTimeout = IOT_NETWORK_SOCKET_TIMEOUT_TICKS;
+ _networkConnection_t * pNewNetworkConnection = NULL;
/* Credentials are not used if TLS is disabled. */
( void ) pCredentialInfo;
/* Check host name length against the maximum length allowed. */
- const size_t hostnameLength = strlen( pServerInfo->pHostName );
+ const size_t hostnameLength = strlen( pServerInfo->pHostName );
if( hostnameLength > ( size_t ) MAX_DNS_NAME_LENGTH )
{
@@ -628,7 +628,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_BAD_PARAMETER );
}
- pNewNetworkConnection = pvPortMalloc( sizeof( _networkConnection_t ) );
+ pNewNetworkConnection = pvPortMalloc( sizeof( _networkConnection_t ) );
if( pNewNetworkConnection == NULL )
{
@@ -640,9 +640,9 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
( void ) memset( pNewNetworkConnection, 0x00, sizeof( _networkConnection_t ) );
/* Create a new TCP socket. */
- tcpSocket = FreeRTOS_socket( FREERTOS_AF_INET,
- FREERTOS_SOCK_STREAM,
- FREERTOS_IPPROTO_TCP );
+ tcpSocket = FreeRTOS_socket( FREERTOS_AF_INET,
+ FREERTOS_SOCK_STREAM,
+ FREERTOS_IPPROTO_TCP );
if( tcpSocket == FREERTOS_INVALID_SOCKET )
{
@@ -651,11 +651,11 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
}
/* Set the timeout for receive. */
- socketStatus = FreeRTOS_setsockopt( tcpSocket,
- 0,
- FREERTOS_SO_RCVTIMEO,
- &receiveTimeout,
- sizeof( TickType_t ) );
+ socketStatus = FreeRTOS_setsockopt( tcpSocket,
+ 0,
+ FREERTOS_SO_RCVTIMEO,
+ &receiveTimeout,
+ sizeof( TickType_t ) );
if( socketStatus != 0 )
{
@@ -664,10 +664,10 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
}
/* Establish connection. */
- serverAddress.sin_family = FREERTOS_AF_INET;
- serverAddress.sin_port = FreeRTOS_htons( pServerInfo->port );
- serverAddress.sin_addr = FreeRTOS_gethostbyname( pServerInfo->pHostName );
- serverAddress.sin_len = ( uint8_t ) sizeof( serverAddress );
+ serverAddress.sin_family = FREERTOS_AF_INET;
+ serverAddress.sin_port = FreeRTOS_htons( pServerInfo->port );
+ serverAddress.sin_addr = FreeRTOS_gethostbyname( pServerInfo->pHostName );
+ serverAddress.sin_len = ( uint8_t ) sizeof( serverAddress );
/* Check for errors from DNS lookup. */
if( serverAddress.sin_addr == 0 )
@@ -676,9 +676,9 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_SYSTEM_ERROR );
}
- socketStatus = FreeRTOS_connect( tcpSocket,
- &serverAddress,
- sizeof( serverAddress ) );
+ socketStatus = FreeRTOS_connect( tcpSocket,
+ &serverAddress,
+ sizeof( serverAddress ) );
if( socketStatus != 0 )
{
@@ -721,7 +721,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
pNewNetworkConnection->socketMutex = xSemaphoreCreateMutexStatic( &( pNewNetworkConnection->socketMutexStorage ) );
/* Set the output parameter. */
- *pConnection = pNewNetworkConnection;
+ *pConnection = pNewNetworkConnection;
IotLogInfo( "(Network connection %p) Connection to %s established.",
pNewNetworkConnection,
@@ -737,7 +737,7 @@ IotNetworkError_t IotNetworkFreeRTOS_SetReceiveCallback( IotNetworkConnection_t
void * pContext )
{
IotNetworkError_t status = IOT_NETWORK_SUCCESS;
- BaseType_t i = 0;
+ BaseType_t i = 0;
/* Set the receive callback and context. */
pConnection->receiveCallback = receiveCallback;
@@ -788,7 +788,7 @@ size_t IotNetworkFreeRTOS_Send( IotNetworkConnection_t pConnection,
const uint8_t * pMessage,
size_t messageLength )
{
- size_t bytesSent = 0;
+ size_t bytesSent = 0;
BaseType_t socketStatus = 0;
/* Only one thread at a time may send on the connection. Lock the send
@@ -857,7 +857,7 @@ size_t IotNetworkFreeRTOS_Receive( IotNetworkConnection_t pConnection,
size_t bytesRequested )
{
BaseType_t socketStatus = 0;
- size_t bytesReceived = 0, bytesRemaining = bytesRequested;
+ size_t bytesReceived = 0, bytesRemaining = bytesRequested;
/* Block and wait for incoming data. */
while( bytesRemaining > 0 )
@@ -911,7 +911,7 @@ size_t IotNetworkFreeRTOS_Receive( IotNetworkConnection_t pConnection,
}
else
{
- bytesReceived += ( size_t ) socketStatus;
+ bytesReceived += ( size_t ) socketStatus;
bytesRemaining -= ( size_t ) socketStatus;
configASSERT( bytesReceived + bytesRemaining == bytesRequested );
@@ -941,8 +941,8 @@ size_t IotNetworkFreeRTOS_ReceiveUpto( IotNetworkConnection_t pConnection,
uint8_t * pBuffer,
size_t bufferSize )
{
- int32_t socketStatus = 0;
- size_t bytesReceived = 0;
+ int32_t socketStatus = 0;
+ size_t bytesReceived = 0;
/* Caller should never pass a zero-length buffer. */
configASSERT( bufferSize > 0 );
@@ -996,7 +996,7 @@ size_t IotNetworkFreeRTOS_ReceiveUpto( IotNetworkConnection_t pConnection,
IotNetworkError_t IotNetworkFreeRTOS_Close( IotNetworkConnection_t pConnection )
{
- BaseType_t socketStatus = 0, i = 0;
+ BaseType_t socketStatus = 0, i = 0;
IotNetworkError_t status = IOT_NETWORK_SUCCESS;
#if ( IOT_NETWORK_ENABLE_TLS == 1 )
@@ -1066,8 +1066,8 @@ IotNetworkError_t IotNetworkFreeRTOS_Close( IotNetworkConnection_t pConnection )
IotNetworkError_t IotNetworkFreeRTOS_Destroy( IotNetworkConnection_t pConnection )
{
- BaseType_t closeSocketStatus = 0;
- IotNetworkError_t status = IOT_NETWORK_SUCCESS;
+ BaseType_t closeSocketStatus = 0;
+ IotNetworkError_t status = IOT_NETWORK_SUCCESS;
closeSocketStatus = FreeRTOS_closesocket( pConnection->socket );
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c
index de79266ba..9894daa15 100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c
@@ -53,9 +53,9 @@
#include "iot_tls.h"
#if !defined( MBEDTLS_CONFIG_FILE )
-#include "mbedtls/config.h"
+ #include "mbedtls/config.h"
#else
-#include MBEDTLS_CONFIG_FILE
+ #include MBEDTLS_CONFIG_FILE
#endif
/* Configure logs for the functions in this file. */
@@ -159,22 +159,22 @@ static IotNetworkError_t _tlsSetup( _networkConnection_t * pNetworkConnection,
const char * pServerName,
IotNetworkCredentials_t pCredentials )
{
- int mbedtlsError = 0;
+ int mbedtlsError = 0;
- TLSParams_t tlsParams = { 0 };
+ TLSParams_t tlsParams = { 0 };
- tlsParams.ulSize = sizeof( tlsParams );
- tlsParams.pcDestination = pServerName;
- tlsParams.pcServerCertificate = pCredentials->pRootCa;
+ tlsParams.ulSize = sizeof( tlsParams );
+ tlsParams.pcDestination = pServerName;
+ tlsParams.pcServerCertificate = pCredentials->pRootCa;
tlsParams.ulServerCertificateLength = pCredentials->rootCaSize;
- tlsParams.ppcAlpnProtocols = ( const char ** ) pCredentials->pAlpnProtos;
- tlsParams.ulAlpnProtocolsCount = 0;
- tlsParams.pxNetworkSend = mbedtls_platform_send;
- tlsParams.pxNetworkRecv = mbedtls_platform_recv;
- tlsParams.pvCallerContext = pNetworkConnection->socket;
+ tlsParams.ppcAlpnProtocols = ( const char ** ) pCredentials->pAlpnProtos;
+ tlsParams.ulAlpnProtocolsCount = 0;
+ tlsParams.pxNetworkSend = mbedtls_platform_send;
+ tlsParams.pxNetworkRecv = mbedtls_platform_recv;
+ tlsParams.pvCallerContext = pNetworkConnection->socket;
/* Initialize TLS context and underlying crypto libraries */
- mbedtlsError = TLS_Init( &pNetworkConnection->pvTLSContext, &tlsParams );
+ mbedtlsError = TLS_Init( &pNetworkConnection->pvTLSContext, &tlsParams );
if( mbedtlsError != CKR_OK )
{
@@ -183,7 +183,7 @@ static IotNetworkError_t _tlsSetup( _networkConnection_t * pNetworkConnection,
/* Attempt to establish a TLS connection. PKCS is used to acquire
* credential objects. */
- mbedtlsError = TLS_Connect( pNetworkConnection->pvTLSContext );
+ mbedtlsError = TLS_Connect( pNetworkConnection->pvTLSContext );
if( mbedtlsError == CKR_OK )
{
@@ -204,8 +204,8 @@ static IotNetworkError_t _tlsSetup( _networkConnection_t * pNetworkConnection,
static void _networkTask( void * pvParameters )
{
_networkConnection_t * pConnection = NULL;
- BaseType_t socketEvents = 0, i = 0, socketStatus = 0;
- SocketSet_t socketSet = pvParameters;
+ BaseType_t socketEvents = 0, i = 0, socketStatus = 0;
+ SocketSet_t socketSet = pvParameters;
while( true )
{
@@ -254,7 +254,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void )
IOT_FUNCTION_ENTRY( IotNetworkError_t, IOT_NETWORK_SUCCESS );
/* Create socket set for network task. */
- _socketSet = FreeRTOS_CreateSocketSet();
+ _socketSet = FreeRTOS_CreateSocketSet();
if( _socketSet == NULL )
{
@@ -262,7 +262,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void )
}
static StaticTask_t networkTask;
- static StackType_t networkTaskStack[ IOT_NETWORK_TASK_STACK_SIZE ];
+ static StackType_t networkTaskStack[ IOT_NETWORK_TASK_STACK_SIZE ];
/* Create the network task. Since valid parameters are provided, this should
* never fail. */
@@ -291,18 +291,18 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
IotNetworkConnection_t * pConnection )
{
IOT_FUNCTION_ENTRY( IotNetworkError_t, IOT_NETWORK_SUCCESS );
- Socket_t tcpSocket = FREERTOS_INVALID_SOCKET;
- BaseType_t socketStatus = 0;
- struct freertos_sockaddr serverAddress = { 0 };
- const TickType_t receiveTimeout =
+ Socket_t tcpSocket = FREERTOS_INVALID_SOCKET;
+ BaseType_t socketStatus = 0;
+ struct freertos_sockaddr serverAddress = { 0 };
+ const TickType_t receiveTimeout =
pdMS_TO_TICKS( IOT_NETWORK_SOCKET_TIMEOUT_MS );
- _networkConnection_t * pNewNetworkConnection = NULL;
+ _networkConnection_t * pNewNetworkConnection = NULL;
/* Credentials are not used if TLS is disabled. */
( void ) pCredentialInfo;
/* Check host name length against the maximum length allowed. */
- const size_t hostnameLength = strlen( pServerInfo->pHostName );
+ const size_t hostnameLength = strlen( pServerInfo->pHostName );
if( hostnameLength > ( size_t ) MAX_DNS_NAME_LENGTH )
{
@@ -312,7 +312,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_BAD_PARAMETER );
}
- pNewNetworkConnection = pvPortMalloc( sizeof( _networkConnection_t ) );
+ pNewNetworkConnection = pvPortMalloc( sizeof( _networkConnection_t ) );
if( pNewNetworkConnection == NULL )
{
@@ -324,7 +324,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
( void ) memset( pNewNetworkConnection, 0x00, sizeof( _networkConnection_t ) );
/* Create a new TCP socket. */
- tcpSocket = FreeRTOS_socket(
+ tcpSocket = FreeRTOS_socket(
FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
if( tcpSocket == FREERTOS_INVALID_SOCKET )
@@ -334,7 +334,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
}
/* Set the timeout for receive. */
- socketStatus = FreeRTOS_setsockopt(
+ socketStatus = FreeRTOS_setsockopt(
tcpSocket, 0, FREERTOS_SO_RCVTIMEO, &receiveTimeout,
sizeof( TickType_t ) );
@@ -345,10 +345,10 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
}
/* Establish connection. */
- serverAddress.sin_family = FREERTOS_AF_INET;
- serverAddress.sin_port = FreeRTOS_htons( pServerInfo->port );
- serverAddress.sin_addr = FreeRTOS_gethostbyname( pServerInfo->pHostName );
- serverAddress.sin_len = ( uint8_t ) sizeof( serverAddress );
+ serverAddress.sin_family = FREERTOS_AF_INET;
+ serverAddress.sin_port = FreeRTOS_htons( pServerInfo->port );
+ serverAddress.sin_addr = FreeRTOS_gethostbyname( pServerInfo->pHostName );
+ serverAddress.sin_len = ( uint8_t ) sizeof( serverAddress );
/* Check for errors from DNS lookup. */
if( serverAddress.sin_addr == 0 )
@@ -357,7 +357,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_SYSTEM_ERROR );
}
- socketStatus =
+ socketStatus =
FreeRTOS_connect( tcpSocket, &serverAddress, sizeof( serverAddress ) );
if( socketStatus != 0 )
@@ -369,7 +369,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo,
}
/* Set the socket. */
- pNewNetworkConnection->socket = tcpSocket;
+ pNewNetworkConnection->socket = tcpSocket;
/* Create the socket mutex. */
pNewNetworkConnection->socketMutex = xSemaphoreCreateMutexStatic(
&( pNewNetworkConnection->socketMutexStorage ) );
@@ -416,7 +416,7 @@ IotNetworkError_t IotNetworkFreeRTOS_SetReceiveCallback( IotNetworkConnection_t
void * pContext )
{
IotNetworkError_t status = IOT_NETWORK_SUCCESS;
- BaseType_t i = 0;
+ BaseType_t i = 0;
/* Set the receive callback and context. */
pConnection->receiveCallback = receiveCallback;
@@ -452,7 +452,7 @@ size_t IotNetworkFreeRTOS_Send( IotNetworkConnection_t pConnection,
const uint8_t * pMessage,
size_t messageLength )
{
- size_t bytesSent = 0;
+ size_t bytesSent = 0;
BaseType_t socketStatus = 0;
/* Only one thread at a time may send on the connection. Lock the send
@@ -499,7 +499,7 @@ size_t IotNetworkFreeRTOS_Receive( IotNetworkConnection_t pConnection,
size_t bytesRequested )
{
BaseType_t socketStatus = 0;
- size_t bytesReceived = 0, bytesRemaining = bytesRequested;
+ size_t bytesReceived = 0, bytesRemaining = bytesRequested;
/* Block and wait for incoming data. */
@@ -558,8 +558,8 @@ size_t IotNetworkFreeRTOS_ReceiveUpto( IotNetworkConnection_t pConnection,
uint8_t * pBuffer,
size_t bufferSize )
{
- int32_t socketStatus = 0;
- size_t bytesReceived = 0;
+ int32_t socketStatus = 0;
+ size_t bytesReceived = 0;
/* Caller should never pass a zero-length buffer. */
configASSERT( bufferSize > 0 );
@@ -570,7 +570,7 @@ size_t IotNetworkFreeRTOS_ReceiveUpto( IotNetworkConnection_t pConnection,
pConnection->socketMutex, IOT_NETWORK_SOCKET_TIMEOUT_MS )
== pdTRUE )
{
- socketStatus =
+ socketStatus =
TLS_Recv( pConnection->pvTLSContext, pBuffer, bufferSize );
bytesReceived = socketStatus;
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c
index bb9124b61..181d07785 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c
@@ -25,7 +25,7 @@
/**
* @file iot_threads_freertos.c
- * @brief Implementation of the platform specific functions in iot_threads.h for
+ * @brief Implementation of the platform specific functions in iot_threads.h for
* FreeRTOS.
*/
@@ -96,7 +96,7 @@ bool Iot_CreateDetachedThread( IotThreadRoutine_t threadRoutine,
int32_t priority,
size_t stackSize )
{
- bool status = true;
+ bool status = true;
configASSERT( threadRoutine != NULL );
@@ -113,7 +113,7 @@ bool Iot_CreateDetachedThread( IotThreadRoutine_t threadRoutine,
if( status )
{
pThreadInfo->threadRoutine = threadRoutine;
- pThreadInfo->pArgument = pArgument;
+ pThreadInfo->pArgument = pArgument;
if( xTaskCreate( _threadRoutineWrapper,
"iot_thread",
@@ -182,7 +182,7 @@ bool prIotMutexTimedLock( IotMutex_t * pMutex,
TickType_t timeout )
{
_IotSystemMutex_t * internalMutex = ( _IotSystemMutex_t * ) pMutex;
- BaseType_t lockResult;
+ BaseType_t lockResult;
configASSERT( internalMutex != NULL );
@@ -258,7 +258,7 @@ bool IotSemaphore_Create( IotSemaphore_t * pNewSemaphore,
uint32_t IotSemaphore_GetCount( IotSemaphore_t * pSemaphore )
{
_IotSystemSemaphore_t * internalSemaphore = ( _IotSystemSemaphore_t * ) pSemaphore;
- UBaseType_t count = 0;
+ UBaseType_t count = 0;
configASSERT( internalSemaphore != NULL );
@@ -299,7 +299,7 @@ void IotSemaphore_Wait( IotSemaphore_t * pSemaphore )
IotLogWarn( "Failed to wait on semaphore %p.",
pSemaphore );
- /* There is an assert here because during debugging we could falsely
+ /* There is an assert here because during debugging we could falsely
* believe that we are waiting successfully on a semaphore. */
configASSERT( false );
}
@@ -354,7 +354,7 @@ void IotSemaphore_Post( IotSemaphore_t * pSemaphore )
IotLogDebug( "Posting to semaphore %p.", internalSemaphore );
/* Give the semaphore using the FreeRTOS API. */
- BaseType_t result = xSemaphoreGive( ( SemaphoreHandle_t ) &internalSemaphore->xSemaphore );
+ BaseType_t result = xSemaphoreGive( ( SemaphoreHandle_t ) &internalSemaphore->xSemaphore );
if( result == pdFALSE )
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c
index 0d55dd2ac..feb9bd8c9 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c
@@ -49,80 +49,80 @@
#include <stdint.h>
#if configSUPPORT_STATIC_ALLOCATION != 1
- #error configSUPPORT_STATIC_ALLOCATION must be set to 1 in FreeRTOSConfig.h
+ #error configSUPPORT_STATIC_ALLOCATION must be set to 1 in FreeRTOSConfig.h
#endif
#if configUSE_TIMERS != 1
- #error configUSE_TIMERS must be set to 1 in FreeRTOSConfig.h
+ #error configUSE_TIMERS must be set to 1 in FreeRTOSConfig.h
#endif
#if INCLUDE_vTaskSuspend != 1
- #error INCLUDE_vTaskSuspend must be set to 1 in FreeRTOSConfig.h
+ #error INCLUDE_vTaskSuspend must be set to 1 in FreeRTOSConfig.h
#endif
/* Task pool include. */
#include "taskpool_freertos.h"
#ifndef configTASKPOOL_DISPATCH_QUEUE_LENGTH
- #define configTASKPOOL_DISPATCH_QUEUE_LENGTH 16U
+ #define configTASKPOOL_DISPATCH_QUEUE_LENGTH 16U
#endif
#ifndef configTASKPOOL_NUMBER_OF_WORKERS
- #error configTASKPOOL_NUMBER_OF_WORKERS must be defined for the task pool.
+ #error configTASKPOOL_NUMBER_OF_WORKERS must be defined for the task pool.
#endif
#ifndef configTASKPOOL_WORKER_PRIORITY
- #error configTASKPOOL_WORKER_PRIORITY must be defined for the task pool.
+ #error configTASKPOOL_WORKER_PRIORITY must be defined for the task pool.
#endif
#ifndef configTASKPOOL_WORKER_STACK_SIZE_BYTES
- #define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048U
+ #define configTASKPOOL_WORKER_STACK_SIZE_BYTES 2048U
#endif
#if TASKPOOL_KEEP_COUNTS == 1
- #define increment( x ) ( taskPoolCounts.x++ )
+ #define increment( x ) ( taskPoolCounts.x++ )
#else
- #define increment( x )
+ #define increment( x )
#endif
-/*
- * Macros for states of a task pool job.
+/*
+ * Macros for states of a task pool job.
* These are not thread-safe and thus, are internal to the taskpool.
*/
/**
* Job is uninitialized.
*/
-#define TASKPOOL_JOB_STATUS_UNDEFINED 0U
+#define TASKPOOL_JOB_STATUS_UNDEFINED 0U
/**
* Job is ready to be dispatched or scheduled.
*/
-#define TASKPOOL_JOB_STATUS_READY 1U
+#define TASKPOOL_JOB_STATUS_READY 1U
/**
* Job has been queued for execution.
*/
-#define TASKPOOL_JOB_STATUS_DISPATCHED 2U
+#define TASKPOOL_JOB_STATUS_DISPATCHED 2U
/**
* Job has been scheduled for deferred execution.
*/
-#define TASKPOOL_JOB_STATUS_DEFERRED 3U
+#define TASKPOOL_JOB_STATUS_DEFERRED 3U
/**
* Job is executing. This is a terminal state.
*/
-#define TASKPOOL_JOB_STATUS_EXECUTING 4U
+#define TASKPOOL_JOB_STATUS_EXECUTING 4U
/**
* Job has been cancelled before executing.
* This is a terminal state.
*/
-#define TASKPOOL_JOB_STATUS_CANCELLED 5U
+#define TASKPOOL_JOB_STATUS_CANCELLED 5U
/**
- * Job has been submitted for scheduling, and
+ * Job has been submitted for scheduling, and
* cannot be cancelled.
*/
-#define TASKPOOL_JOB_STATUS_NOT_CANCELLABLE 6U
+#define TASKPOOL_JOB_STATUS_NOT_CANCELLABLE 6U
/* ------------------------------------------------------------------------------ */
@@ -132,23 +132,24 @@
/* Define instance for tracking task pool usage outcomes. */
#if TASKPOOL_KEEP_COUNTS == 1
- struct taskPoolUsageCounts taskPoolCounts;
+ struct taskPoolUsageCounts taskPoolCounts;
#endif
/**
* This internal unnamed structure holds the global state of the system task pool.
*/
-#define QUEUE_BYTES ( configTASKPOOL_DISPATCH_QUEUE_LENGTH * sizeof( struct taskPoolJob * ) )
-#define STACK_WORDS ( configTASKPOOL_WORKER_STACK_SIZE_BYTES / sizeof( portSTACK_TYPE ) )
+#define QUEUE_BYTES ( configTASKPOOL_DISPATCH_QUEUE_LENGTH * sizeof( struct taskPoolJob * ) )
+#define STACK_WORDS ( configTASKPOOL_WORKER_STACK_SIZE_BYTES / sizeof( portSTACK_TYPE ) )
static struct
{
- QueueHandle_t dispatchQueue; /**< queue of jobs to be executed */
- uint8_t queueData[ QUEUE_BYTES ]; /**< hold copies of enqueued values */
- StaticQueue_t queueBuffer; /**< static storage for queue itself */
- BaseType_t running; /**< has the task pool been started */
- StaticTask_t workerTaskTCBs[ configTASKPOOL_NUMBER_OF_WORKERS ]; /**< static storage of TCBs for workers tasks */
- StackType_t workerTaskStacks[ configTASKPOOL_NUMBER_OF_WORKERS ][ STACK_WORDS ]; /**< static storage for stack memory of workers tasks */
-} taskPool;
+ QueueHandle_t dispatchQueue; /**< queue of jobs to be executed */
+ uint8_t queueData[ QUEUE_BYTES ]; /**< hold copies of enqueued values */
+ StaticQueue_t queueBuffer; /**< static storage for queue itself */
+ BaseType_t running; /**< has the task pool been started */
+ StaticTask_t workerTaskTCBs[ configTASKPOOL_NUMBER_OF_WORKERS ]; /**< static storage of TCBs for workers tasks */
+ StackType_t workerTaskStacks[ configTASKPOOL_NUMBER_OF_WORKERS ][ STACK_WORDS ]; /**< static storage for stack memory of workers tasks */
+}
+taskPool;
/**
* Each task pool worker runs this function perpetually.
@@ -156,7 +157,7 @@ static struct
* @param[in] userContext The user context.
*
*/
-static void taskPoolWorker( void *pContext );
+static void taskPoolWorker( void * pContext );
/**
* Dispatch a job for execution whose timer has expired.
@@ -173,268 +174,273 @@ static void timerCallback( TimerHandle_t xTimer );
void taskPoolCreateSystemTaskPool( void )
{
-BaseType_t running;
-uint8_t x;
-
- /* Has the task pool already been started? */
- taskENTER_CRITICAL();
- running = taskPool.running;
- taskPool.running = pdTRUE;
- taskEXIT_CRITICAL();
-
- if( running == pdFALSE )
- {
- /*
- * The schedule function and timer callbacks add jobs to this queue.
- * Workers read and execute jobs from this queue.
- */
- taskPool.dispatchQueue =
- xQueueCreateStatic( configTASKPOOL_DISPATCH_QUEUE_LENGTH,
- sizeof ( struct taskPoolJob * ),
- taskPool.queueData,
- &taskPool.queueBuffer );
-
- configASSERT( taskPool.dispatchQueue != NULL );
-
- /* Launch the worker task(s). */
- for( x = 0; x < ( UBaseType_t ) configTASKPOOL_NUMBER_OF_WORKERS; x++ )
- {
- /* a unique name for the task. */
- char taskName[] = "worker.n";
- taskName[ sizeof( taskName ) - 2U ] = '0' + x;
-
- /* Coverity suggests adding const qualification to the local variable `task`.
- * There is no value in making the task handle variable const as it is defined
- * only for the purpose of assert checking.
- */
- /* coverity[misra_c_2012_rule_8_13_violation] */
- TaskHandle_t task =
- xTaskCreateStatic( taskPoolWorker,
- taskName,
- ( uint32_t ) STACK_WORDS,
- NULL,
- configTASKPOOL_WORKER_PRIORITY,
- &( taskPool.workerTaskStacks[ x ][ 0 ] ),
- &( taskPool.workerTaskTCBs[ x ] ) );
-
- configASSERT( task != NULL );
-
- /* Suppress unused local variable compiler warning. */
- ( void ) task;
- }
- }
+ BaseType_t running;
+ uint8_t x;
+
+ /* Has the task pool already been started? */
+ taskENTER_CRITICAL();
+ running = taskPool.running;
+ taskPool.running = pdTRUE;
+ taskEXIT_CRITICAL();
+
+ if( running == pdFALSE )
+ {
+ /*
+ * The schedule function and timer callbacks add jobs to this queue.
+ * Workers read and execute jobs from this queue.
+ */
+ taskPool.dispatchQueue =
+ xQueueCreateStatic( configTASKPOOL_DISPATCH_QUEUE_LENGTH,
+ sizeof( struct taskPoolJob * ),
+ taskPool.queueData,
+ &taskPool.queueBuffer );
+
+ configASSERT( taskPool.dispatchQueue != NULL );
+
+ /* Launch the worker task(s). */
+ for( x = 0; x < ( UBaseType_t ) configTASKPOOL_NUMBER_OF_WORKERS; x++ )
+ {
+ /* a unique name for the task. */
+ char taskName[] = "worker.n";
+ taskName[ sizeof( taskName ) - 2U ] = '0' + x;
+
+ /* Coverity suggests adding const qualification to the local variable `task`.
+ * There is no value in making the task handle variable const as it is defined
+ * only for the purpose of assert checking.
+ */
+ /* coverity[misra_c_2012_rule_8_13_violation] */
+ TaskHandle_t task =
+ xTaskCreateStatic( taskPoolWorker,
+ taskName,
+ ( uint32_t ) STACK_WORDS,
+ NULL,
+ configTASKPOOL_WORKER_PRIORITY,
+ &( taskPool.workerTaskStacks[ x ][ 0 ] ),
+ &( taskPool.workerTaskTCBs[ x ] ) );
+
+ configASSERT( task != NULL );
+
+ /* Suppress unused local variable compiler warning. */
+ ( void ) task;
+ }
+ }
}
/*-----------------------------------------------------------*/
-void taskPoolInitializeJob( taskPoolRoutine_t userCallback,
- void *userContext,
- taskPoolJob_t *jobStorage )
+void taskPoolInitializeJob( taskPoolRoutine_t userCallback,
+ void * userContext,
+ taskPoolJob_t * jobStorage )
{
- configASSERT( taskPool.running == pdTRUE );
+ configASSERT( taskPool.running == pdTRUE );
- /* Parameter checking. */
- configASSERT( userCallback != NULL );
- configASSERT( jobStorage != NULL );
+ /* Parameter checking. */
+ configASSERT( userCallback != NULL );
+ configASSERT( jobStorage != NULL );
- /* Initialize the job within the user-provided storage instance. */
- jobStorage->userCallback = userCallback;
- jobStorage->userContext = userContext;
- jobStorage->status = TASKPOOL_JOB_STATUS_READY;
+ /* Initialize the job within the user-provided storage instance. */
+ jobStorage->userCallback = userCallback;
+ jobStorage->userContext = userContext;
+ jobStorage->status = TASKPOOL_JOB_STATUS_READY;
- increment( initialized );
+ increment( initialized );
}
/*-----------------------------------------------------------*/
BaseType_t taskPoolIsJobInitialised( taskPoolJob_t * job )
{
- return ( job->status != TASKPOOL_JOB_STATUS_UNDEFINED );
+ return( job->status != TASKPOOL_JOB_STATUS_UNDEFINED );
}
/*-----------------------------------------------------------*/
-taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job,
- uint32_t timeMs )
+taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job,
+ uint32_t timeMs )
{
-taskPoolError_t status = TASKPOOL_GENERAL_FAILURE;
-BaseType_t result;
-UBaseType_t savedStatus;
-
- /*
- * Check that the timer task priority is higher than that of the calling task.
- * Reason: Deferred scheduling of a job requires starting the job's timer. To guarantee
- * that the timer has been started before this function returns, we have to wait for the
- * timer (service) task to process the timer start command that is enqueued by xTimerStart.
- * The enqueue operation within FreeRTOS contains a "yield" operation that will ensure
- * processing of the timer start command, IF the timer task has a higher priority than this
- * function's calling task.
- */
- configASSERT( uxTaskPriorityGet( xTaskGetCurrentTaskHandle() ) < configTIMER_TASK_PRIORITY );
-
- configASSERT( taskPool.running == pdTRUE );
- configASSERT( ( job != NULL ) && ( job->status != TASKPOOL_JOB_STATUS_UNDEFINED ) );
-
- /* This critical section complements synchronization with TryCancel function. */
- taskENTER_CRITICAL();
- savedStatus = job->status;
- if( job->status == TASKPOOL_JOB_STATUS_READY )
- {
- /* Prevent job from being cancelled (temporarily).*/
- job->status = TASKPOOL_JOB_STATUS_NOT_CANCELLABLE;
- }
- taskEXIT_CRITICAL();
-
- if( savedStatus != TASKPOOL_JOB_STATUS_READY )
- {
- /* Only a job in the ready state may be scheduled. */
- status = TASKPOOL_ILLEGAL_OPERATION;
- increment( schedule_illegal );
- }
- else
- {
- /* If not deferred, dispatch the job without starting the timer. */
- if( timeMs == 0UL )
- {
- /*
- * Update the job state before enqueueing the job to avoid data race
- * in case when job's callback re-uses the job memory for scheduling a new job.
- */
- job->status = TASKPOOL_JOB_STATUS_DISPATCHED;
-
- /*
- * Do not block on the enqueue operation as the job has been requested
- * to be executed immediately.
- */
- if( xQueueSendToBack( taskPool.dispatchQueue, &job, 0 ) == pdPASS )
- {
- status = TASKPOOL_SUCCESS;
- increment( direct_dispatch );
- }
- else
- {
- job->status = TASKPOOL_JOB_STATUS_CANCELLED;
- status = TASKPOOL_FAILED_OPERATION;
- increment( direct_dispatch_failed );
- }
- }
- else
- {
- /* Software timer will manage the time delay for the deferred job. */
- job->timer =
- xTimerCreateStatic( NULL,
- pdMS_TO_TICKS( timeMs ),
- pdFALSE,
- job,
- timerCallback,
- &job->timerStorage );
-
- configASSERT( job->timer != NULL );
- /*
- * Block on sending the timer start command to the timer command queue
- * to ensure that the job's timer is started before this function returns.
- * Reason: Blocking indefinitely on the call causes the timer task (of higher
- * priority ) to be executed which ensures that the timer start command has
- * been processed to start the job's timer.
- */
- result = xTimerStart( job->timer, portMAX_DELAY );
- configASSERT( result == pdPASS );
-
- job->status = TASKPOOL_JOB_STATUS_DEFERRED;
- status = TASKPOOL_SUCCESS;
- increment( timer_start );
- }
- }
-
- return status;
+ taskPoolError_t status = TASKPOOL_GENERAL_FAILURE;
+ BaseType_t result;
+ UBaseType_t savedStatus;
+
+ /*
+ * Check that the timer task priority is higher than that of the calling task.
+ * Reason: Deferred scheduling of a job requires starting the job's timer. To guarantee
+ * that the timer has been started before this function returns, we have to wait for the
+ * timer (service) task to process the timer start command that is enqueued by xTimerStart.
+ * The enqueue operation within FreeRTOS contains a "yield" operation that will ensure
+ * processing of the timer start command, IF the timer task has a higher priority than this
+ * function's calling task.
+ */
+ configASSERT( uxTaskPriorityGet( xTaskGetCurrentTaskHandle() ) < configTIMER_TASK_PRIORITY );
+
+ configASSERT( taskPool.running == pdTRUE );
+ configASSERT( ( job != NULL ) && ( job->status != TASKPOOL_JOB_STATUS_UNDEFINED ) );
+
+ /* This critical section complements synchronization with TryCancel function. */
+ taskENTER_CRITICAL();
+ savedStatus = job->status;
+
+ if( job->status == TASKPOOL_JOB_STATUS_READY )
+ {
+ /* Prevent job from being cancelled (temporarily).*/
+ job->status = TASKPOOL_JOB_STATUS_NOT_CANCELLABLE;
+ }
+
+ taskEXIT_CRITICAL();
+
+ if( savedStatus != TASKPOOL_JOB_STATUS_READY )
+ {
+ /* Only a job in the ready state may be scheduled. */
+ status = TASKPOOL_ILLEGAL_OPERATION;
+ increment( schedule_illegal );
+ }
+ else
+ {
+ /* If not deferred, dispatch the job without starting the timer. */
+ if( timeMs == 0UL )
+ {
+ /*
+ * Update the job state before enqueueing the job to avoid data race
+ * in case when job's callback re-uses the job memory for scheduling a new job.
+ */
+ job->status = TASKPOOL_JOB_STATUS_DISPATCHED;
+
+ /*
+ * Do not block on the enqueue operation as the job has been requested
+ * to be executed immediately.
+ */
+ if( xQueueSendToBack( taskPool.dispatchQueue, &job, 0 ) == pdPASS )
+ {
+ status = TASKPOOL_SUCCESS;
+ increment( direct_dispatch );
+ }
+ else
+ {
+ job->status = TASKPOOL_JOB_STATUS_CANCELLED;
+ status = TASKPOOL_FAILED_OPERATION;
+ increment( direct_dispatch_failed );
+ }
+ }
+ else
+ {
+ /* Software timer will manage the time delay for the deferred job. */
+ job->timer =
+ xTimerCreateStatic( NULL,
+ pdMS_TO_TICKS( timeMs ),
+ pdFALSE,
+ job,
+ timerCallback,
+ &job->timerStorage );
+
+ configASSERT( job->timer != NULL );
+
+ /*
+ * Block on sending the timer start command to the timer command queue
+ * to ensure that the job's timer is started before this function returns.
+ * Reason: Blocking indefinitely on the call causes the timer task (of higher
+ * priority ) to be executed which ensures that the timer start command has
+ * been processed to start the job's timer.
+ */
+ result = xTimerStart( job->timer, portMAX_DELAY );
+ configASSERT( result == pdPASS );
+
+ job->status = TASKPOOL_JOB_STATUS_DEFERRED;
+ status = TASKPOOL_SUCCESS;
+ increment( timer_start );
+ }
+ }
+
+ return status;
}
/*-----------------------------------------------------------*/
-taskPoolError_t taskPoolTryCancel( taskPoolJob_t *job )
+taskPoolError_t taskPoolTryCancel( taskPoolJob_t * job )
{
-taskPoolError_t status = TASKPOOL_GENERAL_FAILURE;
-UBaseType_t savedStatus;
-BaseType_t result = pdFAIL;
-
- /*
- * Check that the timer task priority is higher than that of the calling task.
- * Reason: Cancelling a job requires cancellation of the job's associated timer,
- * and this function needs to wait for the timer (service) task to cancel the timer
- * before this function returns. The enqueue operation, that is part of the xTimerDelete
- * call, contains a "yield" operation that will ensure the timer (service) task runs,
- * only IF the timer task has a higher priority than this function's calling task.
- */
- configASSERT( uxTaskPriorityGet( xTaskGetCurrentTaskHandle() ) < configTIMER_TASK_PRIORITY );
-
- configASSERT( taskPool.running == pdTRUE );
- configASSERT( ( job != NULL ) && ( job->status != TASKPOOL_JOB_STATUS_UNDEFINED ) );
-
- /* This critical section complements the one in timerCallback() for synchronization. */
- taskENTER_CRITICAL();
- savedStatus = job->status;
- if( ( savedStatus == TASKPOOL_JOB_STATUS_READY ) ||
- ( savedStatus == TASKPOOL_JOB_STATUS_DEFERRED ) ||
- ( savedStatus == TASKPOOL_JOB_STATUS_CANCELLED ) )
- {
- job->status = TASKPOOL_JOB_STATUS_CANCELLED;
- status = TASKPOOL_SUCCESS;
- increment( cancel );
- }
- else
- {
- status = TASKPOOL_ILLEGAL_OPERATION;
- increment( cancel_illegal );
- }
- taskEXIT_CRITICAL();
-
- if( savedStatus == TASKPOOL_JOB_STATUS_DEFERRED )
- {
- /*
- * Block on sending the delete command to the timer task's command queue
- * to ensure that the job's timer is either deleted OR the job is not dispatched
- * (if the job's timer has expired and has invoked the timer's callback).
- * Reason: Blocking indefinitely on the call causes the timer task (of higher
- * priority ) to be executed which ensures that the timer delete command has
- * been processed, and the job is not executed.
- */
- result = xTimerDelete( job->timer, portMAX_DELAY );
- configASSERT( result == pdTRUE );
- }
-
- return status;
+ taskPoolError_t status = TASKPOOL_GENERAL_FAILURE;
+ UBaseType_t savedStatus;
+ BaseType_t result = pdFAIL;
+
+ /*
+ * Check that the timer task priority is higher than that of the calling task.
+ * Reason: Cancelling a job requires cancellation of the job's associated timer,
+ * and this function needs to wait for the timer (service) task to cancel the timer
+ * before this function returns. The enqueue operation, that is part of the xTimerDelete
+ * call, contains a "yield" operation that will ensure the timer (service) task runs,
+ * only IF the timer task has a higher priority than this function's calling task.
+ */
+ configASSERT( uxTaskPriorityGet( xTaskGetCurrentTaskHandle() ) < configTIMER_TASK_PRIORITY );
+
+ configASSERT( taskPool.running == pdTRUE );
+ configASSERT( ( job != NULL ) && ( job->status != TASKPOOL_JOB_STATUS_UNDEFINED ) );
+
+ /* This critical section complements the one in timerCallback() for synchronization. */
+ taskENTER_CRITICAL();
+ savedStatus = job->status;
+
+ if( ( savedStatus == TASKPOOL_JOB_STATUS_READY ) ||
+ ( savedStatus == TASKPOOL_JOB_STATUS_DEFERRED ) ||
+ ( savedStatus == TASKPOOL_JOB_STATUS_CANCELLED ) )
+ {
+ job->status = TASKPOOL_JOB_STATUS_CANCELLED;
+ status = TASKPOOL_SUCCESS;
+ increment( cancel );
+ }
+ else
+ {
+ status = TASKPOOL_ILLEGAL_OPERATION;
+ increment( cancel_illegal );
+ }
+
+ taskEXIT_CRITICAL();
+
+ if( savedStatus == TASKPOOL_JOB_STATUS_DEFERRED )
+ {
+ /*
+ * Block on sending the delete command to the timer task's command queue
+ * to ensure that the job's timer is either deleted OR the job is not dispatched
+ * (if the job's timer has expired and has invoked the timer's callback).
+ * Reason: Blocking indefinitely on the call causes the timer task (of higher
+ * priority ) to be executed which ensures that the timer delete command has
+ * been processed, and the job is not executed.
+ */
+ result = xTimerDelete( job->timer, portMAX_DELAY );
+ configASSERT( result == pdTRUE );
+ }
+
+ return status;
}
/*-----------------------------------------------------------*/
const char * taskPoolStrError( taskPoolError_t status )
{
-const char *pMessage = NULL;
+ const char * pMessage = NULL;
- switch( status )
- {
- case TASKPOOL_SUCCESS:
- pMessage = "SUCCESS";
- break;
+ switch( status )
+ {
+ case TASKPOOL_SUCCESS:
+ pMessage = "SUCCESS";
+ break;
- case TASKPOOL_ILLEGAL_OPERATION:
- pMessage = "OPERATION NOT ALLOWED";
- break;
+ case TASKPOOL_ILLEGAL_OPERATION:
+ pMessage = "OPERATION NOT ALLOWED";
+ break;
- case TASKPOOL_FAILED_OPERATION:
- pMessage = "OPERATION FAILED";
- break;
+ case TASKPOOL_FAILED_OPERATION:
+ pMessage = "OPERATION FAILED";
+ break;
- case TASKPOOL_GENERAL_FAILURE:
- pMessage = "GENERAL FAILURE";
- break;
+ case TASKPOOL_GENERAL_FAILURE:
+ pMessage = "GENERAL FAILURE";
+ break;
- default:
- pMessage = "INVALID STATUS";
- break;
- }
+ default:
+ pMessage = "INVALID STATUS";
+ break;
+ }
- return pMessage;
+ return pMessage;
}
/* ------------------------------------------------------------------------------ */
@@ -447,84 +453,84 @@ const char *pMessage = NULL;
*/
static void timerCallback( TimerHandle_t xTimer )
{
-struct taskPoolJob *job;
-
- increment( timer_callback );
- configASSERT( xTimer != NULL );
-
- job = ( struct taskPoolJob * ) pvTimerGetTimerID( xTimer );
- configASSERT( job != NULL );
-
- configASSERT( ( job->status == TASKPOOL_JOB_STATUS_READY ) ||
- ( job->status == TASKPOOL_JOB_STATUS_DEFERRED ) ||
- ( job->status == TASKPOOL_JOB_STATUS_CANCELLED ) );
-
- /*
- * Skip enqueue of a job that's been cancelled.
- */
- if( job->status != TASKPOOL_JOB_STATUS_CANCELLED )
- {
- /* No blocking time for the enqueue operation to avoid blocking operation on timer task. */
- if( xQueueSendToBack( taskPool.dispatchQueue, &job, 0 ) == pdPASS )
- {
- job->status = TASKPOOL_JOB_STATUS_DISPATCHED;
- increment( callback_dispatch );
- }
- else
- {
- /*
- * The queue must be full. Re-try dispatching the job after some delay
- * by resetting the job's timer.
- */
- if( xTimerReset( job->timer, 0 ) == pdPASS )
- {
- job->status = TASKPOOL_JOB_STATUS_DEFERRED;
- increment( callback_reschedule );
- }
- else
- {
- job->status = TASKPOOL_JOB_STATUS_CANCELLED;
- increment( reschedule_failed );
- }
- }
- }
+ struct taskPoolJob * job;
+
+ increment( timer_callback );
+ configASSERT( xTimer != NULL );
+
+ job = ( struct taskPoolJob * ) pvTimerGetTimerID( xTimer );
+ configASSERT( job != NULL );
+
+ configASSERT( ( job->status == TASKPOOL_JOB_STATUS_READY ) ||
+ ( job->status == TASKPOOL_JOB_STATUS_DEFERRED ) ||
+ ( job->status == TASKPOOL_JOB_STATUS_CANCELLED ) );
+
+ /*
+ * Skip enqueue of a job that's been cancelled.
+ */
+ if( job->status != TASKPOOL_JOB_STATUS_CANCELLED )
+ {
+ /* No blocking time for the enqueue operation to avoid blocking operation on timer task. */
+ if( xQueueSendToBack( taskPool.dispatchQueue, &job, 0 ) == pdPASS )
+ {
+ job->status = TASKPOOL_JOB_STATUS_DISPATCHED;
+ increment( callback_dispatch );
+ }
+ else
+ {
+ /*
+ * The queue must be full. Re-try dispatching the job after some delay
+ * by resetting the job's timer.
+ */
+ if( xTimerReset( job->timer, 0 ) == pdPASS )
+ {
+ job->status = TASKPOOL_JOB_STATUS_DEFERRED;
+ increment( callback_reschedule );
+ }
+ else
+ {
+ job->status = TASKPOOL_JOB_STATUS_CANCELLED;
+ increment( reschedule_failed );
+ }
+ }
+ }
}
/*-----------------------------------------------------------*/
/* Coverity suggests adding const qualification to the parameter.
* Suppress the violation as this function follows the signature of
- * the `TaskFunction_t` type required by `xTaskCreateStatic` function.
+ * the `TaskFunction_t` type required by `xTaskCreateStatic` function.
*/
/* coverity[misra_c_2012_rule_8_13_violation] */
-static void taskPoolWorker( void *pContext )
+static void taskPoolWorker( void * pContext )
{
- /*
- * Timer task is critical to the functioning of the task pool. Thus, we want to
- * prevent possibility of context switch from timer task during execution of the
- * timer callback by requiring task pool worker(s) to have lower priority than timer
- * task.
- */
- configASSERT( configTASKPOOL_WORKER_PRIORITY < configTIMER_TASK_PRIORITY );
-
- /* Suppress unused parameter compiler warning. */
- ( void ) pContext;
-
- for( ; ; )
- {
- struct taskPoolJob *job;
- BaseType_t result;
-
- /* block until a job arrives */
- result = xQueueReceive( taskPool.dispatchQueue, &job, portMAX_DELAY );
- configASSERT( result == pdTRUE );
- configASSERT( ( job != NULL ) && ( job->userCallback != NULL ) );
-
- job->status = TASKPOOL_JOB_STATUS_EXECUTING;
-
- /* The job may reuse job storage within the callback for a new job. */
- increment( job_started );
- job->userCallback( job, job->userContext );
- increment( job_done );
- }
+ /*
+ * Timer task is critical to the functioning of the task pool. Thus, we want to
+ * prevent possibility of context switch from timer task during execution of the
+ * timer callback by requiring task pool worker(s) to have lower priority than timer
+ * task.
+ */
+ configASSERT( configTASKPOOL_WORKER_PRIORITY < configTIMER_TASK_PRIORITY );
+
+ /* Suppress unused parameter compiler warning. */
+ ( void ) pContext;
+
+ for( ; ; )
+ {
+ struct taskPoolJob * job;
+ BaseType_t result;
+
+ /* block until a job arrives */
+ result = xQueueReceive( taskPool.dispatchQueue, &job, portMAX_DELAY );
+ configASSERT( result == pdTRUE );
+ configASSERT( ( job != NULL ) && ( job->userCallback != NULL ) );
+
+ job->status = TASKPOOL_JOB_STATUS_EXECUTING;
+
+ /* The job may reuse job storage within the callback for a new job. */
+ increment( job_started );
+ job->userCallback( job, job->userContext );
+ increment( job_done );
+ }
}
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.h
index b9ff81868..6165870bd 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.h
@@ -42,26 +42,25 @@
*/
typedef enum taskPoolError
{
- /**
- * @brief Task pool operation general failure.
- */
- TASKPOOL_GENERAL_FAILURE = 0,
+ /**
+ * @brief Task pool operation general failure.
+ */
+ TASKPOOL_GENERAL_FAILURE = 0,
- /**
- * @brief Task pool operation completed successfully.
- */
- TASKPOOL_SUCCESS,
+ /**
+ * @brief Task pool operation completed successfully.
+ */
+ TASKPOOL_SUCCESS,
- /**
- * @brief Task pool operation failed because it is illegal.
- */
- TASKPOOL_ILLEGAL_OPERATION,
-
- /**
- * @brief Task pool operation failed due to an OS error.
- */
- TASKPOOL_FAILED_OPERATION,
+ /**
+ * @brief Task pool operation failed because it is illegal.
+ */
+ TASKPOOL_ILLEGAL_OPERATION,
+ /**
+ * @brief Task pool operation failed due to an OS error.
+ */
+ TASKPOOL_FAILED_OPERATION,
} taskPoolError_t;
/*------------------------- Task pool types --------------------------*/
@@ -73,63 +72,64 @@ typedef enum taskPoolError
* @note Counting may be disabled by defining TASKPOOL_KEEP_COUNTS to 0.
*/
#ifndef TASKPOOL_KEEP_COUNTS
- #define TASKPOOL_KEEP_COUNTS 1
+ #define TASKPOOL_KEEP_COUNTS 1
#endif
#if TASKPOOL_KEEP_COUNTS == 1
-struct taskPoolUsageCounts
-{
- UBaseType_t initialized; /**< jobs initialized */
+ struct taskPoolUsageCounts
+ {
+ UBaseType_t initialized; /**< jobs initialized */
- UBaseType_t schedule_illegal; /**< illegal to schedule a job not ready */
- UBaseType_t direct_dispatch; /**< job with 0 wait directly dispatched */
- UBaseType_t direct_dispatch_failed; /**< direct dispatch failed */
- UBaseType_t timer_start; /**< job timer started */
+ UBaseType_t schedule_illegal; /**< illegal to schedule a job not ready */
+ UBaseType_t direct_dispatch; /**< job with 0 wait directly dispatched */
+ UBaseType_t direct_dispatch_failed; /**< direct dispatch failed */
+ UBaseType_t timer_start; /**< job timer started */
- UBaseType_t cancel; /**< deferred job cancelled before execution */
- UBaseType_t cancel_illegal; /**< illegal to cancel job in non-deferred state */
+ UBaseType_t cancel; /**< deferred job cancelled before execution */
+ UBaseType_t cancel_illegal; /**< illegal to cancel job in non-deferred state */
- UBaseType_t timer_callback; /**< callback runs for expired timers */
- UBaseType_t callback_dispatch; /**< job added to dispatch queue */
- UBaseType_t callback_reschedule; /**< timer reset due to full dispatch queue */
- UBaseType_t reschedule_failed; /**< jobs cancelled due to failed reschedule */
+ UBaseType_t timer_callback; /**< callback runs for expired timers */
+ UBaseType_t callback_dispatch; /**< job added to dispatch queue */
+ UBaseType_t callback_reschedule; /**< timer reset due to full dispatch queue */
+ UBaseType_t reschedule_failed; /**< jobs cancelled due to failed reschedule */
- UBaseType_t job_started; /**< worker to call job callback */
- UBaseType_t job_done; /**< worker done with job callback */
-};
+ UBaseType_t job_started; /**< worker to call job callback */
+ UBaseType_t job_done; /**< worker done with job callback */
+ };
-extern struct taskPoolUsageCounts taskPoolCounts;
+ extern struct taskPoolUsageCounts taskPoolCounts;
-#define taskPoolDumpCounts() do { \
- configPRINTF( ( "%24s: %5u\n", "initialized", \
- taskPoolCounts.initialized ) ); \
- configPRINTF( ( "%24s: %5u\n", "schedule_illegal", \
- taskPoolCounts.schedule_illegal ) ); \
- configPRINTF( ( "%24s: %5u\n", "direct_dispatch", \
- taskPoolCounts.direct_dispatch ) ); \
- configPRINTF( ( "%24s: %5u\n", "direct_dispatch_failed", \
- taskPoolCounts.direct_dispatch_failed ) ); \
- configPRINTF( ( "%24s: %5u\n", "timer_start", \
- taskPoolCounts.timer_start ) ); \
- configPRINTF( ( "%24s: %5u\n", "cancel", \
- taskPoolCounts.cancel ) ); \
- configPRINTF( ( "%24s: %5u\n", "cancel_illegal", \
- taskPoolCounts.cancel_illegal ) ); \
- configPRINTF( ( "%24s: %5u\n", "timer_callback", \
- taskPoolCounts.timer_callback ) ); \
- configPRINTF( ( "%24s: %5u\n", "callback_dispatch", \
- taskPoolCounts.callback_dispatch ) ); \
- configPRINTF( ( "%24s: %5u\n", "callback_reschedule", \
- taskPoolCounts.callback_reschedule ) ); \
- configPRINTF( ( "%24s: %5u\n", "reschedule_failed", \
- taskPoolCounts.reschedule_failed ) ); \
- configPRINTF( ( "%24s: %5u\n", "job_started", \
- taskPoolCounts.job_started ) ); \
- configPRINTF( ( "%24s: %5u\n", "job_done", \
- taskPoolCounts.job_done ) ); \
-} while (0)
-#else
- #define taskPoolDumpCounts( ... )
-#endif
+ #define taskPoolDumpCounts() \
+ do { \
+ configPRINTF( ( "%24s: %5u\n", "initialized", \
+ taskPoolCounts.initialized ) ); \
+ configPRINTF( ( "%24s: %5u\n", "schedule_illegal", \
+ taskPoolCounts.schedule_illegal ) ); \
+ configPRINTF( ( "%24s: %5u\n", "direct_dispatch", \
+ taskPoolCounts.direct_dispatch ) ); \
+ configPRINTF( ( "%24s: %5u\n", "direct_dispatch_failed", \
+ taskPoolCounts.direct_dispatch_failed ) ); \
+ configPRINTF( ( "%24s: %5u\n", "timer_start", \
+ taskPoolCounts.timer_start ) ); \
+ configPRINTF( ( "%24s: %5u\n", "cancel", \
+ taskPoolCounts.cancel ) ); \
+ configPRINTF( ( "%24s: %5u\n", "cancel_illegal", \
+ taskPoolCounts.cancel_illegal ) ); \
+ configPRINTF( ( "%24s: %5u\n", "timer_callback", \
+ taskPoolCounts.timer_callback ) ); \
+ configPRINTF( ( "%24s: %5u\n", "callback_dispatch", \
+ taskPoolCounts.callback_dispatch ) ); \
+ configPRINTF( ( "%24s: %5u\n", "callback_reschedule", \
+ taskPoolCounts.callback_reschedule ) ); \
+ configPRINTF( ( "%24s: %5u\n", "reschedule_failed", \
+ taskPoolCounts.reschedule_failed ) ); \
+ configPRINTF( ( "%24s: %5u\n", "job_started", \
+ taskPoolCounts.job_started ) ); \
+ configPRINTF( ( "%24s: %5u\n", "job_done", \
+ taskPoolCounts.job_done ) ); \
+ } while( 0 )
+#else /* if TASKPOOL_KEEP_COUNTS == 1 */
+ #define taskPoolDumpCounts( ... )
+#endif /* if TASKPOOL_KEEP_COUNTS == 1 */
/**
* @ingroup taskpool_datatypes_handles
@@ -151,8 +151,8 @@ typedef struct taskPoolJob taskPoolJob_t;
* @ref taskPoolScheduleDeferred.
*
*/
-typedef void ( * taskPoolRoutine_t )( taskPoolJob_t * job,
- void * userContext );
+typedef void ( * taskPoolRoutine_t )( taskPoolJob_t * job,
+ void * userContext );
/**
* @ingroup taskpool_datatypes_structs
@@ -167,11 +167,11 @@ typedef void ( * taskPoolRoutine_t )( taskPoolJob_t * job,
*/
struct taskPoolJob
{
- UBaseType_t status; /**< status of the job */
- taskPoolRoutine_t userCallback; /**< user provided callback */
- void *userContext; /**< user provided context */
- TimerHandle_t timer; /**< timer for deferring a job */
- StaticTimer_t timerStorage; /**< storage for the above timer */
+ UBaseType_t status; /**< status of the job */
+ taskPoolRoutine_t userCallback; /**< user provided callback */
+ void * userContext; /**< user provided context */
+ TimerHandle_t timer; /**< timer for deferring a job */
+ StaticTimer_t timerStorage; /**< storage for the above timer */
};
/*------------------------- Task Pool library functions --------------------------*/
@@ -194,17 +194,17 @@ void taskPoolCreateSystemTaskPool( void );
* @param[in] userCallback A user-specified callback for the job.
* @param[in] userContext A user-specified context for the callback.
* @param[in] jobStorage The storage memory for the job data structure.
- *
+ *
* @note This function is not thread-safe in initializing the provided job memory
* while another task context is accessing the same memory.
- *
+ *
* @warning A job's memory is safe for re-use ONLY when the job has been
* executed or cancelled. Also, the contents of the job memory SHOULD NOT
* be modified directly by the caller.
*/
-void taskPoolInitializeJob( taskPoolRoutine_t userCallback,
- void * userContext,
- taskPoolJob_t * jobStorage );
+void taskPoolInitializeJob( taskPoolRoutine_t userCallback,
+ void * userContext,
+ taskPoolJob_t * jobStorage );
/**
* @brief Helper function to determine if a job memory has been initialised.
@@ -224,11 +224,11 @@ BaseType_t taskPoolIsJobInitialised( taskPoolJob_t * job );
* - #TASKPOOL_SUCCESS
* - #TASKPOOL_ILLEGAL_OPERATION
* - #TASKPOOL_FAILED_OPERATION
- *
+ *
* @note Be aware of the following:
* 1. The calling task MUST have a lower priority than the timer (service) task
* to ensure reliable behavior of the taskpool.
- * 2. This is a blocking function for starting the timer for deferred jobs.
+ * 2. This is a blocking function for starting the timer for deferred jobs.
*
* <b>Example</b>
* @code{c}
@@ -241,7 +241,7 @@ BaseType_t taskPoolIsJobInitialised( taskPoolJob_t * job );
* // Statically allocate job and callback context instances.
* static taskPoolJob_t job;
* static JobUserContext_t userContext;
- *
+ *
* // An example of a user callback to invoke through a task pool thread.
* static void ExecutionCb( taskPoolJob_t * job, void * context )
* {
@@ -279,9 +279,9 @@ BaseType_t taskPoolIsJobInitialised( taskPoolJob_t * job );
* }
* @endcode
*/
-taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job,
- uint32_t timeMs );
-#define taskPoolSchedule( x ) taskPoolScheduleDeferred( x, 0 )
+taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job,
+ uint32_t timeMs );
+#define taskPoolSchedule( x ) taskPoolScheduleDeferred( x, 0 )
/**
* @brief Attempt to cancel a job
@@ -294,12 +294,12 @@ taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job,
* @return One of the following:
* - #TASKPOOL_SUCCESS
* - #TASKPOOL_ILLEGAL_OPERATION
- *
+ *
* @note Be aware of the following:
* 1. The calling task must have a lower priority than the timer (service) task
* to ensure reliable behavior of the taskpool.
* 2. This is a blocking function for cancelling the timer associated with a deferred job.
- *
+ *
*/
taskPoolError_t taskPoolTryCancel( taskPoolJob_t * job );
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c
index 2fcea4681..29ec7a979 100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c
@@ -76,7 +76,7 @@ static const char * pNoHighLevelMbedTlsCodeStr = "<No-High-Level-Code>";
* @brief Represents string to be logged when mbedTLS returned error
* does not contain a low-level code.
*/
-static const char * pNoLowLevelMbedTlsCodeStr = "<No-Low-Level-Code>";
+static const char * pNoLowLevelMbedTlsCodeStr = "<No-Low-Level-Code>";
/**
* @brief Utility for converting the high-level code in an mbedTLS error to string,
@@ -476,7 +476,7 @@ static CK_RV prvMbedTLS_Initialize( void )
xP11Context.xObjectList.xMutex = xSemaphoreCreateMutexStatic(
&xP11Context.xObjectList.xMutexBuffer );
- xP11Context.xSessionMutex = xSemaphoreCreateMutexStatic(
+ xP11Context.xSessionMutex = xSemaphoreCreateMutexStatic(
&xP11Context.xSessionMutexBuffer );
if( ( xP11Context.xObjectList.xMutex == NULL ) || ( xP11Context.xSessionMutex == NULL ) )
@@ -518,7 +518,7 @@ static CK_RV prvGetObjectClass( const CK_ATTRIBUTE * pxTemplate,
CK_ULONG ulCount,
CK_OBJECT_CLASS * pxClass )
{
- CK_RV xResult = CKR_TEMPLATE_INCOMPLETE;
+ CK_RV xResult = CKR_TEMPLATE_INCOMPLETE;
CK_ULONG ulIndex = 0;
/* Search template for class attribute. */
@@ -547,10 +547,10 @@ static CK_RV prvCertAttParse( CK_ATTRIBUTE * pxAttribute,
CK_ULONG * pxCertificateLength,
CK_ATTRIBUTE ** ppxLabel )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE;
+ CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE;
switch( pxAttribute->type )
{
@@ -602,7 +602,7 @@ static CK_RV prvCertAttParse( CK_ATTRIBUTE * pxAttribute,
break;
default:
- xResult = CKR_ATTRIBUTE_TYPE_INVALID;
+ xResult = CKR_ATTRIBUTE_TYPE_INVALID;
break;
}
@@ -616,9 +616,9 @@ static CK_RV prvCertAttParse( CK_ATTRIBUTE * pxAttribute,
static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute,
const mbedtls_pk_context * pxMbedContext )
{
- CK_RV xResult = CKR_OK;
- int32_t lMbedReturn = 0;
- CK_BBOOL xBool;
+ CK_RV xResult = CKR_OK;
+ int32_t lMbedReturn = 0;
+ CK_BBOOL xBool;
mbedtls_rsa_context * pxRsaContext = ( mbedtls_rsa_context * ) pxMbedContext->pk_ctx;
switch( pxAttribute->type )
@@ -702,7 +702,7 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute,
default:
PKCS11_PRINT( ( "Unknown attribute found for RSA private key. %d \r\n", pxAttribute->type ) );
- xResult = CKR_ATTRIBUTE_TYPE_INVALID;
+ xResult = CKR_ATTRIBUTE_TYPE_INVALID;
break;
}
@@ -728,10 +728,10 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute,
{
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE;
- int32_t lMbedReturn = 0;
- CK_RV xResult = CKR_OK;
- mbedtls_ecp_keypair * pxKeyPair = ( mbedtls_ecp_keypair * ) pxMbedContext->pk_ctx;
+ CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE;
+ int32_t lMbedReturn = 0;
+ CK_RV xResult = CKR_OK;
+ mbedtls_ecp_keypair * pxKeyPair = ( mbedtls_ecp_keypair * ) pxMbedContext->pk_ctx;
if( pxAttribute->type == CKA_SIGN )
{
@@ -775,10 +775,10 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute,
{
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE;
- int32_t lMbedReturn = 0;
- CK_RV xResult = CKR_OK;
- mbedtls_ecp_keypair * pxKeyPair = ( mbedtls_ecp_keypair * ) pxMbedContext->pk_ctx;
+ CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE;
+ int32_t lMbedReturn = 0;
+ CK_RV xResult = CKR_OK;
+ mbedtls_ecp_keypair * pxKeyPair = ( mbedtls_ecp_keypair * ) pxMbedContext->pk_ctx;
if( pxAttribute->type == CKA_VERIFY )
{
@@ -822,12 +822,12 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute,
const mbedtls_pk_context * pxMbedContext,
CK_BBOOL xIsPrivate )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE;
- const CK_BYTE pxEcCurve[] = pkcs11DER_ENCODED_OID_P256;
- const CK_BYTE * pxEcAttVal = NULL;
+ CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE;
+ const CK_BYTE pxEcCurve[] = pkcs11DER_ENCODED_OID_P256;
+ const CK_BYTE * pxEcAttVal = NULL;
const CK_BBOOL * pxEcBoolAtt = NULL;
/* Common EC key attributes. */
@@ -854,7 +854,7 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute,
break;
case ( CKA_EC_PARAMS ):
- pxEcAttVal = ( CK_BYTE * ) pxAttribute->pValue;
+ pxEcAttVal = ( CK_BYTE * ) pxAttribute->pValue;
if( memcmp( pxEcCurve, pxEcAttVal, pxAttribute->ulValueLen ) != 0 )
{
@@ -898,7 +898,7 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute,
default:
PKCS11_PRINT( ( "Unknown attribute found for an EC public key. %d \r\n", pxAttribute->type ) );
- xResult = CKR_ATTRIBUTE_TYPE_INVALID;
+ xResult = CKR_ATTRIBUTE_TYPE_INVALID;
break;
}
@@ -958,17 +958,17 @@ static void prvFindObjectInListByHandle( CK_OBJECT_HANDLE xAppHandle,
{
uint32_t ulIndex = xAppHandle - 1UL;
- *ppcLabel = NULL;
+ *ppcLabel = NULL;
*pxLabelLength = 0;
- *pxPalHandle = CK_INVALID_HANDLE;
+ *pxPalHandle = CK_INVALID_HANDLE;
if( ulIndex < pkcs11configMAX_NUM_OBJECTS )
{
if( xP11Context.xObjectList.xObjects[ ulIndex ].xHandle != CK_INVALID_HANDLE )
{
- *ppcLabel = xP11Context.xObjectList.xObjects[ ulIndex ].xLabel;
+ *ppcLabel = xP11Context.xObjectList.xObjects[ ulIndex ].xLabel;
*pxLabelLength = xP11Context.xObjectList.xObjects[ ulIndex ].xLabelSize;
- *pxPalHandle = xP11Context.xObjectList.xObjects[ ulIndex ].xHandle;
+ *pxPalHandle = xP11Context.xObjectList.xObjects[ ulIndex ].xHandle;
}
}
}
@@ -983,9 +983,9 @@ static void prvFindObjectInListByHandle( CK_OBJECT_HANDLE xAppHandle,
*/
static CK_RV prvDeleteObjectFromList( CK_OBJECT_HANDLE xAppHandle )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
BaseType_t xGotSemaphore = pdFALSE;
- uint32_t ulIndex = xAppHandle - 1UL;
+ uint32_t ulIndex = xAppHandle - 1UL;
if( ulIndex >= pkcs11configMAX_NUM_OBJECTS )
{
@@ -1033,13 +1033,13 @@ static CK_RV prvAddObjectToList( CK_OBJECT_HANDLE xPalHandle,
const CK_BYTE_PTR pcLabel,
CK_ULONG xLabelLength )
{
- CK_RV xResult = CKR_HOST_MEMORY;
+ CK_RV xResult = CKR_HOST_MEMORY;
BaseType_t xGotSemaphore;
xGotSemaphore = xSemaphoreTake( xP11Context.xObjectList.xMutex, portMAX_DELAY );
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xObjectFound = ( CK_BBOOL ) CK_FALSE;
+ CK_BBOOL xObjectFound = ( CK_BBOOL ) CK_FALSE;
uint32_t ulSearchIndex = 0;
if( pdTRUE == xGotSemaphore )
@@ -1056,7 +1056,7 @@ static CK_RV prvAddObjectToList( CK_OBJECT_HANDLE xPalHandle,
/* Object already exists in list. */
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- xResult = CKR_OK;
+ xResult = CKR_OK;
xObjectFound = ( CK_BBOOL ) CK_TRUE;
}
else if( xP11Context.xObjectList.xObjects[ ulSearchIndex ].xHandle == CK_INVALID_HANDLE )
@@ -1075,7 +1075,7 @@ static CK_RV prvAddObjectToList( CK_OBJECT_HANDLE xPalHandle,
{
if( xLabelLength < pkcs11configMAX_LABEL_LENGTH )
{
- xP11Context.xObjectList.xObjects[ ulSearchIndex - 1UL ].xHandle = xPalHandle;
+ xP11Context.xObjectList.xObjects[ ulSearchIndex - 1UL ].xHandle = xPalHandle;
( void ) memcpy( xP11Context.xObjectList.xObjects[ ulSearchIndex - 1UL ].xLabel, pcLabel, xLabelLength );
xP11Context.xObjectList.xObjects[ ulSearchIndex - 1UL ].xLabelSize = xLabelLength;
*pxAppHandle = ulSearchIndex;
@@ -1106,12 +1106,12 @@ static CK_RV prvSaveDerKeyToPal( mbedtls_pk_context * pxMbedContext,
CK_KEY_TYPE xKeyType,
CK_BBOOL xIsPrivate )
{
- CK_RV xResult = CKR_OK;
- CK_BYTE_PTR pxDerKey;
- int32_t lDerKeyLength = 0;
- uint32_t ulActualKeyLength = 0;
- int32_t lCompare = 0;
- CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
+ CK_RV xResult = CKR_OK;
+ CK_BYTE_PTR pxDerKey;
+ int32_t lDerKeyLength = 0;
+ uint32_t ulActualKeyLength = 0;
+ int32_t lCompare = 0;
+ CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
pxDerKey = pvPortMalloc( MAX_PUBLIC_KEY_SIZE );
@@ -1178,7 +1178,7 @@ static CK_RV prvSaveDerKeyToPal( mbedtls_pk_context * pxMbedContext,
{
/* Do not write the last 6 bytes to key storage. */
pxDerKey[ MAX_LENGTH_KEY - lDerKeyLength + 1 ] -= ( uint8_t ) 6;
- ulActualKeyLength -= 6UL;
+ ulActualKeyLength -= 6UL;
}
}
@@ -1208,21 +1208,21 @@ static CK_RV prvSaveDerKeyToPal( mbedtls_pk_context * pxMbedContext,
#if ( pkcs11configPAL_DESTROY_SUPPORTED != 1 )
CK_RV PKCS11_PAL_DestroyObject( CK_OBJECT_HANDLE xHandle )
{
- CK_BYTE_PTR pcLabel = NULL;
- CK_ULONG xLabelLength = 0;
- CK_ULONG ulObjectLength = 0;
+ CK_BYTE_PTR pcLabel = NULL;
+ CK_ULONG xLabelLength = 0;
+ CK_ULONG ulObjectLength = 0;
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
- CK_RV xResult = CKR_OK;
- CK_BYTE_PTR pxObject = NULL;
- CK_ATTRIBUTE xLabel = { 0 };
- CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
- CK_OBJECT_HANDLE xPalHandle2 = CK_INVALID_HANDLE;
- CK_OBJECT_HANDLE xAppHandle2 = CK_INVALID_HANDLE;
- CK_BYTE_PTR pxZeroedData = NULL;
- CK_BYTE pxPubKeyLabel[] = { pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS };
- CK_BYTE pxPrivKeyLabel[] = { pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS };
+ CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
+ CK_RV xResult = CKR_OK;
+ CK_BYTE_PTR pxObject = NULL;
+ CK_ATTRIBUTE xLabel = { 0 };
+ CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
+ CK_OBJECT_HANDLE xPalHandle2 = CK_INVALID_HANDLE;
+ CK_OBJECT_HANDLE xAppHandle2 = CK_INVALID_HANDLE;
+ CK_BYTE_PTR pxZeroedData = NULL;
+ CK_BYTE pxPubKeyLabel[] = { pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS };
+ CK_BYTE pxPrivKeyLabel[] = { pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS };
prvFindObjectInListByHandle( xHandle, &xPalHandle, &pcLabel, &xLabelLength );
@@ -1240,11 +1240,11 @@ static CK_RV prvSaveDerKeyToPal( mbedtls_pk_context * pxMbedContext,
/* Zero out the object. */
( void ) memset( pxZeroedData, 0x0, ulObjectLength );
/* Create an object label attribute. */
- xLabel.type = CKA_LABEL;
- xLabel.pValue = pcLabel;
+ xLabel.type = CKA_LABEL;
+ xLabel.pValue = pcLabel;
xLabel.ulValueLen = xLabelLength;
/* Overwrite the object in NVM with zeros. */
- xPalHandle2 = PKCS11_PAL_SaveObject( &xLabel, pxZeroedData, ulObjectLength );
+ xPalHandle2 = PKCS11_PAL_SaveObject( &xLabel, pxZeroedData, ulObjectLength );
if( xPalHandle2 != xPalHandle )
{
@@ -1409,7 +1409,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_Finalize )( CK_VOID_PTR pReserved )
/* @[declare_pkcs11_mbedtls_c_getfunctionlist] */
CK_DECLARE_FUNCTION( CK_RV, C_GetFunctionList )( CK_FUNCTION_LIST_PTR_PTR ppFunctionList )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
static CK_FUNCTION_LIST prvP11FunctionList =
{
@@ -1551,7 +1551,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetSlotList )( CK_BBOOL tokenPresent,
else
{
pSlotList[ 0 ] = pkcs11SLOT_ID;
- *pulCount = 1;
+ *pulCount = 1;
}
}
}
@@ -1605,7 +1605,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetMechanismInfo )( CK_SLOT_ID slotID,
/* Disable unused parameter warning. */
( void ) slotID;
- CK_RV xResult = CKR_MECHANISM_INVALID;
+ CK_RV xResult = CKR_MECHANISM_INVALID;
if( pInfo == NULL )
{
@@ -1627,7 +1627,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetMechanismInfo )( CK_SLOT_ID slotID,
#endif
{ CKM_SHA256, { 0, 0, CKF_DIGEST } }
};
- uint32_t ulMech = 0;
+ uint32_t ulMech = 0;
if( xResult == CKR_MECHANISM_INVALID )
{
@@ -1700,9 +1700,9 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID,
CK_NOTIFY Notify,
CK_SESSION_HANDLE_PTR phSession )
{
- CK_RV xResult = CKR_OK;
- P11Session_t * pxSessionObj = NULL;
- uint32_t ulSessionCount = 0;
+ CK_RV xResult = CKR_OK;
+ P11Session_t * pxSessionObj = NULL;
+ uint32_t ulSessionCount = 0;
( void ) ( slotID );
( void ) ( pApplication );
@@ -1745,8 +1745,8 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID,
/* coverity[misra_c_2012_rule_10_5_violation] */
if( pxP11Sessions[ ulSessionCount ].xOpened == ( CK_BBOOL ) CK_FALSE )
{
- xResult = CKR_OK;
- pxSessionObj = &pxP11Sessions[ ulSessionCount ];
+ xResult = CKR_OK;
+ pxSessionObj = &pxP11Sessions[ ulSessionCount ];
/* coverity[misra_c_2012_rule_10_5_violation] */
pxSessionObj->xOpened = ( CK_BBOOL ) CK_TRUE;
break;
@@ -1767,7 +1767,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID,
if( CKR_OK == xResult )
{
- pxSessionObj->xSignMutex = xSemaphoreCreateMutex();
+ pxSessionObj->xSignMutex = xSemaphoreCreateMutex();
if( NULL == pxSessionObj->xSignMutex )
{
@@ -1799,7 +1799,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID,
{
pxSessionObj->xOperationDigestMechanism = pkcs11NO_OPERATION;
pxSessionObj->xOperationVerifyMechanism = pkcs11NO_OPERATION;
- pxSessionObj->xOperationSignMechanism = pkcs11NO_OPERATION;
+ pxSessionObj->xOperationSignMechanism = pkcs11NO_OPERATION;
}
if( CKR_OK != xResult )
@@ -1847,7 +1847,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID,
CK_DECLARE_FUNCTION( CK_RV, C_CloseSession )( CK_SESSION_HANDLE hSession )
{
P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
/* coverity[misra_c_2012_rule_10_5_violation] */
if( xP11Context.xIsInitialized == ( CK_BBOOL ) CK_FALSE )
@@ -1934,13 +1934,13 @@ static CK_RV prvCreateCertificate( CK_ATTRIBUTE * pxTemplate,
CK_ULONG ulCount,
CK_OBJECT_HANDLE_PTR pxObject )
{
- CK_RV xResult = CKR_OK;
- CK_BYTE_PTR pxCertificateValue = NULL;
- CK_ULONG xCertificateLength = 0;
- CK_ATTRIBUTE_PTR pxLabel = NULL;
- CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
- CK_CERTIFICATE_TYPE xCertificateType = 0;
- CK_ULONG ulIndex = 0;
+ CK_RV xResult = CKR_OK;
+ CK_BYTE_PTR pxCertificateValue = NULL;
+ CK_ULONG xCertificateLength = 0;
+ CK_ATTRIBUTE_PTR pxLabel = NULL;
+ CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
+ CK_CERTIFICATE_TYPE xCertificateType = 0;
+ CK_ULONG ulIndex = 0;
/* Search for the pointer to the certificate VALUE. */
for( ulIndex = 0; ulIndex < ulCount; ulIndex++ )
@@ -1996,7 +1996,7 @@ static void prvGetKeyType( CK_KEY_TYPE * pxKeyType,
const CK_ATTRIBUTE * pxTemplate,
CK_ULONG ulCount )
{
- uint32_t ulIndex;
+ uint32_t ulIndex;
CK_ATTRIBUTE xAttribute;
*pxKeyType = PKCS11_INVALID_KEY_TYPE;
@@ -2026,7 +2026,7 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel,
CK_ULONG ulCount )
{
CK_ATTRIBUTE xAttribute;
- CK_ULONG ulIndex;
+ CK_ULONG ulIndex;
*ppxLabel = NULL;
@@ -2060,15 +2060,15 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel,
mbedtls_pk_context * pxMbedContext,
const CK_ATTRIBUTE * pxLabel )
{
- CK_BYTE_PTR pucData = NULL;
- CK_ULONG ulDataLength = 0;
+ CK_BYTE_PTR pucData = NULL;
+ CK_ULONG ulDataLength = 0;
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
- CK_RV xResult = CKR_OK;
- int32_t lMbedResult = 0;
- CK_BYTE pxPubKeyLabel[] = { pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS };
- CK_BYTE pxPrivKeyLabel[] = { pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS };
+ CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
+ CK_RV xResult = CKR_OK;
+ int32_t lMbedResult = 0;
+ CK_BYTE pxPubKeyLabel[] = { pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS };
+ CK_BYTE pxPrivKeyLabel[] = { pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS };
*pxPalHandle = CK_INVALID_HANDLE;
@@ -2081,7 +2081,7 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel,
*pxPalHandle = PKCS11_PAL_FindObject( pxPrivKeyLabel, pxLabel->ulValueLen );
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- xIsPrivate = ( CK_BBOOL ) CK_FALSE;
+ xIsPrivate = ( CK_BBOOL ) CK_FALSE;
}
else
{
@@ -2139,12 +2139,12 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel,
{
- CK_RV xResult = CKR_OK;
- uint32_t ulIndex;
- CK_ATTRIBUTE_PTR pxLabel = NULL;
- CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
- int32_t lMbedTLSReturn = 0;
- mbedtls_pk_context xMbedContext;
+ CK_RV xResult = CKR_OK;
+ uint32_t ulIndex;
+ CK_ATTRIBUTE_PTR pxLabel = NULL;
+ CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
+ int32_t lMbedTLSReturn = 0;
+ mbedtls_pk_context xMbedContext;
mbedtls_ecp_keypair * pxKeyPair;
mbedtls_pk_init( &xMbedContext );
@@ -2177,13 +2177,13 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel,
xMbedContext.pk_info = &mbedtls_eckey_info;
/* Initialize the context. */
- xMbedContext.pk_ctx = pxKeyPair;
+ xMbedContext.pk_ctx = pxKeyPair;
mbedtls_ecp_keypair_init( pxKeyPair );
mbedtls_ecp_group_init( &pxKeyPair->grp );
/* At this time, only P-256 curves are supported. */
- lMbedTLSReturn = mbedtls_ecp_group_load( &pxKeyPair->grp,
- MBEDTLS_ECP_DP_SECP256R1 );
+ lMbedTLSReturn = mbedtls_ecp_group_load( &pxKeyPair->grp,
+ MBEDTLS_ECP_DP_SECP256R1 );
if( lMbedTLSReturn != 0 )
{
@@ -2243,13 +2243,13 @@ static CK_RV prvCreateRsaPrivateKey( CK_ATTRIBUTE * pxTemplate,
CK_ULONG ulCount,
CK_OBJECT_HANDLE_PTR pxObject )
{
- CK_RV xResult = CKR_OK;
- mbedtls_pk_context xMbedContext = { 0 };
- uint32_t ulIndex;
- CK_ATTRIBUTE_PTR pxLabel = NULL;
+ CK_RV xResult = CKR_OK;
+ mbedtls_pk_context xMbedContext = { 0 };
+ uint32_t ulIndex;
+ CK_ATTRIBUTE_PTR pxLabel = NULL;
/* mbedtls_rsa_context must be malloc'ed to use with mbedtls_pk_free function. */
- mbedtls_rsa_context * pxRsaCtx = pvPortMalloc( sizeof( mbedtls_rsa_context ) );
+ mbedtls_rsa_context * pxRsaCtx = pvPortMalloc( sizeof( mbedtls_rsa_context ) );
prvGetLabel( &pxLabel, pxTemplate, ulCount );
@@ -2261,7 +2261,7 @@ static CK_RV prvCreateRsaPrivateKey( CK_ATTRIBUTE * pxTemplate,
if( pxRsaCtx != NULL )
{
mbedtls_pk_init( &xMbedContext );
- xMbedContext.pk_ctx = pxRsaCtx;
+ xMbedContext.pk_ctx = pxRsaCtx;
xMbedContext.pk_info = &mbedtls_rsa_info;
mbedtls_rsa_init( pxRsaCtx, MBEDTLS_RSA_PKCS_V15, 0 /*ignored.*/ );
}
@@ -2313,7 +2313,7 @@ static CK_RV prvCreatePrivateKey( CK_ATTRIBUTE * pxTemplate,
CK_ULONG ulCount,
CK_OBJECT_HANDLE_PTR pxObject )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
CK_KEY_TYPE xKeyType;
prvGetKeyType( &xKeyType, pxTemplate, ulCount );
@@ -2359,7 +2359,7 @@ static CK_RV prvCreatePublicKey( CK_ATTRIBUTE * pxTemplate,
CK_OBJECT_HANDLE_PTR pxObject )
{
CK_KEY_TYPE xKeyType = 0;
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
#if ( pkcs11configSUPPRESS_ECDSA_MECHANISM == 1 )
/* Suppress unused parameter warning if ECDSA is suppressed. */
@@ -2448,10 +2448,10 @@ CK_DECLARE_FUNCTION( CK_RV, C_CreateObject )( CK_SESSION_HANDLE hSession,
CK_ULONG ulCount,
CK_OBJECT_HANDLE_PTR phObject )
{
- CK_OBJECT_CLASS xClass = 0;
+ CK_OBJECT_CLASS xClass = 0;
const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
if( ( NULL == pTemplate ) ||
( NULL == phObject ) )
@@ -2510,7 +2510,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DestroyObject )( CK_SESSION_HANDLE hSession,
CK_OBJECT_HANDLE hObject )
{
const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
if( xResult == CKR_OK )
{
@@ -2568,24 +2568,24 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession,
{
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
- CK_ULONG iAttrib;
- mbedtls_pk_context xKeyContext = { 0 };
- mbedtls_pk_type_t xKeyType;
+ CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
+ CK_ULONG iAttrib;
+ mbedtls_pk_context xKeyContext = { 0 };
+ mbedtls_pk_type_t xKeyType;
const mbedtls_ecp_keypair * pxKeyPair;
- CK_KEY_TYPE xPkcsKeyType = ( CK_KEY_TYPE ) ~0UL;
- CK_OBJECT_CLASS xClass;
- CK_BYTE_PTR pxObjectValue = NULL;
- CK_ULONG ulLength = 0;
- const CK_BYTE ucP256Oid[] = pkcs11DER_ENCODED_OID_P256;
- int32_t lMbedTLSResult = 0;
- CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
- CK_ULONG xSize = 0;
- size_t xMbedSize = 0;
- CK_BYTE_PTR pcLabel = NULL;
-
- const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_KEY_TYPE xPkcsKeyType = ( CK_KEY_TYPE ) ~0UL;
+ CK_OBJECT_CLASS xClass;
+ CK_BYTE_PTR pxObjectValue = NULL;
+ CK_ULONG ulLength = 0;
+ const CK_BYTE ucP256Oid[] = pkcs11DER_ENCODED_OID_P256;
+ int32_t lMbedTLSResult = 0;
+ CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
+ CK_ULONG xSize = 0;
+ size_t xMbedSize = 0;
+ CK_BYTE_PTR pcLabel = NULL;
+
+ const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
if( ( CKR_OK == xResult ) && ( ( ( NULL == pTemplate ) ) || ( 0UL == ulCount ) ) )
{
@@ -2684,7 +2684,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession,
if( xIsPrivate == ( CK_BBOOL ) CK_TRUE )
{
pTemplate[ iAttrib ].ulValueLen = CK_UNAVAILABLE_INFORMATION;
- xResult = CKR_ATTRIBUTE_SENSITIVE;
+ xResult = CKR_ATTRIBUTE_SENSITIVE;
}
else
{
@@ -2736,7 +2736,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession,
break;
default:
- xResult = CKR_ATTRIBUTE_VALUE_INVALID;
+ xResult = CKR_ATTRIBUTE_VALUE_INVALID;
break;
}
@@ -2747,7 +2747,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession,
case CKA_PRIVATE_EXPONENT:
- xResult = CKR_ATTRIBUTE_SENSITIVE;
+ xResult = CKR_ATTRIBUTE_SENSITIVE;
break;
@@ -2779,18 +2779,18 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession,
}
else
{
- pxKeyPair = ( mbedtls_ecp_keypair * ) xKeyContext.pk_ctx;
+ pxKeyPair = ( mbedtls_ecp_keypair * ) xKeyContext.pk_ctx;
*( ( uint8_t * ) pTemplate[ iAttrib ].pValue ) = 0x04; /* Mark the point as uncompressed. */
/* Copy xSize value to avoid casting a CK_ULONG size pointer
* to a size_t sized pointer. */
- xMbedSize = xSize;
- lMbedTLSResult = mbedtls_ecp_tls_write_point( &pxKeyPair->grp,
- &pxKeyPair->Q,
- MBEDTLS_ECP_PF_UNCOMPRESSED,
- &xMbedSize,
- ( uint8_t * ) pTemplate[ iAttrib ].pValue + 1,
- pTemplate[ iAttrib ].ulValueLen - 1UL );
+ xMbedSize = xSize;
+ lMbedTLSResult = mbedtls_ecp_tls_write_point( &pxKeyPair->grp,
+ &pxKeyPair->Q,
+ MBEDTLS_ECP_PF_UNCOMPRESSED,
+ &xMbedSize,
+ ( uint8_t * ) pTemplate[ iAttrib ].pValue + 1,
+ pTemplate[ iAttrib ].ulValueLen - 1UL );
xSize = xMbedSize;
if( lMbedTLSResult < 0 )
@@ -2813,7 +2813,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession,
break;
default:
- xResult = CKR_ATTRIBUTE_TYPE_INVALID;
+ xResult = CKR_ATTRIBUTE_TYPE_INVALID;
break;
}
}
@@ -2856,11 +2856,11 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsInit )( CK_SESSION_HANDLE hSession,
CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG ulCount )
{
- P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
- CK_BYTE * pxFindObjectLabel = NULL;
- uint32_t ulIndex;
- CK_ATTRIBUTE xAttribute;
+ P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_BYTE * pxFindObjectLabel = NULL;
+ uint32_t ulIndex;
+ CK_ATTRIBUTE xAttribute;
if( NULL == pTemplate )
{
@@ -2888,10 +2888,10 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsInit )( CK_SESSION_HANDLE hSession,
if( xResult == CKR_OK )
{
/* Plus one to leave room for a NULL terminator. */
- pxFindObjectLabel = pvPortMalloc( pTemplate->ulValueLen + 1UL );
+ pxFindObjectLabel = pvPortMalloc( pTemplate->ulValueLen + 1UL );
pxSession->xFindObjectLabelLen = pTemplate->ulValueLen;
- pxSession->pxFindObjectLabel = pxFindObjectLabel;
+ pxSession->pxFindObjectLabel = pxFindObjectLabel;
if( pxFindObjectLabel != NULL )
{
@@ -2931,7 +2931,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsInit )( CK_SESSION_HANDLE hSession,
if( ( pxSession != NULL ) && ( xResult != CKR_OK ) )
{
vPortFree( pxFindObjectLabel );
- pxSession->pxFindObjectLabel = NULL;
+ pxSession->pxFindObjectLabel = NULL;
pxSession->xFindObjectLabelLen = 0;
}
@@ -2974,17 +2974,17 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjects )( CK_SESSION_HANDLE hSession,
CK_ULONG ulMaxObjectCount,
CK_ULONG_PTR pulObjectCount )
{
- P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
- CK_BYTE_PTR pucObjectValue = NULL;
- CK_ULONG xObjectLength = 0;
+ CK_BYTE_PTR pucObjectValue = NULL;
+ CK_ULONG xObjectLength = 0;
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
- CK_BYTE xByte = 0;
- CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
- CK_ULONG ulIndex;
+ CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
+ CK_BYTE xByte = 0;
+ CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
+ CK_ULONG ulIndex;
/*
* Check parameters.
@@ -3042,7 +3042,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjects )( CK_SESSION_HANDLE hSession,
}
else
{
- xResult = prvAddObjectToList( xPalHandle, phObject, pxSession->pxFindObjectLabel, pxSession->xFindObjectLabelLen );
+ xResult = prvAddObjectToList( xPalHandle, phObject, pxSession->pxFindObjectLabel, pxSession->xFindObjectLabelLen );
*pulObjectCount = 1;
}
@@ -3064,7 +3064,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjects )( CK_SESSION_HANDLE hSession,
if( pxSession != NULL )
{
vPortFree( pxSession->pxFindObjectLabel );
- pxSession->pxFindObjectLabel = NULL;
+ pxSession->pxFindObjectLabel = NULL;
pxSession->xFindObjectLabelLen = 0;
}
}
@@ -3094,7 +3094,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjects )( CK_SESSION_HANDLE hSession,
CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsFinal )( CK_SESSION_HANDLE hSession )
{
P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
/*
* Check parameters.
@@ -3113,7 +3113,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsFinal )( CK_SESSION_HANDLE hSession )
* Clean-up find objects state.
*/
vPortFree( pxSession->pxFindObjectLabel );
- pxSession->pxFindObjectLabel = NULL;
+ pxSession->pxFindObjectLabel = NULL;
pxSession->xFindObjectLabelLen = 0;
}
@@ -3144,7 +3144,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestInit )( CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism )
{
P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
if( pMechanism == NULL )
{
@@ -3215,7 +3215,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestUpdate )( CK_SESSION_HANDLE hSession,
CK_ULONG ulPartLen )
{
P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
if( pPart == NULL )
{
@@ -3235,7 +3235,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestUpdate )( CK_SESSION_HANDLE hSession,
{
if( 0 != mbedtls_sha256_update_ret( &pxSession->xSHA256Context, pPart, ulPartLen ) )
{
- xResult = CKR_FUNCTION_FAILED;
+ xResult = CKR_FUNCTION_FAILED;
pxSession->xOperationDigestMechanism = pkcs11NO_OPERATION;
}
}
@@ -3284,7 +3284,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestFinal )( CK_SESSION_HANDLE hSession,
CK_ULONG_PTR pulDigestLen )
{
P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
if( pulDigestLen == NULL )
@@ -3296,7 +3296,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestFinal )( CK_SESSION_HANDLE hSession,
{
if( pxSession->xOperationDigestMechanism != CKM_SHA256 )
{
- xResult = CKR_OPERATION_NOT_INITIALIZED;
+ xResult = CKR_OPERATION_NOT_INITIALIZED;
pxSession->xOperationDigestMechanism = pkcs11NO_OPERATION;
}
}
@@ -3368,17 +3368,17 @@ CK_DECLARE_FUNCTION( CK_RV, C_SignInit )( CK_SESSION_HANDLE hSession,
{
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
- CK_OBJECT_HANDLE xPalHandle;
- CK_BYTE_PTR pxLabel = NULL;
- CK_ULONG xLabelLength = 0;
+ CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
+ CK_OBJECT_HANDLE xPalHandle;
+ CK_BYTE_PTR pxLabel = NULL;
+ CK_ULONG xLabelLength = 0;
mbedtls_pk_type_t xKeyType;
- P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
- CK_BYTE_PTR pulKeyData = NULL;
- CK_ULONG ulKeyDataLength = 0;
- int32_t lMbedTLSResult = 0;
+ P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_BYTE_PTR pulKeyData = NULL;
+ CK_ULONG ulKeyDataLength = 0;
+ int32_t lMbedTLSResult = 0;
if( NULL == pMechanism )
@@ -3536,17 +3536,17 @@ CK_DECLARE_FUNCTION( CK_RV, C_Sign )( CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pSignature,
CK_ULONG_PTR pulSignatureLen )
{
- P11Session_t * pxSessionObj = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSessionObj );
+ P11Session_t * pxSessionObj = prvSessionPointerFromHandle( hSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSessionObj );
- CK_ULONG xSignatureLength = 0;
- size_t xExpectedInputLength = 0;
- CK_BYTE_PTR pxSignatureBuffer = pSignature;
+ CK_ULONG xSignatureLength = 0;
+ size_t xExpectedInputLength = 0;
+ CK_BYTE_PTR pxSignatureBuffer = pSignature;
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xSignatureGenerated = ( CK_BBOOL ) CK_FALSE;
- uint8_t ecSignature[ pkcs11ECDSA_P256_SIGNATURE_LENGTH + 15 ]; /*TODO: Figure out this length. */
- int32_t lMbedTLSResult;
+ CK_BBOOL xSignatureGenerated = ( CK_BBOOL ) CK_FALSE;
+ uint8_t ecSignature[ pkcs11ECDSA_P256_SIGNATURE_LENGTH + 15 ]; /*TODO: Figure out this length. */
+ int32_t lMbedTLSResult;
if( ( NULL == pulSignatureLen ) || ( NULL == pData ) )
@@ -3559,14 +3559,14 @@ CK_DECLARE_FUNCTION( CK_RV, C_Sign )( CK_SESSION_HANDLE hSession,
/* Update the signature length. */
if( pxSessionObj->xOperationSignMechanism == CKM_RSA_PKCS )
{
- xSignatureLength = pkcs11RSA_2048_SIGNATURE_LENGTH;
+ xSignatureLength = pkcs11RSA_2048_SIGNATURE_LENGTH;
xExpectedInputLength = pkcs11RSA_SIGNATURE_INPUT_LENGTH;
}
else if( pxSessionObj->xOperationSignMechanism == CKM_ECDSA )
{
- xSignatureLength = pkcs11ECDSA_P256_SIGNATURE_LENGTH;
+ xSignatureLength = pkcs11ECDSA_P256_SIGNATURE_LENGTH;
xExpectedInputLength = pkcs11SHA256_DIGEST_LENGTH;
- pxSignatureBuffer = ecSignature;
+ pxSignatureBuffer = ecSignature;
}
else
{
@@ -3599,14 +3599,14 @@ CK_DECLARE_FUNCTION( CK_RV, C_Sign )( CK_SESSION_HANDLE hSession,
{
if( pdTRUE == xSemaphoreTake( pxSessionObj->xSignMutex, portMAX_DELAY ) )
{
- lMbedTLSResult = mbedtls_pk_sign( &pxSessionObj->xSignKey,
- MBEDTLS_MD_NONE,
- pData,
- ulDataLen,
- pxSignatureBuffer,
- &xExpectedInputLength,
- mbedtls_ctr_drbg_random,
- &xP11Context.xMbedDrbgCtx );
+ lMbedTLSResult = mbedtls_pk_sign( &pxSessionObj->xSignKey,
+ MBEDTLS_MD_NONE,
+ pData,
+ ulDataLen,
+ pxSignatureBuffer,
+ &xExpectedInputLength,
+ mbedtls_ctr_drbg_random,
+ &xP11Context.xMbedDrbgCtx );
if( lMbedTLSResult != 0 )
{
@@ -3691,17 +3691,17 @@ CK_DECLARE_FUNCTION( CK_RV, C_VerifyInit )( CK_SESSION_HANDLE hSession,
{
/* See explanation in prvCheckValidSessionAndModule for this exception. */
/* coverity[misra_c_2012_rule_10_5_violation] */
- CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
- P11Session_t * pxSession;
- CK_BYTE_PTR pucKeyData = NULL;
- CK_ULONG ulKeyDataLength = 0;
+ CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE;
+ P11Session_t * pxSession;
+ CK_BYTE_PTR pucKeyData = NULL;
+ CK_ULONG ulKeyDataLength = 0;
mbedtls_pk_type_t xKeyType;
- CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
- CK_BYTE_PTR pxLabel = NULL;
- CK_ULONG xLabelLength = 0;
+ CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE;
+ CK_BYTE_PTR pxLabel = NULL;
+ CK_ULONG xLabelLength = 0;
pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
if( NULL == pMechanism )
{
@@ -3846,10 +3846,10 @@ CK_DECLARE_FUNCTION( CK_RV, C_Verify )( CK_SESSION_HANDLE hSession,
CK_ULONG ulSignatureLen )
{
P11Session_t * pxSessionObj;
- int32_t lMbedTLSResult;
+ int32_t lMbedTLSResult;
pxSessionObj = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSessionObj );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSessionObj );
/* Check parameters. */
if( ( NULL == pData ) ||
@@ -3927,8 +3927,8 @@ CK_DECLARE_FUNCTION( CK_RV, C_Verify )( CK_SESSION_HANDLE hSession,
/* TODO: Refactor w/ test code
* An ECDSA signature is comprised of 2 components - R & S. C_Sign returns them one after another. */
mbedtls_ecdsa_context * pxEcdsaContext;
- mbedtls_mpi xR;
- mbedtls_mpi xS;
+ mbedtls_mpi xR;
+ mbedtls_mpi xS;
mbedtls_mpi_init( &xR );
mbedtls_mpi_init( &xS );
@@ -4006,14 +4006,14 @@ static CK_RV prvCheckGenerateKeyPairPrivateTemplate( CK_ATTRIBUTE ** ppxLabel,
CK_ATTRIBUTE * pxAttribute,
uint32_t * pulAttributeMap )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
CK_BBOOL xBool;
CK_ULONG xTemp;
switch( pxAttribute->type )
{
case ( CKA_LABEL ):
- *ppxLabel = pxAttribute;
+ *ppxLabel = pxAttribute;
*pulAttributeMap |= LABEL_IN_TEMPLATE;
break;
@@ -4070,7 +4070,7 @@ static CK_RV prvCheckGenerateKeyPairPrivateTemplate( CK_ATTRIBUTE ** ppxLabel,
break;
default:
- xResult = CKR_ATTRIBUTE_TYPE_INVALID;
+ xResult = CKR_ATTRIBUTE_TYPE_INVALID;
break;
}
@@ -4093,16 +4093,16 @@ static CK_RV prvCheckGenerateKeyPairPublicTemplate( CK_ATTRIBUTE ** ppxLabel,
CK_ATTRIBUTE * pxAttribute,
uint32_t * pulAttributeMap )
{
- CK_RV xResult = CKR_OK;
- CK_BBOOL xBool;
- CK_KEY_TYPE xKeyType;
- const CK_BYTE pxEcParams[] = pkcs11DER_ENCODED_OID_P256;
+ CK_RV xResult = CKR_OK;
+ CK_BBOOL xBool;
+ CK_KEY_TYPE xKeyType;
+ const CK_BYTE pxEcParams[] = pkcs11DER_ENCODED_OID_P256;
const CK_BYTE * pxEcAttVal;
switch( pxAttribute->type )
{
case ( CKA_LABEL ):
- *ppxLabel = pxAttribute;
+ *ppxLabel = pxAttribute;
*pulAttributeMap |= LABEL_IN_TEMPLATE;
break;
@@ -4118,7 +4118,7 @@ static CK_RV prvCheckGenerateKeyPairPublicTemplate( CK_ATTRIBUTE ** ppxLabel,
break;
case ( CKA_EC_PARAMS ):
- pxEcAttVal = ( CK_BYTE * ) pxAttribute->pValue;
+ pxEcAttVal = ( CK_BYTE * ) pxAttribute->pValue;
if( memcmp( pxEcParams, pxEcAttVal, sizeof( pxEcParams ) ) != 0 )
{
@@ -4157,7 +4157,7 @@ static CK_RV prvCheckGenerateKeyPairPublicTemplate( CK_ATTRIBUTE ** ppxLabel,
break;
default:
- xResult = CKR_TEMPLATE_INCONSISTENT;
+ xResult = CKR_TEMPLATE_INCONSISTENT;
break;
}
@@ -4232,20 +4232,20 @@ CK_DECLARE_FUNCTION( CK_RV, C_GenerateKeyPair )( CK_SESSION_HANDLE hSession,
CK_OBJECT_HANDLE_PTR phPublicKey,
CK_OBJECT_HANDLE_PTR phPrivateKey )
{
- uint8_t * pucDerFile = pvPortMalloc( pkcs11KEY_GEN_MAX_DER_SIZE );
- int32_t lMbedResult = 0;
- uint32_t ulIndex = 0;
- mbedtls_pk_context xCtx = { 0 };
- CK_ATTRIBUTE_PTR pxPrivateLabel = NULL;
- CK_ATTRIBUTE_PTR pxPublicLabel = NULL;
- CK_OBJECT_HANDLE xPalPublic = CK_INVALID_HANDLE;
- CK_OBJECT_HANDLE xPalPrivate = CK_INVALID_HANDLE;
- uint32_t xPublicRequiredAttributeMap = ( LABEL_IN_TEMPLATE | EC_PARAMS_IN_TEMPLATE | VERIFY_IN_TEMPLATE );
- uint32_t xPrivateRequiredAttributeMap = ( LABEL_IN_TEMPLATE | PRIVATE_IN_TEMPLATE | SIGN_IN_TEMPLATE );
- uint32_t xAttributeMap = 0;
-
- const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
- CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
+ uint8_t * pucDerFile = pvPortMalloc( pkcs11KEY_GEN_MAX_DER_SIZE );
+ int32_t lMbedResult = 0;
+ uint32_t ulIndex = 0;
+ mbedtls_pk_context xCtx = { 0 };
+ CK_ATTRIBUTE_PTR pxPrivateLabel = NULL;
+ CK_ATTRIBUTE_PTR pxPublicLabel = NULL;
+ CK_OBJECT_HANDLE xPalPublic = CK_INVALID_HANDLE;
+ CK_OBJECT_HANDLE xPalPrivate = CK_INVALID_HANDLE;
+ uint32_t xPublicRequiredAttributeMap = ( LABEL_IN_TEMPLATE | EC_PARAMS_IN_TEMPLATE | VERIFY_IN_TEMPLATE );
+ uint32_t xPrivateRequiredAttributeMap = ( LABEL_IN_TEMPLATE | PRIVATE_IN_TEMPLATE | SIGN_IN_TEMPLATE );
+ uint32_t xAttributeMap = 0;
+
+ const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
+ CK_RV xResult = prvCheckValidSessionAndModule( pxSession );
#if ( pkcs11configSUPPRESS_ECDSA_MECHANISM == 1 )
if( xResult == CKR_OK )
@@ -4415,10 +4415,10 @@ CK_DECLARE_FUNCTION( CK_RV, C_GenerateRandom )( CK_SESSION_HANDLE hSession,
CK_BYTE_PTR RandomData,
CK_ULONG ulRandomLen )
{
- CK_RV xResult = CKR_OK;
- int32_t lMbedResult = 0;
+ CK_RV xResult = CKR_OK;
+ int32_t lMbedResult = 0;
- const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
+ const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession );
xResult = prvCheckValidSessionAndModule( pxSession );
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c
index 1ed5a522c..0883ddd96 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c
@@ -66,11 +66,11 @@
*/
enum eObjectHandles
{
- eInvalidHandle = 0, /**< According to PKCS #11 spec, 0 is never a valid object handle. */
- eAwsDevicePrivateKey = 1, /**< Private Key. */
- eAwsDevicePublicKey, /**< Public Key. */
- eAwsDeviceCertificate, /**< Certificate. */
- eAwsCodeSigningKey /**< Code Signing Key. */
+ eInvalidHandle = 0, /**< According to PKCS #11 spec, 0 is never a valid object handle. */
+ eAwsDevicePrivateKey = 1, /**< Private Key. */
+ eAwsDevicePublicKey, /**< Public Key. */
+ eAwsDeviceCertificate, /**< Certificate. */
+ eAwsCodeSigningKey /**< Code Signing Key. */
};
/*-----------------------------------------------------------*/
@@ -79,7 +79,7 @@ enum eObjectHandles
* @brief Checks to see if a file exists
*
* @param[in] pcFileName The name of the file to check for existance.
- *
+ *
* @returns pdTRUE if the file exists, pdFALSE if not.
*/
BaseType_t prvFileExists( const char * pcFileName )
@@ -104,7 +104,7 @@ BaseType_t prvFileExists( const char * pcFileName )
* @param[in] pcLabel The PKCS #11 label to convert to a file name
* @param[out] pcFileName The name of the file to check for existance.
* @param[out] pHandle The type of the PKCS #11 object.
- *
+ *
*/
void prvLabelToFilenameHandle( uint8_t * pcLabel,
char ** pcFileName,
@@ -118,33 +118,33 @@ void prvLabelToFilenameHandle( uint8_t * pcLabel,
sizeof( pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS ) ) )
{
*pcFileName = pkcs11palFILE_NAME_CLIENT_CERTIFICATE;
- *pHandle = eAwsDeviceCertificate;
+ *pHandle = eAwsDeviceCertificate;
}
else if( 0 == memcmp( pcLabel,
&pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS,
sizeof( pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS ) ) )
{
*pcFileName = pkcs11palFILE_NAME_KEY;
- *pHandle = eAwsDevicePrivateKey;
+ *pHandle = eAwsDevicePrivateKey;
}
else if( 0 == memcmp( pcLabel,
&pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS,
sizeof( pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS ) ) )
{
*pcFileName = pkcs11palFILE_NAME_KEY;
- *pHandle = eAwsDevicePublicKey;
+ *pHandle = eAwsDevicePublicKey;
}
else if( 0 == memcmp( pcLabel,
&pkcs11configLABEL_CODE_VERIFICATION_KEY,
sizeof( pkcs11configLABEL_CODE_VERIFICATION_KEY ) ) )
{
*pcFileName = pkcs11palFILE_CODE_SIGN_PUBLIC_KEY;
- *pHandle = eAwsCodeSigningKey;
+ *pHandle = eAwsCodeSigningKey;
}
else
{
*pcFileName = NULL;
- *pHandle = eInvalidHandle;
+ *pHandle = eInvalidHandle;
}
}
}
@@ -160,11 +160,11 @@ CK_OBJECT_HANDLE PKCS11_PAL_SaveObject( CK_ATTRIBUTE_PTR pxLabel,
CK_BYTE_PTR pucData,
CK_ULONG ulDataSize )
{
- uint32_t ulStatus = 0;
- HANDLE hFile = INVALID_HANDLE_VALUE;
- DWORD lpNumberOfBytesWritten;
- char * pcFileName = NULL;
- CK_OBJECT_HANDLE xHandle = eInvalidHandle;
+ uint32_t ulStatus = 0;
+ HANDLE hFile = INVALID_HANDLE_VALUE;
+ DWORD lpNumberOfBytesWritten;
+ char * pcFileName = NULL;
+ CK_OBJECT_HANDLE xHandle = eInvalidHandle;
/* Converts a label to its respective filename and handle. */
prvLabelToFilenameHandle( pxLabel->pValue,
@@ -188,7 +188,7 @@ CK_OBJECT_HANDLE PKCS11_PAL_SaveObject( CK_ATTRIBUTE_PTR pxLabel,
{
ulStatus = GetLastError();
PKCS11_PAL_PRINT( ( "ERROR: Unable to create file %d \r\n", ulStatus ) );
- xHandle = eInvalidHandle;
+ xHandle = eInvalidHandle;
}
/* Write the object data. */
@@ -197,7 +197,7 @@ CK_OBJECT_HANDLE PKCS11_PAL_SaveObject( CK_ATTRIBUTE_PTR pxLabel,
if( FALSE == WriteFile( hFile, pucData, ulDataSize, &lpNumberOfBytesWritten, NULL ) )
{
ulStatus = GetLastError();
- xHandle = eInvalidHandle;
+ xHandle = eInvalidHandle;
}
}
@@ -220,8 +220,8 @@ CK_OBJECT_HANDLE PKCS11_PAL_FindObject( CK_BYTE_PTR pxLabel,
/* Avoid compiler warnings about unused variables. */
( void ) usLength;
- CK_OBJECT_HANDLE xHandle = eInvalidHandle;
- char * pcFileName = NULL;
+ CK_OBJECT_HANDLE xHandle = eInvalidHandle;
+ char * pcFileName = NULL;
/* Converts a label to its respective filename and handle. */
prvLabelToFilenameHandle( pxLabel,
@@ -239,36 +239,36 @@ CK_OBJECT_HANDLE PKCS11_PAL_FindObject( CK_BYTE_PTR pxLabel,
/*-----------------------------------------------------------*/
CK_RV PKCS11_PAL_GetObjectValue( CK_OBJECT_HANDLE xHandle,
- CK_BYTE_PTR * ppucData,
- CK_ULONG_PTR pulDataSize,
- CK_BBOOL * pIsPrivate )
+ CK_BYTE_PTR * ppucData,
+ CK_ULONG_PTR pulDataSize,
+ CK_BBOOL * pIsPrivate )
{
- CK_RV ulReturn = CKR_OK;
+ CK_RV ulReturn = CKR_OK;
uint32_t ulDriverReturn = 0;
- HANDLE hFile = INVALID_HANDLE_VALUE;
- uint32_t ulSize = 0;
- char * pcFileName = NULL;
+ HANDLE hFile = INVALID_HANDLE_VALUE;
+ uint32_t ulSize = 0;
+ char * pcFileName = NULL;
if( xHandle == eAwsDeviceCertificate )
{
- pcFileName = pkcs11palFILE_NAME_CLIENT_CERTIFICATE;
+ pcFileName = pkcs11palFILE_NAME_CLIENT_CERTIFICATE;
*pIsPrivate = CK_FALSE;
}
else if( xHandle == eAwsDevicePrivateKey )
{
- pcFileName = pkcs11palFILE_NAME_KEY;
+ pcFileName = pkcs11palFILE_NAME_KEY;
*pIsPrivate = CK_TRUE;
}
else if( xHandle == eAwsDevicePublicKey )
{
/* Public and private key are stored together in same file. */
- pcFileName = pkcs11palFILE_NAME_KEY;
+ pcFileName = pkcs11palFILE_NAME_KEY;
*pIsPrivate = CK_FALSE;
}
else if( xHandle == eAwsCodeSigningKey )
{
- pcFileName = pkcs11palFILE_CODE_SIGN_PUBLIC_KEY;
+ pcFileName = pkcs11palFILE_CODE_SIGN_PUBLIC_KEY;
*pIsPrivate = CK_FALSE;
}
else
@@ -291,7 +291,7 @@ CK_RV PKCS11_PAL_GetObjectValue( CK_OBJECT_HANDLE xHandle,
{
ulDriverReturn = GetLastError();
PKCS11_PAL_PRINT( ( "ERROR: Unable to open file %d \r\n", ulDriverReturn ) );
- ulReturn = CKR_FUNCTION_FAILED;
+ ulReturn = CKR_FUNCTION_FAILED;
}
if( 0 == ulReturn )
@@ -300,7 +300,7 @@ CK_RV PKCS11_PAL_GetObjectValue( CK_OBJECT_HANDLE xHandle,
*pulDataSize = GetFileSize( hFile, ( LPDWORD ) ( &ulSize ) );
/* Create a buffer. */
- *ppucData = pvPortMalloc( *pulDataSize );
+ *ppucData = pvPortMalloc( *pulDataSize );
if( NULL == *ppucData )
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c
index 74d050695..78f472544 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c
@@ -51,7 +51,7 @@
static CK_RV prvOpenSession( CK_SESSION_HANDLE * pxSession,
CK_SLOT_ID xSlotId )
{
- CK_RV xResult;
+ CK_RV xResult;
CK_FUNCTION_LIST_PTR pxFunctionList;
xResult = C_GetFunctionList( &pxFunctionList );
@@ -73,9 +73,9 @@ static CK_RV prvOpenSession( CK_SESSION_HANDLE * pxSession,
CK_RV xGetSlotList( CK_SLOT_ID ** ppxSlotId,
CK_ULONG * pxSlotCount )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
CK_FUNCTION_LIST_PTR pxFunctionList;
- CK_SLOT_ID * pxSlotId = NULL;
+ CK_SLOT_ID * pxSlotId = NULL;
xResult = C_GetFunctionList( &pxFunctionList );
@@ -125,18 +125,18 @@ CK_RV xGetSlotList( CK_SLOT_ID ** ppxSlotId,
CK_RV xInitializePKCS11( void )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
CK_FUNCTION_LIST_PTR pxFunctionList = NULL;
- CK_C_INITIALIZE_ARGS xInitArgs = { 0 };
+ CK_C_INITIALIZE_ARGS xInitArgs = { 0 };
- xInitArgs.CreateMutex = NULL;
+ xInitArgs.CreateMutex = NULL;
xInitArgs.DestroyMutex = NULL;
- xInitArgs.LockMutex = NULL;
- xInitArgs.UnlockMutex = NULL;
- xInitArgs.flags = CKF_OS_LOCKING_OK;
- xInitArgs.pReserved = NULL;
+ xInitArgs.LockMutex = NULL;
+ xInitArgs.UnlockMutex = NULL;
+ xInitArgs.flags = CKF_OS_LOCKING_OK;
+ xInitArgs.pReserved = NULL;
- xResult = C_GetFunctionList( &pxFunctionList );
+ xResult = C_GetFunctionList( &pxFunctionList );
/* Initialize the PKCS #11 module. */
if( xResult == CKR_OK )
@@ -151,13 +151,13 @@ CK_RV xInitializePKCS11( void )
CK_RV xInitializePkcs11Token( void )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
CK_FUNCTION_LIST_PTR pxFunctionList = NULL;
- CK_SLOT_ID * pxSlotId = NULL;
- CK_ULONG xSlotCount;
- CK_FLAGS xTokenFlags = 0;
- CK_TOKEN_INFO_PTR pxTokenInfo = NULL;
+ CK_SLOT_ID * pxSlotId = NULL;
+ CK_ULONG xSlotCount;
+ CK_FLAGS xTokenFlags = 0;
+ CK_TOKEN_INFO_PTR pxTokenInfo = NULL;
xResult = C_GetFunctionList( &pxFunctionList );
@@ -223,10 +223,10 @@ CK_RV xInitializePkcs11Token( void )
CK_RV xInitializePkcs11Session( CK_SESSION_HANDLE * pxSession )
{
- CK_RV xResult = CKR_OK;
- CK_SLOT_ID * pxSlotId = NULL;
+ CK_RV xResult = CKR_OK;
+ CK_SLOT_ID * pxSlotId = NULL;
CK_FUNCTION_LIST_PTR pxFunctionList = NULL;
- CK_ULONG xSlotCount = 0;
+ CK_ULONG xSlotCount = 0;
xResult = C_GetFunctionList( &pxFunctionList );
@@ -282,10 +282,10 @@ CK_RV xFindObjectWithLabelAndClass( CK_SESSION_HANDLE xSession,
CK_OBJECT_CLASS xClass,
CK_OBJECT_HANDLE_PTR pxHandle )
{
- CK_RV xResult = CKR_OK;
- CK_ULONG ulCount = 0;
+ CK_RV xResult = CKR_OK;
+ CK_ULONG ulCount = 0;
CK_FUNCTION_LIST_PTR pxFunctionList = NULL;
- CK_ATTRIBUTE xTemplate[ 2 ] = { 0 };
+ CK_ATTRIBUTE xTemplate[ 2 ] = { 0 };
if( ( pcLabelName == NULL ) || ( pxHandle == NULL ) )
{
@@ -293,15 +293,15 @@ CK_RV xFindObjectWithLabelAndClass( CK_SESSION_HANDLE xSession,
}
else
{
- xTemplate[ 0 ].type = CKA_LABEL;
- xTemplate[ 0 ].pValue = ( CK_VOID_PTR ) pcLabelName;
+ xTemplate[ 0 ].type = CKA_LABEL;
+ xTemplate[ 0 ].pValue = ( CK_VOID_PTR ) pcLabelName;
xTemplate[ 0 ].ulValueLen = strlen( pcLabelName );
- xTemplate[ 1 ].type = CKA_CLASS;
- xTemplate[ 1 ].pValue = &xClass;
+ xTemplate[ 1 ].type = CKA_CLASS;
+ xTemplate[ 1 ].pValue = &xClass;
xTemplate[ 1 ].ulValueLen = sizeof( CK_OBJECT_CLASS );
- xResult = C_GetFunctionList( &pxFunctionList );
+ xResult = C_GetFunctionList( &pxFunctionList );
}
/* Initialize the FindObject state in the underlying PKCS #11 module based
@@ -338,7 +338,7 @@ CK_RV xFindObjectWithLabelAndClass( CK_SESSION_HANDLE xSession,
CK_RV vAppendSHA256AlgorithmIdentifierSequence( const uint8_t * puc32ByteHashedMessage,
uint8_t * puc51ByteHashOidBuffer )
{
- CK_RV xResult = CKR_OK;
+ CK_RV xResult = CKR_OK;
const uint8_t pucOidSequence[] = pkcs11STUFF_APPENDED_TO_RSA_SIG;
if( ( puc32ByteHashedMessage == NULL ) || ( puc51ByteHashOidBuffer == NULL ) )
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c
index d1f743054..2aae00034 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c
@@ -43,7 +43,7 @@
#include "mbedtls/pk_internal.h"
#include "mbedtls/debug.h"
#ifdef MBEDTLS_DEBUG_C
-#define tlsDEBUG_VERBOSE 4
+ #define tlsDEBUG_VERBOSE 4
#endif
/* C runtime includes. */
@@ -74,16 +74,17 @@
* @param[out] xP11Session PKCS#11 session context.
* @param[out] xP11PrivateKey PKCS#11 private key context.
*/
-typedef struct TLSContext {
- const char* pcDestination;
- const char* pcServerCertificate;
+typedef struct TLSContext
+{
+ const char * pcDestination;
+ const char * pcServerCertificate;
uint32_t ulServerCertificateLength;
- const char** ppcAlpnProtocols;
+ const char ** ppcAlpnProtocols;
uint32_t ulAlpnProtocolsCount;
NetworkRecv_t xNetworkRecv;
NetworkSend_t xNetworkSend;
- void* pvCallerContext;
+ void * pvCallerContext;
BaseType_t xTLSHandshakeSuccessful;
/* mbedTLS. */
@@ -101,7 +102,7 @@ typedef struct TLSContext {
CK_KEY_TYPE xKeyType;
} TLSContext_t;
-#define TLS_PRINT(X) configPRINTF( X )
+#define TLS_PRINT( X ) configPRINTF( X )
/*-----------------------------------------------------------*/
@@ -114,22 +115,24 @@ typedef struct TLSContext {
*
* @param[in] pvContext Caller context.
*/
-static void prvFreeContext(TLSContext_t* pxCtx)
+static void prvFreeContext( TLSContext_t * pxCtx )
{
- if (NULL != pxCtx) {
+ if( NULL != pxCtx )
+ {
/* Cleanup mbedTLS. */
mbedtls_ssl_close_notify(
- &pxCtx->xMbedSslCtx); /*lint !e534 The error is already taken care
- of inside mbedtls_ssl_close_notify*/
- mbedtls_ssl_free(&pxCtx->xMbedSslCtx);
- mbedtls_ssl_config_free(&pxCtx->xMbedSslConfig);
+ &pxCtx->xMbedSslCtx ); /*lint !e534 The error is already taken care
+ * of inside mbedtls_ssl_close_notify*/
+ mbedtls_ssl_free( &pxCtx->xMbedSslCtx );
+ mbedtls_ssl_config_free( &pxCtx->xMbedSslConfig );
/* Cleanup PKCS#11. */
- if ((NULL != pxCtx->pxP11FunctionList)
- && (NULL != pxCtx->pxP11FunctionList->C_CloseSession)) {
+ if( ( NULL != pxCtx->pxP11FunctionList ) &&
+ ( NULL != pxCtx->pxP11FunctionList->C_CloseSession ) )
+ {
pxCtx->pxP11FunctionList->C_CloseSession(
- pxCtx->xP11Session); /*lint !e534 This function always return
- CKR_OK. */
+ pxCtx->xP11Session ); /*lint !e534 This function always return
+ * CKR_OK. */
}
pxCtx->xTLSHandshakeSuccessful = pdFALSE;
@@ -147,14 +150,15 @@ static void prvFreeContext(TLSContext_t* pxCtx)
*
* @return Number of bytes sent, or a negative value on error.
*/
-static int prvNetworkSend(
- void* pvContext, const unsigned char* pucData, size_t xDataLength)
+static int prvNetworkSend( void * pvContext,
+ const unsigned char * pucData,
+ size_t xDataLength )
{
- TLSContext_t* pxCtx = (TLSContext_t*)
- pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
+ TLSContext_t * pxCtx = ( TLSContext_t * )
+ pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
- return (int)pxCtx->xNetworkSend(
- pxCtx->pvCallerContext, pucData, xDataLength);
+ return ( int ) pxCtx->xNetworkSend(
+ pxCtx->pvCallerContext, pucData, xDataLength );
}
/*-----------------------------------------------------------*/
@@ -168,14 +172,15 @@ static int prvNetworkSend(
*
* @return Number of bytes received, or a negative value on error.
*/
-static int prvNetworkRecv(
- void* pvContext, unsigned char* pucReceiveBuffer, size_t xReceiveLength)
+static int prvNetworkRecv( void * pvContext,
+ unsigned char * pucReceiveBuffer,
+ size_t xReceiveLength )
{
- TLSContext_t* pxCtx = (TLSContext_t*)
- pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
+ TLSContext_t * pxCtx = ( TLSContext_t * )
+ pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
- return (int)pxCtx->xNetworkRecv(
- pxCtx->pvCallerContext, pucReceiveBuffer, xReceiveLength);
+ return ( int ) pxCtx->xNetworkRecv(
+ pxCtx->pvCallerContext, pucReceiveBuffer, xReceiveLength );
}
/*-----------------------------------------------------------*/
@@ -189,18 +194,20 @@ static int prvNetworkRecv(
*
* @return Zero on success.
*/
-static int prvGenerateRandomBytes(
- void* pvCtx, unsigned char* pucRandom, size_t xRandomLength)
+static int prvGenerateRandomBytes( void * pvCtx,
+ unsigned char * pucRandom,
+ size_t xRandomLength )
{
- TLSContext_t* pxCtx = (TLSContext_t*)
- pvCtx; /*lint !e9087 !e9079 Allow casting void* to other types. */
- BaseType_t xResult;
+ TLSContext_t * pxCtx = ( TLSContext_t * )
+ pvCtx; /*lint !e9087 !e9079 Allow casting void* to other types. */
+ BaseType_t xResult;
xResult = pxCtx->pxP11FunctionList->C_GenerateRandom(
- pxCtx->xP11Session, pucRandom, xRandomLength);
+ pxCtx->xP11Session, pucRandom, xRandomLength );
- if (xResult != CKR_OK) {
- TLS_PRINT(("ERROR: Failed to generate random bytes %d \r\n", xResult));
+ if( xResult != CKR_OK )
+ {
+ TLS_PRINT( ( "ERROR: Failed to generate random bytes %d \r\n", xResult ) );
xResult = TLS_ERROR_RNG;
}
@@ -220,50 +227,61 @@ static int prvGenerateRandomBytes(
*
* @return Zero on success.
*/
-static int prvCheckCertificate(
- void* pvCtx, mbedtls_x509_crt* pxCertificate, int lPathCount,
- uint32_t* pulFlags)
+static int prvCheckCertificate( void * pvCtx,
+ mbedtls_x509_crt * pxCertificate,
+ int lPathCount,
+ uint32_t * pulFlags )
{
- int lCompilationYear = 0;
+ int lCompilationYear = 0;
-#define tlsCOMPILER_DATE_STRING_MONTH_LENGTH 4
-#define tlsDATE_STRING_FIELD_COUNT 3
- char cCompilationMonth[tlsCOMPILER_DATE_STRING_MONTH_LENGTH];
- int lCompilationMonth = 0;
- int lCompilationDay = 0;
- const char cMonths[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
+#define tlsCOMPILER_DATE_STRING_MONTH_LENGTH 4
+#define tlsDATE_STRING_FIELD_COUNT 3
+ char cCompilationMonth[ tlsCOMPILER_DATE_STRING_MONTH_LENGTH ];
+ int lCompilationMonth = 0;
+ int lCompilationDay = 0;
+ const char cMonths[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
/* Unreferenced parameters. */
- (void)(pvCtx);
- (void)(lPathCount);
+ ( void ) ( pvCtx );
+ ( void ) ( lPathCount );
/* Parse the date string fields. */
- if (tlsDATE_STRING_FIELD_COUNT
+ if( tlsDATE_STRING_FIELD_COUNT
== sscanf(
__DATE__, "%3s %d %d", cCompilationMonth, &lCompilationDay,
- &lCompilationYear)) {
- cCompilationMonth[tlsCOMPILER_DATE_STRING_MONTH_LENGTH - 1] = '\0';
+ &lCompilationYear ) )
+ {
+ cCompilationMonth[ tlsCOMPILER_DATE_STRING_MONTH_LENGTH - 1 ] = '\0';
/* Check for server expiration. First check the year. */
- if (pxCertificate->valid_to.year < lCompilationYear) {
+ if( pxCertificate->valid_to.year < lCompilationYear )
+ {
*pulFlags |= MBEDTLS_X509_BADCERT_EXPIRED;
- } else if (pxCertificate->valid_to.year == lCompilationYear) {
+ }
+ else if( pxCertificate->valid_to.year == lCompilationYear )
+ {
/* Convert the month. */
- lCompilationMonth = ((strstr(cMonths, cCompilationMonth) - cMonths)
- / (tlsCOMPILER_DATE_STRING_MONTH_LENGTH - 1))
+ lCompilationMonth = ( ( strstr( cMonths, cCompilationMonth ) - cMonths )
+ / ( tlsCOMPILER_DATE_STRING_MONTH_LENGTH - 1 ) )
+ 1;
/* Check the month. */
- if (pxCertificate->valid_to.mon < lCompilationMonth) {
+ if( pxCertificate->valid_to.mon < lCompilationMonth )
+ {
*pulFlags |= MBEDTLS_X509_BADCERT_EXPIRED;
- } else if (pxCertificate->valid_to.mon == lCompilationMonth) {
+ }
+ else if( pxCertificate->valid_to.mon == lCompilationMonth )
+ {
/* Check the day. */
- if (pxCertificate->valid_to.day < lCompilationDay) {
+ if( pxCertificate->valid_to.day < lCompilationDay )
+ {
*pulFlags |= MBEDTLS_X509_BADCERT_EXPIRED;
}
}
}
- } else {
+ }
+ else
+ {
*pulFlags |= MBEDTLS_X509_BADCERT_EXPIRED;
}
@@ -286,77 +304,92 @@ static int prvCheckCertificate(
*
* @return Zero on success.
*/
-static int prvPrivateKeySigningCallback(
- void* pvContext, mbedtls_md_type_t xMdAlg, const unsigned char* pucHash,
- size_t xHashLen, unsigned char* pucSig, size_t* pxSigLen,
- int (*piRng)(
- void*, unsigned char*,
- size_t), /*lint !e955 This parameter is unused. */
- void* pvRng)
+static int prvPrivateKeySigningCallback( void * pvContext,
+ mbedtls_md_type_t xMdAlg,
+ const unsigned char * pucHash,
+ size_t xHashLen,
+ unsigned char * pucSig,
+ size_t * pxSigLen,
+ int ( * piRng )(
+ void *, unsigned char *,
+ size_t ), /*lint !e955 This parameter is unused. */
+ void * pvRng )
{
- CK_RV xResult = CKR_OK;
- int lFinalResult = 0;
- TLSContext_t* pxTLSContext = (TLSContext_t*)pvContext;
- CK_MECHANISM xMech = {0};
- CK_BYTE xToBeSigned[256];
- CK_ULONG xToBeSignedLen = sizeof(xToBeSigned);
+ CK_RV xResult = CKR_OK;
+ int lFinalResult = 0;
+ TLSContext_t * pxTLSContext = ( TLSContext_t * ) pvContext;
+ CK_MECHANISM xMech = { 0 };
+ CK_BYTE xToBeSigned[ 256 ];
+ CK_ULONG xToBeSignedLen = sizeof( xToBeSigned );
/* Unreferenced parameters. */
- (void)(piRng);
- (void)(pvRng);
- (void)(xMdAlg);
+ ( void ) ( piRng );
+ ( void ) ( pvRng );
+ ( void ) ( xMdAlg );
/* Sanity check buffer length. */
- if (xHashLen > sizeof(xToBeSigned)) {
+ if( xHashLen > sizeof( xToBeSigned ) )
+ {
xResult = CKR_ARGUMENTS_BAD;
}
/* Format the hash data to be signed. */
- if (CKK_RSA == pxTLSContext->xKeyType) {
+ if( CKK_RSA == pxTLSContext->xKeyType )
+ {
xMech.mechanism = CKM_RSA_PKCS;
/* mbedTLS expects hashed data without padding, but PKCS #11 C_Sign
* function performs a hash & sign if hash algorithm is specified. This
* helper function applies padding indicating data was hashed with
* SHA-256 while still allowing pre-hashed data to be provided. */
- xResult = vAppendSHA256AlgorithmIdentifierSequence(
- (uint8_t*)pucHash, xToBeSigned);
- xToBeSignedLen = pkcs11RSA_SIGNATURE_INPUT_LENGTH;
- } else if (CKK_EC == pxTLSContext->xKeyType) {
+ xResult = vAppendSHA256AlgorithmIdentifierSequence(
+ ( uint8_t * ) pucHash, xToBeSigned );
+ xToBeSignedLen = pkcs11RSA_SIGNATURE_INPUT_LENGTH;
+ }
+ else if( CKK_EC == pxTLSContext->xKeyType )
+ {
xMech.mechanism = CKM_ECDSA;
- memcpy(xToBeSigned, pucHash, xHashLen);
- xToBeSignedLen = xHashLen;
- } else {
+ memcpy( xToBeSigned, pucHash, xHashLen );
+ xToBeSignedLen = xHashLen;
+ }
+ else
+ {
xResult = CKR_ARGUMENTS_BAD;
}
- if (CKR_OK == xResult) {
+ if( CKR_OK == xResult )
+ {
/* Use the PKCS#11 module to sign. */
xResult = pxTLSContext->pxP11FunctionList->C_SignInit(
- pxTLSContext->xP11Session, &xMech, pxTLSContext->xP11PrivateKey);
+ pxTLSContext->xP11Session, &xMech, pxTLSContext->xP11PrivateKey );
}
- if (CKR_OK == xResult) {
- *pxSigLen = sizeof(xToBeSigned);
- xResult = pxTLSContext->pxP11FunctionList->C_Sign(
- (CK_SESSION_HANDLE)pxTLSContext->xP11Session, xToBeSigned,
- xToBeSignedLen, pucSig, (CK_ULONG_PTR)pxSigLen);
+ if( CKR_OK == xResult )
+ {
+ *pxSigLen = sizeof( xToBeSigned );
+ xResult = pxTLSContext->pxP11FunctionList->C_Sign(
+ ( CK_SESSION_HANDLE ) pxTLSContext->xP11Session, xToBeSigned,
+ xToBeSignedLen, pucSig, ( CK_ULONG_PTR ) pxSigLen );
}
- if ((xResult == CKR_OK) && (CKK_EC == pxTLSContext->xKeyType)) {
+ if( ( xResult == CKR_OK ) && ( CKK_EC == pxTLSContext->xKeyType ) )
+ {
/* PKCS #11 for P256 returns a 64-byte signature with 32 bytes for R and
* 32 bytes for S. This must be converted to an ASN.1 encoded array. */
- if (*pxSigLen != pkcs11ECDSA_P256_SIGNATURE_LENGTH) {
+ if( *pxSigLen != pkcs11ECDSA_P256_SIGNATURE_LENGTH )
+ {
xResult = CKR_FUNCTION_FAILED;
}
- if (xResult == CKR_OK) {
- PKI_pkcs11SignatureTombedTLSSignature(pucSig, pxSigLen);
+ if( xResult == CKR_OK )
+ {
+ PKI_pkcs11SignatureTombedTLSSignature( pucSig, pxSigLen );
}
}
- if (xResult != CKR_OK) {
- TLS_PRINT(("ERROR: Failure in signing callback: %d \r\n", xResult));
+ if( xResult != CKR_OK )
+ {
+ TLS_PRINT( ( "ERROR: Failure in signing callback: %d \r\n", xResult ) );
lFinalResult = TLS_ERROR_SIGN;
}
@@ -377,60 +410,68 @@ static int prvPrivateKeySigningCallback(
*
* @return Zero on success.
*/
-static int prvReadCertificateIntoContext(
- TLSContext_t* pxTlsContext, const char* pcLabelName, CK_OBJECT_CLASS xClass,
- mbedtls_x509_crt* pxCertificateContext)
+static int prvReadCertificateIntoContext( TLSContext_t * pxTlsContext,
+ const char * pcLabelName,
+ CK_OBJECT_CLASS xClass,
+ mbedtls_x509_crt * pxCertificateContext )
{
- BaseType_t xResult = CKR_OK;
- CK_ATTRIBUTE xTemplate = {0};
- CK_OBJECT_HANDLE xCertObj = 0;
+ BaseType_t xResult = CKR_OK;
+ CK_ATTRIBUTE xTemplate = { 0 };
+ CK_OBJECT_HANDLE xCertObj = 0;
/* Get the handle of the certificate. */
xResult = xFindObjectWithLabelAndClass(
- pxTlsContext->xP11Session, pcLabelName, xClass, &xCertObj);
+ pxTlsContext->xP11Session, pcLabelName, xClass, &xCertObj );
- if ((CKR_OK == xResult) && (xCertObj == CK_INVALID_HANDLE)) {
+ if( ( CKR_OK == xResult ) && ( xCertObj == CK_INVALID_HANDLE ) )
+ {
xResult = CKR_OBJECT_HANDLE_INVALID;
}
/* Query the certificate size. */
- if (0 == xResult) {
- xTemplate.type = CKA_VALUE;
+ if( 0 == xResult )
+ {
+ xTemplate.type = CKA_VALUE;
xTemplate.ulValueLen = 0;
- xTemplate.pValue = NULL;
- xResult =
- (BaseType_t)pxTlsContext->pxP11FunctionList->C_GetAttributeValue(
- pxTlsContext->xP11Session, xCertObj, &xTemplate, 1);
+ xTemplate.pValue = NULL;
+ xResult =
+ ( BaseType_t ) pxTlsContext->pxP11FunctionList->C_GetAttributeValue(
+ pxTlsContext->xP11Session, xCertObj, &xTemplate, 1 );
}
/* Create a buffer for the certificate. */
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
xTemplate.pValue =
- pvPortMalloc(xTemplate.ulValueLen); /*lint !e9079 Allow casting
- void* to other types. */
+ pvPortMalloc( xTemplate.ulValueLen ); /*lint !e9079 Allow casting
+ * void* to other types. */
- if (NULL == xTemplate.pValue) {
- xResult = (BaseType_t)CKR_HOST_MEMORY;
+ if( NULL == xTemplate.pValue )
+ {
+ xResult = ( BaseType_t ) CKR_HOST_MEMORY;
}
}
/* Export the certificate. */
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
xResult =
- (BaseType_t)pxTlsContext->pxP11FunctionList->C_GetAttributeValue(
- pxTlsContext->xP11Session, xCertObj, &xTemplate, 1);
+ ( BaseType_t ) pxTlsContext->pxP11FunctionList->C_GetAttributeValue(
+ pxTlsContext->xP11Session, xCertObj, &xTemplate, 1 );
}
/* Decode the certificate. */
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
xResult = mbedtls_x509_crt_parse(
- pxCertificateContext, (const unsigned char*)xTemplate.pValue,
- xTemplate.ulValueLen);
+ pxCertificateContext, ( const unsigned char * ) xTemplate.pValue,
+ xTemplate.ulValueLen );
}
/* Free memory. */
- if (NULL != xTemplate.pValue) {
- vPortFree(xTemplate.pValue);
+ if( NULL != xTemplate.pValue )
+ {
+ vPortFree( xTemplate.pValue );
}
return xResult;
@@ -446,77 +487,88 @@ static int prvReadCertificateIntoContext(
*
* @return Zero on success.
*/
-static int prvInitializeClientCredential(TLSContext_t* pxCtx)
+static int prvInitializeClientCredential( TLSContext_t * pxCtx )
{
- BaseType_t xResult = CKR_OK;
- CK_SLOT_ID* pxSlotIds = NULL;
- CK_ULONG xCount = 0;
- CK_ATTRIBUTE xTemplate[2];
- mbedtls_pk_type_t xKeyAlgo = (mbedtls_pk_type_t)~0;
+ BaseType_t xResult = CKR_OK;
+ CK_SLOT_ID * pxSlotIds = NULL;
+ CK_ULONG xCount = 0;
+ CK_ATTRIBUTE xTemplate[ 2 ];
+ mbedtls_pk_type_t xKeyAlgo = ( mbedtls_pk_type_t ) ~0;
/* Initialize the mbed contexts. */
- mbedtls_x509_crt_init(&pxCtx->xMbedX509Cli);
+ mbedtls_x509_crt_init( &pxCtx->xMbedX509Cli );
/* Get the PKCS #11 module/token slot count. */
- if (CKR_OK == xResult) {
- xResult = (BaseType_t)pxCtx->pxP11FunctionList->C_GetSlotList(
- CK_TRUE, NULL, &xCount);
+ if( CKR_OK == xResult )
+ {
+ xResult = ( BaseType_t ) pxCtx->pxP11FunctionList->C_GetSlotList(
+ CK_TRUE, NULL, &xCount );
}
/* Allocate memory to store the token slots. */
- if (CKR_OK == xResult) {
- pxSlotIds = (CK_SLOT_ID*)pvPortMalloc(sizeof(CK_SLOT_ID) * xCount);
+ if( CKR_OK == xResult )
+ {
+ pxSlotIds = ( CK_SLOT_ID * ) pvPortMalloc( sizeof( CK_SLOT_ID ) * xCount );
- if (NULL == pxSlotIds) {
+ if( NULL == pxSlotIds )
+ {
xResult = CKR_HOST_MEMORY;
}
}
/* Get all of the available private key slot identities. */
- if (CKR_OK == xResult) {
- xResult = (BaseType_t)pxCtx->pxP11FunctionList->C_GetSlotList(
- CK_TRUE, pxSlotIds, &xCount);
+ if( CKR_OK == xResult )
+ {
+ xResult = ( BaseType_t ) pxCtx->pxP11FunctionList->C_GetSlotList(
+ CK_TRUE, pxSlotIds, &xCount );
}
/* Start a private session with the P#11 module using the first
* enumerated slot. */
- if (CKR_OK == xResult) {
- xResult = (BaseType_t)pxCtx->pxP11FunctionList->C_OpenSession(
- pxSlotIds[0], CKF_SERIAL_SESSION, NULL, NULL, &pxCtx->xP11Session);
+ if( CKR_OK == xResult )
+ {
+ xResult = ( BaseType_t ) pxCtx->pxP11FunctionList->C_OpenSession(
+ pxSlotIds[ 0 ], CKF_SERIAL_SESSION, NULL, NULL, &pxCtx->xP11Session );
}
/* Put the module in authenticated mode. */
- if (CKR_OK == xResult) {
- xResult = (BaseType_t)pxCtx->pxP11FunctionList->C_Login(
+ if( CKR_OK == xResult )
+ {
+ xResult = ( BaseType_t ) pxCtx->pxP11FunctionList->C_Login(
pxCtx->xP11Session, CKU_USER,
- (CK_UTF8CHAR_PTR)configPKCS11_DEFAULT_USER_PIN,
- sizeof(configPKCS11_DEFAULT_USER_PIN) - 1);
+ ( CK_UTF8CHAR_PTR ) configPKCS11_DEFAULT_USER_PIN,
+ sizeof( configPKCS11_DEFAULT_USER_PIN ) - 1 );
}
- if (CKR_OK == xResult) {
+ if( CKR_OK == xResult )
+ {
/* Get the handle of the device private key. */
xResult = xFindObjectWithLabelAndClass(
pxCtx->xP11Session, pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS,
- CKO_PRIVATE_KEY, &pxCtx->xP11PrivateKey);
+ CKO_PRIVATE_KEY, &pxCtx->xP11PrivateKey );
}
- if ((CKR_OK == xResult) && (pxCtx->xP11PrivateKey == CK_INVALID_HANDLE)) {
+ if( ( CKR_OK == xResult ) && ( pxCtx->xP11PrivateKey == CK_INVALID_HANDLE ) )
+ {
xResult = TLS_ERROR_NO_PRIVATE_KEY;
- TLS_PRINT(("ERROR: Private key not found. "));
+ TLS_PRINT( ( "ERROR: Private key not found. " ) );
}
/* Query the device private key type. */
- if (xResult == CKR_OK) {
- xTemplate[0].type = CKA_KEY_TYPE;
- xTemplate[0].pValue = &pxCtx->xKeyType;
- xTemplate[0].ulValueLen = sizeof(CK_KEY_TYPE);
- xResult = pxCtx->pxP11FunctionList->C_GetAttributeValue(
- pxCtx->xP11Session, pxCtx->xP11PrivateKey, xTemplate, 1);
+ if( xResult == CKR_OK )
+ {
+ xTemplate[ 0 ].type = CKA_KEY_TYPE;
+ xTemplate[ 0 ].pValue = &pxCtx->xKeyType;
+ xTemplate[ 0 ].ulValueLen = sizeof( CK_KEY_TYPE );
+ xResult = pxCtx->pxP11FunctionList->C_GetAttributeValue(
+ pxCtx->xP11Session, pxCtx->xP11PrivateKey, xTemplate, 1 );
}
/* Map the PKCS #11 key type to an mbedTLS algorithm. */
- if (xResult == CKR_OK) {
- switch (pxCtx->xKeyType) {
+ if( xResult == CKR_OK )
+ {
+ switch( pxCtx->xKeyType )
+ {
case CKK_RSA:
xKeyAlgo = MBEDTLS_PK_RSA;
break;
@@ -526,39 +578,43 @@ static int prvInitializeClientCredential(TLSContext_t* pxCtx)
break;
default:
- xResult = CKR_ATTRIBUTE_VALUE_INVALID;
+ xResult = CKR_ATTRIBUTE_VALUE_INVALID;
break;
}
}
/* Map the mbedTLS algorithm to its internal metadata. */
- if (xResult == CKR_OK) {
+ if( xResult == CKR_OK )
+ {
memcpy(
- &pxCtx->xMbedPkInfo, mbedtls_pk_info_from_type(xKeyAlgo),
- sizeof(mbedtls_pk_info_t));
+ &pxCtx->xMbedPkInfo, mbedtls_pk_info_from_type( xKeyAlgo ),
+ sizeof( mbedtls_pk_info_t ) );
pxCtx->xMbedPkInfo.sign_func = prvPrivateKeySigningCallback;
- pxCtx->xMbedPkCtx.pk_info = &pxCtx->xMbedPkInfo;
- pxCtx->xMbedPkCtx.pk_ctx = pxCtx;
+ pxCtx->xMbedPkCtx.pk_info = &pxCtx->xMbedPkInfo;
+ pxCtx->xMbedPkCtx.pk_ctx = pxCtx;
}
/* Get the handle of the device client certificate. */
- if (xResult == CKR_OK) {
+ if( xResult == CKR_OK )
+ {
xResult = prvReadCertificateIntoContext(
pxCtx, pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS,
- CKO_CERTIFICATE, &pxCtx->xMbedX509Cli);
+ CKO_CERTIFICATE, &pxCtx->xMbedX509Cli );
}
/* Attach the client certificate(s) and private key to the TLS
* configuration. */
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
xResult = mbedtls_ssl_conf_own_cert(
- &pxCtx->xMbedSslConfig, &pxCtx->xMbedX509Cli, &pxCtx->xMbedPkCtx);
+ &pxCtx->xMbedSslConfig, &pxCtx->xMbedX509Cli, &pxCtx->xMbedPkCtx );
}
/* Free memory. */
- if (NULL != pxSlotIds) {
- vPortFree(pxSlotIds);
+ if( NULL != pxSlotIds )
+ {
+ vPortFree( pxSlotIds );
}
return xResult;
@@ -570,46 +626,52 @@ static int prvInitializeClientCredential(TLSContext_t* pxCtx)
* Interface routines.
*/
-BaseType_t TLS_Init(void** ppvContext, TLSParams_t* pxParams)
+BaseType_t TLS_Init( void ** ppvContext,
+ TLSParams_t * pxParams )
{
- BaseType_t xResult = CKR_OK;
- TLSContext_t* pxCtx = NULL;
+ BaseType_t xResult = CKR_OK;
+ TLSContext_t * pxCtx = NULL;
CK_C_GetFunctionList xCkGetFunctionList = NULL;
/* Allocate an internal context. */
- pxCtx = (TLSContext_t*)pvPortMalloc(
- sizeof(TLSContext_t)); /*lint !e9087 !e9079 Allow casting void* to other
- types. */
+ pxCtx = ( TLSContext_t * ) pvPortMalloc(
+ sizeof( TLSContext_t ) ); /*lint !e9087 !e9079 Allow casting void* to other
+ * types. */
- if (NULL != pxCtx) {
- memset(pxCtx, 0, sizeof(TLSContext_t));
- *ppvContext = pxCtx;
+ if( NULL != pxCtx )
+ {
+ memset( pxCtx, 0, sizeof( TLSContext_t ) );
+ *ppvContext = pxCtx;
/* Initialize the context. */
- pxCtx->pcDestination = pxParams->pcDestination;
- pxCtx->pcServerCertificate = pxParams->pcServerCertificate;
+ pxCtx->pcDestination = pxParams->pcDestination;
+ pxCtx->pcServerCertificate = pxParams->pcServerCertificate;
pxCtx->ulServerCertificateLength = pxParams->ulServerCertificateLength;
- pxCtx->ppcAlpnProtocols = pxParams->ppcAlpnProtocols;
- pxCtx->ulAlpnProtocolsCount = pxParams->ulAlpnProtocolsCount;
- pxCtx->xNetworkRecv = pxParams->pxNetworkRecv;
- pxCtx->xNetworkSend = pxParams->pxNetworkSend;
- pxCtx->pvCallerContext = pxParams->pvCallerContext;
+ pxCtx->ppcAlpnProtocols = pxParams->ppcAlpnProtocols;
+ pxCtx->ulAlpnProtocolsCount = pxParams->ulAlpnProtocolsCount;
+ pxCtx->xNetworkRecv = pxParams->pxNetworkRecv;
+ pxCtx->xNetworkSend = pxParams->pxNetworkSend;
+ pxCtx->pvCallerContext = pxParams->pvCallerContext;
/* Get the function pointer list for the PKCS#11 module. */
- xCkGetFunctionList = C_GetFunctionList;
- xResult = (BaseType_t)xCkGetFunctionList(&pxCtx->pxP11FunctionList);
+ xCkGetFunctionList = C_GetFunctionList;
+ xResult = ( BaseType_t ) xCkGetFunctionList( &pxCtx->pxP11FunctionList );
/* Ensure that the PKCS #11 module is initialized. */
- if (CKR_OK == xResult) {
- xResult = (BaseType_t)xInitializePKCS11();
+ if( CKR_OK == xResult )
+ {
+ xResult = ( BaseType_t ) xInitializePKCS11();
/* It is ok if the module was previously initialized. */
- if (xResult == CKR_CRYPTOKI_ALREADY_INITIALIZED) {
+ if( xResult == CKR_CRYPTOKI_ALREADY_INITIALIZED )
+ {
xResult = CKR_OK;
}
}
- } else {
- xResult = (BaseType_t)CKR_HOST_MEMORY;
+ }
+ else
+ {
+ xResult = ( BaseType_t ) CKR_HOST_MEMORY;
}
return xResult;
@@ -618,186 +680,214 @@ BaseType_t TLS_Init(void** ppvContext, TLSParams_t* pxParams)
/*-----------------------------------------------------------*/
#ifdef MBEDTLS_DEBUG_C
-static void prvTlsDebugPrint(
- void* ctx, int lLevel, const char* pcFile, int lLine, const char* pcStr)
-{
- /* Unused parameters. */
- (void)ctx;
- (void)pcFile;
- (void)lLine;
-
- /* Send the debug string to the portable logger. */
- vLoggingPrintf("mbedTLS: |%d| %s", lLevel, pcStr);
-}
+ static void prvTlsDebugPrint( void * ctx,
+ int lLevel,
+ const char * pcFile,
+ int lLine,
+ const char * pcStr )
+ {
+ /* Unused parameters. */
+ ( void ) ctx;
+ ( void ) pcFile;
+ ( void ) lLine;
+
+ /* Send the debug string to the portable logger. */
+ vLoggingPrintf( "mbedTLS: |%d| %s", lLevel, pcStr );
+ }
#endif /* ifdef MBEDTLS_DEBUG_C */
/*-----------------------------------------------------------*/
-BaseType_t TLS_Connect(void* pvContext)
+BaseType_t TLS_Connect( void * pvContext )
{
- BaseType_t xResult = 0;
- TLSContext_t* pxCtx = (TLSContext_t*)
- pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
+ BaseType_t xResult = 0;
+ TLSContext_t * pxCtx = ( TLSContext_t * )
+ pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
/* Initialize mbedTLS structures. */
- mbedtls_ssl_init(&pxCtx->xMbedSslCtx);
- mbedtls_ssl_config_init(&pxCtx->xMbedSslConfig);
- mbedtls_x509_crt_init(&pxCtx->xMbedX509CA);
+ mbedtls_ssl_init( &pxCtx->xMbedSslCtx );
+ mbedtls_ssl_config_init( &pxCtx->xMbedSslConfig );
+ mbedtls_x509_crt_init( &pxCtx->xMbedX509CA );
/* Decode the root certificate: either the default or the override. */
- if (NULL != pxCtx->pcServerCertificate) {
+ if( NULL != pxCtx->pcServerCertificate )
+ {
xResult = mbedtls_x509_crt_parse(
&pxCtx->xMbedX509CA,
- (const unsigned char*)pxCtx->pcServerCertificate,
- pxCtx->ulServerCertificateLength);
+ ( const unsigned char * ) pxCtx->pcServerCertificate,
+ pxCtx->ulServerCertificateLength );
- if (0 != xResult) {
+ if( 0 != xResult )
+ {
TLS_PRINT(
- ("ERROR: Failed to parse custom server certificates %d \r\n",
- xResult));
+ ( "ERROR: Failed to parse custom server certificates %d \r\n",
+ xResult ) );
}
- } else {
+ }
+ else
+ {
TLS_PRINT(
- ("ERROR: Could not find a server certificate to parse. \r\n"));
+ ( "ERROR: Could not find a server certificate to parse. \r\n" ) );
}
/* Start with protocol defaults. */
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
xResult = mbedtls_ssl_config_defaults(
&pxCtx->xMbedSslConfig, MBEDTLS_SSL_IS_CLIENT,
- MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT);
+ MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT );
- if (0 != xResult) {
+ if( 0 != xResult )
+ {
TLS_PRINT(
- ("ERROR: Failed to set ssl config defaults %d \r\n", xResult));
+ ( "ERROR: Failed to set ssl config defaults %d \r\n", xResult ) );
}
}
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
/* Use a callback for additional server certificate validation. */
mbedtls_ssl_conf_verify(
- &pxCtx->xMbedSslConfig, &prvCheckCertificate, pxCtx);
+ &pxCtx->xMbedSslConfig, &prvCheckCertificate, pxCtx );
/* Server certificate validation is mandatory. */
mbedtls_ssl_conf_authmode(
- &pxCtx->xMbedSslConfig, MBEDTLS_SSL_VERIFY_REQUIRED);
+ &pxCtx->xMbedSslConfig, MBEDTLS_SSL_VERIFY_REQUIRED );
/* Set the RNG callback. */
mbedtls_ssl_conf_rng(
&pxCtx->xMbedSslConfig, &prvGenerateRandomBytes,
- pxCtx); /*lint !e546 Nothing wrong here. */
+ pxCtx ); /*lint !e546 Nothing wrong here. */
/* Set issuer certificate. */
mbedtls_ssl_conf_ca_chain(
- &pxCtx->xMbedSslConfig, &pxCtx->xMbedX509CA, NULL);
+ &pxCtx->xMbedSslConfig, &pxCtx->xMbedX509CA, NULL );
/* Configure the SSL context for the device credentials. */
- xResult = prvInitializeClientCredential(pxCtx);
+ xResult = prvInitializeClientCredential( pxCtx );
}
- if ((0 == xResult) && (NULL != pxCtx->ppcAlpnProtocols)) {
+ if( ( 0 == xResult ) && ( NULL != pxCtx->ppcAlpnProtocols ) )
+ {
/* Include an application protocol list in the TLS ClientHello
* message. */
xResult = mbedtls_ssl_conf_alpn_protocols(
- &pxCtx->xMbedSslConfig, pxCtx->ppcAlpnProtocols);
+ &pxCtx->xMbedSslConfig, pxCtx->ppcAlpnProtocols );
}
-#ifdef MBEDTLS_DEBUG_C
+ #ifdef MBEDTLS_DEBUG_C
- /* If mbedTLS is being compiled with debug support, assume that the
- * runtime configuration should use verbose output. */
- mbedtls_ssl_conf_dbg(&pxCtx->xMbedSslConfig, prvTlsDebugPrint, NULL);
- mbedtls_debug_set_threshold(tlsDEBUG_VERBOSE);
-#endif
+ /* If mbedTLS is being compiled with debug support, assume that the
+ * runtime configuration should use verbose output. */
+ mbedtls_ssl_conf_dbg( &pxCtx->xMbedSslConfig, prvTlsDebugPrint, NULL );
+ mbedtls_debug_set_threshold( tlsDEBUG_VERBOSE );
+ #endif
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
/* Set the resulting protocol configuration. */
xResult =
- mbedtls_ssl_setup(&pxCtx->xMbedSslCtx, &pxCtx->xMbedSslConfig);
+ mbedtls_ssl_setup( &pxCtx->xMbedSslCtx, &pxCtx->xMbedSslConfig );
}
/* Set the hostname, if requested. */
- if ((0 == xResult) && (NULL != pxCtx->pcDestination)) {
+ if( ( 0 == xResult ) && ( NULL != pxCtx->pcDestination ) )
+ {
xResult =
- mbedtls_ssl_set_hostname(&pxCtx->xMbedSslCtx, pxCtx->pcDestination);
+ mbedtls_ssl_set_hostname( &pxCtx->xMbedSslCtx, pxCtx->pcDestination );
}
/* Set the socket callbacks. */
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
mbedtls_ssl_set_bio(
- &pxCtx->xMbedSslCtx, pxCtx, prvNetworkSend, prvNetworkRecv, NULL);
+ &pxCtx->xMbedSslCtx, pxCtx, prvNetworkSend, prvNetworkRecv, NULL );
/* Negotiate. */
- while (0 != (xResult = mbedtls_ssl_handshake(&pxCtx->xMbedSslCtx))) {
- if ((MBEDTLS_ERR_SSL_WANT_READ != xResult)
- && (MBEDTLS_ERR_SSL_WANT_WRITE != xResult)) {
+ while( 0 != ( xResult = mbedtls_ssl_handshake( &pxCtx->xMbedSslCtx ) ) )
+ {
+ if( ( MBEDTLS_ERR_SSL_WANT_READ != xResult ) &&
+ ( MBEDTLS_ERR_SSL_WANT_WRITE != xResult ) )
+ {
/* There was an unexpected error. Per mbedTLS API documentation,
* ensure that upstream clean-up code doesn't accidentally use
* a context that failed the handshake. */
- prvFreeContext(pxCtx);
+ prvFreeContext( pxCtx );
TLS_PRINT(
- ("ERROR: Handshake failed with error code %d \r\n",
- xResult));
+ ( "ERROR: Handshake failed with error code %d \r\n",
+ xResult ) );
break;
}
}
}
/* Keep track of successful completion of the handshake. */
- if (0 == xResult) {
+ if( 0 == xResult )
+ {
pxCtx->xTLSHandshakeSuccessful = pdTRUE;
- } else if (xResult > 0) {
+ }
+ else if( xResult > 0 )
+ {
TLS_PRINT(
- ("ERROR: TLS_Connect failed with error code %d \r\n", xResult));
+ ( "ERROR: TLS_Connect failed with error code %d \r\n", xResult ) );
/* Convert PKCS #11 failures to a negative error code. */
xResult = TLS_ERROR_HANDSHAKE_FAILED;
}
/* Free up allocated memory. */
- mbedtls_x509_crt_free(&pxCtx->xMbedX509CA);
- mbedtls_x509_crt_free(&pxCtx->xMbedX509Cli);
+ mbedtls_x509_crt_free( &pxCtx->xMbedX509CA );
+ mbedtls_x509_crt_free( &pxCtx->xMbedX509Cli );
return xResult;
}
/*-----------------------------------------------------------*/
-BaseType_t
-TLS_Recv(void* pvContext, unsigned char* pucReadBuffer, size_t xReadLength)
+BaseType_t TLS_Recv( void * pvContext,
+ unsigned char * pucReadBuffer,
+ size_t xReadLength )
{
- BaseType_t xResult = 0;
- TLSContext_t* pxCtx = (TLSContext_t*)
- pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
- size_t xRead = 0;
+ BaseType_t xResult = 0;
+ TLSContext_t * pxCtx = ( TLSContext_t * )
+ pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
+ size_t xRead = 0;
- if ((NULL != pxCtx) && (pdTRUE == pxCtx->xTLSHandshakeSuccessful)) {
+ if( ( NULL != pxCtx ) && ( pdTRUE == pxCtx->xTLSHandshakeSuccessful ) )
+ {
/* This routine will return however many bytes are returned from from
* mbedtls_ssl_read immediately unless MBEDTLS_ERR_SSL_WANT_READ is
* returned, in which case we try again. */
- do {
+ do
+ {
xResult = mbedtls_ssl_read(
&pxCtx->xMbedSslCtx, pucReadBuffer + xRead,
- xReadLength - xRead);
+ xReadLength - xRead );
- if (xResult > 0) {
+ if( xResult > 0 )
+ {
/* Got data, so update the tally and keep looping. */
- xRead += (size_t)xResult;
+ xRead += ( size_t ) xResult;
}
/* If xResult == 0, then no data was received (and there is no
* error). The secure sockets API supports non-blocking read, so
* stop the loop, but don't flag an error. */
- } while ((xResult == MBEDTLS_ERR_SSL_WANT_READ));
- } else {
+ } while( ( xResult == MBEDTLS_ERR_SSL_WANT_READ ) );
+ }
+ else
+ {
xResult = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
}
- if (xResult >= 0) {
- xResult = (BaseType_t)xRead;
- } else {
+ if( xResult >= 0 )
+ {
+ xResult = ( BaseType_t ) xRead;
+ }
+ else
+ {
/* xResult < 0 is a hard error, so invalidate the context and stop. */
- prvFreeContext(pxCtx);
+ prvFreeContext( pxCtx );
}
return xResult;
@@ -805,41 +895,52 @@ TLS_Recv(void* pvContext, unsigned char* pucReadBuffer, size_t xReadLength)
/*-----------------------------------------------------------*/
-BaseType_t
-TLS_Send(void* pvContext, const unsigned char* pucMsg, size_t xMsgLength)
+BaseType_t TLS_Send( void * pvContext,
+ const unsigned char * pucMsg,
+ size_t xMsgLength )
{
- BaseType_t xResult = 0;
- TLSContext_t* pxCtx = (TLSContext_t*)
- pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
- size_t xWritten = 0;
-
- if ((NULL != pxCtx) && (pdTRUE == pxCtx->xTLSHandshakeSuccessful)) {
- while (xWritten < xMsgLength) {
+ BaseType_t xResult = 0;
+ TLSContext_t * pxCtx = ( TLSContext_t * )
+ pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
+ size_t xWritten = 0;
+
+ if( ( NULL != pxCtx ) && ( pdTRUE == pxCtx->xTLSHandshakeSuccessful ) )
+ {
+ while( xWritten < xMsgLength )
+ {
xResult = mbedtls_ssl_write(
- &pxCtx->xMbedSslCtx, pucMsg + xWritten, xMsgLength - xWritten);
+ &pxCtx->xMbedSslCtx, pucMsg + xWritten, xMsgLength - xWritten );
- if (0 < xResult) {
+ if( 0 < xResult )
+ {
/* Sent data, so update the tally and keep looping. */
- xWritten += (size_t)xResult;
- } else if (
- (0 == xResult) || (-pdFREERTOS_ERRNO_ENOSPC == xResult)) {
+ xWritten += ( size_t ) xResult;
+ }
+ else if(
+ ( 0 == xResult ) || ( -pdFREERTOS_ERRNO_ENOSPC == xResult ) )
+ {
/* No data sent. The secure sockets
* API supports non-blocking send, so stop the loop but don't
* flag an error. */
xResult = 0;
break;
- } else if (MBEDTLS_ERR_SSL_WANT_WRITE != xResult) {
+ }
+ else if( MBEDTLS_ERR_SSL_WANT_WRITE != xResult )
+ {
/* Hard error: invalidate the context and stop. */
- prvFreeContext(pxCtx);
+ prvFreeContext( pxCtx );
break;
}
}
- } else {
+ }
+ else
+ {
xResult = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
}
- if (0 <= xResult) {
- xResult = (BaseType_t)xWritten;
+ if( 0 <= xResult )
+ {
+ xResult = ( BaseType_t ) xWritten;
}
return xResult;
@@ -847,17 +948,19 @@ TLS_Send(void* pvContext, const unsigned char* pucMsg, size_t xMsgLength)
/*-----------------------------------------------------------*/
-void TLS_Cleanup(void* pvContext)
+void TLS_Cleanup( void * pvContext )
{
- TLSContext_t* pxCtx = (TLSContext_t*)
- pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
-
- if (NULL != pxCtx) {
- if (pdTRUE == pxCtx->xTLSHandshakeSuccessful) {
- prvFreeContext(pxCtx);
+ TLSContext_t * pxCtx = ( TLSContext_t * )
+ pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */
+
+ if( NULL != pxCtx )
+ {
+ if( pdTRUE == pxCtx->xTLSHandshakeSuccessful )
+ {
+ prvFreeContext( pxCtx );
}
/* Free memory. */
- vPortFree(pxCtx);
+ vPortFree( pxCtx );
}
}
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c
index d56fa0ceb..ad02b77ad 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c
@@ -45,9 +45,9 @@
BaseType_t PKI_mbedTLSSignatureToPkcs11Signature( uint8_t * pxSignaturePKCS,
const uint8_t * pxMbedSignature )
{
- BaseType_t xReturn = 0;
+ BaseType_t xReturn = 0;
const uint8_t * pxNextLength;
- uint8_t ucSigComponentLength;
+ uint8_t ucSigComponentLength;
if( ( pxSignaturePKCS == NULL ) || ( pxMbedSignature == NULL ) )
{
@@ -122,9 +122,9 @@ BaseType_t PKI_mbedTLSSignatureToPkcs11Signature( uint8_t * pxSignaturePKCS,
BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig,
size_t * pxSigLen )
{
- BaseType_t xReturn = 0;
- uint8_t * pucSigPtr;
- uint8_t ucTemp[ 64 ] = { 0 }; /* A temporary buffer for the pre-formatted signature. */
+ BaseType_t xReturn = 0;
+ uint8_t * pucSigPtr;
+ uint8_t ucTemp[ 64 ] = { 0 }; /* A temporary buffer for the pre-formatted signature. */
if( ( pucSig == NULL ) || ( pxSigLen == NULL ) )
{
@@ -145,9 +145,9 @@ BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig,
* R[32] + S[32]
*/
- pucSig[ 0 ] = 0x30; /* Sequence. */
- pucSig[ 1 ] = 0x44; /* The minimum length the signature could be. */
- pucSig[ 2 ] = 0x02; /* Integer. */
+ pucSig[ 0 ] = 0x30; /* Sequence. */
+ pucSig[ 1 ] = 0x44; /* The minimum length the signature could be. */
+ pucSig[ 2 ] = 0x02; /* Integer. */
/*************** R Component. *******************/
@@ -159,18 +159,18 @@ BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig,
pucSig[ 3 ] = 0x21; /* Increment the length of the R value to account for the 0x00 pad. */
pucSig[ 4 ] = 0x0; /* Write the 0x00 pad. */
( void ) memcpy( &pucSig[ 5 ], ucTemp, 32 ); /* Copy the 32-byte R value. */
- pucSigPtr = pucSig + 33; /* Increment the pointer to compensate for padded R length. */
+ pucSigPtr = pucSig + 33; /* Increment the pointer to compensate for padded R length. */
}
else
{
pucSig[ 3 ] = 0x20; /* R length with be 32 bytes. */
( void ) memcpy( &pucSig[ 4 ], ucTemp, 32 ); /* Copy 32 bytes of R into the signature buffer. */
- pucSigPtr = pucSig + 32; /* Increment the pointer for 32 byte R length. */
+ pucSigPtr = pucSig + 32; /* Increment the pointer for 32 byte R length. */
}
- pucSigPtr += 4; /* Increment the pointer to offset the SEQUENCE, LENGTH, R-INTEGER, LENGTH. */
+ pucSigPtr += 4; /* Increment the pointer to offset the SEQUENCE, LENGTH, R-INTEGER, LENGTH. */
pucSigPtr[ 0 ] = 0x02; /* INTEGER tag for S. */
- pucSigPtr += 1; /* Increment over S INTEGER tag. */
+ pucSigPtr += 1; /* Increment over S INTEGER tag. */
/******************* S Component. ****************/
@@ -181,7 +181,7 @@ BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig,
pucSig[ 1 ]++; /* Increment the length of the structure to account for the 0x00 pad. */
pucSigPtr[ 0 ] = 0x21; /* Increment the length of the S value to account for the 0x00 pad. */
pucSigPtr[ 1 ] = 0x00; /* Write the 0x00 pad. */
- pucSigPtr += 2; /* pucSigPtr was pointing at the S-length. Increment by 2 to hop over length and 0 padding. */
+ pucSigPtr += 2; /* pucSigPtr was pointing at the S-length. Increment by 2 to hop over length and 0 padding. */
( void ) memcpy( pucSigPtr, &ucTemp[ 32 ], 32 ); /* Copy the S value. */
}
@@ -194,7 +194,7 @@ BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig,
/* The total signature length is the length of the R and S integers plus 2 bytes for
* the SEQUENCE and LENGTH wrapping the entire struct. */
- *pxSigLen = pucSig[ 1 ] + 2UL;
+ *pxSigLen = pucSig[ 1 ] + 2UL;
}
return xReturn;
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c
index 921610440..91aec871f 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c
@@ -50,9 +50,9 @@ bool AwsIotDocParser_FindValue( const char * pAwsIotJsonDocument,
{
size_t i = 0;
size_t jsonValueLength = 0;
- char openCharacter = '\0', closeCharacter = '\0';
- int nestingLevel = 0;
- bool isWithinQuotes = false;
+ char openCharacter = '\0', closeCharacter = '\0';
+ int nestingLevel = 0;
+ bool isWithinQuotes = false;
/* Validate all the arguments.*/
if( ( pAwsIotJsonDocument == NULL ) || ( pAwsIotJsonKey == NULL ) ||
@@ -163,7 +163,7 @@ bool AwsIotDocParser_FindValue( const char * pAwsIotJsonDocument,
( pAwsIotJsonDocument[ i + 1 ] == '\"' ) )
{
/* Skip the characters \" */
- i += 2;
+ i += 2;
jsonValueLength += 2;
}
else
@@ -185,13 +185,13 @@ bool AwsIotDocParser_FindValue( const char * pAwsIotJsonDocument,
/* Set the matching opening and closing characters of a JSON object or array.
* The length calculation is performed below. */
case '{':
- openCharacter = '{';
- closeCharacter = '}';
+ openCharacter = '{';
+ closeCharacter = '}';
break;
case '[':
- openCharacter = '[';
- closeCharacter = ']';
+ openCharacter = '[';
+ closeCharacter = ']';
break;
/* Calculate the length of a JSON primitive. */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c
index bf4472ace..b4d262b5e 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c
@@ -50,11 +50,11 @@ bool AwsIot_InitLists( IotListDouble_t * pPendingOperationsList,
IOT_FUNCTION_ENTRY( bool, true );
/* Flags to track cleanup. */
- bool operationsMutexCreated = false;
+ bool operationsMutexCreated = false;
bool subscriptionsMutexCreated = false;
/* Create the mutex guarding the pending operations list. */
- operationsMutexCreated = IotMutex_Create( pPendingOperationsMutex, false );
+ operationsMutexCreated = IotMutex_Create( pPendingOperationsMutex, false );
if( operationsMutexCreated == false )
{
@@ -93,10 +93,10 @@ bool AwsIot_GenerateOperationTopic( const AwsIotTopicInfo_t * pTopicInfo,
char ** pTopicBuffer,
uint16_t * pOperationTopicLength )
{
- bool status = true;
- uint16_t bufferLength = 0;
+ bool status = true;
+ uint16_t bufferLength = 0;
uint16_t operationTopicLength = 0;
- char * pBuffer = NULL;
+ char * pBuffer = NULL;
/* Calculate the required topic buffer length. */
bufferLength = ( uint16_t ) ( AWS_IOT_TOPIC_PREFIX_LENGTH +
@@ -124,19 +124,19 @@ bool AwsIot_GenerateOperationTopic( const AwsIotTopicInfo_t * pTopicInfo,
{
/* Copy the AWS IoT topic prefix into the topic buffer. */
( void ) memcpy( pBuffer, AWS_IOT_TOPIC_PREFIX, AWS_IOT_TOPIC_PREFIX_LENGTH );
- operationTopicLength = ( uint16_t ) ( operationTopicLength + AWS_IOT_TOPIC_PREFIX_LENGTH );
+ operationTopicLength = ( uint16_t ) ( operationTopicLength + AWS_IOT_TOPIC_PREFIX_LENGTH );
/* Copy the Thing Name into the topic buffer. */
( void ) memcpy( pBuffer + operationTopicLength,
pTopicInfo->pThingName,
pTopicInfo->thingNameLength );
- operationTopicLength = ( uint16_t ) ( operationTopicLength + pTopicInfo->thingNameLength );
+ operationTopicLength = ( uint16_t ) ( operationTopicLength + pTopicInfo->thingNameLength );
/* Copy the Shadow operation string into the topic buffer. */
( void ) memcpy( pBuffer + operationTopicLength,
pTopicInfo->pOperationName,
pTopicInfo->operationNameLength );
- operationTopicLength = ( uint16_t ) ( operationTopicLength + pTopicInfo->operationNameLength );
+ operationTopicLength = ( uint16_t ) ( operationTopicLength + pTopicInfo->operationNameLength );
/* Set the output parameters. */
if( *pTopicBuffer == NULL )
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c
index d7b6ce0ed..7b9d8c344 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c
@@ -97,7 +97,7 @@ bool AwsIot_ParseThingName( const char * pTopicName,
{
IOT_FUNCTION_ENTRY( bool, true );
const char * pThingNameStart = NULL;
- size_t thingNameLength = 0;
+ size_t thingNameLength = 0;
/* Check that the topic name is at least as long as the minimum allowed. */
if( topicNameLength < MINIMUM_TOPIC_NAME_LENGTH )
@@ -114,7 +114,7 @@ bool AwsIot_ParseThingName( const char * pTopicName,
}
/* The Thing Name starts immediately after the topic prefix. */
- pThingNameStart = pTopicName + AWS_IOT_TOPIC_PREFIX_LENGTH;
+ pThingNameStart = pTopicName + AWS_IOT_TOPIC_PREFIX_LENGTH;
/* Calculate the length of the Thing Name, which is terminated with a '/'. */
while( ( thingNameLength + AWS_IOT_TOPIC_PREFIX_LENGTH < ( size_t ) topicNameLength ) &&
@@ -131,7 +131,7 @@ bool AwsIot_ParseThingName( const char * pTopicName,
}
/* Set the output parameters. */
- *pThingName = pThingNameStart;
+ *pThingName = pThingNameStart;
*pThingNameLength = thingNameLength;
IOT_FUNCTION_EXIT_NO_CLEANUP();
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c
index e0f76df67..b6586f9fc 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c
@@ -65,28 +65,28 @@ static IotMqttError_t _modifySubscriptions( AwsIotMqttFunction_t mqttOperation,
const char * pTopicFilter,
uint16_t topicFilterLength )
{
- IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
+ IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER;
/* Per the AWS IoT documentation, topic subscriptions are QoS 1. */
- subscription.qos = IOT_MQTT_QOS_1;
+ subscription.qos = IOT_MQTT_QOS_1;
/* Set the members of the subscription parameter. */
- subscription.pTopicFilter = pTopicFilter;
- subscription.topicFilterLength = topicFilterLength;
+ subscription.pTopicFilter = pTopicFilter;
+ subscription.topicFilterLength = topicFilterLength;
subscription.callback.pCallbackContext = NULL;
- subscription.callback.function = pSubscriptionInfo->callbackFunction;
+ subscription.callback.function = pSubscriptionInfo->callbackFunction;
/* Call the MQTT operation function.
* Subscription count is 1 in this case.
* None of the flags are set in this call. Hence 0 is passed for flags.
* Please refer to documentation for AwsIotMqttFunction_t for more details.
*/
- status = mqttOperation( pSubscriptionInfo->mqttConnection,
- &subscription,
- 1,
- 0,
- pSubscriptionInfo->timeout );
+ status = mqttOperation( pSubscriptionInfo->mqttConnection,
+ &subscription,
+ 1,
+ 0,
+ pSubscriptionInfo->timeout );
return status;
}
@@ -97,8 +97,8 @@ IotMqttError_t AwsIot_ModifySubscriptions( AwsIotMqttFunction_t mqttOperation,
const AwsIotSubscriptionInfo_t * pSubscriptionInfo )
{
IOT_FUNCTION_ENTRY( IotMqttError_t, IOT_MQTT_STATUS_PENDING );
- IotMqttError_t acceptedStatus = IOT_MQTT_STATUS_PENDING;
- uint16_t topicFilterLength = 0;
+ IotMqttError_t acceptedStatus = IOT_MQTT_STATUS_PENDING;
+ uint16_t topicFilterLength = 0;
/* Place the topic "accepted" suffix at the end of the topic buffer. */
( void ) memcpy( pSubscriptionInfo->pTopicFilterBase
@@ -109,10 +109,10 @@ IotMqttError_t AwsIot_ModifySubscriptions( AwsIotMqttFunction_t mqttOperation,
+ AWS_IOT_ACCEPTED_SUFFIX_LENGTH );
/* Modify the subscription to the "accepted" topic. */
- acceptedStatus = _modifySubscriptions( mqttOperation,
- pSubscriptionInfo,
- pSubscriptionInfo->pTopicFilterBase,
- topicFilterLength );
+ acceptedStatus = _modifySubscriptions( mqttOperation,
+ pSubscriptionInfo,
+ pSubscriptionInfo->pTopicFilterBase,
+ topicFilterLength );
if( acceptedStatus != IOT_MQTT_SUCCESS )
{
@@ -128,10 +128,10 @@ IotMqttError_t AwsIot_ModifySubscriptions( AwsIotMqttFunction_t mqttOperation,
+ AWS_IOT_REJECTED_SUFFIX_LENGTH );
/* Modify the subscription to the "rejected" topic. */
- status = _modifySubscriptions( mqttOperation,
- pSubscriptionInfo,
- pSubscriptionInfo->pTopicFilterBase,
- topicFilterLength );
+ status = _modifySubscriptions( mqttOperation,
+ pSubscriptionInfo,
+ pSubscriptionInfo->pTopicFilterBase,
+ topicFilterLength );
IOT_FUNCTION_CLEANUP_BEGIN();
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h
index 2a82e6960..b3924133f 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h
@@ -567,9 +567,9 @@ typedef struct AwsIotJobsRequestInfo
/* These members allow Jobs commands to be retried. Be careful that duplicate
* commands do no cause unexpected application behavior. Use of QoS 0 is recommended. */
- IotMqttQos_t qos; /**< @brief QoS when sending the Jobs command. See #IotMqttPublishInfo_t.qos. */
- uint32_t retryLimit; /**< @brief Maximum number of retries for the Jobs command. See #IotMqttPublishInfo_t.retryLimit. */
- uint32_t retryMs; /**< @brief First retry time for the Jobs command. See IotMqttPublishInfo_t.retryMs. */
+ IotMqttQos_t qos; /**< @brief QoS when sending the Jobs command. See #IotMqttPublishInfo_t.qos. */
+ uint32_t retryLimit; /**< @brief Maximum number of retries for the Jobs command. See #IotMqttPublishInfo_t.retryLimit. */
+ uint32_t retryMs; /**< @brief First retry time for the Jobs command. See IotMqttPublishInfo_t.retryMs. */
/**
* @brief Function to allocate memory for an incoming response.
@@ -892,14 +892,14 @@ typedef struct AwsIotJobsUpdateInfo
#define AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER \
{ .pClientToken = AWS_IOT_JOBS_CLIENT_TOKEN_AUTOGENERATE }
/** @brief Initializer for #AwsIotJobsUpdateInfo_t. */
-#define AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER \
- { .newStatus = AWS_IOT_JOB_STATE_IN_PROGRESS, \
- .expectedVersion = AWS_IOT_JOBS_NO_VERSION, \
- .executionNumber = AWS_IOT_JOBS_NO_EXECUTION_NUMBER, \
- .stepTimeoutInMinutes = AWS_IOT_JOBS_NO_TIMEOUT, \
- .includeJobExecutionState = false, \
- .includeJobDocument = false, \
- .pStatusDetails = AWS_IOT_JOBS_NO_STATUS_DETAILS }
+#define AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER \
+ { .newStatus = AWS_IOT_JOB_STATE_IN_PROGRESS, \
+ .expectedVersion = AWS_IOT_JOBS_NO_VERSION, \
+ .executionNumber = AWS_IOT_JOBS_NO_EXECUTION_NUMBER, \
+ .stepTimeoutInMinutes = AWS_IOT_JOBS_NO_TIMEOUT, \
+ .includeJobExecutionState = false, \
+ .includeJobDocument = false, \
+ .pStatusDetails = AWS_IOT_JOBS_NO_STATUS_DETAILS }
#define AWS_IOT_JOBS_OPERATION_INITIALIZER NULL /**< @brief Initializer for #AwsIotJobsOperation_t. */
#define AWS_IOT_JOBS_RESPONSE_INITIALIZER { 0 } /**< @brief Initializer for #AwsIotJobsResponse_t. */
/* @[define_jobs_initializers] */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c
index a3ba636ed..dd4a01375 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c
@@ -190,12 +190,12 @@ static void _callbackWrapperCommon( _jobsCallbackType_t type,
*
* API functions will fail if @ref jobs_function_init was not called.
*/
-static uint32_t _initCalled = 0;
+static uint32_t _initCalled = 0;
/**
* @brief Timeout used for MQTT operations.
*/
-uint32_t _AwsIotJobsMqttTimeoutMs = AWS_IOT_JOBS_DEFAULT_MQTT_TIMEOUT_MS;
+uint32_t _AwsIotJobsMqttTimeoutMs = AWS_IOT_JOBS_DEFAULT_MQTT_TIMEOUT_MS;
#if LIBRARY_LOG_LEVEL > IOT_LOG_NONE
@@ -483,9 +483,9 @@ static AwsIotJobsError_t _setCallbackCommon( IotMqttConnection_t mqttConnection,
const AwsIotJobsCallbackInfo_t * pCallbackInfo )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS );
- bool subscriptionMutexLocked = false;
- _jobsSubscription_t * pSubscription = NULL;
- int32_t callbackIndex = 0;
+ bool subscriptionMutexLocked = false;
+ _jobsSubscription_t * pSubscription = NULL;
+ int32_t callbackIndex = 0;
/* Check that AwsIotJobs_Init was called. */
if( _checkInit() == false )
@@ -535,7 +535,7 @@ static AwsIotJobsError_t _setCallbackCommon( IotMqttConnection_t mqttConnection,
/* Check for an existing subscription. This function will attempt to allocate
* a new subscription if not found. */
- pSubscription = _AwsIotJobs_FindSubscription( pThingName, thingNameLength, true );
+ pSubscription = _AwsIotJobs_FindSubscription( pThingName, thingNameLength, true );
if( pSubscription == NULL )
{
@@ -545,7 +545,7 @@ static AwsIotJobsError_t _setCallbackCommon( IotMqttConnection_t mqttConnection,
}
/* Get the index of the callback element to modify. */
- callbackIndex = _getCallbackIndex( type, pSubscription, pCallbackInfo );
+ callbackIndex = _getCallbackIndex( type, pSubscription, pCallbackInfo );
switch( callbackIndex )
{
@@ -652,29 +652,29 @@ static AwsIotJobsError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqttC
AwsIotMqttFunction_t mqttOperation )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS );
- int32_t i = 0;
- IotMqttError_t mqttStatus = IOT_MQTT_STATUS_PENDING;
- IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER;
- AwsIotTopicInfo_t topicInfo = { 0 };
- char * pTopicFilter = NULL;
- uint16_t topicFilterLength = 0;
+ int32_t i = 0;
+ IotMqttError_t mqttStatus = IOT_MQTT_STATUS_PENDING;
+ IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER;
+ AwsIotTopicInfo_t topicInfo = { 0 };
+ char * pTopicFilter = NULL;
+ uint16_t topicFilterLength = 0;
/* Lookup table for Jobs callback suffixes. */
- const char * const pCallbackSuffix[ JOBS_CALLBACK_COUNT ] =
+ const char * const pCallbackSuffix[ JOBS_CALLBACK_COUNT ] =
{
JOBS_NOTIFY_PENDING_CALLBACK_STRING, /* Notify pending callback. */
JOBS_NOTIFY_NEXT_CALLBACK_STRING /* Notify next callback. */
};
/* Lookup table for Jobs callback suffix lengths. */
- const uint16_t pCallbackSuffixLength[ JOBS_CALLBACK_COUNT ] =
+ const uint16_t pCallbackSuffixLength[ JOBS_CALLBACK_COUNT ] =
{
JOBS_NOTIFY_PENDING_CALLBACK_STRING_LENGTH, /* Notify pending callback. */
JOBS_NOTIFY_NEXT_CALLBACK_STRING_LENGTH /* Notify next callback. */
};
/* Lookup table for Jobs callback function wrappers. */
- const AwsIotMqttCallbackFunction_t pCallbackWrapper[ JOBS_CALLBACK_COUNT ] =
+ const AwsIotMqttCallbackFunction_t pCallbackWrapper[ JOBS_CALLBACK_COUNT ] =
{
_notifyPendingCallbackWrapper, /* Notify pending callback. */
_notifyNextCallbackWrapper, /* Notify next callback. */
@@ -701,12 +701,12 @@ static AwsIotJobsError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqttC
}
/* Generate the topic for the MQTT subscription. */
- topicInfo.pThingName = pSubscription->pThingName;
- topicInfo.thingNameLength = pSubscription->thingNameLength;
- topicInfo.longestSuffixLength = JOBS_LONGEST_SUFFIX_LENGTH;
- topicInfo.mallocString = AwsIotJobs_MallocString;
- topicInfo.pOperationName = pCallbackSuffix[ type ];
- topicInfo.operationNameLength = pCallbackSuffixLength[ type ];
+ topicInfo.pThingName = pSubscription->pThingName;
+ topicInfo.thingNameLength = pSubscription->thingNameLength;
+ topicInfo.longestSuffixLength = JOBS_LONGEST_SUFFIX_LENGTH;
+ topicInfo.mallocString = AwsIotJobs_MallocString;
+ topicInfo.pOperationName = pCallbackSuffix[ type ];
+ topicInfo.operationNameLength = pCallbackSuffixLength[ type ];
if( AwsIot_GenerateOperationTopic( &topicInfo,
&pTopicFilter,
@@ -721,18 +721,18 @@ static AwsIotJobsError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqttC
pTopicFilter );
/* Set the members of the MQTT subscription. */
- subscription.qos = IOT_MQTT_QOS_1;
- subscription.pTopicFilter = pTopicFilter;
- subscription.topicFilterLength = topicFilterLength;
+ subscription.qos = IOT_MQTT_QOS_1;
+ subscription.pTopicFilter = pTopicFilter;
+ subscription.topicFilterLength = topicFilterLength;
subscription.callback.pCallbackContext = NULL;
- subscription.callback.function = pCallbackWrapper[ type ];
+ subscription.callback.function = pCallbackWrapper[ type ];
/* Call the MQTT operation function. */
- mqttStatus = mqttOperation( mqttConnection,
- &subscription,
- 1,
- 0,
- _AwsIotJobsMqttTimeoutMs );
+ mqttStatus = mqttOperation( mqttConnection,
+ &subscription,
+ 1,
+ 0,
+ _AwsIotJobsMqttTimeoutMs );
/* Check the result of the MQTT operation. */
if( mqttStatus != IOT_MQTT_SUCCESS )
@@ -806,12 +806,12 @@ static void _notifyNextCallbackWrapper( void * pArgument,
static void _callbackWrapperCommon( _jobsCallbackType_t type,
IotMqttCallbackParam_t * pMessage )
{
- int32_t callbackIndex = 0;
- AwsIotJobsCallbackInfo_t callbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
+ int32_t callbackIndex = 0;
+ AwsIotJobsCallbackInfo_t callbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
AwsIotJobsCallbackParam_t callbackParam = { .callbackType = ( AwsIotJobsCallbackType_t ) 0 };
- _jobsSubscription_t * pSubscription = NULL;
- const char * pThingName = NULL;
- size_t thingNameLength = 0;
+ _jobsSubscription_t * pSubscription = NULL;
+ const char * pThingName = NULL;
+ size_t thingNameLength = 0;
/* Parse the Thing Name from the topic. */
if( AwsIot_ParseThingName( pMessage->u.message.info.pTopicName,
@@ -851,13 +851,13 @@ static void _callbackWrapperCommon( _jobsCallbackType_t type,
if( callbackInfo.function != NULL )
{
/* Set the callback type. Jobs callbacks are enumerated after the operations. */
- callbackParam.callbackType = ( AwsIotJobsCallbackType_t ) ( type + JOBS_OPERATION_COUNT );
+ callbackParam.callbackType = ( AwsIotJobsCallbackType_t ) ( type + JOBS_OPERATION_COUNT );
/* Set the remaining members of the callback param. */
- callbackParam.mqttConnection = pMessage->mqttConnection;
- callbackParam.pThingName = pThingName;
- callbackParam.thingNameLength = thingNameLength;
- callbackParam.u.callback.pDocument = pMessage->u.message.info.pPayload;
+ callbackParam.mqttConnection = pMessage->mqttConnection;
+ callbackParam.pThingName = pThingName;
+ callbackParam.thingNameLength = thingNameLength;
+ callbackParam.u.callback.pDocument = pMessage->u.message.info.pPayload;
callbackParam.u.callback.documentLength = pMessage->u.message.info.payloadLength;
/* Invoke the callback function. */
@@ -886,8 +886,8 @@ static void _callbackWrapperCommon( _jobsCallbackType_t type,
AwsIotJobsError_t AwsIotJobs_Init( uint32_t mqttTimeoutMs )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
- bool listInitStatus = false;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
+ bool listInitStatus = false;
if( _initCalled == 0 )
{
@@ -930,7 +930,7 @@ void AwsIotJobs_Cleanup( void )
{
if( _initCalled == 1 )
{
- _initCalled = 0;
+ _initCalled = 0;
/* Remove and free all items in the Jobs pending operation list. */
IotMutex_Lock( &_AwsIotJobsPendingOperationsMutex );
@@ -1030,7 +1030,7 @@ AwsIotJobsError_t AwsIotJobs_GetPendingSync( const AwsIotJobsRequestInfo_t * pRe
uint32_t timeoutMs,
AwsIotJobsResponse_t * const pJobsResponse )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING;
AwsIotJobsOperation_t getPendingOperation = AWS_IOT_JOBS_OPERATION_INITIALIZER;
/* Set the waitable flag. */
@@ -1062,7 +1062,7 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe
AwsIotJobsOperation_t * const pStartNextOperation )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_STATUS_PENDING );
- _jobsOperation_t * pOperation = NULL;
+ _jobsOperation_t * pOperation = NULL;
_jsonRequestContents_t requestContents = { 0 };
/* Check that AwsIotJobs_Init was called. */
@@ -1072,11 +1072,11 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe
}
/* Check request info. */
- status = _validateRequestInfo( JOBS_START_NEXT,
- pRequestInfo,
- flags,
- pCallbackInfo,
- pStartNextOperation );
+ status = _validateRequestInfo( JOBS_START_NEXT,
+ pRequestInfo,
+ flags,
+ pCallbackInfo,
+ pStartNextOperation );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -1084,8 +1084,8 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe
}
/* Check update info. */
- status = _validateUpdateInfo( JOBS_START_NEXT,
- pUpdateInfo );
+ status = _validateUpdateInfo( JOBS_START_NEXT,
+ pUpdateInfo );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -1095,12 +1095,12 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe
/* Allocate a new Jobs operation. */
requestContents.pUpdateInfo = pUpdateInfo;
- status = _AwsIotJobs_CreateOperation( JOBS_START_NEXT,
- pRequestInfo,
- &requestContents,
- flags,
- pCallbackInfo,
- &pOperation );
+ status = _AwsIotJobs_CreateOperation( JOBS_START_NEXT,
+ pRequestInfo,
+ &requestContents,
+ flags,
+ pCallbackInfo,
+ &pOperation );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -1117,7 +1117,7 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe
/* Process the Jobs operation. This subscribes to any required topics and
* sends the MQTT message for the Jobs operation. */
- status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation );
+ status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation );
/* If the Jobs operation failed, clear the now invalid reference. */
if( ( status != AWS_IOT_JOBS_STATUS_PENDING ) && ( pStartNextOperation != NULL ) )
@@ -1136,7 +1136,7 @@ AwsIotJobsError_t AwsIotJobs_StartNextSync( const AwsIotJobsRequestInfo_t * pReq
uint32_t timeoutMs,
AwsIotJobsResponse_t * const pJobsResponse )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING;
AwsIotJobsOperation_t startNextOperation = AWS_IOT_JOBS_OPERATION_INITIALIZER;
/* Set the waitable flag. */
@@ -1170,7 +1170,7 @@ AwsIotJobsError_t AwsIotJobs_DescribeAsync( const AwsIotJobsRequestInfo_t * pReq
AwsIotJobsOperation_t * const pDescribeOperation )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_STATUS_PENDING );
- _jobsOperation_t * pOperation = NULL;
+ _jobsOperation_t * pOperation = NULL;
_jsonRequestContents_t requestContents = { 0 };
/* Check that AwsIotJobs_Init was called. */
@@ -1180,11 +1180,11 @@ AwsIotJobsError_t AwsIotJobs_DescribeAsync( const AwsIotJobsRequestInfo_t * pReq
}
/* Check request info. */
- status = _validateRequestInfo( JOBS_DESCRIBE,
- pRequestInfo,
- flags,
- pCallbackInfo,
- pDescribeOperation );
+ status = _validateRequestInfo( JOBS_DESCRIBE,
+ pRequestInfo,
+ flags,
+ pCallbackInfo,
+ pDescribeOperation );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -1192,15 +1192,15 @@ AwsIotJobsError_t AwsIotJobs_DescribeAsync( const AwsIotJobsRequestInfo_t * pReq
}
/* Allocate a new Jobs operation. */
- requestContents.describe.executionNumber = executionNumber;
+ requestContents.describe.executionNumber = executionNumber;
requestContents.describe.includeJobDocument = includeJobDocument;
- status = _AwsIotJobs_CreateOperation( JOBS_DESCRIBE,
- pRequestInfo,
- &requestContents,
- flags,
- pCallbackInfo,
- &pOperation );
+ status = _AwsIotJobs_CreateOperation( JOBS_DESCRIBE,
+ pRequestInfo,
+ &requestContents,
+ flags,
+ pCallbackInfo,
+ &pOperation );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -1217,7 +1217,7 @@ AwsIotJobsError_t AwsIotJobs_DescribeAsync( const AwsIotJobsRequestInfo_t * pReq
/* Process the Jobs operation. This subscribes to any required topics and
* sends the MQTT message for the Jobs operation. */
- status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation );
+ status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation );
/* If the Jobs operation failed, clear the now invalid reference. */
if( ( status != AWS_IOT_JOBS_STATUS_PENDING ) && ( pDescribeOperation != NULL ) )
@@ -1237,7 +1237,7 @@ AwsIotJobsError_t AwsIotJobs_DescribeSync( const AwsIotJobsRequestInfo_t * pRequ
uint32_t timeoutMs,
AwsIotJobsResponse_t * const pJobsResponse )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING;
AwsIotJobsOperation_t describeOperation = AWS_IOT_JOBS_OPERATION_INITIALIZER;
/* Set the waitable flag. */
@@ -1271,7 +1271,7 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque
AwsIotJobsOperation_t * const pUpdateOperation )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_STATUS_PENDING );
- _jobsOperation_t * pOperation = NULL;
+ _jobsOperation_t * pOperation = NULL;
_jsonRequestContents_t requestContents = { 0 };
/* Check that AwsIotJobs_Init was called. */
@@ -1281,11 +1281,11 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque
}
/* Check request info. */
- status = _validateRequestInfo( JOBS_UPDATE,
- pRequestInfo,
- flags,
- pCallbackInfo,
- pUpdateOperation );
+ status = _validateRequestInfo( JOBS_UPDATE,
+ pRequestInfo,
+ flags,
+ pCallbackInfo,
+ pUpdateOperation );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -1293,8 +1293,8 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque
}
/* Check update info. */
- status = _validateUpdateInfo( JOBS_UPDATE,
- pUpdateInfo );
+ status = _validateUpdateInfo( JOBS_UPDATE,
+ pUpdateInfo );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -1304,12 +1304,12 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque
/* Allocate a new Jobs operation. */
requestContents.pUpdateInfo = pUpdateInfo;
- status = _AwsIotJobs_CreateOperation( JOBS_UPDATE,
- pRequestInfo,
- &requestContents,
- flags,
- pCallbackInfo,
- &pOperation );
+ status = _AwsIotJobs_CreateOperation( JOBS_UPDATE,
+ pRequestInfo,
+ &requestContents,
+ flags,
+ pCallbackInfo,
+ &pOperation );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -1326,7 +1326,7 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque
/* Process the Jobs operation. This subscribes to any required topics and
* sends the MQTT message for the Jobs operation. */
- status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation );
+ status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation );
/* If the Jobs operation failed, clear the now invalid reference. */
if( ( status != AWS_IOT_JOBS_STATUS_PENDING ) && ( pUpdateOperation != NULL ) )
@@ -1345,7 +1345,7 @@ AwsIotJobsError_t AwsIotJobs_UpdateSync( const AwsIotJobsRequestInfo_t * pReques
uint32_t timeoutMs,
AwsIotJobsResponse_t * const pJobsResponse )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING;
AwsIotJobsOperation_t updateOperation = AWS_IOT_JOBS_OPERATION_INITIALIZER;
/* Set the waitable flag. */
@@ -1439,7 +1439,7 @@ AwsIotJobsError_t AwsIotJobs_Wait( AwsIotJobsOperation_t operation,
AwsIotJobs_Assert( operation->pJobsResponse != NULL );
AwsIotJobs_Assert( operation->jobsResponseLength > 0 );
- pJobsResponse->pJobsResponse = operation->pJobsResponse;
+ pJobsResponse->pJobsResponse = operation->pJobsResponse;
pJobsResponse->jobsResponseLength = operation->jobsResponseLength;
}
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c
index 8810d4606..94c175fa3 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c
@@ -173,7 +173,7 @@ static AwsIotJobsError_t _findSubscription( const AwsIotJobsRequestInfo_t * pReq
* @brief List of active Jobs operations awaiting a response from the Jobs
* service.
*/
-IotListDouble_t _AwsIotJobsPendingOperations = { 0 };
+IotListDouble_t _AwsIotJobsPendingOperations = { 0 };
/**
* @brief Protects #_AwsIotJobsPendingOperations from concurrent access.
@@ -189,20 +189,20 @@ static bool _jobsOperation_match( const IotLink_t * pOperationLink,
* must never be NULL. */
AwsIotJobs_Assert( pOperationLink != NULL );
- _jobsOperation_t * pOperation = IotLink_Container( _jobsOperation_t,
- pOperationLink,
- link );
- _operationMatchParams_t * pParam = ( _operationMatchParams_t * ) pMatch;
- _jobsSubscription_t * pSubscription = pOperation->pSubscription;
- const char * pClientToken = NULL;
- size_t clientTokenLength = 0;
+ _jobsOperation_t * pOperation = IotLink_Container( _jobsOperation_t,
+ pOperationLink,
+ link );
+ _operationMatchParams_t * pParam = ( _operationMatchParams_t * ) pMatch;
+ _jobsSubscription_t * pSubscription = pOperation->pSubscription;
+ const char * pClientToken = NULL;
+ size_t clientTokenLength = 0;
/* Check for matching Thing Name and operation type. */
- bool match = ( pOperation->type == pParam->type ) &&
- ( pParam->thingNameLength == pSubscription->thingNameLength ) &&
- ( strncmp( pParam->pThingName,
- pSubscription->pThingName,
- pParam->thingNameLength ) == 0 );
+ bool match = ( pOperation->type == pParam->type ) &&
+ ( pParam->thingNameLength == pSubscription->thingNameLength ) &&
+ ( strncmp( pParam->pThingName,
+ pSubscription->pThingName,
+ pParam->thingNameLength ) == 0 );
if( match == true )
{
@@ -283,15 +283,15 @@ static void _updateCallback( void * pArgument,
static void _commonOperationCallback( _jobsOperationType_t type,
IotMqttCallbackParam_t * pMessage )
{
- _jobsOperation_t * pOperation = NULL;
- IotLink_t * pOperationLink = NULL;
- _operationMatchParams_t param = { 0 };
- AwsIotStatus_t status = AWS_IOT_UNKNOWN;
- uint32_t flags = 0;
+ _jobsOperation_t * pOperation = NULL;
+ IotLink_t * pOperationLink = NULL;
+ _operationMatchParams_t param = { 0 };
+ AwsIotStatus_t status = AWS_IOT_UNKNOWN;
+ uint32_t flags = 0;
/* Set operation type and response. */
- param.type = type;
- param.pResponse = pMessage->u.message.info.pPayload;
+ param.type = type;
+ param.pResponse = pMessage->u.message.info.pPayload;
param.responseLength = pMessage->u.message.info.payloadLength;
/* Parse the Thing Name from the MQTT topic name. */
@@ -307,10 +307,10 @@ static void _commonOperationCallback( _jobsOperationType_t type,
IotMutex_Lock( &( _AwsIotJobsPendingOperationsMutex ) );
/* Search for a matching pending operation. */
- pOperationLink = IotListDouble_FindFirstMatch( &_AwsIotJobsPendingOperations,
- NULL,
- _jobsOperation_match,
- &param );
+ pOperationLink = IotListDouble_FindFirstMatch( &_AwsIotJobsPendingOperations,
+ NULL,
+ _jobsOperation_match,
+ &param );
/* Find and remove the first Jobs operation of the given type. */
if( pOperationLink == NULL )
@@ -329,7 +329,7 @@ static void _commonOperationCallback( _jobsOperationType_t type,
pOperation = IotLink_Container( _jobsOperation_t, pOperationLink, link );
/* Copy the flags from the Jobs operation. */
- flags = pOperation->flags;
+ flags = pOperation->flags;
/* Remove a non-waitable operation from the pending operation list.
* Waitable operations are removed by the Wait function. */
@@ -341,8 +341,8 @@ static void _commonOperationCallback( _jobsOperationType_t type,
}
/* Parse the status from the topic name. */
- status = AwsIot_ParseStatus( pMessage->u.message.info.pTopicName,
- pMessage->u.message.info.topicNameLength );
+ status = AwsIot_ParseStatus( pMessage->u.message.info.pTopicName,
+ pMessage->u.message.info.topicNameLength );
switch( status )
{
@@ -383,8 +383,8 @@ static void _commonOperationCallback( _jobsOperationType_t type,
static void _notifyCompletion( _jobsOperation_t * pOperation )
{
- AwsIotJobsCallbackParam_t callbackParam = { .callbackType = ( AwsIotJobsCallbackType_t ) 0 };
- _jobsSubscription_t * pSubscription = pOperation->pSubscription,
+ AwsIotJobsCallbackParam_t callbackParam = { .callbackType = ( AwsIotJobsCallbackType_t ) 0 };
+ _jobsSubscription_t * pSubscription = pOperation->pSubscription,
* pRemovedSubscription = NULL;
/* If the operation is waiting, post to its wait semaphore and return. */
@@ -415,13 +415,13 @@ static void _notifyCompletion( _jobsOperation_t * pOperation )
if( pOperation->notify.callback.function != NULL )
{
/* Set the common members of the callback parameter. */
- callbackParam.callbackType = ( AwsIotJobsCallbackType_t ) pOperation->type;
- callbackParam.mqttConnection = pOperation->mqttConnection;
- callbackParam.pThingName = pSubscription->pThingName;
- callbackParam.thingNameLength = pSubscription->thingNameLength;
- callbackParam.u.operation.result = pOperation->status;
- callbackParam.u.operation.reference = pOperation;
- callbackParam.u.operation.pResponse = pOperation->pJobsResponse;
+ callbackParam.callbackType = ( AwsIotJobsCallbackType_t ) pOperation->type;
+ callbackParam.mqttConnection = pOperation->mqttConnection;
+ callbackParam.pThingName = pSubscription->pThingName;
+ callbackParam.thingNameLength = pSubscription->thingNameLength;
+ callbackParam.u.operation.result = pOperation->status;
+ callbackParam.u.operation.reference = pOperation;
+ callbackParam.u.operation.pResponse = pOperation->pJobsResponse;
callbackParam.u.operation.responseLength = pOperation->jobsResponseLength;
pOperation->notify.callback.function( pOperation->notify.callback.pCallbackContext,
@@ -446,8 +446,8 @@ static AwsIotJobsError_t _findSubscription( const AwsIotJobsRequestInfo_t * pReq
_jobsOperation_t * pOperation,
bool * pFreeTopicBuffer )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
- _jobsSubscription_t * pSubscription = NULL;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
+ _jobsSubscription_t * pSubscription = NULL;
/* Lookup table for Jobs operation callbacks. */
const AwsIotMqttCallbackFunction_t jobsCallbacks[ JOBS_OPERATION_COUNT ] =
@@ -490,7 +490,7 @@ static AwsIotJobsError_t _findSubscription( const AwsIotJobsRequestInfo_t * pReq
pSubscription->pTopicBuffer = pTopicBuffer;
/* Don't free the topic buffer if it was allocated to the subscription. */
- *pFreeTopicBuffer = false;
+ *pFreeTopicBuffer = false;
}
else
{
@@ -499,10 +499,10 @@ static AwsIotJobsError_t _findSubscription( const AwsIotJobsRequestInfo_t * pReq
/* Increment the reference count for this Jobs operation's
* subscriptions. */
- status = _AwsIotJobs_IncrementReferences( pOperation,
- pTopicBuffer,
- operationTopicLength,
- jobsCallbacks[ pOperation->type ] );
+ status = _AwsIotJobs_IncrementReferences( pOperation,
+ pTopicBuffer,
+ operationTopicLength,
+ jobsCallbacks[ pOperation->type ] );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -529,8 +529,8 @@ AwsIotJobsError_t _AwsIotJobs_CreateOperation( _jobsOperationType_t type,
_jobsOperation_t ** pNewOperation )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS );
- size_t operationSize = sizeof( _jobsOperation_t );
- _jobsOperation_t * pOperation = NULL;
+ size_t operationSize = sizeof( _jobsOperation_t );
+ _jobsOperation_t * pOperation = NULL;
IotLogDebug( "Creating operation record for Jobs %s.",
_pAwsIotJobsOperationNames[ type ] );
@@ -547,7 +547,7 @@ AwsIotJobsError_t _AwsIotJobs_CreateOperation( _jobsOperationType_t type,
}
/* Allocate memory for a new Jobs operation. */
- pOperation = AwsIotJobs_MallocOperation( operationSize );
+ pOperation = AwsIotJobs_MallocOperation( operationSize );
if( pOperation == NULL )
{
@@ -561,9 +561,9 @@ AwsIotJobsError_t _AwsIotJobs_CreateOperation( _jobsOperationType_t type,
( void ) memset( pOperation, 0x00, sizeof( _jobsOperation_t ) );
/* Set the remaining common members of the Jobs operation. */
- pOperation->type = type;
- pOperation->flags = flags;
- pOperation->status = AWS_IOT_JOBS_STATUS_PENDING;
+ pOperation->type = type;
+ pOperation->flags = flags;
+ pOperation->status = AWS_IOT_JOBS_STATUS_PENDING;
pOperation->mallocResponse = pRequestInfo->mallocResponse;
/* Save the Job ID for DESCRIBE and UPDATE operations. */
@@ -575,10 +575,10 @@ AwsIotJobsError_t _AwsIotJobs_CreateOperation( _jobsOperationType_t type,
}
/* Generate a Jobs request document. */
- status = _AwsIotJobs_GenerateJsonRequest( type,
- pRequestInfo,
- pRequestContents,
- pOperation );
+ status = _AwsIotJobs_GenerateJsonRequest( type,
+ pRequestInfo,
+ pRequestContents,
+ pOperation );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -668,13 +668,13 @@ AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic( _jobsOperationType_t type,
char ** pTopicBuffer,
uint16_t * pOperationTopicLength )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
- AwsIotTopicInfo_t topicInfo = { 0 };
- char pJobOperationName[ JOBS_LONGEST_SUFFIX_LENGTH ] = { 0 };
- uint16_t operationNameLength = 0;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
+ AwsIotTopicInfo_t topicInfo = { 0 };
+ char pJobOperationName[ JOBS_LONGEST_SUFFIX_LENGTH ] = { 0 };
+ uint16_t operationNameLength = 0;
/* Lookup table for Jobs operation strings. */
- const char * const pOperationString[ JOBS_OPERATION_COUNT ] =
+ const char * const pOperationString[ JOBS_OPERATION_COUNT ] =
{
JOBS_GET_PENDING_OPERATION_STRING, /* Jobs get pending operation. */
JOBS_START_NEXT_OPERATION_STRING, /* Jobs start next operation. */
@@ -683,7 +683,7 @@ AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic( _jobsOperationType_t type,
};
/* Lookup table for Jobs operation string lengths. */
- const uint16_t pOperationStringLength[ JOBS_OPERATION_COUNT ] =
+ const uint16_t pOperationStringLength[ JOBS_OPERATION_COUNT ] =
{
JOBS_GET_PENDING_OPERATION_STRING_LENGTH, /* Jobs get pending operation */
JOBS_START_NEXT_OPERATION_STRING_LENGTH, /* Jobs start next operation. */
@@ -696,10 +696,10 @@ AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic( _jobsOperationType_t type,
( type == JOBS_DESCRIBE ) || ( type == JOBS_UPDATE ) );
/* Set the members needed to generate an operation topic. */
- topicInfo.pThingName = pRequestInfo->pThingName;
- topicInfo.thingNameLength = pRequestInfo->thingNameLength;
+ topicInfo.pThingName = pRequestInfo->pThingName;
+ topicInfo.thingNameLength = pRequestInfo->thingNameLength;
topicInfo.longestSuffixLength = JOBS_LONGEST_SUFFIX_LENGTH;
- topicInfo.mallocString = AwsIotJobs_MallocString;
+ topicInfo.mallocString = AwsIotJobs_MallocString;
/* Job operations that require a Job ID require additional processing to
* create an operation name with the Job ID. */
@@ -711,24 +711,24 @@ AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic( _jobsOperationType_t type,
/* Construct the Jobs operation name with the Job ID. */
( void ) memcpy( pJobOperationName, "/jobs/", 6 );
- operationNameLength = 6;
+ operationNameLength = 6;
( void ) memcpy( pJobOperationName + operationNameLength,
pRequestInfo->pJobId,
pRequestInfo->jobIdLength );
- operationNameLength = ( uint16_t ) ( pRequestInfo->jobIdLength + operationNameLength );
+ operationNameLength = ( uint16_t ) ( pRequestInfo->jobIdLength + operationNameLength );
( void ) memcpy( pJobOperationName + operationNameLength,
pOperationString[ type ],
pOperationStringLength[ type ] );
- operationNameLength = ( uint16_t ) ( operationNameLength + pOperationStringLength[ type ] );
+ operationNameLength = ( uint16_t ) ( operationNameLength + pOperationStringLength[ type ] );
- topicInfo.pOperationName = pJobOperationName;
+ topicInfo.pOperationName = pJobOperationName;
topicInfo.operationNameLength = operationNameLength;
}
else
{
- topicInfo.pOperationName = pOperationString[ type ];
+ topicInfo.pOperationName = pOperationString[ type ];
topicInfo.operationNameLength = pOperationStringLength[ type ];
}
@@ -748,11 +748,11 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t *
_jobsOperation_t * pOperation )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_STATUS_PENDING );
- char * pTopicBuffer = NULL;
- uint16_t operationTopicLength = 0;
- bool freeTopicBuffer = true;
- IotMqttPublishInfo_t publishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER;
- IotMqttError_t publishStatus = IOT_MQTT_STATUS_PENDING;
+ char * pTopicBuffer = NULL;
+ uint16_t operationTopicLength = 0;
+ bool freeTopicBuffer = true;
+ IotMqttPublishInfo_t publishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER;
+ IotMqttError_t publishStatus = IOT_MQTT_STATUS_PENDING;
IotLogDebug( "Processing Jobs operation %s for Thing %.*s.",
_pAwsIotJobsOperationNames[ pOperation->type ],
@@ -760,13 +760,13 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t *
pRequestInfo->pThingName );
/* Set the operation's MQTT connection. */
- pOperation->mqttConnection = pRequestInfo->mqttConnection;
+ pOperation->mqttConnection = pRequestInfo->mqttConnection;
/* Generate the operation topic buffer. */
- status = _AwsIotJobs_GenerateJobsTopic( pOperation->type,
- pRequestInfo,
- &pTopicBuffer,
- &operationTopicLength );
+ status = _AwsIotJobs_GenerateJobsTopic( pOperation->type,
+ pRequestInfo,
+ &pTopicBuffer,
+ &operationTopicLength );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -776,11 +776,11 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t *
}
/* Get a subscription object for this Jobs operation. */
- status = _findSubscription( pRequestInfo,
- pTopicBuffer,
- operationTopicLength,
- pOperation,
- &freeTopicBuffer );
+ status = _findSubscription( pRequestInfo,
+ pTopicBuffer,
+ operationTopicLength,
+ pOperation,
+ &freeTopicBuffer );
if( status != AWS_IOT_JOBS_SUCCESS )
{
@@ -789,16 +789,16 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t *
}
/* Set the members for PUBLISH retry. */
- publishInfo.qos = pRequestInfo->qos;
- publishInfo.retryLimit = pRequestInfo->retryLimit;
- publishInfo.retryMs = pRequestInfo->retryMs;
+ publishInfo.qos = pRequestInfo->qos;
+ publishInfo.retryLimit = pRequestInfo->retryLimit;
+ publishInfo.retryMs = pRequestInfo->retryMs;
/* Set the payload as the Jobs request. */
- publishInfo.pPayload = pOperation->pJobsRequest;
- publishInfo.payloadLength = pOperation->jobsRequestLength;
+ publishInfo.pPayload = pOperation->pJobsRequest;
+ publishInfo.payloadLength = pOperation->jobsRequestLength;
/* Set the operation topic name. */
- publishInfo.pTopicName = pTopicBuffer;
+ publishInfo.pTopicName = pTopicBuffer;
publishInfo.topicNameLength = operationTopicLength;
IotLogDebug( "Jobs %s message will be published to topic %.*s",
@@ -813,10 +813,10 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t *
IotMutex_Unlock( &( _AwsIotJobsPendingOperationsMutex ) );
/* Publish to the Jobs topic name. */
- publishStatus = IotMqtt_PublishSync( pOperation->mqttConnection,
- &publishInfo,
- 0,
- _AwsIotJobsMqttTimeoutMs );
+ publishStatus = IotMqtt_PublishSync( pOperation->mqttConnection,
+ &publishInfo,
+ 0,
+ _AwsIotJobsMqttTimeoutMs );
if( publishStatus != IOT_MQTT_SUCCESS )
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c
index 6e0209957..612af6660 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c
@@ -421,8 +421,8 @@ static size_t _appendClientToken( char * pBuffer,
const AwsIotJobsRequestInfo_t * pRequestInfo,
_jobsOperation_t * pOperation )
{
- int clientTokenLength = 0;
- uint32_t clientToken = 0;
+ int clientTokenLength = 0;
+ uint32_t clientToken = 0;
/* Place the client token key in the buffer. */
APPEND_STRING( pBuffer,
@@ -438,14 +438,14 @@ static size_t _appendClientToken( char * pBuffer,
{
/* Take the address of the given buffer, truncated to 8 characters. This
* provides a client token that is very likely to be unique while in use. */
- clientToken = ( uint32_t ) ( ( uint64_t ) pBuffer % 100000000ULL );
+ clientToken = ( uint32_t ) ( ( uint64_t ) pBuffer % 100000000ULL );
- clientTokenLength = snprintf( pBuffer + copyOffset,
- CLIENT_TOKEN_AUTOGENERATE_LENGTH + 1,
- "%08u", clientToken );
+ clientTokenLength = snprintf( pBuffer + copyOffset,
+ CLIENT_TOKEN_AUTOGENERATE_LENGTH + 1,
+ "%08u", clientToken );
AwsIotJobs_Assert( clientTokenLength == CLIENT_TOKEN_AUTOGENERATE_LENGTH );
- copyOffset += ( size_t ) clientTokenLength;
+ copyOffset += ( size_t ) clientTokenLength;
pOperation->clientTokenLength = CLIENT_TOKEN_AUTOGENERATE_LENGTH + 2;
}
else
@@ -466,10 +466,10 @@ static size_t _appendClientToken( char * pBuffer,
static AwsIotJobsError_t _generateGetPendingRequest( const AwsIotJobsRequestInfo_t * pRequestInfo,
_jobsOperation_t * pOperation )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
- char * pJobsRequest = NULL;
- size_t copyOffset = 0;
- size_t requestLength = MINIMUM_REQUEST_LENGTH;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
+ char * pJobsRequest = NULL;
+ size_t copyOffset = 0;
+ size_t requestLength = MINIMUM_REQUEST_LENGTH;
/* Add the length of the client token. */
if( pRequestInfo->pClientToken != AWS_IOT_JOBS_CLIENT_TOKEN_AUTOGENERATE )
@@ -498,11 +498,11 @@ static AwsIotJobsError_t _generateGetPendingRequest( const AwsIotJobsRequestInfo
/* Construct the request JSON, which consists of just a clientToken key. */
APPEND_STRING( pJobsRequest, copyOffset, "{\"", 2 );
- copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation );
+ copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation );
APPEND_STRING( pJobsRequest, copyOffset, "\"}", 2 );
/* Set the output parameters. */
- pOperation->pJobsRequest = pJobsRequest;
+ pOperation->pJobsRequest = pJobsRequest;
pOperation->jobsRequestLength = requestLength;
/* Ensure offsets are valid. */
@@ -525,12 +525,12 @@ static AwsIotJobsError_t _generateStartNextRequest( const AwsIotJobsRequestInfo_
const AwsIotJobsUpdateInfo_t * pUpdateInfo,
_jobsOperation_t * pOperation )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
- char * pJobsRequest = NULL;
- size_t copyOffset = 0;
- size_t requestLength = MINIMUM_REQUEST_LENGTH;
- char pStepTimeout[ STEP_TIMEOUT_STRING_LENGTH ] = { 0 };
- int stepTimeoutLength = 0;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
+ char * pJobsRequest = NULL;
+ size_t copyOffset = 0;
+ size_t requestLength = MINIMUM_REQUEST_LENGTH;
+ char pStepTimeout[ STEP_TIMEOUT_STRING_LENGTH ] = { 0 };
+ int stepTimeoutLength = 0;
/* Add the length of status details if provided. */
if( pUpdateInfo->pStatusDetails != AWS_IOT_JOBS_NO_STATUS_DETAILS )
@@ -613,12 +613,12 @@ static AwsIotJobsError_t _generateStartNextRequest( const AwsIotJobsRequestInfo_
}
/* Add client token. */
- copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation );
+ copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation );
APPEND_STRING( pJobsRequest, copyOffset, "\"}", 2 );
/* Set the output parameters. */
- pOperation->pJobsRequest = pJobsRequest;
+ pOperation->pJobsRequest = pJobsRequest;
pOperation->jobsRequestLength = requestLength;
/* Ensure offsets are valid. */
@@ -642,12 +642,12 @@ static AwsIotJobsError_t _generateDescribeRequest( const AwsIotJobsRequestInfo_t
bool includeJobDocument,
_jobsOperation_t * pOperation )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
- char * pJobsRequest = NULL;
- size_t copyOffset = 0;
- size_t requestLength = MINIMUM_REQUEST_LENGTH;
- char pExecutionNumber[ EXECUTION_NUMBER_STRING_LENGTH ] = { 0 };
- int executionNumberLength = 0;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
+ char * pJobsRequest = NULL;
+ size_t copyOffset = 0;
+ size_t requestLength = MINIMUM_REQUEST_LENGTH;
+ char pExecutionNumber[ EXECUTION_NUMBER_STRING_LENGTH ] = { 0 };
+ int executionNumberLength = 0;
/* Add the "include job document" flag if false. The default value is true,
* so the flag is not needed if true. */
@@ -672,8 +672,8 @@ static AwsIotJobsError_t _generateDescribeRequest( const AwsIotJobsRequestInfo_t
AwsIotJobs_Assert( executionNumberLength > 0 );
AwsIotJobs_Assert( executionNumberLength < EXECUTION_NUMBER_STRING_LENGTH );
- requestLength += EXECUTION_NUMBER_KEY_LENGTH + 4;
- requestLength += ( size_t ) executionNumberLength;
+ requestLength += EXECUTION_NUMBER_KEY_LENGTH + 4;
+ requestLength += ( size_t ) executionNumberLength;
}
/* Add the length of the client token. */
@@ -724,12 +724,12 @@ static AwsIotJobsError_t _generateDescribeRequest( const AwsIotJobsRequestInfo_t
}
/* Add client token. */
- copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation );
+ copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation );
APPEND_STRING( pJobsRequest, copyOffset, "\"}", 2 );
/* Set the output parameters. */
- pOperation->pJobsRequest = pJobsRequest;
+ pOperation->pJobsRequest = pJobsRequest;
pOperation->jobsRequestLength = requestLength;
/* Ensure offsets are valid. */
@@ -753,15 +753,15 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t *
_jobsOperation_t * pOperation )
{
AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS;
- char * pJobsRequest = NULL;
- size_t copyOffset = 0;
- size_t requestLength = MINIMUM_REQUEST_LENGTH;
- const char * pStatus = NULL;
- size_t statusLength = 0;
- char pExpectedVersion[ EXPECTED_VERSION_STRING_LENGTH ] = { 0 };
- char pExecutionNumber[ EXECUTION_NUMBER_STRING_LENGTH ] = { 0 };
- char pStepTimeout[ STEP_TIMEOUT_STRING_LENGTH ] = { 0 };
- int expectedVersionLength = 0, executionNumberLength = 0, stepTimeoutLength = 0;
+ char * pJobsRequest = NULL;
+ size_t copyOffset = 0;
+ size_t requestLength = MINIMUM_REQUEST_LENGTH;
+ const char * pStatus = NULL;
+ size_t statusLength = 0;
+ char pExpectedVersion[ EXPECTED_VERSION_STRING_LENGTH ] = { 0 };
+ char pExecutionNumber[ EXECUTION_NUMBER_STRING_LENGTH ] = { 0 };
+ char pStepTimeout[ STEP_TIMEOUT_STRING_LENGTH ] = { 0 };
+ int expectedVersionLength = 0, executionNumberLength = 0, stepTimeoutLength = 0;
/* Determine the status string and length to report to the Jobs service.
* Add 6 for the 4 quotes, colon, and comma. */
@@ -788,7 +788,7 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t *
break;
}
- statusLength = strlen( pStatus );
+ statusLength = strlen( pStatus );
requestLength += statusLength;
/* Add the length of status details if provided. */
@@ -811,8 +811,8 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t *
AwsIotJobs_Assert( expectedVersionLength < EXPECTED_VERSION_STRING_LENGTH );
/* Add 6 for the 4 quotes, colon, and comma. */
- requestLength += EXPECTED_VERSION_KEY_LENGTH + 6;
- requestLength += ( size_t ) expectedVersionLength;
+ requestLength += EXPECTED_VERSION_KEY_LENGTH + 6;
+ requestLength += ( size_t ) expectedVersionLength;
}
/* Add the length of the execution number if present. */
@@ -826,8 +826,8 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t *
AwsIotJobs_Assert( executionNumberLength > 0 );
AwsIotJobs_Assert( executionNumberLength < EXECUTION_NUMBER_STRING_LENGTH );
- requestLength += EXECUTION_NUMBER_KEY_LENGTH + 4;
- requestLength += ( size_t ) executionNumberLength;
+ requestLength += EXECUTION_NUMBER_KEY_LENGTH + 4;
+ requestLength += ( size_t ) executionNumberLength;
}
/* Add the flags if true. The default values are false, so the flags are not
@@ -972,12 +972,12 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t *
}
/* Add the client token. */
- copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation );
+ copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation );
APPEND_STRING( pJobsRequest, copyOffset, "\"}", 2 );
/* Set the output parameters. */
- pOperation->pJobsRequest = pJobsRequest;
+ pOperation->pJobsRequest = pJobsRequest;
pOperation->jobsRequestLength = requestLength;
/* Ensure offsets are valid. */
@@ -999,9 +999,9 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t *
static AwsIotJobsError_t _parseErrorDocument( const char * pErrorDocument,
size_t errorDocumentLength )
{
- AwsIotJobsError_t status = AWS_IOT_JOBS_BAD_RESPONSE;
- const char * pCode = NULL;
- size_t codeLength = 0;
+ AwsIotJobsError_t status = AWS_IOT_JOBS_BAD_RESPONSE;
+ const char * pCode = NULL;
+ size_t codeLength = 0;
/* Find the error code. */
if( AwsIotDocParser_FindValue( pErrorDocument,
@@ -1165,7 +1165,7 @@ void _AwsIotJobs_ParseResponse( AwsIotStatus_t status,
* info. */
if( ( pOperation->flags & AWS_IOT_JOBS_FLAG_WAITABLE ) == 0 )
{
- pOperation->pJobsResponse = pResponse;
+ pOperation->pJobsResponse = pResponse;
pOperation->jobsResponseLength = responseLength;
}
else
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c
index b5ddee558..f13e6dac9 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c
@@ -32,15 +32,15 @@
#if IOT_STATIC_MEMORY_ONLY == 1
/* Standard includes. */
-#include <stdbool.h>
-#include <stddef.h>
-#include <string.h>
+ #include <stdbool.h>
+ #include <stddef.h>
+ #include <string.h>
/* Static memory include. */
-#include "iot_static_memory.h"
+ #include "iot_static_memory.h"
/* Jobs internal include. */
-#include "private/aws_iot_jobs_internal.h"
+ #include "private/aws_iot_jobs_internal.h"
/*-----------------------------------------------------------*/
@@ -50,21 +50,21 @@
*
* Provide default values for undefined configuration constants.
*/
-#ifndef AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS
- #define AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ( 10 )
-#endif
-#ifndef AWS_IOT_JOBS_SUBSCRIPTIONS
- #define AWS_IOT_JOBS_SUBSCRIPTIONS ( 2 )
-#endif
+ #ifndef AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS
+ #define AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ( 10 )
+ #endif
+ #ifndef AWS_IOT_JOBS_SUBSCRIPTIONS
+ #define AWS_IOT_JOBS_SUBSCRIPTIONS ( 2 )
+ #endif
/** @endcond */
/* Validate static memory configuration settings. */
-#if AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS <= 0
- #error "AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS cannot be 0 or negative."
-#endif
-#if AWS_IOT_JOBS_SUBSCRIPTIONS <= 0
- #error "AWS_IOT_JOBS_SUBSCRIPTIONS cannot be 0 or negative."
-#endif
+ #if AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS <= 0
+ #error "AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS cannot be 0 or negative."
+ #endif
+ #if AWS_IOT_JOBS_SUBSCRIPTIONS <= 0
+ #error "AWS_IOT_JOBS_SUBSCRIPTIONS cannot be 0 or negative."
+ #endif
/**
* @brief The size of a static memory Jobs operation.
@@ -73,7 +73,7 @@
* the constant `JOBS_MAX_ID_LENGTH` is used for the length of
* #_jobsOperation_t.pJobId.
*/
-#define JOBS_OPERATION_SIZE ( sizeof( _jobsOperation_t ) + JOBS_MAX_ID_LENGTH )
+ #define JOBS_OPERATION_SIZE ( sizeof( _jobsOperation_t ) + JOBS_MAX_ID_LENGTH )
/**
* @brief The size of a static memory Jobs subscription.
@@ -82,88 +82,88 @@
* the constant `AWS_IOT_MAX_THING_NAME_LENGTH` is used for the length of
* #_jobsSubscription_t.pThingName.
*/
-#define JOBS_SUBSCRIPTION_SIZE ( sizeof( _jobsSubscription_t ) + AWS_IOT_MAX_THING_NAME_LENGTH )
+ #define JOBS_SUBSCRIPTION_SIZE ( sizeof( _jobsSubscription_t ) + AWS_IOT_MAX_THING_NAME_LENGTH )
/*-----------------------------------------------------------*/
/*
* Static memory buffers and flags, allocated and zeroed at compile-time.
*/
-static uint32_t _pInUseJobsOperations[ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ] = { 0U }; /**< @brief Jobs operation in-use flags. */
-static char _pJobsOperations[ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ][ JOBS_OPERATION_SIZE ] = { { 0 } }; /**< @brief Jobs operations. */
+ static uint32_t _pInUseJobsOperations[ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ] = { 0U }; /**< @brief Jobs operation in-use flags. */
+ static char _pJobsOperations[ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ][ JOBS_OPERATION_SIZE ] = { { 0 } }; /**< @brief Jobs operations. */
-static uint32_t _pInUseJobsSubscriptions[ AWS_IOT_JOBS_SUBSCRIPTIONS ] = { 0U }; /**< @brief Jobs subscription in-use flags. */
-static char _pJobsSubscriptions[ AWS_IOT_JOBS_SUBSCRIPTIONS ][ JOBS_SUBSCRIPTION_SIZE ] = { { 0 } }; /**< @brief Jobs subscriptions. */
+ static uint32_t _pInUseJobsSubscriptions[ AWS_IOT_JOBS_SUBSCRIPTIONS ] = { 0U }; /**< @brief Jobs subscription in-use flags. */
+ static char _pJobsSubscriptions[ AWS_IOT_JOBS_SUBSCRIPTIONS ][ JOBS_SUBSCRIPTION_SIZE ] = { { 0 } }; /**< @brief Jobs subscriptions. */
/*-----------------------------------------------------------*/
-void * AwsIotJobs_MallocOperation( size_t size )
-{
- int32_t freeIndex = -1;
- void * pNewOperation = NULL;
-
- /* Check size argument. */
- if( size <= JOBS_OPERATION_SIZE )
+ void * AwsIotJobs_MallocOperation( size_t size )
{
- /* Find a free Jobs operation. */
- freeIndex = IotStaticMemory_FindFree( _pInUseJobsOperations,
- AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS );
+ int32_t freeIndex = -1;
+ void * pNewOperation = NULL;
- if( freeIndex != -1 )
+ /* Check size argument. */
+ if( size <= JOBS_OPERATION_SIZE )
{
- pNewOperation = &( _pJobsOperations[ freeIndex ] );
+ /* Find a free Jobs operation. */
+ freeIndex = IotStaticMemory_FindFree( _pInUseJobsOperations,
+ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS );
+
+ if( freeIndex != -1 )
+ {
+ pNewOperation = &( _pJobsOperations[ freeIndex ] );
+ }
}
- }
- return pNewOperation;
-}
+ return pNewOperation;
+ }
/*-----------------------------------------------------------*/
-void AwsIotJobs_FreeOperation( void * ptr )
-{
- /* Return the in-use Jobs operation. */
- IotStaticMemory_ReturnInUse( ptr,
- _pJobsOperations,
- _pInUseJobsOperations,
- AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS,
- JOBS_OPERATION_SIZE );
-}
+ void AwsIotJobs_FreeOperation( void * ptr )
+ {
+ /* Return the in-use Jobs operation. */
+ IotStaticMemory_ReturnInUse( ptr,
+ _pJobsOperations,
+ _pInUseJobsOperations,
+ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS,
+ JOBS_OPERATION_SIZE );
+ }
/*-----------------------------------------------------------*/
-void * AwsIotJobs_MallocSubscription( size_t size )
-{
- int32_t freeIndex = -1;
- void * pNewSubscription = NULL;
-
- if( size <= JOBS_SUBSCRIPTION_SIZE )
+ void * AwsIotJobs_MallocSubscription( size_t size )
{
- /* Get the index of a free Jobs subscription. */
- freeIndex = IotStaticMemory_FindFree( _pInUseJobsSubscriptions,
- AWS_IOT_JOBS_SUBSCRIPTIONS );
+ int32_t freeIndex = -1;
+ void * pNewSubscription = NULL;
- if( freeIndex != -1 )
+ if( size <= JOBS_SUBSCRIPTION_SIZE )
{
- pNewSubscription = &( _pJobsSubscriptions[ freeIndex ][ 0 ] );
+ /* Get the index of a free Jobs subscription. */
+ freeIndex = IotStaticMemory_FindFree( _pInUseJobsSubscriptions,
+ AWS_IOT_JOBS_SUBSCRIPTIONS );
+
+ if( freeIndex != -1 )
+ {
+ pNewSubscription = &( _pJobsSubscriptions[ freeIndex ][ 0 ] );
+ }
}
- }
- return pNewSubscription;
-}
+ return pNewSubscription;
+ }
/*-----------------------------------------------------------*/
-void AwsIotJobs_FreeSubscription( void * ptr )
-{
- /* Return the in-use Jobs subscription. */
- IotStaticMemory_ReturnInUse( ptr,
- _pJobsSubscriptions,
- _pInUseJobsSubscriptions,
- AWS_IOT_JOBS_SUBSCRIPTIONS,
- JOBS_SUBSCRIPTION_SIZE );
-}
+ void AwsIotJobs_FreeSubscription( void * ptr )
+ {
+ /* Return the in-use Jobs subscription. */
+ IotStaticMemory_ReturnInUse( ptr,
+ _pJobsSubscriptions,
+ _pInUseJobsSubscriptions,
+ AWS_IOT_JOBS_SUBSCRIPTIONS,
+ JOBS_SUBSCRIPTION_SIZE );
+ }
/*-----------------------------------------------------------*/
-#endif
+#endif /* if IOT_STATIC_MEMORY_ONLY == 1 */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c
index 5fae60072..2d8c15af8 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c
@@ -75,7 +75,7 @@ IotMutex_t _AwsIotJobsSubscriptionsMutex;
static bool _jobsSubscription_match( const IotLink_t * pSubscriptionLink,
void * pMatch )
{
- bool match = false;
+ bool match = false;
/* Because this function is called from a container function, the given link
* must never be NULL. */
@@ -84,7 +84,7 @@ static bool _jobsSubscription_match( const IotLink_t * pSubscriptionLink,
const _jobsSubscription_t * pSubscription = IotLink_Container( _jobsSubscription_t,
pSubscriptionLink,
link );
- const AwsIotThingName_t * pThingName = ( AwsIotThingName_t * ) pMatch;
+ const AwsIotThingName_t * pThingName = ( AwsIotThingName_t * ) pMatch;
if( pThingName->thingNameLength == pSubscription->thingNameLength )
{
@@ -103,18 +103,18 @@ _jobsSubscription_t * _AwsIotJobs_FindSubscription( const char * pThingName,
size_t thingNameLength,
bool createIfNotFound )
{
- _jobsSubscription_t * pSubscription = NULL;
- IotLink_t * pSubscriptionLink = NULL;
- AwsIotThingName_t thingName = { 0 };
+ _jobsSubscription_t * pSubscription = NULL;
+ IotLink_t * pSubscriptionLink = NULL;
+ AwsIotThingName_t thingName = { 0 };
- thingName.pThingName = pThingName;
+ thingName.pThingName = pThingName;
thingName.thingNameLength = thingNameLength;
/* Search the list for an existing subscription for Thing Name. */
- pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotJobsSubscriptions ),
- NULL,
- _jobsSubscription_match,
- &thingName );
+ pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotJobsSubscriptions ),
+ NULL,
+ _jobsSubscription_match,
+ &thingName );
/* Check if a subscription was found. */
if( pSubscriptionLink == NULL )
@@ -277,10 +277,10 @@ AwsIotJobsError_t _AwsIotJobs_IncrementReferences( _jobsOperation_t * pOperation
AwsIotMqttCallbackFunction_t callback )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS );
- const _jobsOperationType_t type = pOperation->type;
- _jobsSubscription_t * pSubscription = pOperation->pSubscription;
- IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING;
- AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
+ const _jobsOperationType_t type = pOperation->type;
+ _jobsSubscription_t * pSubscription = pOperation->pSubscription;
+ IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING;
+ AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
/* Do nothing if this operation has persistent subscriptions. */
if( pSubscription->operationReferences[ type ] == AWS_IOT_PERSISTENT_SUBSCRIPTION )
@@ -302,14 +302,14 @@ AwsIotJobsError_t _AwsIotJobs_IncrementReferences( _jobsOperation_t * pOperation
if( pSubscription->operationReferences[ type ] == 0 )
{
/* Set the parameters needed to add subscriptions. */
- subscriptionInfo.mqttConnection = pOperation->mqttConnection;
- subscriptionInfo.callbackFunction = callback;
- subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs;
- subscriptionInfo.pTopicFilterBase = pTopicBuffer;
+ subscriptionInfo.mqttConnection = pOperation->mqttConnection;
+ subscriptionInfo.callbackFunction = callback;
+ subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs;
+ subscriptionInfo.pTopicFilterBase = pTopicBuffer;
subscriptionInfo.topicFilterBaseLength = operationTopicLength;
- subscriptionStatus = AwsIot_ModifySubscriptions( IotMqtt_SubscribeSync,
- &subscriptionInfo );
+ subscriptionStatus = AwsIot_ModifySubscriptions( IotMqtt_SubscribeSync,
+ &subscriptionInfo );
/* Convert MQTT return code to Jobs return code. */
switch( subscriptionStatus )
@@ -365,11 +365,11 @@ void _AwsIotJobs_DecrementReferences( _jobsOperation_t * pOperation,
char * pTopicBuffer,
_jobsSubscription_t ** pRemovedSubscription )
{
- const _jobsOperationType_t type = pOperation->type;
- _jobsSubscription_t * pSubscription = pOperation->pSubscription;
- uint16_t operationTopicLength = 0;
- AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
- AwsIotJobsRequestInfo_t requestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER;
+ const _jobsOperationType_t type = pOperation->type;
+ _jobsSubscription_t * pSubscription = pOperation->pSubscription;
+ uint16_t operationTopicLength = 0;
+ AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
+ AwsIotJobsRequestInfo_t requestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER;
/* Do nothing if this Jobs operation has persistent subscriptions. */
if( pSubscription->operationReferences[ type ] != AWS_IOT_PERSISTENT_SUBSCRIPTION )
@@ -391,10 +391,10 @@ void _AwsIotJobs_DecrementReferences( _jobsOperation_t * pOperation,
AwsIotJobs_Assert( pSubscription->pTopicBuffer != NULL );
/* Set the parameters needed to generate a Jobs topic. */
- requestInfo.pThingName = pSubscription->pThingName;
- requestInfo.thingNameLength = pSubscription->thingNameLength;
- requestInfo.pJobId = pOperation->pJobId;
- requestInfo.jobIdLength = pOperation->jobIdLength;
+ requestInfo.pThingName = pSubscription->pThingName;
+ requestInfo.thingNameLength = pSubscription->thingNameLength;
+ requestInfo.pJobId = pOperation->pJobId;
+ requestInfo.jobIdLength = pOperation->jobIdLength;
/* Generate the prefix of the Jobs topic. This function will not
* fail when given a buffer. */
@@ -404,9 +404,9 @@ void _AwsIotJobs_DecrementReferences( _jobsOperation_t * pOperation,
&operationTopicLength );
/* Set the parameters needed to remove subscriptions. */
- subscriptionInfo.mqttConnection = pOperation->mqttConnection;
- subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs;
- subscriptionInfo.pTopicFilterBase = pTopicBuffer;
+ subscriptionInfo.mqttConnection = pOperation->mqttConnection;
+ subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs;
+ subscriptionInfo.pTopicFilterBase = pTopicBuffer;
subscriptionInfo.topicFilterBaseLength = operationTopicLength;
( void ) AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync,
@@ -433,15 +433,15 @@ AwsIotJobsError_t AwsIotJobs_RemovePersistentSubscriptions( const AwsIotJobsRequ
uint32_t flags )
{
IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS );
- int32_t i = 0;
- uint16_t operationTopicLength = 0;
- IotMqttError_t unsubscribeStatus = IOT_MQTT_STATUS_PENDING;
- AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
- _jobsSubscription_t * pSubscription = NULL;
- IotLink_t * pSubscriptionLink = NULL;
- AwsIotThingName_t thingName = { 0 };
-
- thingName.pThingName = pRequestInfo->pThingName;
+ int32_t i = 0;
+ uint16_t operationTopicLength = 0;
+ IotMqttError_t unsubscribeStatus = IOT_MQTT_STATUS_PENDING;
+ AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
+ _jobsSubscription_t * pSubscription = NULL;
+ IotLink_t * pSubscriptionLink = NULL;
+ AwsIotThingName_t thingName = { 0 };
+
+ thingName.pThingName = pRequestInfo->pThingName;
thingName.thingNameLength = pRequestInfo->thingNameLength;
IotLogInfo( "Removing persistent subscriptions for %.*s.",
@@ -486,10 +486,10 @@ AwsIotJobsError_t AwsIotJobs_RemovePersistentSubscriptions( const AwsIotJobsRequ
IotMutex_Lock( &( _AwsIotJobsSubscriptionsMutex ) );
/* Search the list for an existing subscription for Thing Name. */
- pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotJobsSubscriptions ),
- NULL,
- _jobsSubscription_match,
- &thingName );
+ pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotJobsSubscriptions ),
+ NULL,
+ _jobsSubscription_match,
+ &thingName );
if( pSubscriptionLink != NULL )
{
@@ -522,13 +522,13 @@ AwsIotJobsError_t AwsIotJobs_RemovePersistentSubscriptions( const AwsIotJobsRequ
&operationTopicLength );
/* Set the parameters needed to remove subscriptions. */
- subscriptionInfo.mqttConnection = pRequestInfo->mqttConnection;
- subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs;
- subscriptionInfo.pTopicFilterBase = pSubscription->pTopicBuffer;
- subscriptionInfo.topicFilterBaseLength = operationTopicLength;
+ subscriptionInfo.mqttConnection = pRequestInfo->mqttConnection;
+ subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs;
+ subscriptionInfo.pTopicFilterBase = pSubscription->pTopicBuffer;
+ subscriptionInfo.topicFilterBaseLength = operationTopicLength;
- unsubscribeStatus = AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync,
- &subscriptionInfo );
+ unsubscribeStatus = AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync,
+ &subscriptionInfo );
/* Convert MQTT return code to Shadow return code. */
switch( unsubscribeStatus )
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h
index 370bb8e94..938e0edb0 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h
@@ -425,11 +425,11 @@ typedef struct _jobsOperation
#endif
/* Declarations of variables for internal Jobs files. */
-extern uint32_t _AwsIotJobsMqttTimeoutMs;
-extern IotListDouble_t _AwsIotJobsPendingOperations;
-extern IotListDouble_t _AwsIotJobsSubscriptions;
-extern IotMutex_t _AwsIotJobsPendingOperationsMutex;
-extern IotMutex_t _AwsIotJobsSubscriptionsMutex;
+extern uint32_t _AwsIotJobsMqttTimeoutMs;
+extern IotListDouble_t _AwsIotJobsPendingOperations;
+extern IotListDouble_t _AwsIotJobsSubscriptions;
+extern IotMutex_t _AwsIotJobsPendingOperationsMutex;
+extern IotMutex_t _AwsIotJobsSubscriptionsMutex;
/*------------------------ Jobs operation functions -------------------------*/
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c
index 2d63d128a..790f9c55a 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c
@@ -94,11 +94,11 @@ typedef union MultiParmPtr
/* Array containing pointer to the OTA event structures used to send events to the OTA task. */
-static OTA_EventMsg_t xQueueData[ OTA_NUM_MSG_Q_ENTRIES ];
+static OTA_EventMsg_t xQueueData[ OTA_NUM_MSG_Q_ENTRIES ];
/* Buffers used to push event data. */
-static OTA_EventData_t xEventBuffer[ otaconfigMAX_NUM_OTA_DATA_BUFFERS ];
+static OTA_EventData_t xEventBuffer[ otaconfigMAX_NUM_OTA_DATA_BUFFERS ];
/* OTA control interface. */
@@ -106,7 +106,7 @@ static OTA_ControlInterface_t xOTA_ControlInterface;
/* OTA data interface. */
-static OTA_DataInterface_t xOTA_DataInterface;
+static OTA_DataInterface_t xOTA_DataInterface;
/*
* Test a null terminated string against a JSON string of known length and return whether
@@ -264,21 +264,21 @@ static OTA_Err_t prvResumeHandler( OTA_EventData_t * pxEventData );
#define OTA_JOB_CALLBACK_DEFAULT_INITIALIZER \
{ \
- .xAbort = prvPAL_Abort, \
- .xActivateNewImage = prvPAL_DefaultActivateNewImage, \
- .xCloseFile = prvPAL_CloseFile, \
- .xCreateFileForRx = prvPAL_CreateFileForRx, \
+ .xAbort = prvPAL_Abort, \
+ .xActivateNewImage = prvPAL_DefaultActivateNewImage, \
+ .xCloseFile = prvPAL_CloseFile, \
+ .xCreateFileForRx = prvPAL_CreateFileForRx, \
.xGetPlatformImageState = prvPAL_DefaultGetPlatformImageState, \
- .xResetDevice = prvPAL_DefaultResetDevice, \
+ .xResetDevice = prvPAL_DefaultResetDevice, \
.xSetPlatformImageState = prvPAL_DefaultSetPlatformImageState, \
- .xWriteBlock = prvPAL_WriteBlock, \
- .xCompleteCallback = prvDefaultOTACompleteCallback, \
- .xCustomJobCallback = prvDefaultCustomJobCallback \
+ .xWriteBlock = prvPAL_WriteBlock, \
+ .xCompleteCallback = prvDefaultOTACompleteCallback, \
+ .xCustomJobCallback = prvDefaultCustomJobCallback \
}
/* This is THE OTA agent context and initialization state. */
-static OTA_AgentContext_t xOTA_Agent =
+static OTA_AgentContext_t xOTA_Agent =
{
.eState = eOTA_AgentState_Stopped,
.pcThingName = { 0 },
@@ -298,7 +298,7 @@ static OTA_AgentContext_t xOTA_Agent =
.ulRequestMomentum = 0
};
-static OTAStateTableEntry_t OTATransitionTable[] =
+static OTAStateTableEntry_t OTATransitionTable[] =
{
/*STATE , EVENT , ACTION , NEXT STATE */
{ eOTA_AgentState_Ready, eOTA_AgentEvent_Start, prvStartHandler, eOTA_AgentState_RequestingJob },
@@ -321,7 +321,7 @@ static OTAStateTableEntry_t OTATransitionTable[] =
{ eOTA_AgentState_All, eOTA_AgentEvent_Shutdown, prvShutdownHandler, eOTA_AgentState_ShuttingDown },
};
-static const char * pcOTA_AgentState_Strings[ eOTA_AgentState_All ] =
+static const char * pcOTA_AgentState_Strings[ eOTA_AgentState_All ] =
{
"Init",
"Ready",
@@ -336,7 +336,7 @@ static const char * pcOTA_AgentState_Strings[ eOTA_AgentState_All ] =
"Stopped"
};
-static const char * pcOTA_Event_Strings[ eOTA_AgentEvent_Max ] =
+static const char * pcOTA_Event_Strings[ eOTA_AgentEvent_Max ] =
{
"Start",
"StartSelfTest",
@@ -383,8 +383,8 @@ static bool prvInSelftest( void )
static BaseType_t prvStartSelfTestTimer( void )
{
DEFINE_OTA_METHOD_NAME( "prvStartSelfTestTimer" );
- static const char pcTimerName[] = "OTA_SelfTest";
- BaseType_t xTimerStarted = pdFALSE;
+ static const char pcTimerName[] = "OTA_SelfTest";
+ BaseType_t xTimerStarted = pdFALSE;
static StaticTimer_t xTimerBuffer;
if( prvInSelftest() == true )
@@ -473,7 +473,7 @@ static void prvStartRequestTimer( uint32_t xPeriodMS )
DEFINE_OTA_METHOD_NAME( "prvStartRequestTimer" );
static const char pcTimerName[] = "OTA_FileRequest";
- BaseType_t xTimerStarted = pdFALSE;
+ BaseType_t xTimerStarted = pdFALSE;
if( xOTA_Agent.xRequestTimer == NULL )
{
@@ -519,8 +519,8 @@ static void prvStopRequestTimer( void )
static OTA_Err_t prvUpdateJobStatusFromImageState( OTA_ImageState_t eState,
int32_t lSubReason )
{
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
- int32_t lReason = 0;
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ int32_t lReason = 0;
if( eState == eOTA_ImageState_Testing )
{
@@ -542,7 +542,7 @@ static OTA_Err_t prvUpdateJobStatusFromImageState( OTA_ImageState_t eState,
* doesn't allow us to set REJECTED after the job has been started already).
*/
lReason = ( eState == eOTA_ImageState_Rejected ) ? eJobReason_Rejected : eJobReason_Aborted;
- xErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, eJobStatus_Failed, lReason, lSubReason );
+ xErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, eJobStatus_Failed, lReason, lSubReason );
}
/*
@@ -563,7 +563,7 @@ static OTA_Err_t prvSetImageStateWithReason( OTA_ImageState_t eState,
configASSERT( ( eState > eOTA_ImageState_Unknown ) && ( eState <= eOTA_LastImageState ) );
/* Call the platform specific code to set the image state. */
- xErr = xOTA_Agent.xPALCallbacks.xSetPlatformImageState( xOTA_Agent.ulServerFileID, eState );
+ xErr = xOTA_Agent.xPALCallbacks.xSetPlatformImageState( xOTA_Agent.ulServerFileID, eState );
/*
* If the platform image state couldn't be set correctly, force fail the update by setting the
@@ -793,7 +793,7 @@ static OTA_Err_t prvStartHandler( OTA_EventData_t * pxEventData )
DEFINE_OTA_METHOD_NAME( "prvStartHandler" );
( void ) pxEventData;
- OTA_Err_t xReturn = kOTA_Err_None;
+ OTA_Err_t xReturn = kOTA_Err_None;
OTA_EventMsg_t xEventMsg = { 0 };
/* Start self-test timer, if platform is in self-test. */
@@ -842,7 +842,7 @@ static OTA_Err_t prvRequestJobHandler( OTA_EventData_t * pxEventData )
DEFINE_OTA_METHOD_NAME( "prvRequestJobHandler" );
( void ) pxEventData;
- OTA_Err_t xReturn = kOTA_Err_Uninitialized;
+ OTA_Err_t xReturn = kOTA_Err_Uninitialized;
OTA_EventMsg_t xEventMsg = { 0 };
/*
@@ -898,9 +898,9 @@ static OTA_Err_t prvProcessJobHandler( OTA_EventData_t * pxEventData )
{
DEFINE_OTA_METHOD_NAME( "prvProcessJobHandler" );
- OTA_Err_t xReturn = kOTA_Err_Uninitialized;
+ OTA_Err_t xReturn = kOTA_Err_Uninitialized;
OTA_FileContext_t * xOTAFileContext = NULL;
- OTA_EventMsg_t xEventMsg = { 0 };
+ OTA_EventMsg_t xEventMsg = { 0 };
/*
* Parse the job document and update file information in the file context.
@@ -983,7 +983,7 @@ static OTA_Err_t prvProcessJobHandler( OTA_EventData_t * pxEventData )
static OTA_Err_t prvInitFileHandler( OTA_EventData_t * pxEventData )
{
( void ) pxEventData;
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
OTA_EventMsg_t xEventMsg = { 0 };
xErr = xOTA_DataInterface.prvInitFileTransfer( &xOTA_Agent );
@@ -1022,7 +1022,7 @@ static OTA_Err_t prvInitFileHandler( OTA_EventData_t * pxEventData )
/* Reset the request momentum. */
xOTA_Agent.ulRequestMomentum = 0;
- xEventMsg.xEventId = eOTA_AgentEvent_RequestFileBlock;
+ xEventMsg.xEventId = eOTA_AgentEvent_RequestFileBlock;
if( !OTA_SignalEvent( &xEventMsg ) )
{
@@ -1036,7 +1036,7 @@ static OTA_Err_t prvInitFileHandler( OTA_EventData_t * pxEventData )
static OTA_Err_t prvRequestDataHandler( OTA_EventData_t * pxEventData )
{
( void ) pxEventData;
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
OTA_EventMsg_t xEventMsg = { 0 };
if( xOTA_Agent.pxOTA_Files[ xOTA_Agent.ulFileIndex ].ulBlocksRemaining > 0U )
@@ -1072,7 +1072,7 @@ static OTA_Err_t prvRequestDataHandler( OTA_EventData_t * pxEventData )
{
/* Too many requests have been sent without a response or too many failures
* when trying to publish the request message. Abort. Store attempt count in low bits. */
- xErr = ( uint32_t ) kOTA_Err_MomentumAbort | ( otaconfigMAX_NUM_REQUEST_MOMENTUM & ( uint32_t ) kOTA_PAL_ErrMask );
+ xErr = ( uint32_t ) kOTA_Err_MomentumAbort | ( otaconfigMAX_NUM_REQUEST_MOMENTUM & ( uint32_t ) kOTA_PAL_ErrMask );
/* Reset the request momentum. */
xOTA_Agent.ulRequestMomentum = 0;
@@ -1087,18 +1087,18 @@ static OTA_Err_t prvProcessDataHandler( OTA_EventData_t * pxEventData )
{
DEFINE_OTA_METHOD_NAME( "prvProcessDataMessage" );
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
- OTA_Err_t xCloseResult = kOTA_Err_Uninitialized;
- OTA_EventMsg_t xEventMsg = { 0 };
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ OTA_Err_t xCloseResult = kOTA_Err_Uninitialized;
+ OTA_EventMsg_t xEventMsg = { 0 };
/* Get the file context. */
OTA_FileContext_t * pxFileContext = &xOTA_Agent.pxOTA_Files[ xOTA_Agent.ulFileIndex ];
/* Ingest data blocks received. */
- IngestResult_t xResult = prvIngestDataBlock( pxFileContext,
- pxEventData->ucData,
- pxEventData->ulDataLength,
- &xCloseResult );
+ IngestResult_t xResult = prvIngestDataBlock( pxFileContext,
+ pxEventData->ucData,
+ pxEventData->ulDataLength,
+ &xCloseResult );
if( xResult < eIngest_Result_Accepted_Continue )
{
@@ -1165,7 +1165,7 @@ static OTA_Err_t prvProcessDataHandler( OTA_EventData_t * pxEventData )
/* We're actively receiving a file so update the job status as needed. */
/* First reset the momentum counter since we received a good block. */
xOTA_Agent.ulRequestMomentum = 0;
- xErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, eJobStatus_InProgress, eJobReason_Receiving, 0 );
+ xErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, eJobStatus_InProgress, eJobReason_Receiving, 0 );
if( xErr != kOTA_Err_None )
{
@@ -1281,7 +1281,7 @@ static OTA_Err_t prvResumeHandler( OTA_EventData_t * pxEventData )
/*
* Send signal to request job document.
*/
- xEventMsg.xEventId = eOTA_AgentEvent_RequestJobDocument;
+ xEventMsg.xEventId = eOTA_AgentEvent_RequestJobDocument;
return OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed;
}
@@ -1332,7 +1332,7 @@ OTA_EventData_t * prvOTAEventBufferGet( void )
{
DEFINE_OTA_METHOD_NAME( "prvOTAEventBufferGet" );
- uint32_t ulIndex = 0;
+ uint32_t ulIndex = 0;
OTA_EventData_t * pxOTAFreeMsg = NULL;
/* Wait at most 1 task switch for a buffer so as not to block the callback. */
@@ -1343,7 +1343,7 @@ OTA_EventData_t * prvOTAEventBufferGet( void )
if( xEventBuffer[ ulIndex ].bBufferUsed == false )
{
xEventBuffer[ ulIndex ].bBufferUsed = true;
- pxOTAFreeMsg = &xEventBuffer[ ulIndex ];
+ pxOTAFreeMsg = &xEventBuffer[ ulIndex ];
break;
}
}
@@ -1452,8 +1452,8 @@ static bool prvOTA_Close( OTA_FileContext_t * const C )
static OTA_FileContext_t * prvGetFreeContext( void )
{
- uint32_t ulIndex = 0U;
- OTA_FileContext_t * C = NULL;
+ uint32_t ulIndex = 0U;
+ OTA_FileContext_t * C = NULL;
while( ( ulIndex < OTA_MAX_FILES ) && ( xOTA_Agent.pxOTA_Files[ ulIndex ].pucFilePath != NULL ) )
{
@@ -1463,7 +1463,7 @@ static OTA_FileContext_t * prvGetFreeContext( void )
if( ulIndex != OTA_MAX_FILES )
{
( void ) memset( &xOTA_Agent.pxOTA_Files[ ulIndex ], 0, sizeof( OTA_FileContext_t ) );
- C = &xOTA_Agent.pxOTA_Files[ ulIndex ];
+ C = &xOTA_Agent.pxOTA_Files[ ulIndex ];
xOTA_Agent.ulFileIndex = ulIndex;
}
else
@@ -1503,7 +1503,7 @@ static DocParseErr_t prvSearchModelForTokenKey( JSON_DocModel_t * pxDocModel,
uint16_t * pulMatchingIndexResult )
{
DocParseErr_t eErr = eDocParseErr_ParamKeyNotInModel;
- uint16_t usParamIndex;
+ uint16_t usParamIndex;
for( usParamIndex = 0; usParamIndex < pxDocModel->usNumModelParams; usParamIndex++ )
{
@@ -1519,8 +1519,8 @@ static DocParseErr_t prvSearchModelForTokenKey( JSON_DocModel_t * pxDocModel,
{
/* Mark parameter as received in the bitmap. */
pxDocModel->ulParamsReceivedBitmap |= ( ( uint32_t ) 1U << usParamIndex ); /*lint !e9032 usParamIndex will never be greater than kDocModel_MaxParams, which is the the size of the bitmap. */
- *pulMatchingIndexResult = usParamIndex; /* Save result index for caller. */
- eErr = eDocParseErr_None; /* We found a matching key in the document model. */
+ *pulMatchingIndexResult = usParamIndex; /* Save result index for caller. */
+ eErr = eDocParseErr_None; /* We found a matching key in the document model. */
}
break; /* We found a key match so stop searching. */
@@ -1539,16 +1539,16 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
DEFINE_OTA_METHOD_NAME( "prvParseJSONbyModel" );
const JSON_DocParam_t * pxModelParam = NULL;
- jsmn_parser xParser;
- jsmntok_t * pxTokens = NULL;
- const jsmntok_t * pxValTok = NULL;
- int32_t jsmn_result = 0;
- uint32_t ulNumTokens = 0, ulTokenLen = 0;
- MultiParmPtr_t xParamAddr; /*lint !e9018 We intentionally use this union to cast the parameter address to the proper type. */
- uint32_t ulIndex = 0;
- uint16_t usModelParamIndex = 0;
- uint32_t ulScanIndex = 0;
- DocParseErr_t eErr = eDocParseErr_None;
+ jsmn_parser xParser;
+ jsmntok_t * pxTokens = NULL;
+ const jsmntok_t * pxValTok = NULL;
+ int32_t jsmn_result = 0;
+ uint32_t ulNumTokens = 0, ulTokenLen = 0;
+ MultiParmPtr_t xParamAddr; /*lint !e9018 We intentionally use this union to cast the parameter address to the proper type. */
+ uint32_t ulIndex = 0;
+ uint16_t usModelParamIndex = 0;
+ uint32_t ulScanIndex = 0;
+ DocParseErr_t eErr = eDocParseErr_None;
/* Reset the Jasmine tokenizer. */
jsmn_init( &xParser );
@@ -1596,8 +1596,8 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
pxModelParam = pxDocModel->pxBodyDef;
/* Count the total number of tokens in our JSON document. */
- jsmn_result = jsmn_parse( &xParser, pcJSON, ( size_t ) ulMsgLen, NULL, 1UL );
- ulNumTokens = jsmn_result < 0 ? 0 : ( uint32_t ) jsmn_result;
+ jsmn_result = jsmn_parse( &xParser, pcJSON, ( size_t ) ulMsgLen, NULL, 1UL );
+ ulNumTokens = jsmn_result < 0 ? 0 : ( uint32_t ) jsmn_result;
if( ulNumTokens == 0 )
{
@@ -1654,7 +1654,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
{
/* Search the document model to see if it matches the current key. */
ulTokenLen = ( uint32_t ) pxTokens[ ulIndex ].end - ( uint32_t ) pxTokens[ ulIndex ].start;
- eErr = prvSearchModelForTokenKey( pxDocModel, &pcJSON[ pxTokens[ ulIndex ].start ], ulTokenLen, &usModelParamIndex );
+ eErr = prvSearchModelForTokenKey( pxDocModel, &pcJSON[ pxTokens[ ulIndex ].start ], ulTokenLen, &usModelParamIndex );
/* If we didn't find a match in the model, skip over it and its descendants. */
if( eErr == eDocParseErr_ParamKeyNotInModel )
@@ -1686,7 +1686,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
OTA_METHOD_NAME, pxModelParam[ usModelParamIndex ].pcSrcKey, ulTokenLen,
&pcJSON[ pxValTok->start ],
pxValTok->type, pxModelParam[ usModelParamIndex ].eJasmineType );
- eErr = eDocParseErr_FieldTypeMismatch;
+ eErr = eDocParseErr_FieldTypeMismatch;
}
else if( OTA_DONT_STORE_PARAM == pxModelParam[ usModelParamIndex ].ulDestOffset )
{
@@ -1716,7 +1716,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
if( pvStringCopy != NULL )
{
- *xParamAddr.ppvPtr = pvStringCopy;
+ *xParamAddr.ppvPtr = pvStringCopy;
char * pcStringCopy = *xParamAddr.ppcPtr;
/* Copy parameter string into newly allocated memory. */
( void ) memcpy( pcStringCopy, &pcJSON[ pxValTok->start ], ulTokenLen );
@@ -1737,7 +1737,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
/* Copy pointer to source string instead of duplicating the string. */
const char * pcStringInDoc = &pcJSON[ pxValTok->start ];
*xParamAddr.ppccPtr = pcStringInDoc;
- ulTokenLen = ( uint32_t ) ( pxValTok->end ) - ( uint32_t ) ( pxValTok->start );
+ ulTokenLen = ( uint32_t ) ( pxValTok->end ) - ( uint32_t ) ( pxValTok->start );
OTA_LOG_L1( "[%s] Extracted parameter [ %s: %.*s ]\r\n",
OTA_METHOD_NAME,
pxModelParam[ usModelParamIndex ].pcSrcKey,
@@ -1745,7 +1745,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
}
else if( eModelParamType_UInt32 == pxModelParam[ usModelParamIndex ].xModelParamType )
{
- char * pEnd;
+ char * pEnd;
const char * pStart = &pcJSON[ pxValTok->start ];
*xParamAddr.pulPtr = strtoul( pStart, &pEnd, 0 );
@@ -1768,10 +1768,10 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
if( pvSignature != NULL )
{
- size_t xActualLen = 0;
+ size_t xActualLen = 0;
*xParamAddr.ppvPtr = pvSignature;
- Sig256_t * pxSig256 = *xParamAddr.ppxSig256Ptr;
- ulTokenLen = ( uint32_t ) ( pxValTok->end ) - ( uint32_t ) ( pxValTok->start );
+ Sig256_t * pxSig256 = *xParamAddr.ppxSig256Ptr;
+ ulTokenLen = ( uint32_t ) ( pxValTok->end ) - ( uint32_t ) ( pxValTok->start );
if( mbedtls_base64_decode( pxSig256->ucData, sizeof( pxSig256->ucData ), &xActualLen,
( const uint8_t * ) &pcJSON[ pxValTok->start ], ulTokenLen ) != 0 )
@@ -1810,7 +1810,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON,
if( pvStringCopy != NULL )
{
- *xParamAddr.ppvPtr = pvStringCopy;
+ *xParamAddr.ppvPtr = pvStringCopy;
char * pcStringCopy = *xParamAddr.ppcPtr;
/* Copy parameter string into newly allocated memory. */
( void ) memcpy( pcStringCopy, &pcJSON[ pxValTok->start ], ulTokenLen );
@@ -1892,7 +1892,7 @@ static DocParseErr_t prvInitDocModel( JSON_DocModel_t * pxDocModel,
DEFINE_OTA_METHOD_NAME( "prvInitDocModel" );
DocParseErr_t eErr = eDocParseErr_Unknown;
- uint32_t ulScanIndex;
+ uint32_t ulScanIndex;
/* Sanity check the model pointers and parameter count. Exclude the context base address and size since
* it is technically possible to create a model that writes entirely into absolute memory locations.
@@ -1914,10 +1914,10 @@ static DocParseErr_t prvInitDocModel( JSON_DocModel_t * pxDocModel,
}
else
{
- pxDocModel->ulContextBase = ulContextBaseAddr;
- pxDocModel->ulContextSize = ulContextSize;
- pxDocModel->pxBodyDef = pxBodyDef;
- pxDocModel->usNumModelParams = usNumJobParams;
+ pxDocModel->ulContextBase = ulContextBaseAddr;
+ pxDocModel->ulContextSize = ulContextSize;
+ pxDocModel->pxBodyDef = pxBodyDef;
+ pxDocModel->usNumModelParams = usNumJobParams;
pxDocModel->ulParamsReceivedBitmap = 0;
pxDocModel->ulParamsRequiredBitmap = 0;
@@ -1931,7 +1931,7 @@ static DocParseErr_t prvInitDocModel( JSON_DocModel_t * pxDocModel,
}
}
- eErr = eDocParseErr_None;
+ eErr = eDocParseErr_None;
}
return eErr;
@@ -2021,13 +2021,13 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON,
};
OTA_Err_t xOTAErr = kOTA_Err_None;
- OTA_JobParseErr_t eErr = eOTA_JobParseErr_Unknown;
- OTA_FileContext_t * pxFinalFile = NULL;
- OTA_FileContext_t xFileContext = { 0 };
- OTA_FileContext_t * C = &xFileContext;
- OTA_Err_t xErrVersionCheck = kOTA_Err_Uninitialized;
+ OTA_JobParseErr_t eErr = eOTA_JobParseErr_Unknown;
+ OTA_FileContext_t * pxFinalFile = NULL;
+ OTA_FileContext_t xFileContext = { 0 };
+ OTA_FileContext_t * C = &xFileContext;
+ OTA_Err_t xErrVersionCheck = kOTA_Err_Uninitialized;
- JSON_DocModel_t xOTA_JobDocModel;
+ JSON_DocModel_t xOTA_JobDocModel;
if( prvInitDocModel( &xOTA_JobDocModel,
xOTA_JobDocModelParamStructure,
@@ -2039,7 +2039,7 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON,
}
else if( prvParseJSONbyModel( pcJSON, ulMsgLen, &xOTA_JobDocModel ) == eDocParseErr_None )
{ /* Validate the job document parameters. */
- eErr = eOTA_JobParseErr_None;
+ eErr = eOTA_JobParseErr_None;
if( C->ulFileSize == 0U )
{
@@ -2071,10 +2071,10 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON,
prvOTA_FreeContext( C );
- pxFinalFile = &xOTA_Agent.pxOTA_Files[ xOTA_Agent.ulFileIndex ];
+ pxFinalFile = &xOTA_Agent.pxOTA_Files[ xOTA_Agent.ulFileIndex ];
*pbUpdateJob = true;
- eErr = eOTA_JobParseErr_UpdateCurrentJob;
+ eErr = eOTA_JobParseErr_UpdateCurrentJob;
}
}
else
@@ -2086,7 +2086,7 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON,
else
{ /* Assume control of the job name from the context. */
xOTA_Agent.pcOTA_Singleton_ActiveJobName = C->pucJobName;
- C->pucJobName = NULL;
+ C->pucJobName = NULL;
}
/* Store the File ID received in the job */
@@ -2167,11 +2167,11 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON,
if( C->pucJobName != NULL )
{
xOTA_Agent.pcOTA_Singleton_ActiveJobName = C->pucJobName;
- C->pucJobName = NULL;
- xOTAErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent,
- eJobStatus_Succeeded,
- eJobReason_Accepted,
- 0 );
+ C->pucJobName = NULL;
+ xOTAErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent,
+ eJobStatus_Succeeded,
+ eJobReason_Accepted,
+ 0 );
if( xOTAErr != kOTA_Err_None )
{
@@ -2202,11 +2202,11 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON,
OTA_LOG_L1( "[%s] Rejecting job due to OTA_JobParseErr_t %d\r\n", OTA_METHOD_NAME, eErr );
/* Assume control of the job name from the context. */
xOTA_Agent.pcOTA_Singleton_ActiveJobName = C->pucJobName;
- C->pucJobName = NULL;
- xOTAErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent,
- eJobStatus_FailedWithVal,
- ( int32_t ) kOTA_Err_JobParserError,
- ( int32_t ) eErr );
+ C->pucJobName = NULL;
+ xOTAErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent,
+ eJobStatus_FailedWithVal,
+ ( int32_t ) kOTA_Err_JobParserError,
+ ( int32_t ) eErr );
if( xOTAErr != kOTA_Err_None )
{
@@ -2249,13 +2249,13 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg,
{
DEFINE_OTA_METHOD_NAME( "prvGetFileContextFromJob" );
- uint32_t ulIndex;
- uint32_t ulNumBlocks; /* How many data pages are in the expected update image. */
- uint32_t ulBitmapLen; /* Length of the file block bitmap in bytes. */
+ uint32_t ulIndex;
+ uint32_t ulNumBlocks; /* How many data pages are in the expected update image. */
+ uint32_t ulBitmapLen; /* Length of the file block bitmap in bytes. */
OTA_FileContext_t * pstUpdateFile; /* Pointer to an OTA update context. */
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
- bool bUpdateJob = false;
+ bool bUpdateJob = false;
/* Populate an OTA file context from the OTA job document. */
@@ -2277,8 +2277,8 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg,
/* Calculate how many bytes we need in our bitmap for tracking received blocks.
* The below calculation requires power of 2 page sizes. */
- ulNumBlocks = ( pstUpdateFile->ulFileSize + ( OTA_FILE_BLOCK_SIZE - 1U ) ) >> otaconfigLOG2_FILE_BLOCK_SIZE;
- ulBitmapLen = ( ulNumBlocks + ( BITS_PER_BYTE - 1U ) ) >> LOG2_BITS_PER_BYTE;
+ ulNumBlocks = ( pstUpdateFile->ulFileSize + ( OTA_FILE_BLOCK_SIZE - 1U ) ) >> otaconfigLOG2_FILE_BLOCK_SIZE;
+ ulBitmapLen = ( ulNumBlocks + ( BITS_PER_BYTE - 1U ) ) >> LOG2_BITS_PER_BYTE;
pstUpdateFile->pucRxBlockBitmap = ( uint8_t * ) pvPortMalloc( ulBitmapLen ); /*lint !e9079 FreeRTOS malloc port returns void*. */
if( pstUpdateFile->pucRxBlockBitmap != NULL )
@@ -2293,7 +2293,7 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg,
* Files aren't always a multiple of 8 pages (8 bits/pages per byte) so some bits of the
* last byte may be out of range and those are the bits we want to clear. */
- uint8_t ulBit = 1U << ( BITS_PER_BYTE - 1U );
+ uint8_t ulBit = 1U << ( BITS_PER_BYTE - 1U );
uint32_t ulNumOutOfRange = ( ulBitmapLen * BITS_PER_BYTE ) - ulNumBlocks;
for( ulIndex = 0U; ulIndex < ulNumOutOfRange; ulIndex++ )
@@ -2305,7 +2305,7 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg,
pstUpdateFile->ulBlocksRemaining = ulNumBlocks; /* Initialize our blocks remaining counter. */
/* Create/Open the OTA file on the file system. */
- xErr = xOTA_Agent.xPALCallbacks.xCreateFileForRx( pstUpdateFile );
+ xErr = xOTA_Agent.xPALCallbacks.xCreateFileForRx( pstUpdateFile );
if( xErr != kOTA_Err_None )
{
@@ -2336,7 +2336,7 @@ static bool prvValidateDataBlock( const OTA_FileContext_t * C,
uint32_t ulBlockIndex,
uint32_t ulBlockSize )
{
- bool bRet = false;
+ bool bRet = false;
uint32_t ulLastBlock = 0;
ulLastBlock = ( ( C->ulFileSize + ( OTA_FILE_BLOCK_SIZE - 1U ) ) >> otaconfigLOG2_FILE_BLOCK_SIZE ) - 1U;
@@ -2368,15 +2368,15 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C,
DEFINE_OTA_METHOD_NAME( "prvIngestDataBlock" );
IngestResult_t eIngestResult = eIngest_Result_Uninitialized;
- int32_t lFileId = 0;
- int32_t lBlockSize = 0;
- int32_t lBlockIndex = 0;
- uint32_t ulBlockSize = 0;
- uint32_t ulBlockIndex = 0;
- uint8_t * pucPayload = NULL;
- size_t xPayloadSize = 0;
- uint32_t ulByte = 0;
- uint8_t ucBitMask = 0;
+ int32_t lFileId = 0;
+ int32_t lBlockSize = 0;
+ int32_t lBlockIndex = 0;
+ uint32_t ulBlockSize = 0;
+ uint32_t ulBlockIndex = 0;
+ uint8_t * pucPayload = NULL;
+ size_t xPayloadSize = 0;
+ uint32_t ulByte = 0;
+ uint8_t ucBitMask = 0;
/* Check if the file context is NULL. */
if( C == NULL )
@@ -2422,7 +2422,7 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C,
else
{
ulBlockIndex = ( uint32_t ) lBlockIndex;
- ulBlockSize = ( uint32_t ) lBlockSize;
+ ulBlockSize = ( uint32_t ) lBlockSize;
}
}
else
@@ -2442,7 +2442,7 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C,
ucBitMask = 1U << ( ulBlockIndex % BITS_PER_BYTE ); /*lint !e9031 The composite expression will never be greater than BITS_PER_BYTE(8). */
/* Calculate byte offset into bitmap. */
- ulByte = ulBlockIndex >> LOG2_BITS_PER_BYTE;
+ ulByte = ulBlockIndex >> LOG2_BITS_PER_BYTE;
/* Check if we've already received this block. */
if( ( ( C->pucRxBlockBitmap[ ulByte ] ) & ucBitMask ) == 0U )
@@ -2451,7 +2451,7 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C,
ulBlockIndex,
C->ulBlocksRemaining );
- eIngestResult = eIngest_Result_Duplicate_Continue;
+ eIngestResult = eIngest_Result_Duplicate_Continue;
*pxCloseResult = kOTA_Err_None; /* This is a success path. */
}
}
@@ -2478,8 +2478,8 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C,
{
C->pucRxBlockBitmap[ ulByte ] &= ~ucBitMask; /* Mark this block as received in our bitmap. */
C->ulBlocksRemaining--;
- eIngestResult = eIngest_Result_Accepted_Continue;
- *pxCloseResult = kOTA_Err_None;
+ eIngestResult = eIngest_Result_Accepted_Continue;
+ *pxCloseResult = kOTA_Err_None;
}
}
else
@@ -2528,7 +2528,7 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C,
}
}
- C->pucFile = NULL; /* File is now closed so clear the file handle in the context. */
+ C->pucFile = NULL; /* File is now closed so clear the file handle in the context. */
}
else
{
@@ -2702,9 +2702,9 @@ static void prvOTAAgentTask( void * pvUnused )
( void ) pvUnused;
- OTA_EventMsg_t xEventMsg = { 0 };
- uint32_t ulTransitionTableLen = sizeof( OTATransitionTable ) / sizeof( OTATransitionTable[ 0 ] );
- uint32_t i = 0;
+ OTA_EventMsg_t xEventMsg = { 0 };
+ uint32_t ulTransitionTableLen = sizeof( OTATransitionTable ) / sizeof( OTATransitionTable[ 0 ] );
+ uint32_t i = 0;
/*
* OTA Agent is ready to receive and process events so update the state to ready.
@@ -2755,12 +2755,12 @@ static BaseType_t prvStartOTAAgentTask( void * pvConnectionContext,
TickType_t xTicksToWait )
{
BaseType_t xReturn = 0;
- uint32_t ulIndex = 0;
+ uint32_t ulIndex = 0;
/*
* The actual OTA Task and queue control structure. Only created once.
*/
- static TaskHandle_t pxOTA_TaskHandle;
+ static TaskHandle_t pxOTA_TaskHandle;
static StaticQueue_t xStaticQueue;
portENTER_CRITICAL();
@@ -2768,17 +2768,17 @@ static BaseType_t prvStartOTAAgentTask( void * pvConnectionContext,
/*
* The current OTA image state as set by the OTA agent.
*/
- xOTA_Agent.eImageState = eOTA_ImageState_Unknown;
+ xOTA_Agent.eImageState = eOTA_ImageState_Unknown;
/*
* Save the current connection context provided by the user.
*/
- xOTA_Agent.pvConnectionContext = pvConnectionContext;
+ xOTA_Agent.pvConnectionContext = pvConnectionContext;
/*
* Create the queue used to pass event messages to the OTA task.
*/
- xOTA_Agent.xOTA_EventQueue = xQueueCreateStatic( ( UBaseType_t ) OTA_NUM_MSG_Q_ENTRIES, ( UBaseType_t ) sizeof( OTA_EventMsg_t ), ( uint8_t * ) xQueueData, &xStaticQueue );
+ xOTA_Agent.xOTA_EventQueue = xQueueCreateStatic( ( UBaseType_t ) OTA_NUM_MSG_Q_ENTRIES, ( UBaseType_t ) sizeof( OTA_EventMsg_t ), ( uint8_t * ) xQueueData, &xStaticQueue );
configASSERT( xOTA_Agent.xOTA_EventQueue != NULL );
/*
@@ -2803,7 +2803,7 @@ static BaseType_t prvStartOTAAgentTask( void * pvConnectionContext,
xEventBuffer[ ulIndex ].bBufferUsed = false;
}
- xReturn = xTaskCreate( prvOTAAgentTask, "OTA Agent Task", otaconfigSTACK_SIZE, NULL, otaconfigAGENT_PRIORITY, &pxOTA_TaskHandle );
+ xReturn = xTaskCreate( prvOTAAgentTask, "OTA Agent Task", otaconfigSTACK_SIZE, NULL, otaconfigAGENT_PRIORITY, &pxOTA_TaskHandle );
portEXIT_CRITICAL(); /* Protected elements are initialized. It's now safe to context switch. */
@@ -2826,8 +2826,8 @@ bool OTA_SignalEvent( const OTA_EventMsg_t * const pxEventMsg )
{
DEFINE_OTA_METHOD_NAME( "OTA_SignalEvent" );
- bool bReturn = false;
- BaseType_t xErr = pdFALSE;
+ bool bReturn = false;
+ BaseType_t xErr = pdFALSE;
/*
* Send event to back of the queue.
@@ -2874,7 +2874,7 @@ OTA_State_t OTA_AgentInit( void * pvConnectionContext,
/* Set the OTA complete callback. */
xPALCallbacks.xCompleteCallback = xFunc;
- xState = OTA_AgentInit_internal( pvConnectionContext, pucThingName, &xPALCallbacks, xTicksToWait );
+ xState = OTA_AgentInit_internal( pvConnectionContext, pucThingName, &xPALCallbacks, xTicksToWait );
}
/* If OTA agent is already running, just update the CompleteCallback and reset the statistics. */
else
@@ -2898,13 +2898,13 @@ OTA_State_t OTA_AgentInit_internal( void * pvConnectionContext,
{
DEFINE_OTA_METHOD_NAME( "OTA_AgentInit_internal" );
- BaseType_t xReturn = 0;
+ BaseType_t xReturn = 0;
OTA_EventMsg_t xEventMsg = { 0 };
/*
* OTA Task is not running yet so update the state to init direclty in OTA context.
*/
- xOTA_Agent.eState = eOTA_AgentState_Init;
+ xOTA_Agent.eState = eOTA_AgentState_Init;
/*
* Check all the callbacks for null values and initialize the values in the ota agent context.
@@ -2922,9 +2922,9 @@ OTA_State_t OTA_AgentInit_internal( void * pvConnectionContext,
/*
* Reset all the statistics counters.
*/
- xOTA_Agent.xStatistics.ulOTA_PacketsReceived = 0;
- xOTA_Agent.xStatistics.ulOTA_PacketsDropped = 0;
- xOTA_Agent.xStatistics.ulOTA_PacketsQueued = 0;
+ xOTA_Agent.xStatistics.ulOTA_PacketsReceived = 0;
+ xOTA_Agent.xStatistics.ulOTA_PacketsDropped = 0;
+ xOTA_Agent.xStatistics.ulOTA_PacketsQueued = 0;
xOTA_Agent.xStatistics.ulOTA_PacketsProcessed = 0;
if( pucThingName == NULL )
@@ -3061,7 +3061,7 @@ OTA_Err_t OTA_CheckForUpdate( void )
{
DEFINE_OTA_METHOD_NAME( "OTA_CheckForUpdate" );
- OTA_Err_t xReturn = kOTA_Err_None;
+ OTA_Err_t xReturn = kOTA_Err_None;
OTA_EventMsg_t xEventMsg = { 0 };
OTA_LOG_L1( "[%s] Sending event to check for update.\r\n", OTA_METHOD_NAME );
@@ -3125,7 +3125,7 @@ OTA_Err_t OTA_SetImageState( OTA_ImageState_t eState )
{
DEFINE_OTA_METHOD_NAME( "OTA_SetImageState" );
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
OTA_EventMsg_t xEventMsg = { 0 };
switch( eState )
@@ -3139,7 +3139,7 @@ OTA_Err_t OTA_SetImageState( OTA_ImageState_t eState )
/*
* Send the event, xOTA_Agent.eImageState will be set later when the event is processed.
*/
- xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed;
+ xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed;
}
else
{
@@ -3194,7 +3194,7 @@ OTA_Err_t OTA_Suspend( void )
{
DEFINE_OTA_METHOD_NAME( "OTA_Suspend" );
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
OTA_EventMsg_t xEventMsg = { 0 };
/* Stop the request timer. */
@@ -3207,7 +3207,7 @@ OTA_Err_t OTA_Suspend( void )
* Send event to OTA agent task.
*/
xEventMsg.xEventId = eOTA_AgentEvent_Suspend;
- xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed;
+ xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed;
}
else
{
@@ -3226,7 +3226,7 @@ OTA_Err_t OTA_Resume( void * pxConnection )
{
DEFINE_OTA_METHOD_NAME( "OTA_Resume" );
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
OTA_EventMsg_t xEventMsg = { 0 };
xEventMsg.pxEventData = pxConnection;
@@ -3238,7 +3238,7 @@ OTA_Err_t OTA_Resume( void * pxConnection )
* Send event to OTA agent task.
*/
xEventMsg.xEventId = eOTA_AgentEvent_Resume;
- xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed;
+ xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed;
}
else
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c
index 2f9b81ead..6eab921bd 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c
@@ -72,7 +72,7 @@
void prvSetControlInterface( OTA_ControlInterface_t * pxControlInterface )
{
#if ( configENABLED_CONTROL_PROTOCOL == OTA_CONTROL_OVER_MQTT )
- pxControlInterface->prvRequestJob = prvRequestJob_Mqtt;
+ pxControlInterface->prvRequestJob = prvRequestJob_Mqtt;
pxControlInterface->prvUpdateJobStatus = prvUpdateJobStatus_Mqtt;
#else
#error "Enable MQTT control as control operations are only supported over MQTT."
@@ -85,7 +85,7 @@ OTA_Err_t prvSetDataInterface( OTA_DataInterface_t * pxDataInterface,
DEFINE_OTA_METHOD_NAME( "prvSetDataInterface" );
OTA_Err_t xErr = kOTA_Err_InvalidDataProtocol;
- uint32_t i;
+ uint32_t i;
for( i = 0; i < OTA_DATA_NUM_PROTOCOLS; i++ )
{
@@ -96,12 +96,12 @@ OTA_Err_t prvSetDataInterface( OTA_DataInterface_t * pxDataInterface,
{
pxDataInterface->prvInitFileTransfer = prvInitFileTransfer_Mqtt;
pxDataInterface->prvRequestFileBlock = prvRequestFileBlock_Mqtt;
- pxDataInterface->prvDecodeFileBlock = prvDecodeFileBlock_Mqtt;
- pxDataInterface->prvCleanup = prvCleanup_Mqtt;
+ pxDataInterface->prvDecodeFileBlock = prvDecodeFileBlock_Mqtt;
+ pxDataInterface->prvCleanup = prvCleanup_Mqtt;
OTA_LOG_L1( "[%s] Data interface is set to MQTT.\r\n", OTA_METHOD_NAME );
- xErr = kOTA_Err_None;
+ xErr = kOTA_Err_None;
break;
}
#endif /* if ( configENABLED_DATA_PROTOCOLS & OTA_DATA_OVER_MQTT ) */
@@ -111,12 +111,12 @@ OTA_Err_t prvSetDataInterface( OTA_DataInterface_t * pxDataInterface,
{
pxDataInterface->prvInitFileTransfer = _AwsIotOTA_InitFileTransfer_HTTP;
pxDataInterface->prvRequestFileBlock = _AwsIotOTA_RequestDataBlock_HTTP;
- pxDataInterface->prvDecodeFileBlock = _AwsIotOTA_DecodeFileBlock_HTTP;
- pxDataInterface->prvCleanup = _AwsIotOTA_Cleanup_HTTP;
+ pxDataInterface->prvDecodeFileBlock = _AwsIotOTA_DecodeFileBlock_HTTP;
+ pxDataInterface->prvCleanup = _AwsIotOTA_Cleanup_HTTP;
OTA_LOG_L1( "[%s] Data interface is set to HTTP.\r\n", OTA_METHOD_NAME );
- xErr = kOTA_Err_None;
+ xErr = kOTA_Err_None;
break;
}
#endif /* if ( configENABLED_DATA_PROTOCOLS & OTA_DATA_OVER_HTTP ) */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c
index d1a6b6b54..654ee9c30 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c
@@ -202,13 +202,13 @@ typedef struct _httpDownloader
} _httpDownloader_t;
/* Global HTTP downloader instance. */
-static _httpDownloader_t _httpDownloader = { 0 };
+static _httpDownloader_t _httpDownloader = { 0 };
/* Buffers for HTTP library. */
-uint8_t * pConnectionUserBuffer = NULL; /* Buffer to store the HTTP connection context. */
-uint8_t * pRequestUserBuffer = NULL; /* Buffer to store the HTTP request context and header. */
-uint8_t * pResponseUserBuffer = NULL; /* Buffer to store the HTTP response context and header. */
-uint8_t * pResponseBodyBuffer = NULL; /* Buffer to store the HTTP response body. */
+uint8_t * pConnectionUserBuffer = NULL; /* Buffer to store the HTTP connection context. */
+uint8_t * pRequestUserBuffer = NULL; /* Buffer to store the HTTP request context and header. */
+uint8_t * pResponseUserBuffer = NULL; /* Buffer to store the HTTP response context and header. */
+uint8_t * pResponseBodyBuffer = NULL; /* Buffer to store the HTTP response body. */
/* We need to use this function defined in iot_logging_task_dynamic_buffers.c to print HTTP message
* without appending the task name and tick count. */
@@ -229,7 +229,7 @@ static bool _httpAllocateBuffers()
isSuccess = false;
}
- pRequestUserBuffer = pvPortMalloc( HTTPS_REQUEST_USER_BUFFER_SIZE );
+ pRequestUserBuffer = pvPortMalloc( HTTPS_REQUEST_USER_BUFFER_SIZE );
if( isSuccess && ( pRequestUserBuffer == NULL ) )
{
@@ -237,7 +237,7 @@ static bool _httpAllocateBuffers()
isSuccess = false;
}
- pResponseUserBuffer = pvPortMalloc( HTTPS_RESPONSE_USER_BUFFER_SIZE );
+ pResponseUserBuffer = pvPortMalloc( HTTPS_RESPONSE_USER_BUFFER_SIZE );
if( isSuccess && ( pResponseUserBuffer == NULL ) )
{
@@ -245,7 +245,7 @@ static bool _httpAllocateBuffers()
isSuccess = false;
}
- pResponseBodyBuffer = pvPortMalloc( HTTPS_RESPONSE_BODY_BUFFER_SIZE );
+ pResponseBodyBuffer = pvPortMalloc( HTTPS_RESPONSE_BODY_BUFFER_SIZE );
if( isSuccess && ( pResponseBodyBuffer == NULL ) )
{
@@ -293,7 +293,7 @@ static void _httpProcessResponseBody( OTA_AgentContext_t * pAgentCtx,
IotLogDebug( "Invoking _httpProcessResponseBody" );
OTA_EventData_t * pMessage;
- OTA_EventMsg_t eventMsg = { 0 };
+ OTA_EventMsg_t eventMsg = { 0 };
pAgentCtx->xStatistics.ulOTA_PacketsReceived++;
@@ -310,8 +310,8 @@ static void _httpProcessResponseBody( OTA_AgentContext_t * pAgentCtx,
pMessage->ulDataLength = bufferSize;
memcpy( pMessage->ucData, pHTTPResponseBody, pMessage->ulDataLength );
- eventMsg.xEventId = eOTA_AgentEvent_ReceivedFileBlock;
- eventMsg.pxEventData = pMessage;
+ eventMsg.xEventId = eOTA_AgentEvent_ReceivedFileBlock;
+ eventMsg.pxEventData = pMessage;
/* Send job document received event. */
OTA_SignalEvent( &eventMsg );
}
@@ -321,7 +321,7 @@ static void _httpProcessResponseBody( OTA_AgentContext_t * pAgentCtx,
static void _httpErrorHandler( uint16_t responseCode )
{
const char * pResponseBody = ( const char * ) pResponseBodyBuffer;
- char * endPos = NULL;
+ char * endPos = NULL;
/* Force the response body to be NULL terminated. */
pResponseBodyBuffer[ HTTPS_RESPONSE_BODY_BUFFER_SIZE - 1 ] = '\0';
@@ -387,14 +387,14 @@ static void _httpAppendHeaderCallback( void * pPrivateData,
IotLogDebug( "Invoking _httpAppendHeaderCallback." );
/* Value of the "Range" field in HTTP GET request header, set when requesting the file block. */
- char * pRangeValueStr = ( ( _httpCallbackData_t * ) ( pPrivateData ) )->pRangeValueStr;
+ char * pRangeValueStr = ( ( _httpCallbackData_t * ) ( pPrivateData ) )->pRangeValueStr;
/* Set the header for this range request. */
- IotHttpsReturnCode_t status = IotHttpsClient_AddHeader( requestHandle,
- "Range",
- sizeof( "Range" ) - 1,
- pRangeValueStr,
- strlen( pRangeValueStr ) );
+ IotHttpsReturnCode_t status = IotHttpsClient_AddHeader( requestHandle,
+ "Range",
+ sizeof( "Range" ) - 1,
+ pRangeValueStr,
+ strlen( pRangeValueStr ) );
/* If case of error, the request will be canceled, then _httpErrorCallback will be invoked,
* followed by _httpResponseCompleteCallback. */
@@ -424,25 +424,25 @@ static void _httpReadReadyCallback( void * pPrivateData,
( void ) returnCode;
/* HTTP return status. */
- IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
+ IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
/* The content length of this HTTP response. */
- uint32_t contentLength = 0;
+ uint32_t contentLength = 0;
/* Size of the response body returned from HTTP API. */
- uint32_t responseBodyLength = 0;
+ uint32_t responseBodyLength = 0;
/* Buffer to read the "Connection" field in HTTP header. */
- char connectionValueStr[ HTTP_HEADER_CONNECTION_VALUE_MAX_LEN ] = { 0 };
+ char connectionValueStr[ HTTP_HEADER_CONNECTION_VALUE_MAX_LEN ] = { 0 };
/* A response is received from the server, setting the state to processing response. */
_httpDownloader.state = OTA_HTTP_PROCESSING_RESPONSE;
/* Read the data from the network. */
- responseBodyLength = HTTPS_RESPONSE_BODY_BUFFER_SIZE;
- httpsStatus = IotHttpsClient_ReadResponseBody( responseHandle,
- pResponseBodyBuffer,
- &responseBodyLength );
+ responseBodyLength = HTTPS_RESPONSE_BODY_BUFFER_SIZE;
+ httpsStatus = IotHttpsClient_ReadResponseBody( responseHandle,
+ pResponseBodyBuffer,
+ &responseBodyLength );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -460,7 +460,7 @@ static void _httpReadReadyCallback( void * pPrivateData,
}
/* Read the "Content-Length" field from HTTP header. */
- httpsStatus = IotHttpsClient_ReadContentLength( responseHandle, &contentLength );
+ httpsStatus = IotHttpsClient_ReadContentLength( responseHandle, &contentLength );
if( ( httpsStatus != IOT_HTTPS_OK ) || ( contentLength == 0 ) )
{
@@ -482,11 +482,11 @@ static void _httpReadReadyCallback( void * pPrivateData,
/* The connection could be closed by S3 after 100 requests, so we need to check the value
* of the "Connection" filed in HTTP header to see if we need to reconnect. */
memset( connectionValueStr, 0, sizeof( connectionValueStr ) );
- httpsStatus = IotHttpsClient_ReadHeader( responseHandle,
- "Connection",
- sizeof( "Connection" ) - 1,
- connectionValueStr,
- sizeof( connectionValueStr ) );
+ httpsStatus = IotHttpsClient_ReadHeader( responseHandle,
+ "Connection",
+ sizeof( "Connection" ) - 1,
+ connectionValueStr,
+ sizeof( connectionValueStr ) );
/* Check if there is any other error besides not found when parsing the http header. */
if( ( httpsStatus != IOT_HTTPS_OK ) && ( httpsStatus != IOT_HTTPS_NOT_FOUND ) )
@@ -618,7 +618,7 @@ static IotHttpsReturnCode_t _httpInitUrl( const char * pURL )
IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
/* HTTP URL information. */
- _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo;
+ _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo;
/* Retrieve the resource path from the HTTP URL. pPath will point to the start of this part. */
httpsStatus = IotHttpsClient_GetUrlPath( pURL,
@@ -633,10 +633,10 @@ static IotHttpsReturnCode_t _httpInitUrl( const char * pURL )
pUrlInfo->pathLength = strlen( pUrlInfo->pPath );
/* Retrieve the authority part and length from the HTTP URL. */
- httpsStatus = IotHttpsClient_GetUrlAddress( pURL,
- strlen( pURL ),
- &pUrlInfo->pAddress,
- &pUrlInfo->addressLength );
+ httpsStatus = IotHttpsClient_GetUrlAddress( pURL,
+ strlen( pURL ),
+ &pUrlInfo->pAddress,
+ &pUrlInfo->addressLength );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -655,60 +655,60 @@ static IotHttpsReturnCode_t _httpConnect( const IotNetworkInterface_t * pNetwork
struct IotNetworkCredentials * pNetworkCredentials )
{
/* HTTP API return status. */
- IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
+ IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
/* HTTP connection data. */
- _httpConnection_t * pConnection = &_httpDownloader.httpConnection;
+ _httpConnection_t * pConnection = &_httpDownloader.httpConnection;
/* HTTP connection configuration. */
IotHttpsConnectionInfo_t * pConnectionConfig = &pConnection->connectionConfig;
/* HTTP request data. */
- _httpRequest_t * pRequest = &_httpDownloader.httpRequest;
+ _httpRequest_t * pRequest = &_httpDownloader.httpRequest;
/* HTTP response data. */
- _httpResponse_t * pResponse = &_httpDownloader.httpResponse;
+ _httpResponse_t * pResponse = &_httpDownloader.httpResponse;
/* HTTP URL information. */
- _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo;
+ _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo;
/* Set the connection configurations. */
- pConnectionConfig->pAddress = pUrlInfo->pAddress;
- pConnectionConfig->addressLen = pUrlInfo->addressLength;
- pConnectionConfig->port = HTTPS_PORT;
- pConnectionConfig->pCaCert = HTTPS_TRUSTED_ROOT_CA;
- pConnectionConfig->caCertLen = sizeof( HTTPS_TRUSTED_ROOT_CA );
- pConnectionConfig->userBuffer.pBuffer = pConnectionUserBuffer;
- pConnectionConfig->userBuffer.bufferLen = HTTPS_CONNECTION_USER_BUFFER_SIZE;
- pConnectionConfig->pClientCert = pNetworkCredentials->pClientCert;
- pConnectionConfig->clientCertLen = pNetworkCredentials->clientCertSize;
- pConnectionConfig->pPrivateKey = pNetworkCredentials->pPrivateKey;
- pConnectionConfig->privateKeyLen = pNetworkCredentials->privateKeySize;
- pConnectionConfig->pNetworkInterface = pNetworkInterface;
+ pConnectionConfig->pAddress = pUrlInfo->pAddress;
+ pConnectionConfig->addressLen = pUrlInfo->addressLength;
+ pConnectionConfig->port = HTTPS_PORT;
+ pConnectionConfig->pCaCert = HTTPS_TRUSTED_ROOT_CA;
+ pConnectionConfig->caCertLen = sizeof( HTTPS_TRUSTED_ROOT_CA );
+ pConnectionConfig->userBuffer.pBuffer = pConnectionUserBuffer;
+ pConnectionConfig->userBuffer.bufferLen = HTTPS_CONNECTION_USER_BUFFER_SIZE;
+ pConnectionConfig->pClientCert = pNetworkCredentials->pClientCert;
+ pConnectionConfig->clientCertLen = pNetworkCredentials->clientCertSize;
+ pConnectionConfig->pPrivateKey = pNetworkCredentials->pPrivateKey;
+ pConnectionConfig->privateKeyLen = pNetworkCredentials->privateKeySize;
+ pConnectionConfig->pNetworkInterface = pNetworkInterface;
/* Initialize HTTP request configuration. */
- pRequest->requestConfig.pPath = pUrlInfo->pPath;
- pRequest->requestConfig.pathLen = pUrlInfo->pathLength;
- pRequest->requestConfig.pHost = pUrlInfo->pAddress;
- pRequest->requestConfig.hostLen = pUrlInfo->addressLength;
- pRequest->requestConfig.method = IOT_HTTPS_METHOD_GET;
- pRequest->requestConfig.userBuffer.pBuffer = pRequestUserBuffer;
- pRequest->requestConfig.userBuffer.bufferLen = HTTPS_REQUEST_USER_BUFFER_SIZE;
- pRequest->requestConfig.isAsync = true;
- pRequest->requestConfig.u.pAsyncInfo = &pRequest->asyncInfo;
+ pRequest->requestConfig.pPath = pUrlInfo->pPath;
+ pRequest->requestConfig.pathLen = pUrlInfo->pathLength;
+ pRequest->requestConfig.pHost = pUrlInfo->pAddress;
+ pRequest->requestConfig.hostLen = pUrlInfo->addressLength;
+ pRequest->requestConfig.method = IOT_HTTPS_METHOD_GET;
+ pRequest->requestConfig.userBuffer.pBuffer = pRequestUserBuffer;
+ pRequest->requestConfig.userBuffer.bufferLen = HTTPS_REQUEST_USER_BUFFER_SIZE;
+ pRequest->requestConfig.isAsync = true;
+ pRequest->requestConfig.u.pAsyncInfo = &pRequest->asyncInfo;
/* Initialize HTTP response configuration. */
- pResponse->responseConfig.userBuffer.pBuffer = pResponseUserBuffer;
- pResponse->responseConfig.userBuffer.bufferLen = HTTPS_RESPONSE_USER_BUFFER_SIZE;
- pResponse->responseConfig.pSyncInfo = NULL;
+ pResponse->responseConfig.userBuffer.pBuffer = pResponseUserBuffer;
+ pResponse->responseConfig.userBuffer.bufferLen = HTTPS_RESPONSE_USER_BUFFER_SIZE;
+ pResponse->responseConfig.pSyncInfo = NULL;
/* Initialize HTTP asynchronous configuration. */
- pRequest->asyncInfo.callbacks.appendHeaderCallback = _httpAppendHeaderCallback;
- pRequest->asyncInfo.callbacks.readReadyCallback = _httpReadReadyCallback;
+ pRequest->asyncInfo.callbacks.appendHeaderCallback = _httpAppendHeaderCallback;
+ pRequest->asyncInfo.callbacks.readReadyCallback = _httpReadReadyCallback;
pRequest->asyncInfo.callbacks.responseCompleteCallback = _httpResponseCompleteCallback;
- pRequest->asyncInfo.callbacks.errorCallback = _httpErrorCallback;
+ pRequest->asyncInfo.callbacks.errorCallback = _httpErrorCallback;
pRequest->asyncInfo.callbacks.connectionClosedCallback = _httpConnectionClosedCallback;
- pRequest->asyncInfo.pPrivData = ( void * ) ( &_httpDownloader.httpCallbackData );
+ pRequest->asyncInfo.pPrivData = ( void * ) ( &_httpDownloader.httpCallbackData );
httpsStatus = IotHttpsClient_Connect( &pConnection->connectionHandle, pConnectionConfig );
@@ -722,60 +722,60 @@ static IotHttpsReturnCode_t _httpConnect( const IotNetworkInterface_t * pNetwork
static _httpErr _httpGetFileSize( uint32_t * pFileSize )
{
/* Return status. */
- _httpErr status = OTA_HTTP_ERR_NONE;
- IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
+ _httpErr status = OTA_HTTP_ERR_NONE;
+ IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
/* HTTP response code. */
- uint16_t responseStatus = IOT_HTTPS_STATUS_OK;
+ uint16_t responseStatus = IOT_HTTPS_STATUS_OK;
/* HTTP request and response configurations. We're creating local variables here because this is
* a temporary synchronous request. */
- IotHttpsRequestInfo_t requestConfig = { 0 };
- IotHttpsResponseInfo_t responseConfig = { 0 };
+ IotHttpsRequestInfo_t requestConfig = { 0 };
+ IotHttpsResponseInfo_t responseConfig = { 0 };
/* Synchronous request and response configurations. */
- IotHttpsSyncInfo_t requestSyncInfo = { 0 };
- IotHttpsSyncInfo_t responseSyncInfo = { 0 };
+ IotHttpsSyncInfo_t requestSyncInfo = { 0 };
+ IotHttpsSyncInfo_t responseSyncInfo = { 0 };
/* Handle for HTTP request and response. */
- IotHttpsRequestHandle_t requestHandle = NULL;
- IotHttpsResponseHandle_t responseHandle = NULL;
+ IotHttpsRequestHandle_t requestHandle = NULL;
+ IotHttpsResponseHandle_t responseHandle = NULL;
/* HTTP URL information. */
- _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo;
+ _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo;
/* Value of the "Content-Range" field in HTTP response header. The format is "bytes 0-0/FILESIZE". */
- char pContentRange[ sizeof( "bytes 0-0/" ) + OTA_MAX_FILE_SIZE_STR_LEN ] = { 0 };
+ char pContentRange[ sizeof( "bytes 0-0/" ) + OTA_MAX_FILE_SIZE_STR_LEN ] = { 0 };
/* Pointer to the location of the file size in pContentRange. */
char * pFileSizeStr = NULL;
/* There's no message body in this GET request. */
- requestSyncInfo.pBody = NULL;
- requestSyncInfo.bodyLen = 0;
+ requestSyncInfo.pBody = NULL;
+ requestSyncInfo.bodyLen = 0;
/* Store the response body in case there's any failure. */
- responseSyncInfo.pBody = pResponseBodyBuffer;
- responseSyncInfo.bodyLen = HTTPS_RESPONSE_BODY_BUFFER_SIZE;
+ responseSyncInfo.pBody = pResponseBodyBuffer;
+ responseSyncInfo.bodyLen = HTTPS_RESPONSE_BODY_BUFFER_SIZE;
/* Set the request configurations. */
- requestConfig.pPath = pUrlInfo->pPath;
- requestConfig.pathLen = pUrlInfo->pathLength;
- requestConfig.pHost = pUrlInfo->pAddress;
- requestConfig.hostLen = pUrlInfo->addressLength;
- requestConfig.method = IOT_HTTPS_METHOD_GET;
- requestConfig.userBuffer.pBuffer = pRequestUserBuffer;
- requestConfig.userBuffer.bufferLen = HTTPS_REQUEST_USER_BUFFER_SIZE;
- requestConfig.isAsync = false;
- requestConfig.u.pSyncInfo = &requestSyncInfo;
+ requestConfig.pPath = pUrlInfo->pPath;
+ requestConfig.pathLen = pUrlInfo->pathLength;
+ requestConfig.pHost = pUrlInfo->pAddress;
+ requestConfig.hostLen = pUrlInfo->addressLength;
+ requestConfig.method = IOT_HTTPS_METHOD_GET;
+ requestConfig.userBuffer.pBuffer = pRequestUserBuffer;
+ requestConfig.userBuffer.bufferLen = HTTPS_REQUEST_USER_BUFFER_SIZE;
+ requestConfig.isAsync = false;
+ requestConfig.u.pSyncInfo = &requestSyncInfo;
/* Set the response configurations. */
- responseConfig.userBuffer.pBuffer = pResponseUserBuffer;
+ responseConfig.userBuffer.pBuffer = pResponseUserBuffer;
responseConfig.userBuffer.bufferLen = HTTPS_RESPONSE_USER_BUFFER_SIZE;
- responseConfig.pSyncInfo = &responseSyncInfo;
+ responseConfig.pSyncInfo = &responseSyncInfo;
/* Initialize the request to retrieve a request handle. */
- httpsStatus = IotHttpsClient_InitializeRequest( &requestHandle, &requestConfig );
+ httpsStatus = IotHttpsClient_InitializeRequest( &requestHandle, &requestConfig );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -785,11 +785,11 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize )
}
/* Set the "Range" field in HTTP header to "bytes=0-0" since we just want the file size. */
- httpsStatus = IotHttpsClient_AddHeader( requestHandle,
- "Range",
- sizeof( "Range" ) - 1,
- "bytes=0-0",
- sizeof( "bytes=0-0" ) - 1 );
+ httpsStatus = IotHttpsClient_AddHeader( requestHandle,
+ "Range",
+ sizeof( "Range" ) - 1,
+ "bytes=0-0",
+ sizeof( "bytes=0-0" ) - 1 );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -799,11 +799,11 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize )
}
/* Send the request synchronously. */
- httpsStatus = IotHttpsClient_SendSync( _httpDownloader.httpConnection.connectionHandle,
- requestHandle,
- &responseHandle,
- &responseConfig,
- HTTP_SYNC_TIMEOUT );
+ httpsStatus = IotHttpsClient_SendSync( _httpDownloader.httpConnection.connectionHandle,
+ requestHandle,
+ &responseHandle,
+ &responseConfig,
+ HTTP_SYNC_TIMEOUT );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -812,7 +812,7 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize )
OTA_GOTO_CLEANUP();
}
- httpsStatus = IotHttpsClient_ReadResponseStatus( responseHandle, &responseStatus );
+ httpsStatus = IotHttpsClient_ReadResponseStatus( responseHandle, &responseStatus );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -830,11 +830,11 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize )
}
/* Parse the HTTP header and retrieve the file size. */
- httpsStatus = IotHttpsClient_ReadHeader( responseHandle,
- "Content-Range",
- sizeof( "Content-Range" ) - 1,
- pContentRange,
- sizeof( pContentRange ) );
+ httpsStatus = IotHttpsClient_ReadHeader( responseHandle,
+ "Content-Range",
+ sizeof( "Content-Range" ) - 1,
+ pContentRange,
+ sizeof( pContentRange ) );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -843,7 +843,7 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize )
OTA_GOTO_CLEANUP();
}
- pFileSizeStr = strstr( pContentRange, "/" );
+ pFileSizeStr = strstr( pContentRange, "/" );
if( pFileSizeStr == NULL )
{
@@ -856,7 +856,7 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize )
pFileSizeStr += sizeof( char );
}
- *pFileSize = ( uint32_t ) strtoul( pFileSizeStr, NULL, 10 );
+ *pFileSize = ( uint32_t ) strtoul( pFileSizeStr, NULL, 10 );
if( ( *pFileSize == 0 ) || ( *pFileSize == UINT32_MAX ) )
{
@@ -917,28 +917,28 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx )
IotLogDebug( "Invoking _AwsIotOTA_InitFileTransfer_HTTP" );
/* Return status. */
- OTA_Err_t status = kOTA_Err_None;
- IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
+ OTA_Err_t status = kOTA_Err_None;
+ IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
/* Cleanup status. */
- bool cleanupRequired = false;
+ bool cleanupRequired = false;
/* Network interface and credentials from OTA agent. */
- OTA_ConnectionContext_t * connContext = pAgentCtx->pvConnectionContext;
- const IotNetworkInterface_t * pNetworkInterface = connContext->pxNetworkInterface;
+ OTA_ConnectionContext_t * connContext = pAgentCtx->pvConnectionContext;
+ const IotNetworkInterface_t * pNetworkInterface = connContext->pxNetworkInterface;
struct IotNetworkCredentials * pNetworkCredentials = connContext->pvNetworkCredentials;
/* Pre-signed URL. */
- const char * pURL = NULL;
+ const char * pURL = NULL;
/* File context from OTA agent. */
- OTA_FileContext_t * fileContext = &( pAgentCtx->pxOTA_Files[ pAgentCtx->ulFileIndex ] );
+ OTA_FileContext_t * fileContext = &( pAgentCtx->pxOTA_Files[ pAgentCtx->ulFileIndex ] );
/* OTA download file size from OTA agent (parsed from job document). */
- uint32_t otaFileSize = 0;
+ uint32_t otaFileSize = 0;
/* OTA download file size from the HTTP server, this should match otaFileSize. */
- uint32_t httpFileSize = 0;
+ uint32_t httpFileSize = 0;
/* Store the OTA agent for later access. */
_httpDownloader.pAgentCtx = pAgentCtx;
@@ -951,14 +951,14 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx )
}
/* Get the file size from OTA agent (parsed from job document). */
- otaFileSize = fileContext->ulFileSize;
+ otaFileSize = fileContext->ulFileSize;
/* Get pre-signed URL from pAgentCtx. */
- pURL = ( const char * ) ( fileContext->pucUpdateUrlPath );
+ pURL = ( const char * ) ( fileContext->pucUpdateUrlPath );
IotLogInfo( "Pre-signed URL size: %d.", strlen( pURL ) );
/* Initialize the HTTPS library. */
- httpsStatus = IotHttpsClient_Init();
+ httpsStatus = IotHttpsClient_Init();
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -975,23 +975,23 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx )
}
/* Connect to the HTTP server and initialize download information. */
- httpsStatus = _httpInitUrl( pURL );
+ httpsStatus = _httpInitUrl( pURL );
if( httpsStatus != IOT_HTTPS_OK )
{
IotLogError( "Failed to parse the HTTP Url. Error code: %d", httpsStatus );
- status = kOTA_Err_HTTPInitFailed;
+ status = kOTA_Err_HTTPInitFailed;
cleanupRequired = true;
OTA_GOTO_CLEANUP();
}
- httpsStatus = _httpConnect( pNetworkInterface, pNetworkCredentials );
+ httpsStatus = _httpConnect( pNetworkInterface, pNetworkCredentials );
if( httpsStatus != IOT_HTTPS_OK )
{
IotLogError( "Failed to connect to %.*s. Error code: %d", _httpDownloader.httpUrlInfo.addressLength,
_httpDownloader.httpUrlInfo.pAddress, httpsStatus );
- status = kOTA_Err_HTTPInitFailed;
+ status = kOTA_Err_HTTPInitFailed;
cleanupRequired = true;
OTA_GOTO_CLEANUP();
}
@@ -1002,7 +1002,7 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx )
if( _httpGetFileSize( &httpFileSize ) != OTA_HTTP_ERR_NONE )
{
IotLogError( "Cannot retrieve the file size from HTTP server." );
- status = kOTA_Err_HTTPInitFailed;
+ status = kOTA_Err_HTTPInitFailed;
cleanupRequired = true;
OTA_GOTO_CLEANUP();
}
@@ -1013,7 +1013,7 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx )
"job document (%u bytes).",
( unsigned int ) httpFileSize,
( unsigned int ) otaFileSize );
- status = kOTA_Err_HTTPInitFailed;
+ status = kOTA_Err_HTTPInitFailed;
cleanupRequired = true;
OTA_GOTO_CLEANUP();
}
@@ -1038,25 +1038,25 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx )
IotLogDebug( "Invoking _AwsIotOTA_RequestDataBlock_HTTP" );
/* Return status. */
- OTA_Err_t status = kOTA_Err_None;
+ OTA_Err_t status = kOTA_Err_None;
IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK;
/* HTTP connection data. */
- _httpConnection_t * pConnection = &_httpDownloader.httpConnection;
+ _httpConnection_t * pConnection = &_httpDownloader.httpConnection;
/* HTTP request data. */
- _httpRequest_t * pRequest = &_httpDownloader.httpRequest;
+ _httpRequest_t * pRequest = &_httpDownloader.httpRequest;
/* HTTP response data. */
- _httpResponse_t * pResponse = &_httpDownloader.httpResponse;
+ _httpResponse_t * pResponse = &_httpDownloader.httpResponse;
/* Values for the "Range" field in HTTP header. */
- uint32_t rangeStart = 0;
- uint32_t rangeEnd = 0;
- int numWritten = 0;
+ uint32_t rangeStart = 0;
+ uint32_t rangeEnd = 0;
+ int numWritten = 0;
/* File context from OTA agent. */
- OTA_FileContext_t * fileContext = &( pAgentCtx->pxOTA_Files[ pAgentCtx->ulFileIndex ] );
+ OTA_FileContext_t * fileContext = &( pAgentCtx->pxOTA_Files[ pAgentCtx->ulFileIndex ] );
/* Exit if we're still busy downloading or reconnect is required but failed. */
if( _requestDataBlockPreCheck() != OTA_HTTP_ERR_NONE )
@@ -1065,8 +1065,8 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx )
OTA_GOTO_CLEANUP();
}
- _httpDownloader.state = OTA_HTTP_SENDING_REQUEST;
- _httpDownloader.err = OTA_HTTP_ERR_NONE;
+ _httpDownloader.state = OTA_HTTP_SENDING_REQUEST;
+ _httpDownloader.err = OTA_HTTP_ERR_NONE;
if( fileContext == NULL )
{
@@ -1079,7 +1079,7 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx )
pAgentCtx->ulNumOfBlocksToReceive = 1;
/* Calculate ranges. */
- rangeStart = _httpDownloader.currBlock * OTA_FILE_BLOCK_SIZE;
+ rangeStart = _httpDownloader.currBlock * OTA_FILE_BLOCK_SIZE;
if( fileContext->ulBlocksRemaining == 1 )
{
@@ -1090,14 +1090,14 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx )
rangeEnd = rangeStart + OTA_FILE_BLOCK_SIZE - 1;
}
- _httpDownloader.currBlockSize = rangeEnd - rangeStart + 1;
+ _httpDownloader.currBlockSize = rangeEnd - rangeStart + 1;
/* Creating the "range" field in HTTP header. */
- numWritten = snprintf( _httpDownloader.httpCallbackData.pRangeValueStr,
- HTTP_HEADER_RANGE_VALUE_MAX_LEN,
- "bytes=%u-%u",
- ( unsigned int ) rangeStart,
- ( unsigned int ) rangeEnd );
+ numWritten = snprintf( _httpDownloader.httpCallbackData.pRangeValueStr,
+ HTTP_HEADER_RANGE_VALUE_MAX_LEN,
+ "bytes=%u-%u",
+ ( unsigned int ) rangeStart,
+ ( unsigned int ) rangeEnd );
if( ( numWritten < 0 ) || ( numWritten >= HTTP_HEADER_RANGE_VALUE_MAX_LEN ) )
{
@@ -1107,7 +1107,7 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx )
}
/* Re-initialize the request handle as it could be changed when handling last response. */
- httpsStatus = IotHttpsClient_InitializeRequest( &pRequest->requestHandle, &pRequest->requestConfig );
+ httpsStatus = IotHttpsClient_InitializeRequest( &pRequest->requestHandle, &pRequest->requestConfig );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -1118,10 +1118,10 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx )
/* Send the request asynchronously. Receiving is handled in a callback. */
IotLogInfo( "Sending HTTP request to download block %d.", _httpDownloader.currBlock );
- httpsStatus = IotHttpsClient_SendAsync( pConnection->connectionHandle,
- pRequest->requestHandle,
- &pResponse->responseHandle,
- &pResponse->responseConfig );
+ httpsStatus = IotHttpsClient_SendAsync( pConnection->connectionHandle,
+ pRequest->requestHandle,
+ &pResponse->responseHandle,
+ &pResponse->responseConfig );
if( httpsStatus != IOT_HTTPS_OK )
{
@@ -1156,14 +1156,14 @@ OTA_Err_t _AwsIotOTA_DecodeFileBlock_HTTP( uint8_t * pMessageBuffer,
/* Unused parameters. */
( void ) messageSize;
- *pPayload = pMessageBuffer;
- *pFileId = 0;
- *pBlockId = _httpDownloader.currBlock;
- *pBlockSize = _httpDownloader.currBlockSize;
- *pPayloadSize = _httpDownloader.currBlockSize;
+ *pPayload = pMessageBuffer;
+ *pFileId = 0;
+ *pBlockId = _httpDownloader.currBlock;
+ *pBlockSize = _httpDownloader.currBlockSize;
+ *pPayloadSize = _httpDownloader.currBlockSize;
/* Current block is processed, set the file block to next one and the state to idle. */
- _httpDownloader.state = OTA_HTTP_IDLE;
+ _httpDownloader.state = OTA_HTTP_IDLE;
_httpDownloader.currBlock += 1;
return kOTA_Err_None;
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c
index 8bfa8a101..b304d52cd 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c
@@ -59,9 +59,9 @@ BaseType_t OTA_CBOR_Decode_GetStreamResponseMessage( const uint8_t * pucMessageB
uint8_t ** ppucPayload,
size_t * pxPayloadSize )
{
- CborError xCborResult = CborNoError;
+ CborError xCborResult = CborNoError;
CborParser xCborParser;
- CborValue xCborValue, xCborMap;
+ CborValue xCborValue, xCborMap;
/* Initialize the parser. */
xCborResult = cbor_parser_init( pucMessageBuffer,
@@ -207,7 +207,7 @@ BaseType_t OTA_CBOR_Encode_GetStreamRequestMessage( uint8_t * pucMessageBuffer,
size_t xBlockBitmapSize,
int32_t lNumOfBlocksRequested )
{
- CborError xCborResult = CborNoError;
+ CborError xCborResult = CborNoError;
CborEncoder xCborEncoder, xCborMapEncoder;
/* Initialize the CBOR encoder. */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c
index 21ab6b010..55024ae62 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c
@@ -63,30 +63,30 @@
/*lint -e830 -e9003 Keep these in one location for easy discovery should they change in the future. */
/* Topic strings used by the OTA process. */
/* These first few are topic extensions to the dynamic base topic that includes the Thing name. */
-static const char pcOTA_JobsGetNextAccepted_TopicTemplate[] = "$aws/things/%s/jobs/$next/get/accepted";
-static const char pcOTA_JobsNotifyNext_TopicTemplate[] = "$aws/things/%s/jobs/notify-next";
-static const char pcOTA_JobsGetNext_TopicTemplate[] = "$aws/things/%s/jobs/$next/get";
-static const char pcOTA_JobStatus_TopicTemplate[] = "$aws/things/%s/jobs/%s/update";
-static const char pcOTA_StreamData_TopicTemplate[] = "$aws/things/%s/streams/%s/data/cbor";
-static const char pcOTA_GetStream_TopicTemplate[] = "$aws/things/%s/streams/%s/get/cbor";
-static const char pcOTA_GetNextJob_MsgTemplate[] = "{\"clientToken\":\"%u:%s\"}";
-static const char pcOTA_JobStatus_StatusTemplate[] = "{\"status\":\"%s\",\"statusDetails\":{";
-static const char pcOTA_JobStatus_ReceiveDetailsTemplate[] = "\"%s\":\"%u/%u\"}}";
-static const char pcOTA_JobStatus_SelfTestDetailsTemplate[] = "\"%s\":\"%s\",\"" OTA_JSON_UPDATED_BY_KEY "\":\"0x%x\"}}";
-static const char pcOTA_JobStatus_ReasonStrTemplate[] = "\"reason\":\"%s: 0x%08x\"}}";
-static const char pcOTA_JobStatus_SucceededStrTemplate[] = "\"reason\":\"%s v%u.%u.%u\"}}";
-static const char pcOTA_JobStatus_ReasonValTemplate[] = "\"reason\":\"0x%08x: 0x%08x\"}}";
-static const char pcOTA_String_Receive[] = "receive";
+static const char pcOTA_JobsGetNextAccepted_TopicTemplate[] = "$aws/things/%s/jobs/$next/get/accepted";
+static const char pcOTA_JobsNotifyNext_TopicTemplate[] = "$aws/things/%s/jobs/notify-next";
+static const char pcOTA_JobsGetNext_TopicTemplate[] = "$aws/things/%s/jobs/$next/get";
+static const char pcOTA_JobStatus_TopicTemplate[] = "$aws/things/%s/jobs/%s/update";
+static const char pcOTA_StreamData_TopicTemplate[] = "$aws/things/%s/streams/%s/data/cbor";
+static const char pcOTA_GetStream_TopicTemplate[] = "$aws/things/%s/streams/%s/get/cbor";
+static const char pcOTA_GetNextJob_MsgTemplate[] = "{\"clientToken\":\"%u:%s\"}";
+static const char pcOTA_JobStatus_StatusTemplate[] = "{\"status\":\"%s\",\"statusDetails\":{";
+static const char pcOTA_JobStatus_ReceiveDetailsTemplate[] = "\"%s\":\"%u/%u\"}}";
+static const char pcOTA_JobStatus_SelfTestDetailsTemplate[] = "\"%s\":\"%s\",\"" OTA_JSON_UPDATED_BY_KEY "\":\"0x%x\"}}";
+static const char pcOTA_JobStatus_ReasonStrTemplate[] = "\"reason\":\"%s: 0x%08x\"}}";
+static const char pcOTA_JobStatus_SucceededStrTemplate[] = "\"reason\":\"%s v%u.%u.%u\"}}";
+static const char pcOTA_JobStatus_ReasonValTemplate[] = "\"reason\":\"0x%08x: 0x%08x\"}}";
+static const char pcOTA_String_Receive[] = "receive";
/* We map all of the above status cases to one of these 4 status strings.
* These are the only strings that are supported by the Job Service. You
* shall not change them to arbitrary strings or the job will not change
* states.
* */
-const char pcOTA_String_InProgress[] = "IN_PROGRESS";
-const char pcOTA_String_Failed[] = "FAILED";
-const char pcOTA_String_Succeeded[] = "SUCCEEDED";
-const char pcOTA_String_Rejected[] = "REJECTED";
+const char pcOTA_String_InProgress[] = "IN_PROGRESS";
+const char pcOTA_String_Failed[] = "FAILED";
+const char pcOTA_String_Succeeded[] = "SUCCEEDED";
+const char pcOTA_String_Rejected[] = "REJECTED";
const char * pcOTA_JobStatus_Strings[ eNumJobStatusMappings ] =
{
@@ -101,7 +101,7 @@ const char * pcOTA_JobStatus_Strings[ eNumJobStatusMappings ] =
* the above enums during the OTA update process. The 'Receiving' state is
* updated with transfer progress as #blocks received of #total.
*/
-const char * pcOTA_JobReason_Strings[ eNumJobReasons ] = { "", "ready", "active", "accepted", "rejected", "aborted" };
+const char * pcOTA_JobReason_Strings[ eNumJobReasons ] = { "", "ready", "active", "accepted", "rejected", "aborted" };
/* Queue MQTT callback event for processing. */
@@ -146,26 +146,26 @@ static bool prvSubscribeToJobNotificationTopics( const OTA_AgentContext_t * pxAg
{
DEFINE_OTA_METHOD_NAME( "prvSubscribeToJobNotificationTopics" );
- bool bResult = false;
- char pcJobTopic[ OTA_MAX_TOPIC_LEN ];
- IotMqttSubscription_t stJobsSubscription;
- IotMqttError_t eResult = IOT_MQTT_STATUS_PENDING;
- uint16_t usTopicLen = 0;
+ bool bResult = false;
+ char pcJobTopic[ OTA_MAX_TOPIC_LEN ];
+ IotMqttSubscription_t stJobsSubscription;
+ IotMqttError_t eResult = IOT_MQTT_STATUS_PENDING;
+ uint16_t usTopicLen = 0;
OTA_ConnectionContext_t * pvConnContext = pxAgentCtx->pvConnectionContext;
/* Build the first topic. */
- usTopicLen = ( uint16_t ) snprintf( pcJobTopic, /*lint -e586 Intentionally using snprintf. */
- sizeof( pcJobTopic ),
- pcOTA_JobsGetNextAccepted_TopicTemplate,
- pxAgentCtx->pcThingName );
+ usTopicLen = ( uint16_t ) snprintf( pcJobTopic, /*lint -e586 Intentionally using snprintf. */
+ sizeof( pcJobTopic ),
+ pcOTA_JobsGetNextAccepted_TopicTemplate,
+ pxAgentCtx->pcThingName );
/* Clear subscription struct and set common parameters for job topics used by OTA. */
memset( &stJobsSubscription, 0, sizeof( stJobsSubscription ) );
- stJobsSubscription.qos = IOT_MQTT_QOS_1;
- stJobsSubscription.pTopicFilter = ( const char * ) pcJobTopic; /* Point to local string storage. Built below. */
- stJobsSubscription.callback.pCallbackContext = ( void * ) pxAgentCtx; /*lint !e923 The publish callback context is implementing data hiding with a void* type.*/
- stJobsSubscription.callback.function = prvJobPublishCallback;
- stJobsSubscription.topicFilterLength = usTopicLen;
+ stJobsSubscription.qos = IOT_MQTT_QOS_1;
+ stJobsSubscription.pTopicFilter = ( const char * ) pcJobTopic; /* Point to local string storage. Built below. */
+ stJobsSubscription.callback.pCallbackContext = ( void * ) pxAgentCtx; /*lint !e923 The publish callback context is implementing data hiding with a void* type.*/
+ stJobsSubscription.callback.function = prvJobPublishCallback;
+ stJobsSubscription.topicFilterLength = usTopicLen;
if( ( usTopicLen > 0U ) && ( usTopicLen < sizeof( pcJobTopic ) ) )
{
@@ -195,11 +195,11 @@ static bool prvSubscribeToJobNotificationTopics( const OTA_AgentContext_t * pxAg
{
/* Subscribe to the second of two jobs topics. */
stJobsSubscription.topicFilterLength = usTopicLen;
- eResult = IotMqtt_TimedSubscribe( pvConnContext->pvControlClient,
- &stJobsSubscription,
- 1, /* Subscriptions count */
- 0, /* flags */
- OTA_SUBSCRIBE_WAIT_MS );
+ eResult = IotMqtt_TimedSubscribe( pvConnContext->pvControlClient,
+ &stJobsSubscription,
+ 1, /* Subscriptions count */
+ 0, /* flags */
+ OTA_SUBSCRIBE_WAIT_MS );
if( eResult == IOT_MQTT_SUCCESS )
{
@@ -224,8 +224,8 @@ static bool prvUnSubscribeFromDataStream( const OTA_AgentContext_t * pxAgentCtx
IotMqttSubscription_t xUnSub;
- bool bResult = false;
- char pcOTA_RxStreamTopic[ OTA_MAX_TOPIC_LEN ];
+ bool bResult = false;
+ char pcOTA_RxStreamTopic[ OTA_MAX_TOPIC_LEN ];
xUnSub.qos = IOT_MQTT_QOS_0;
@@ -273,15 +273,15 @@ static void prvUnSubscribeFromJobNotificationTopic( const OTA_AgentContext_t * p
{
DEFINE_OTA_METHOD_NAME( "prvUnSubscribeFromJobNotificationTopic" );
- IotMqttSubscription_t xUnSub;
- IotMqttOperation_t paUnubscribeOperation[ 2 ] = { NULL };
- char pcJobTopic[ OTA_MAX_TOPIC_LEN ];
+ IotMqttSubscription_t xUnSub;
+ IotMqttOperation_t paUnubscribeOperation[ 2 ] = { NULL };
+ char pcJobTopic[ OTA_MAX_TOPIC_LEN ];
- OTA_ConnectionContext_t * pvConnContext = pxAgentCtx->pvConnectionContext;
+ OTA_ConnectionContext_t * pvConnContext = pxAgentCtx->pvConnectionContext;
/* Try to unsubscribe from the first of two job topics. */
- xUnSub.qos = IOT_MQTT_QOS_0;
- xUnSub.pTopicFilter = ( const char * ) pcJobTopic; /* Point to local string storage. Built below. */
+ xUnSub.qos = IOT_MQTT_QOS_0;
+ xUnSub.pTopicFilter = ( const char * ) pcJobTopic; /* Point to local string storage. Built below. */
xUnSub.topicFilterLength = ( uint16_t ) snprintf( pcJobTopic, /*lint -e586 Intentionally using snprintf. */
sizeof( pcJobTopic ),
pcOTA_JobsNotifyNext_TopicTemplate,
@@ -354,20 +354,20 @@ static IotMqttError_t prvPublishMessage( const OTA_AgentContext_t * pxAgentCtx,
uint32_t ulMsgSize,
IotMqttQos_t eQOS )
{
- IotMqttError_t eResult;
- IotMqttPublishInfo_t xPublishParams;
+ IotMqttError_t eResult;
+ IotMqttPublishInfo_t xPublishParams;
OTA_ConnectionContext_t * pvConnContext = pxAgentCtx->pvConnectionContext;
- xPublishParams.pTopicName = pacTopic;
+ xPublishParams.pTopicName = pacTopic;
xPublishParams.topicNameLength = usTopicLen;
- xPublishParams.qos = eQOS;
- xPublishParams.pPayload = pcMsg;
- xPublishParams.payloadLength = ulMsgSize;
- xPublishParams.retryLimit = OTA_MAX_PUBLISH_RETRIES;
- xPublishParams.retryMs = OTA_RETRY_DELAY_MS;
- xPublishParams.retain = false;
+ xPublishParams.qos = eQOS;
+ xPublishParams.pPayload = pcMsg;
+ xPublishParams.payloadLength = ulMsgSize;
+ xPublishParams.retryLimit = OTA_MAX_PUBLISH_RETRIES;
+ xPublishParams.retryMs = OTA_RETRY_DELAY_MS;
+ xPublishParams.retain = false;
- eResult = IotMqtt_TimedPublish( pvConnContext->pvControlClient, &xPublishParams, 0, OTA_PUBLISH_WAIT_MS );
+ eResult = IotMqtt_TimedPublish( pvConnContext->pvControlClient, &xPublishParams, 0, OTA_PUBLISH_WAIT_MS );
return eResult;
}
@@ -383,9 +383,9 @@ static void prvPublishStatusMessage( OTA_AgentContext_t * pxAgentCtx,
{
DEFINE_OTA_METHOD_NAME( "prvPublishStatusMessage" );
- uint32_t ulTopicLen = 0;
+ uint32_t ulTopicLen = 0;
IotMqttError_t eResult;
- char pcTopicBuffer[ OTA_MAX_TOPIC_LEN ];
+ char pcTopicBuffer[ OTA_MAX_TOPIC_LEN ];
/* Try to build the dynamic job status topic . */
ulTopicLen = ( uint32_t ) snprintf( pcTopicBuffer, /*lint -e586 Intentionally using snprintf. */
@@ -429,20 +429,20 @@ static uint32_t prvBuildStatusMessageReceiving( char * pcMsgBuffer,
DEFINE_OTA_METHOD_NAME( "prvBuildStatusMessageReceiving" );
uint32_t ulNumBlocks = 0;
- uint32_t ulReceived = 0;
- uint32_t ulMsgSize = 0;
+ uint32_t ulReceived = 0;
+ uint32_t ulMsgSize = 0;
if( pxOTAFileCtx != NULL )
{
ulNumBlocks = ( pxOTAFileCtx->ulFileSize + ( OTA_FILE_BLOCK_SIZE - 1U ) ) >> otaconfigLOG2_FILE_BLOCK_SIZE;
- ulReceived = ulNumBlocks - pxOTAFileCtx->ulBlocksRemaining;
+ ulReceived = ulNumBlocks - pxOTAFileCtx->ulBlocksRemaining;
if( ( ulReceived % OTA_UPDATE_STATUS_FREQUENCY ) == 0U ) /* Output a status update once in a while. */
{
- ulMsgSize = ( uint32_t ) snprintf( pcMsgBuffer, /*lint -e586 Intentionally using snprintf. */
- xMsgBufferSize,
- pcOTA_JobStatus_StatusTemplate,
- pcOTA_JobStatus_Strings[ eStatus ] );
+ ulMsgSize = ( uint32_t ) snprintf( pcMsgBuffer, /*lint -e586 Intentionally using snprintf. */
+ xMsgBufferSize,
+ pcOTA_JobStatus_StatusTemplate,
+ pcOTA_JobStatus_Strings[ eStatus ] );
ulMsgSize += ( uint32_t ) snprintf( &pcMsgBuffer[ ulMsgSize ], /*lint -e586 Intentionally using snprintf. */
xMsgBufferSize - ulMsgSize,
pcOTA_JobStatus_ReceiveDetailsTemplate,
@@ -466,10 +466,10 @@ static uint32_t prvBuildStatusMessageSelfTest( char * pcMsgBuffer,
{
uint32_t ulMsgSize = 0;
- ulMsgSize = ( uint32_t ) snprintf( pcMsgBuffer, /*lint -e586 Intentionally using snprintf. */
- xMsgBufferSize,
- pcOTA_JobStatus_StatusTemplate,
- pcOTA_JobStatus_Strings[ eStatus ] );
+ ulMsgSize = ( uint32_t ) snprintf( pcMsgBuffer, /*lint -e586 Intentionally using snprintf. */
+ xMsgBufferSize,
+ pcOTA_JobStatus_StatusTemplate,
+ pcOTA_JobStatus_Strings[ eStatus ] );
ulMsgSize += ( uint32_t ) snprintf( &pcMsgBuffer[ ulMsgSize ], /*lint -e586 Intentionally using snprintf. */
xMsgBufferSize - ulMsgSize,
pcOTA_JobStatus_SelfTestDetailsTemplate,
@@ -515,13 +515,13 @@ static uint32_t prvBuildStatusMessageFinish( char * pcMsgBuffer,
AppVersion32_t xNewVersion;
xNewVersion.u.lVersion32 = lSubReason;
- ulMsgSize += ( uint32_t ) snprintf( &pcMsgBuffer[ ulMsgSize ], /*lint -e586 Intentionally using snprintf. */
- xMsgBufferSize - ulMsgSize,
- pcOTA_JobStatus_SucceededStrTemplate,
- pcOTA_JobReason_Strings[ lReason ],
- xNewVersion.u.x.ucMajor,
- xNewVersion.u.x.ucMinor,
- xNewVersion.u.x.usBuild );
+ ulMsgSize += ( uint32_t ) snprintf( &pcMsgBuffer[ ulMsgSize ], /*lint -e586 Intentionally using snprintf. */
+ xMsgBufferSize - ulMsgSize,
+ pcOTA_JobStatus_SucceededStrTemplate,
+ pcOTA_JobReason_Strings[ lReason ],
+ xNewVersion.u.x.ucMajor,
+ xNewVersion.u.x.ucMinor,
+ xNewVersion.u.x.usBuild );
}
/* Status updates that are NOT "InProgress" or "Succeeded" or "FailedWithVal" map status and
@@ -547,9 +547,9 @@ static void prvSendCallbackEvent( void * pvCallbackContext,
OTA_Event_t xEventId )
{
DEFINE_OTA_METHOD_NAME( "prvSendCallbackEvent" );
- OTA_EventMsg_t xEventMsg = { 0 };
- BaseType_t xErr = pdFALSE;
- OTA_EventData_t * pxData;
+ OTA_EventMsg_t xEventMsg = { 0 };
+ BaseType_t xErr = pdFALSE;
+ OTA_EventData_t * pxData;
/* Get the OTA agent context. */
OTA_AgentContext_t * pxAgentCtx = ( OTA_AgentContext_t * ) pvCallbackContext;
@@ -562,12 +562,12 @@ static void prvSendCallbackEvent( void * pvCallbackContext,
if( pxData != NULL )
{
memcpy( pxData->ucData, pxPublishData->u.message.info.pPayload, pxPublishData->u.message.info.payloadLength );
- pxData->ulDataLength = pxPublishData->u.message.info.payloadLength;
- xEventMsg.xEventId = xEventId;
+ pxData->ulDataLength = pxPublishData->u.message.info.payloadLength;
+ xEventMsg.xEventId = xEventId;
xEventMsg.pxEventData = pxData;
/* Send job document received event. */
- xErr = OTA_SignalEvent( &xEventMsg );
+ xErr = OTA_SignalEvent( &xEventMsg );
}
else
{
@@ -632,27 +632,27 @@ OTA_Err_t prvRequestJob_Mqtt( OTA_AgentContext_t * pxAgentCtx )
{
DEFINE_OTA_METHOD_NAME( "prvRequestJob_Mqtt" );
- char pcJobTopic[ OTA_MAX_TOPIC_LEN ];
+ char pcJobTopic[ OTA_MAX_TOPIC_LEN ];
static uint32_t ulReqCounter = 0;
- IotMqttError_t eResult;
- uint32_t ulMsgLen;
- uint16_t usTopicLen;
- OTA_Err_t xError = kOTA_Err_PublishFailed;
+ IotMqttError_t eResult;
+ uint32_t ulMsgLen;
+ uint16_t usTopicLen;
+ OTA_Err_t xError = kOTA_Err_PublishFailed;
/* The following buffer is big enough to hold a dynamically constructed $next/get job message.
* It contains a client token that is used to track how many requests have been made. */
- char pcMsg[ CONST_STRLEN( pcOTA_GetNextJob_MsgTemplate ) + U32_MAX_PLACES + otaconfigMAX_THINGNAME_LEN ];
+ char pcMsg[ CONST_STRLEN( pcOTA_GetNextJob_MsgTemplate ) + U32_MAX_PLACES + otaconfigMAX_THINGNAME_LEN ];
/* Subscribe to the OTA job notification topic. */
if( prvSubscribeToJobNotificationTopics( pxAgentCtx ) )
{
OTA_LOG_L1( "[%s] Request #%u\r\n", OTA_METHOD_NAME, ulReqCounter );
/*lint -e586 Intentionally using snprintf. */
- ulMsgLen = ( uint32_t ) snprintf( pcMsg,
- sizeof( pcMsg ),
- pcOTA_GetNextJob_MsgTemplate,
- ulReqCounter,
- pxAgentCtx->pcThingName );
+ ulMsgLen = ( uint32_t ) snprintf( pcMsg,
+ sizeof( pcMsg ),
+ pcOTA_GetNextJob_MsgTemplate,
+ ulReqCounter,
+ pxAgentCtx->pcThingName );
ulReqCounter++;
usTopicLen = ( uint16_t ) snprintf( pcJobTopic,
sizeof( pcJobTopic ),
@@ -702,13 +702,13 @@ OTA_Err_t prvUpdateJobStatus_Mqtt( OTA_AgentContext_t * pxAgentCtx,
DEFINE_OTA_METHOD_NAME( "prvUpdateJobStatus_Mqtt" );
/* A message size of zero means don't publish anything. */
- uint32_t ulMsgSize = 0;
+ uint32_t ulMsgSize = 0;
/* All job state transitions except streaming progress use QOS 1 since it is required to have status in the job document. */
- IotMqttQos_t eQOS = IOT_MQTT_QOS_1;
- char pcMsg[ OTA_STATUS_MSG_MAX_SIZE ];
+ IotMqttQos_t eQOS = IOT_MQTT_QOS_1;
+ char pcMsg[ OTA_STATUS_MSG_MAX_SIZE ];
/* Get the current file context. */
- OTA_FileContext_t * C = &( pxAgentCtx->pxOTA_Files[ pxAgentCtx->ulFileIndex ] );
+ OTA_FileContext_t * C = &( pxAgentCtx->pxOTA_Files[ pxAgentCtx->ulFileIndex ] );
if( eStatus == eJobStatus_InProgress )
{
@@ -756,20 +756,20 @@ OTA_Err_t prvInitFileTransfer_Mqtt( OTA_AgentContext_t * pxAgentCtx )
{
DEFINE_OTA_METHOD_NAME( "prvInitFileTransfer_Mqtt" );
- OTA_Err_t xResult = kOTA_Err_PublishFailed;
- char pcOTA_RxStreamTopic[ OTA_MAX_TOPIC_LEN ];
+ OTA_Err_t xResult = kOTA_Err_PublishFailed;
+ char pcOTA_RxStreamTopic[ OTA_MAX_TOPIC_LEN ];
IotMqttSubscription_t xOTAUpdateDataSubscription;
memset( &xOTAUpdateDataSubscription, 0, sizeof( xOTAUpdateDataSubscription ) );
- xOTAUpdateDataSubscription.qos = IOT_MQTT_QOS_0;
- xOTAUpdateDataSubscription.pTopicFilter = ( const char * ) pcOTA_RxStreamTopic;
- xOTAUpdateDataSubscription.callback.pCallbackContext = ( void * ) pxAgentCtx; /*lint !e923 The publish callback context is implementing data hiding with a void* type.*/
- xOTAUpdateDataSubscription.callback.function = prvDataPublishCallback;
- xOTAUpdateDataSubscription.topicFilterLength = ( uint16_t ) snprintf( pcOTA_RxStreamTopic, /*lint -e586 Intentionally using snprintf. */
- sizeof( pcOTA_RxStreamTopic ),
- pcOTA_StreamData_TopicTemplate,
- pxAgentCtx->pcThingName,
- ( const char * ) pxAgentCtx->pxOTA_Files->pucStreamName );
+ xOTAUpdateDataSubscription.qos = IOT_MQTT_QOS_0;
+ xOTAUpdateDataSubscription.pTopicFilter = ( const char * ) pcOTA_RxStreamTopic;
+ xOTAUpdateDataSubscription.callback.pCallbackContext = ( void * ) pxAgentCtx; /*lint !e923 The publish callback context is implementing data hiding with a void* type.*/
+ xOTAUpdateDataSubscription.callback.function = prvDataPublishCallback;
+ xOTAUpdateDataSubscription.topicFilterLength = ( uint16_t ) snprintf( pcOTA_RxStreamTopic, /*lint -e586 Intentionally using snprintf. */
+ sizeof( pcOTA_RxStreamTopic ),
+ pcOTA_StreamData_TopicTemplate,
+ pxAgentCtx->pcThingName,
+ ( const char * ) pxAgentCtx->pxOTA_Files->pucStreamName );
if( ( xOTAUpdateDataSubscription.topicFilterLength > 0U ) && ( xOTAUpdateDataSubscription.topicFilterLength < sizeof( pcOTA_RxStreamTopic ) ) )
{
@@ -802,19 +802,19 @@ OTA_Err_t prvRequestFileBlock_Mqtt( OTA_AgentContext_t * pxAgentCtx )
{
DEFINE_OTA_METHOD_NAME( "prvRequestFileBlock_Mqtt" );
- size_t xMsgSizeFromStream;
- uint32_t ulNumBlocks, ulBitmapLen;
- uint32_t ulMsgSizeToPublish = 0;
- uint32_t ulTopicLen = 0;
- IotMqttError_t eResult = IOT_MQTT_STATUS_PENDING;
- OTA_Err_t xErr = kOTA_Err_Uninitialized;
- char pcMsg[ OTA_REQUEST_MSG_MAX_SIZE ];
- char pcTopicBuffer[ OTA_MAX_TOPIC_LEN ];
+ size_t xMsgSizeFromStream;
+ uint32_t ulNumBlocks, ulBitmapLen;
+ uint32_t ulMsgSizeToPublish = 0;
+ uint32_t ulTopicLen = 0;
+ IotMqttError_t eResult = IOT_MQTT_STATUS_PENDING;
+ OTA_Err_t xErr = kOTA_Err_Uninitialized;
+ char pcMsg[ OTA_REQUEST_MSG_MAX_SIZE ];
+ char pcTopicBuffer[ OTA_MAX_TOPIC_LEN ];
/*
* Get the current file context.
*/
- OTA_FileContext_t * C = &( pxAgentCtx->pxOTA_Files[ pxAgentCtx->ulFileIndex ] );
+ OTA_FileContext_t * C = &( pxAgentCtx->pxOTA_Files[ pxAgentCtx->ulFileIndex ] );
/* Reset number of blocks requested. */
pxAgentCtx->ulNumOfBlocksToReceive = otaconfigMAX_NUM_BLOCKS_REQUEST;
@@ -850,11 +850,11 @@ OTA_Err_t prvRequestFileBlock_Mqtt( OTA_AgentContext_t * pxAgentCtx )
ulMsgSizeToPublish = ( uint32_t ) xMsgSizeFromStream;
/* Try to build the dynamic data REQUEST topic to publish to. */
- ulTopicLen = ( uint32_t ) snprintf( pcTopicBuffer, /*lint -e586 Intentionally using snprintf. */
- sizeof( pcTopicBuffer ),
- pcOTA_GetStream_TopicTemplate,
- pxAgentCtx->pcThingName,
- ( const char * ) C->pucStreamName );
+ ulTopicLen = ( uint32_t ) snprintf( pcTopicBuffer, /*lint -e586 Intentionally using snprintf. */
+ sizeof( pcTopicBuffer ),
+ pcOTA_GetStream_TopicTemplate,
+ pxAgentCtx->pcThingName,
+ ( const char * ) C->pucStreamName );
if( ( ulTopicLen > 0U ) && ( ulTopicLen < sizeof( pcTopicBuffer ) ) )
{
@@ -928,7 +928,7 @@ OTA_Err_t prvDecodeFileBlock_Mqtt( uint8_t * pucMessageBuffer,
vPortFree( *ppucPayload );
*ppucPayload = pucMessageBuffer;
- xErr = kOTA_Err_None;
+ xErr = kOTA_Err_None;
}
return xErr;
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c
index d845e20f2..4fcab618b 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c
@@ -163,12 +163,12 @@ static void _updatedCallbackWrapper( void * pArgument,
*
* API functions will fail if @ref shadow_function_init was not called.
*/
-static uint32_t _initCalled = 0U;
+static uint32_t _initCalled = 0U;
/**
* @brief Timeout used for MQTT operations.
*/
-uint32_t _AwsIotShadowMqttTimeoutMs = AWS_IOT_SHADOW_DEFAULT_MQTT_TIMEOUT_MS;
+uint32_t _AwsIotShadowMqttTimeoutMs = AWS_IOT_SHADOW_DEFAULT_MQTT_TIMEOUT_MS;
#if LIBRARY_LOG_LEVEL > IOT_LOG_NONE
@@ -339,7 +339,7 @@ static AwsIotShadowError_t _setCallbackCommon( IotMqttConnection_t mqttConnectio
const AwsIotShadowCallbackInfo_t * pCallbackInfo )
{
IOT_FUNCTION_ENTRY( AwsIotShadowError_t, AWS_IOT_SHADOW_SUCCESS );
- bool subscriptionMutexLocked = false;
+ bool subscriptionMutexLocked = false;
_shadowSubscription_t * pSubscription = NULL;
/* Check that AwsIotShadow_Init was called. */
@@ -349,12 +349,12 @@ static AwsIotShadowError_t _setCallbackCommon( IotMqttConnection_t mqttConnectio
}
/* Check parameters. */
- status = _validateThingNameFlags( _AwsIotShadow_IntToShadowOperationType( ( ( uint32_t ) type ) + SHADOW_OPERATION_COUNT ),
- pThingName,
- thingNameLength,
- 0,
- pCallbackInfo,
- NULL );
+ status = _validateThingNameFlags( _AwsIotShadow_IntToShadowOperationType( ( ( uint32_t ) type ) + SHADOW_OPERATION_COUNT ),
+ pThingName,
+ thingNameLength,
+ 0,
+ pCallbackInfo,
+ NULL );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -373,9 +373,9 @@ static AwsIotShadowError_t _setCallbackCommon( IotMqttConnection_t mqttConnectio
/* Check for an existing subscription. This function will attempt to allocate
* a new subscription if not found. */
- pSubscription = _AwsIotShadow_FindSubscription( pThingName,
- thingNameLength,
- true );
+ pSubscription = _AwsIotShadow_FindSubscription( pThingName,
+ thingNameLength,
+ true );
if( pSubscription == NULL )
{
@@ -475,27 +475,27 @@ static AwsIotShadowError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqt
AwsIotMqttFunction_t mqttOperation )
{
IOT_FUNCTION_ENTRY( AwsIotShadowError_t, AWS_IOT_SHADOW_SUCCESS );
- IotMqttError_t mqttStatus = IOT_MQTT_STATUS_PENDING;
- IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER;
- char * pTopicFilter = NULL;
- uint16_t operationTopicLength = 0;
+ IotMqttError_t mqttStatus = IOT_MQTT_STATUS_PENDING;
+ IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER;
+ char * pTopicFilter = NULL;
+ uint16_t operationTopicLength = 0;
/* Lookup table for Shadow callback suffixes. */
- const char * const pCallbackSuffix[ SHADOW_CALLBACK_COUNT ] =
+ const char * const pCallbackSuffix[ SHADOW_CALLBACK_COUNT ] =
{
SHADOW_DELTA_SUFFIX, /* Delta callback. */
SHADOW_UPDATED_SUFFIX /* Updated callback. */
};
/* Lookup table for Shadow callback suffix lengths. */
- const uint16_t pCallbackSuffixLength[ SHADOW_CALLBACK_COUNT ] =
+ const uint16_t pCallbackSuffixLength[ SHADOW_CALLBACK_COUNT ] =
{
SHADOW_DELTA_SUFFIX_LENGTH, /* Delta callback. */
SHADOW_UPDATED_SUFFIX_LENGTH /* Updated callback. */
};
/* Lookup table for Shadow callback function wrappers. */
- const AwsIotMqttCallbackFunction_t pCallbackWrapper[ SHADOW_CALLBACK_COUNT ] =
+ const AwsIotMqttCallbackFunction_t pCallbackWrapper[ SHADOW_CALLBACK_COUNT ] =
{
_deltaCallbackWrapper, /* Delta callback. */
_updatedCallbackWrapper, /* Updated callback. */
@@ -513,11 +513,11 @@ static AwsIotShadowError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqt
/* Generate the prefix portion of the Shadow callback topic filter. Both
* callbacks share the same callback as the Shadow Update operation. */
- status = _AwsIotShadow_GenerateShadowTopic( SHADOW_UPDATE,
- pSubscription->pThingName,
- pSubscription->thingNameLength,
- &pTopicFilter,
- &operationTopicLength );
+ status = _AwsIotShadow_GenerateShadowTopic( SHADOW_UPDATE,
+ pSubscription->pThingName,
+ pSubscription->thingNameLength,
+ &pTopicFilter,
+ &operationTopicLength );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -535,18 +535,18 @@ static AwsIotShadowError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqt
pTopicFilter );
/* Set the members of the MQTT subscription. */
- subscription.qos = IOT_MQTT_QOS_1;
- subscription.pTopicFilter = pTopicFilter;
- subscription.topicFilterLength = ( uint16_t ) ( operationTopicLength + pCallbackSuffixLength[ type ] );
+ subscription.qos = IOT_MQTT_QOS_1;
+ subscription.pTopicFilter = pTopicFilter;
+ subscription.topicFilterLength = ( uint16_t ) ( operationTopicLength + pCallbackSuffixLength[ type ] );
subscription.callback.pCallbackContext = NULL;
- subscription.callback.function = pCallbackWrapper[ type ];
+ subscription.callback.function = pCallbackWrapper[ type ];
/* Call the MQTT operation function. */
- mqttStatus = mqttOperation( mqttConnection,
- &subscription,
- 1,
- 0,
- _AwsIotShadowMqttTimeoutMs );
+ mqttStatus = mqttOperation( mqttConnection,
+ &subscription,
+ 1,
+ 0,
+ _AwsIotShadowMqttTimeoutMs );
/* Check the result of the MQTT operation. */
if( mqttStatus != IOT_MQTT_SUCCESS )
@@ -589,11 +589,11 @@ static AwsIotShadowError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqt
static void _callbackWrapperCommon( _shadowCallbackType_t type,
IotMqttCallbackParam_t * pMessage )
{
- AwsIotShadowCallbackInfo_t callbackInfo = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER;
+ AwsIotShadowCallbackInfo_t callbackInfo = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER;
AwsIotShadowCallbackParam_t callbackParam = { .callbackType = AWS_IOT_SHADOW_DELETE_COMPLETE };
- _shadowSubscription_t * pSubscription = NULL;
- const char * pThingName = NULL;
- size_t thingNameLength = 0;
+ _shadowSubscription_t * pSubscription = NULL;
+ const char * pThingName = NULL;
+ size_t thingNameLength = 0;
/* Parse the Thing Name from the topic. */
if( AwsIot_ParseThingName( pMessage->u.message.info.pTopicName,
@@ -607,9 +607,9 @@ static void _callbackWrapperCommon( _shadowCallbackType_t type,
/* Search for a matching subscription. */
IotMutex_Lock( &_AwsIotShadowSubscriptionsMutex );
- pSubscription = _AwsIotShadow_FindSubscription( pThingName,
- thingNameLength,
- false );
+ pSubscription = _AwsIotShadow_FindSubscription( pThingName,
+ thingNameLength,
+ false );
if( pSubscription == NULL )
{
@@ -623,18 +623,18 @@ static void _callbackWrapperCommon( _shadowCallbackType_t type,
/* Copy the subscription callback info, as the subscription may be modified
* when the subscriptions mutex is released. */
- callbackInfo = pSubscription->callbacks[ type ];
+ callbackInfo = pSubscription->callbacks[ type ];
IotMutex_Unlock( &_AwsIotShadowSubscriptionsMutex );
/* Set the callback type. Shadow callbacks are enumerated after the operations. */
- callbackParam.callbackType = _AwsIotShadow_IntToShadowCallbackType( ( ( uint32_t ) type ) + SHADOW_OPERATION_COUNT );
+ callbackParam.callbackType = _AwsIotShadow_IntToShadowCallbackType( ( ( uint32_t ) type ) + SHADOW_OPERATION_COUNT );
/* Set the remaining members of the callback param. */
- callbackParam.mqttConnection = pMessage->mqttConnection;
- callbackParam.pThingName = pThingName;
- callbackParam.thingNameLength = thingNameLength;
- callbackParam.u.callback.pDocument = pMessage->u.message.info.pPayload;
+ callbackParam.mqttConnection = pMessage->mqttConnection;
+ callbackParam.pThingName = pThingName;
+ callbackParam.thingNameLength = thingNameLength;
+ callbackParam.u.callback.pDocument = pMessage->u.message.info.pPayload;
callbackParam.u.callback.documentLength = pMessage->u.message.info.payloadLength;
/* Invoke the callback function. */
@@ -671,8 +671,8 @@ static void _updatedCallbackWrapper( void * pArgument,
AwsIotShadowError_t AwsIotShadow_Init( uint32_t mqttTimeoutMs )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
- bool listInitStatus = false;
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
+ bool listInitStatus = false;
if( _initCalled == 0U )
{
@@ -716,7 +716,7 @@ void AwsIotShadow_Cleanup( void )
{
if( _initCalled == 1U )
{
- _initCalled = 0U;
+ _initCalled = 0U;
/* Remove and free all items in the Shadow pending operation list. */
IotMutex_Lock( &( _AwsIotShadowPendingOperationsMutex ) );
@@ -829,7 +829,7 @@ AwsIotShadowError_t AwsIotShadow_DeleteSync( IotMqttConnection_t mqttConnection,
uint32_t flags,
uint32_t timeoutMs )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
AwsIotShadowOperation_t deleteOperation = AWS_IOT_SHADOW_OPERATION_INITIALIZER;
/* Set the waitable flag. */
@@ -873,12 +873,12 @@ AwsIotShadowError_t AwsIotShadow_GetAsync( IotMqttConnection_t mqttConnection,
}
/* Validate the Thing Name and flags for Shadow GET. */
- status = _validateThingNameFlags( SHADOW_GET,
- pGetInfo->pThingName,
- pGetInfo->thingNameLength,
- flags,
- pCallbackInfo,
- pGetOperation );
+ status = _validateThingNameFlags( SHADOW_GET,
+ pGetInfo->pThingName,
+ pGetInfo->thingNameLength,
+ flags,
+ pCallbackInfo,
+ pGetOperation );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -887,9 +887,9 @@ AwsIotShadowError_t AwsIotShadow_GetAsync( IotMqttConnection_t mqttConnection,
}
/* Validate the document info for Shadow GET. */
- status = _validateDocumentInfo( SHADOW_GET,
- flags,
- pGetInfo );
+ status = _validateDocumentInfo( SHADOW_GET,
+ flags,
+ pGetInfo );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -898,10 +898,10 @@ AwsIotShadowError_t AwsIotShadow_GetAsync( IotMqttConnection_t mqttConnection,
}
/* Allocate a new Shadow operation for GET. */
- status = _AwsIotShadow_CreateOperation( &pOperation,
- SHADOW_GET,
- flags,
- pCallbackInfo );
+ status = _AwsIotShadow_CreateOperation( &pOperation,
+ SHADOW_GET,
+ flags,
+ pCallbackInfo );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -927,11 +927,11 @@ AwsIotShadowError_t AwsIotShadow_GetAsync( IotMqttConnection_t mqttConnection,
/* Process the Shadow operation. This subscribes to any required topics and
* sends the MQTT message for the Shadow operation. */
- status = _AwsIotShadow_ProcessOperation( mqttConnection,
- pGetInfo->pThingName,
- pGetInfo->thingNameLength,
- pOperation,
- pGetInfo );
+ status = _AwsIotShadow_ProcessOperation( mqttConnection,
+ pGetInfo->pThingName,
+ pGetInfo->thingNameLength,
+ pOperation,
+ pGetInfo );
/* If the Shadow operation failed, clear the now invalid reference. */
if( ( status != AWS_IOT_SHADOW_STATUS_PENDING ) && ( pGetOperation != NULL ) )
@@ -951,7 +951,7 @@ AwsIotShadowError_t AwsIotShadow_GetSync( IotMqttConnection_t mqttConnection,
const char ** const pShadowDocument,
size_t * const pShadowDocumentLength )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
AwsIotShadowOperation_t getOperation = AWS_IOT_SHADOW_OPERATION_INITIALIZER;
/* Set the waitable flag. */
@@ -988,9 +988,9 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection
AwsIotShadowOperation_t * const pUpdateOperation )
{
IOT_FUNCTION_ENTRY( AwsIotShadowError_t, AWS_IOT_SHADOW_STATUS_PENDING );
- _shadowOperation_t * pOperation = NULL;
- const char * pClientToken = NULL;
- size_t clientTokenLength = 0;
+ _shadowOperation_t * pOperation = NULL;
+ const char * pClientToken = NULL;
+ size_t clientTokenLength = 0;
/* Check that AwsIotShadow_Init was called. */
if( _checkInit() == false )
@@ -999,12 +999,12 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection
}
/* Validate the Thing Name and flags for Shadow UPDATE. */
- status = _validateThingNameFlags( SHADOW_UPDATE,
- pUpdateInfo->pThingName,
- pUpdateInfo->thingNameLength,
- flags,
- pCallbackInfo,
- pUpdateOperation );
+ status = _validateThingNameFlags( SHADOW_UPDATE,
+ pUpdateInfo->pThingName,
+ pUpdateInfo->thingNameLength,
+ flags,
+ pCallbackInfo,
+ pUpdateOperation );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -1013,9 +1013,9 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection
}
/* Validate the document info for Shadow UPDATE. */
- status = _validateDocumentInfo( SHADOW_UPDATE,
- flags,
- pUpdateInfo );
+ status = _validateDocumentInfo( SHADOW_UPDATE,
+ flags,
+ pUpdateInfo );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -1035,10 +1035,10 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection
}
/* Allocate a new Shadow operation for UPDATE. */
- status = _AwsIotShadow_CreateOperation( &pOperation,
- SHADOW_UPDATE,
- flags,
- pCallbackInfo );
+ status = _AwsIotShadow_CreateOperation( &pOperation,
+ SHADOW_UPDATE,
+ flags,
+ pCallbackInfo );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -1053,7 +1053,7 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection
AwsIotShadow_Assert( pOperation->status == AWS_IOT_SHADOW_STATUS_PENDING );
/* Allocate memory for the client token. */
- pOperation->u.update.pClientToken = AwsIotShadow_MallocString( clientTokenLength );
+ pOperation->u.update.pClientToken = AwsIotShadow_MallocString( clientTokenLength );
if( pOperation->u.update.pClientToken == NULL )
{
@@ -1079,11 +1079,11 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection
/* Process the Shadow operation. This subscribes to any required topics and
* sends the MQTT message for the Shadow operation. */
- status = _AwsIotShadow_ProcessOperation( mqttConnection,
- pUpdateInfo->pThingName,
- pUpdateInfo->thingNameLength,
- pOperation,
- pUpdateInfo );
+ status = _AwsIotShadow_ProcessOperation( mqttConnection,
+ pUpdateInfo->pThingName,
+ pUpdateInfo->thingNameLength,
+ pOperation,
+ pUpdateInfo );
/* If the Shadow operation failed, clear the now invalid reference. */
if( ( status != AWS_IOT_SHADOW_STATUS_PENDING ) && ( pUpdateOperation != NULL ) )
@@ -1101,7 +1101,7 @@ AwsIotShadowError_t AwsIotShadow_UpdateSync( IotMqttConnection_t mqttConnection,
uint32_t flags,
uint32_t timeoutMs )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
AwsIotShadowOperation_t updateOperation = AWS_IOT_SHADOW_OPERATION_INITIALIZER;
/* Set the waitable flag. */
@@ -1196,7 +1196,7 @@ AwsIotShadowError_t AwsIotShadow_Wait( AwsIotShadowOperation_t operation,
if( ( operation->type == SHADOW_GET ) &&
( status == AWS_IOT_SHADOW_SUCCESS ) )
{
- *pShadowDocument = operation->u.get.pDocument;
+ *pShadowDocument = operation->u.get.pDocument;
*pShadowDocumentLength = operation->u.get.documentLength;
}
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c
index 49b38b1f7..b85f40b14 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c
@@ -175,7 +175,7 @@ static AwsIotShadowError_t _findSubscription( const char * pThingName,
* @brief List of active Shadow operations awaiting a response from the Shadow
* service.
*/
-IotListDouble_t _AwsIotShadowPendingOperations = { 0 };
+IotListDouble_t _AwsIotShadowPendingOperations = { 0 };
/**
* @brief Protects #_AwsIotShadowPendingOperations from concurrent access.
@@ -263,20 +263,20 @@ static bool _shadowOperationMatch( const IotLink_t * pOperationLink,
* must never be NULL. */
AwsIotShadow_Assert( pOperationLink != NULL );
- _shadowOperation_t * pOperation = IotLink_Container( _shadowOperation_t,
- pOperationLink,
- link );
- _operationMatchParams_t * pParam = ( _operationMatchParams_t * ) pMatch;
- _shadowSubscription_t * pSubscription = pOperation->pSubscription;
- const char * pClientToken = NULL;
- size_t clientTokenLength = 0;
+ _shadowOperation_t * pOperation = IotLink_Container( _shadowOperation_t,
+ pOperationLink,
+ link );
+ _operationMatchParams_t * pParam = ( _operationMatchParams_t * ) pMatch;
+ _shadowSubscription_t * pSubscription = pOperation->pSubscription;
+ const char * pClientToken = NULL;
+ size_t clientTokenLength = 0;
/* Check for matching Thing Name and operation type. */
- bool match = ( pOperation->type == pParam->type ) &&
- ( pParam->thingNameLength == pSubscription->thingNameLength ) &&
- ( strncmp( pParam->pThingName,
- pSubscription->pThingName,
- pParam->thingNameLength ) == 0 );
+ bool match = ( pOperation->type == pParam->type ) &&
+ ( pParam->thingNameLength == pSubscription->thingNameLength ) &&
+ ( strncmp( pParam->pThingName,
+ pSubscription->pThingName,
+ pParam->thingNameLength ) == 0 );
/* For a Shadow UPDATE operation, compare the client tokens. */
if( ( match == true ) && ( pOperation->type == SHADOW_UPDATE ) )
@@ -321,11 +321,11 @@ static bool _shadowOperationMatch( const IotLink_t * pOperationLink,
static void _commonOperationCallback( _shadowOperationType_t type,
IotMqttCallbackParam_t * pMessage )
{
- _shadowOperation_t * pOperation = NULL;
- IotLink_t * pOperationLink = NULL;
- AwsIotStatus_t status = AWS_IOT_UNKNOWN;
- _operationMatchParams_t param = { .type = SHADOW_DELETE };
- uint32_t flags = 0;
+ _shadowOperation_t * pOperation = NULL;
+ IotLink_t * pOperationLink = NULL;
+ AwsIotStatus_t status = AWS_IOT_UNKNOWN;
+ _operationMatchParams_t param = { .type = SHADOW_DELETE };
+ uint32_t flags = 0;
/* Set operation type to search. */
param.type = type;
@@ -333,7 +333,7 @@ static void _commonOperationCallback( _shadowOperationType_t type,
/* Set the response document for a Shadow UPDATE. */
if( type == SHADOW_UPDATE )
{
- param.pDocument = pMessage->u.message.info.pPayload;
+ param.pDocument = pMessage->u.message.info.pPayload;
param.documentLength = pMessage->u.message.info.payloadLength;
}
@@ -383,8 +383,8 @@ static void _commonOperationCallback( _shadowOperationType_t type,
pMessage->u.message.info.pTopicName );
/* Parse the status from the topic name. */
- status = AwsIot_ParseStatus( pMessage->u.message.info.pTopicName,
- pMessage->u.message.info.topicNameLength );
+ status = AwsIot_ParseStatus( pMessage->u.message.info.pTopicName,
+ pMessage->u.message.info.topicNameLength );
switch( status )
{
@@ -428,7 +428,7 @@ static void _commonOperationCallback( _shadowOperationType_t type,
}
/* Copy the flags from the Shadow operation. The notify function may delete the operation. */
- flags = pOperation->flags;
+ flags = pOperation->flags;
/* Notify of operation completion. */
_notifyCompletion( pOperation );
@@ -479,7 +479,7 @@ static AwsIotShadowError_t _processAcceptedGet( _shadowOperation_t * pOperation,
* info. */
if( ( pOperation->flags & AWS_IOT_SHADOW_FLAG_WAITABLE ) == 0U )
{
- pOperation->u.get.pDocument = pPublishInfo->pPayload;
+ pOperation->u.get.pDocument = pPublishInfo->pPayload;
pOperation->u.get.documentLength = pPublishInfo->payloadLength;
}
else
@@ -526,8 +526,8 @@ static void _updateCallback( void * pArgument,
static void _notifyCompletion( _shadowOperation_t * pOperation )
{
- AwsIotShadowCallbackParam_t callbackParam = { .callbackType = AWS_IOT_SHADOW_DELETE_COMPLETE };
- _shadowSubscription_t * pSubscription = pOperation->pSubscription,
+ AwsIotShadowCallbackParam_t callbackParam = { .callbackType = AWS_IOT_SHADOW_DELETE_COMPLETE };
+ _shadowSubscription_t * pSubscription = pOperation->pSubscription,
* pRemovedSubscription = NULL;
/* If the operation is waiting, post to its wait semaphore and return. */
@@ -558,17 +558,17 @@ static void _notifyCompletion( _shadowOperation_t * pOperation )
if( pOperation->notify.callback.function != NULL )
{
/* Set the common members of the callback parameter. */
- callbackParam.callbackType = _AwsIotShadow_IntToShadowCallbackType( ( uint32_t ) pOperation->type );
- callbackParam.mqttConnection = pOperation->mqttConnection;
- callbackParam.u.operation.result = pOperation->status;
+ callbackParam.callbackType = _AwsIotShadow_IntToShadowCallbackType( ( uint32_t ) pOperation->type );
+ callbackParam.mqttConnection = pOperation->mqttConnection;
+ callbackParam.u.operation.result = pOperation->status;
callbackParam.u.operation.reference = pOperation;
- callbackParam.pThingName = pSubscription->pThingName;
- callbackParam.thingNameLength = pSubscription->thingNameLength;
+ callbackParam.pThingName = pSubscription->pThingName;
+ callbackParam.thingNameLength = pSubscription->thingNameLength;
/* Set the members of the callback parameter for a received document. */
if( pOperation->type == SHADOW_GET )
{
- callbackParam.u.operation.get.pDocument = pOperation->u.get.pDocument;
+ callbackParam.u.operation.get.pDocument = pOperation->u.get.pDocument;
callbackParam.u.operation.get.documentLength = pOperation->u.get.documentLength;
}
@@ -595,8 +595,8 @@ static AwsIotShadowError_t _findSubscription( const char * pThingName,
_shadowOperation_t * pOperation,
bool * pFreeTopicBuffer )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
- _shadowSubscription_t * pSubscription = NULL;
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
+ _shadowSubscription_t * pSubscription = NULL;
/* Lookup table for Shadow operation callbacks. */
const AwsIotMqttCallbackFunction_t shadowCallbacks[ SHADOW_OPERATION_COUNT ] =
@@ -638,7 +638,7 @@ static AwsIotShadowError_t _findSubscription( const char * pThingName,
pSubscription->pTopicBuffer = pTopicBuffer;
/* Don't free the topic buffer if it was allocated to the subscription. */
- *pFreeTopicBuffer = false;
+ *pFreeTopicBuffer = false;
}
else
{
@@ -647,10 +647,10 @@ static AwsIotShadowError_t _findSubscription( const char * pThingName,
/* Increment the reference count for this Shadow operation's
* subscriptions. */
- status = _AwsIotShadow_IncrementReferences( pOperation,
- pTopicBuffer,
- operationTopicLength,
- shadowCallbacks[ pOperation->type ] );
+ status = _AwsIotShadow_IncrementReferences( pOperation,
+ pTopicBuffer,
+ operationTopicLength,
+ shadowCallbacks[ pOperation->type ] );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -674,7 +674,7 @@ AwsIotShadowError_t _AwsIotShadow_CreateOperation( _shadowOperation_t ** pNewOpe
uint32_t flags,
const AwsIotShadowCallbackInfo_t * pCallbackInfo )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
_shadowOperation_t * pOperation = NULL;
IotLogDebug( "Creating operation record for Shadow %s.",
@@ -689,12 +689,12 @@ AwsIotShadowError_t _AwsIotShadow_CreateOperation( _shadowOperation_t ** pNewOpe
( void ) memset( pOperation, 0x00, sizeof( _shadowOperation_t ) );
/* Set the remaining common members of the Shadow operation. */
- pOperation->type = type;
- pOperation->flags = flags;
+ pOperation->type = type;
+ pOperation->flags = flags;
pOperation->status = AWS_IOT_SHADOW_STATUS_PENDING;
/* Set the output parameter. */
- *pNewOperation = pOperation;
+ *pNewOperation = pOperation;
/* Check if the waitable flag is set. If it is, create a semaphore to
* wait on. */
@@ -707,7 +707,7 @@ AwsIotShadowError_t _AwsIotShadow_CreateOperation( _shadowOperation_t ** pNewOpe
*pNewOperation = NULL;
AwsIotShadow_FreeOperation( pOperation );
- status = AWS_IOT_SHADOW_NO_MEMORY;
+ status = AWS_IOT_SHADOW_NO_MEMORY;
}
}
else
@@ -771,11 +771,11 @@ AwsIotShadowError_t _AwsIotShadow_GenerateShadowTopic( _shadowOperationType_t ty
char ** pTopicBuffer,
uint16_t * pOperationTopicLength )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
- AwsIotTopicInfo_t topicInfo = { 0 };
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
+ AwsIotTopicInfo_t topicInfo = { 0 };
/* Lookup table for Shadow operation strings. */
- const char * const pOperationString[ SHADOW_OPERATION_COUNT ] =
+ const char * const pOperationString[ SHADOW_OPERATION_COUNT ] =
{
SHADOW_DELETE_OPERATION_STRING, /* Shadow delete operation. */
SHADOW_GET_OPERATION_STRING, /* Shadow get operation. */
@@ -783,7 +783,7 @@ AwsIotShadowError_t _AwsIotShadow_GenerateShadowTopic( _shadowOperationType_t ty
};
/* Lookup table for Shadow operation string lengths. */
- const uint16_t pOperationStringLength[ SHADOW_OPERATION_COUNT ] =
+ const uint16_t pOperationStringLength[ SHADOW_OPERATION_COUNT ] =
{
SHADOW_DELETE_OPERATION_STRING_LENGTH, /* Shadow delete operation. */
SHADOW_GET_OPERATION_STRING_LENGTH, /* Shadow get operation. */
@@ -797,12 +797,12 @@ AwsIotShadowError_t _AwsIotShadow_GenerateShadowTopic( _shadowOperationType_t ty
( type == SHADOW_UPDATE ) );
/* Set the members needed to generate an operation topic. */
- topicInfo.pThingName = pThingName;
- topicInfo.thingNameLength = thingNameLength;
- topicInfo.pOperationName = pOperationString[ type ];
+ topicInfo.pThingName = pThingName;
+ topicInfo.thingNameLength = thingNameLength;
+ topicInfo.pOperationName = pOperationString[ type ];
topicInfo.operationNameLength = pOperationStringLength[ type ];
topicInfo.longestSuffixLength = SHADOW_LONGEST_SUFFIX_LENGTH;
- topicInfo.mallocString = AwsIotShadow_MallocString;
+ topicInfo.mallocString = AwsIotShadow_MallocString;
if( AwsIot_GenerateOperationTopic( &topicInfo,
pTopicBuffer,
@@ -822,12 +822,12 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn
_shadowOperation_t * pOperation,
const AwsIotShadowDocumentInfo_t * pDocumentInfo )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
- IotMqttError_t publishStatus = IOT_MQTT_STATUS_PENDING;
- char * pTopicBuffer = NULL;
- uint16_t operationTopicLength = 0;
- bool freeTopicBuffer = true;
- IotMqttPublishInfo_t publishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER;
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
+ IotMqttError_t publishStatus = IOT_MQTT_STATUS_PENDING;
+ char * pTopicBuffer = NULL;
+ uint16_t operationTopicLength = 0;
+ bool freeTopicBuffer = true;
+ IotMqttPublishInfo_t publishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER;
IotLogDebug( "Processing Shadow operation %s for Thing %.*s.",
_pAwsIotShadowOperationNames[ pOperation->type ],
@@ -838,11 +838,11 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn
pOperation->mqttConnection = mqttConnection;
/* Generate the operation topic buffer. */
- status = _AwsIotShadow_GenerateShadowTopic( pOperation->type,
- pThingName,
- thingNameLength,
- &pTopicBuffer,
- &operationTopicLength );
+ status = _AwsIotShadow_GenerateShadowTopic( pOperation->type,
+ pThingName,
+ thingNameLength,
+ &pTopicBuffer,
+ &operationTopicLength );
if( status == AWS_IOT_SHADOW_SUCCESS )
{
@@ -864,7 +864,7 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn
if( status == AWS_IOT_SHADOW_SUCCESS )
{
/* Set the operation topic name. */
- publishInfo.pTopicName = pTopicBuffer;
+ publishInfo.pTopicName = pTopicBuffer;
publishInfo.topicNameLength = operationTopicLength;
IotLogDebug( "Shadow %s message will be published to topic %.*s",
@@ -875,9 +875,9 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn
/* Set the document info if this operation is not a Shadow DELETE. */
if( pOperation->type != SHADOW_DELETE )
{
- publishInfo.qos = pDocumentInfo->qos;
+ publishInfo.qos = pDocumentInfo->qos;
publishInfo.retryLimit = pDocumentInfo->retryLimit;
- publishInfo.retryMs = pDocumentInfo->retryMs;
+ publishInfo.retryMs = pDocumentInfo->retryMs;
IotLogDebug( "Shadow %s message will be published at QoS %d with "
"retryLimit %d and retryMs %llu.",
@@ -890,7 +890,7 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn
/* Set the PUBLISH payload to the update document for Shadow UPDATE. */
if( pOperation->type == SHADOW_UPDATE )
{
- publishInfo.pPayload = pDocumentInfo->u.update.pUpdateDocument;
+ publishInfo.pPayload = pDocumentInfo->u.update.pUpdateDocument;
publishInfo.payloadLength = pDocumentInfo->u.update.updateDocumentLength;
}
@@ -898,7 +898,7 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn
* per the Shadow spec. */
else
{
- publishInfo.pPayload = "";
+ publishInfo.pPayload = "";
publishInfo.payloadLength = 0;
}
@@ -909,10 +909,10 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn
IotMutex_Unlock( &( _AwsIotShadowPendingOperationsMutex ) );
/* Publish to the Shadow topic name. */
- publishStatus = IotMqtt_PublishSync( pOperation->mqttConnection,
- &publishInfo,
- 0,
- _AwsIotShadowMqttTimeoutMs );
+ publishStatus = IotMqtt_PublishSync( pOperation->mqttConnection,
+ &publishInfo,
+ 0,
+ _AwsIotShadowMqttTimeoutMs );
if( publishStatus == IOT_MQTT_SUCCESS )
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c
index f079dd4ea..ee10fa56d 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c
@@ -131,9 +131,9 @@ AwsIotShadowError_t _AwsIotShadow_ParseErrorDocument( const char * pErrorDocumen
size_t errorDocumentLength )
{
AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
- const char * pCode = NULL, * pMessage = NULL;
- size_t codeLength = 0, messageLength = 0;
- uint32_t code = 0;
+ const char * pCode = NULL, * pMessage = NULL;
+ size_t codeLength = 0, messageLength = 0;
+ uint32_t code = 0;
/* Parse the code from the error document. */
if( AwsIotDocParser_FindValue( pErrorDocument,
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c
index 98dd9273d..3dcf6082b 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c
@@ -32,15 +32,15 @@
#if IOT_STATIC_MEMORY_ONLY == 1
/* Standard includes. */
-#include <stdbool.h>
-#include <stddef.h>
-#include <string.h>
+ #include <stdbool.h>
+ #include <stddef.h>
+ #include <string.h>
/* Static memory include. */
-#include "iot_static_memory.h"
+ #include "iot_static_memory.h"
/* Shadow internal include. */
-#include "private/aws_iot_shadow_internal.h"
+ #include "private/aws_iot_shadow_internal.h"
/*-----------------------------------------------------------*/
@@ -50,21 +50,21 @@
*
* Provide default values for undefined configuration constants.
*/
-#ifndef AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS
- #define AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ( 10 )
-#endif
-#ifndef AWS_IOT_SHADOW_SUBSCRIPTIONS
- #define AWS_IOT_SHADOW_SUBSCRIPTIONS ( 2 )
-#endif
+ #ifndef AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS
+ #define AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ( 10 )
+ #endif
+ #ifndef AWS_IOT_SHADOW_SUBSCRIPTIONS
+ #define AWS_IOT_SHADOW_SUBSCRIPTIONS ( 2 )
+ #endif
/** @endcond */
/* Validate static memory configuration settings. */
-#if AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS <= 0
- #error "AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS cannot be 0 or negative."
-#endif
-#if AWS_IOT_SHADOW_SUBSCRIPTIONS <= 0
- #error "AWS_IOT_SHADOW_SUBSCRIPTIONS cannot be 0 or negative."
-#endif
+ #if AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS <= 0
+ #error "AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS cannot be 0 or negative."
+ #endif
+ #if AWS_IOT_SHADOW_SUBSCRIPTIONS <= 0
+ #error "AWS_IOT_SHADOW_SUBSCRIPTIONS cannot be 0 or negative."
+ #endif
/**
* @brief The size of a static memory Shadow subscription.
@@ -73,88 +73,88 @@
* the constant `AWS_IOT_MAX_THING_NAME_LENGTH` is used for the length of
* #_shadowSubscription_t.pThingName.
*/
-#define SHADOW_SUBSCRIPTION_SIZE ( sizeof( _shadowSubscription_t ) + ( size_t ) AWS_IOT_MAX_THING_NAME_LENGTH )
+ #define SHADOW_SUBSCRIPTION_SIZE ( sizeof( _shadowSubscription_t ) + ( size_t ) AWS_IOT_MAX_THING_NAME_LENGTH )
/*-----------------------------------------------------------*/
/*
* Static memory buffers and flags, allocated and zeroed at compile-time.
*/
-static uint32_t _pInUseShadowOperations[ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ] = { 0U }; /**< @brief Shadow operation in-use flags. */
-static _shadowOperation_t _pShadowOperations[ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ] = { { .link = { 0 } } }; /**< @brief Shadow operations. */
+ static uint32_t _pInUseShadowOperations[ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ] = { 0U }; /**< @brief Shadow operation in-use flags. */
+ static _shadowOperation_t _pShadowOperations[ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ] = { { .link = { 0 } } }; /**< @brief Shadow operations. */
-static uint32_t _pInUseShadowSubscriptions[ AWS_IOT_SHADOW_SUBSCRIPTIONS ] = { 0U }; /**< @brief Shadow subscription in-use flags. */
-static char _pShadowSubscriptions[ AWS_IOT_SHADOW_SUBSCRIPTIONS ][ SHADOW_SUBSCRIPTION_SIZE ] = { { '\0' } }; /**< @brief Shadow subscriptions. */
+ static uint32_t _pInUseShadowSubscriptions[ AWS_IOT_SHADOW_SUBSCRIPTIONS ] = { 0U }; /**< @brief Shadow subscription in-use flags. */
+ static char _pShadowSubscriptions[ AWS_IOT_SHADOW_SUBSCRIPTIONS ][ SHADOW_SUBSCRIPTION_SIZE ] = { { '\0' } }; /**< @brief Shadow subscriptions. */
/*-----------------------------------------------------------*/
-void * AwsIotShadow_MallocOperation( size_t size )
-{
- int32_t freeIndex = -1;
- void * pNewOperation = NULL;
-
- /* Check size argument. */
- if( size == sizeof( _shadowOperation_t ) )
+ void * AwsIotShadow_MallocOperation( size_t size )
{
- /* Find a free Shadow operation. */
- freeIndex = IotStaticMemory_FindFree( _pInUseShadowOperations,
- AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS );
+ int32_t freeIndex = -1;
+ void * pNewOperation = NULL;
- if( freeIndex != -1 )
+ /* Check size argument. */
+ if( size == sizeof( _shadowOperation_t ) )
{
- pNewOperation = &( _pShadowOperations[ freeIndex ] );
+ /* Find a free Shadow operation. */
+ freeIndex = IotStaticMemory_FindFree( _pInUseShadowOperations,
+ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS );
+
+ if( freeIndex != -1 )
+ {
+ pNewOperation = &( _pShadowOperations[ freeIndex ] );
+ }
}
- }
- return pNewOperation;
-}
+ return pNewOperation;
+ }
/*-----------------------------------------------------------*/
-void AwsIotShadow_FreeOperation( void * ptr )
-{
- /* Return the in-use Shadow operation. */
- IotStaticMemory_ReturnInUse( ptr,
- _pShadowOperations,
- _pInUseShadowOperations,
- AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS,
- sizeof( _shadowOperation_t ) );
-}
+ void AwsIotShadow_FreeOperation( void * ptr )
+ {
+ /* Return the in-use Shadow operation. */
+ IotStaticMemory_ReturnInUse( ptr,
+ _pShadowOperations,
+ _pInUseShadowOperations,
+ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS,
+ sizeof( _shadowOperation_t ) );
+ }
/*-----------------------------------------------------------*/
-void * AwsIotShadow_MallocSubscription( size_t size )
-{
- int32_t freeIndex = -1;
- void * pNewSubscription = NULL;
-
- if( size <= SHADOW_SUBSCRIPTION_SIZE )
+ void * AwsIotShadow_MallocSubscription( size_t size )
{
- /* Get the index of a free Shadow subscription. */
- freeIndex = IotStaticMemory_FindFree( _pInUseShadowSubscriptions,
- AWS_IOT_SHADOW_SUBSCRIPTIONS );
+ int32_t freeIndex = -1;
+ void * pNewSubscription = NULL;
- if( freeIndex != -1 )
+ if( size <= SHADOW_SUBSCRIPTION_SIZE )
{
- pNewSubscription = &( _pShadowSubscriptions[ freeIndex ][ 0 ] );
+ /* Get the index of a free Shadow subscription. */
+ freeIndex = IotStaticMemory_FindFree( _pInUseShadowSubscriptions,
+ AWS_IOT_SHADOW_SUBSCRIPTIONS );
+
+ if( freeIndex != -1 )
+ {
+ pNewSubscription = &( _pShadowSubscriptions[ freeIndex ][ 0 ] );
+ }
}
- }
- return pNewSubscription;
-}
+ return pNewSubscription;
+ }
/*-----------------------------------------------------------*/
-void AwsIotShadow_FreeSubscription( void * ptr )
-{
- /* Return the in-use Shadow subscription. */
- IotStaticMemory_ReturnInUse( ptr,
- _pShadowSubscriptions,
- _pInUseShadowSubscriptions,
- AWS_IOT_SHADOW_SUBSCRIPTIONS,
- SHADOW_SUBSCRIPTION_SIZE );
-}
+ void AwsIotShadow_FreeSubscription( void * ptr )
+ {
+ /* Return the in-use Shadow subscription. */
+ IotStaticMemory_ReturnInUse( ptr,
+ _pShadowSubscriptions,
+ _pInUseShadowSubscriptions,
+ AWS_IOT_SHADOW_SUBSCRIPTIONS,
+ SHADOW_SUBSCRIPTION_SIZE );
+ }
/*-----------------------------------------------------------*/
-#endif
+#endif /* if IOT_STATIC_MEMORY_ONLY == 1 */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c
index fd15a7054..0a8818e9d 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c
@@ -72,7 +72,7 @@ IotMutex_t _AwsIotShadowSubscriptionsMutex;
static bool _shadowSubscription_match( const IotLink_t * pSubscriptionLink,
void * pMatch )
{
- bool match = false;
+ bool match = false;
/* Because this function is called from a container function, the given link
* must never be NULL. */
@@ -81,7 +81,7 @@ static bool _shadowSubscription_match( const IotLink_t * pSubscriptionLink,
const _shadowSubscription_t * pSubscription = IotLink_Container( _shadowSubscription_t,
pSubscriptionLink,
link );
- const AwsIotThingName_t * pThingName = ( AwsIotThingName_t * ) pMatch;
+ const AwsIotThingName_t * pThingName = ( AwsIotThingName_t * ) pMatch;
if( pThingName->thingNameLength == pSubscription->thingNameLength )
{
@@ -100,18 +100,18 @@ _shadowSubscription_t * _AwsIotShadow_FindSubscription( const char * pThingName,
size_t thingNameLength,
bool createIfNotFound )
{
- _shadowSubscription_t * pSubscription = NULL;
- IotLink_t * pSubscriptionLink = NULL;
- AwsIotThingName_t thingName = { 0 };
+ _shadowSubscription_t * pSubscription = NULL;
+ IotLink_t * pSubscriptionLink = NULL;
+ AwsIotThingName_t thingName = { 0 };
- thingName.pThingName = pThingName;
+ thingName.pThingName = pThingName;
thingName.thingNameLength = thingNameLength;
/* Search the list for an existing subscription for Thing Name. */
- pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotShadowSubscriptions ),
- NULL,
- _shadowSubscription_match,
- &thingName );
+ pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotShadowSubscriptions ),
+ NULL,
+ _shadowSubscription_match,
+ &thingName );
/* Check if a subscription was found. */
if( pSubscriptionLink == NULL )
@@ -163,8 +163,8 @@ _shadowSubscription_t * _AwsIotShadow_FindSubscription( const char * pThingName,
void _AwsIotShadow_RemoveSubscription( _shadowSubscription_t * pSubscription,
_shadowSubscription_t ** pRemovedSubscription )
{
- int32_t i = 0;
- bool removeSubscription = true;
+ int32_t i = 0;
+ bool removeSubscription = true;
IotLogDebug( "Checking if subscription object for %.*s can be removed.",
pSubscription->thingNameLength,
@@ -272,11 +272,11 @@ AwsIotShadowError_t _AwsIotShadow_IncrementReferences( _shadowOperation_t * pOpe
uint16_t operationTopicLength,
AwsIotMqttCallbackFunction_t callback )
{
- AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
- const _shadowOperationType_t type = pOperation->type;
- _shadowSubscription_t * pSubscription = pOperation->pSubscription;
- IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING;
- AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS;
+ const _shadowOperationType_t type = pOperation->type;
+ _shadowSubscription_t * pSubscription = pOperation->pSubscription;
+ IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING;
+ AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
/* Do nothing if this operation has persistent subscriptions. */
if( pSubscription->references[ type ] == AWS_IOT_PERSISTENT_SUBSCRIPTION )
@@ -297,17 +297,17 @@ AwsIotShadowError_t _AwsIotShadow_IncrementReferences( _shadowOperation_t * pOpe
if( pSubscription->references[ type ] == 0 )
{
/* Set the parameters needed to add subscriptions. */
- subscriptionInfo.mqttConnection = pOperation->mqttConnection;
- subscriptionInfo.callbackFunction = callback;
- subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs;
- subscriptionInfo.pTopicFilterBase = pTopicBuffer;
+ subscriptionInfo.mqttConnection = pOperation->mqttConnection;
+ subscriptionInfo.callbackFunction = callback;
+ subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs;
+ subscriptionInfo.pTopicFilterBase = pTopicBuffer;
subscriptionInfo.topicFilterBaseLength = operationTopicLength;
- subscriptionStatus = AwsIot_ModifySubscriptions( IotMqtt_SubscribeSync,
- &subscriptionInfo );
+ subscriptionStatus = AwsIot_ModifySubscriptions( IotMqtt_SubscribeSync,
+ &subscriptionInfo );
/* Convert MQTT return code to Shadow return code. */
- status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( subscriptionStatus );
+ status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( subscriptionStatus );
}
if( status == AWS_IOT_SHADOW_SUCCESS )
@@ -346,10 +346,10 @@ void _AwsIotShadow_DecrementReferences( _shadowOperation_t * pOperation,
char * pTopicBuffer,
_shadowSubscription_t ** pRemovedSubscription )
{
- const _shadowOperationType_t type = pOperation->type;
- _shadowSubscription_t * pSubscription = pOperation->pSubscription;
- uint16_t operationTopicLength = 0;
- AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
+ const _shadowOperationType_t type = pOperation->type;
+ _shadowSubscription_t * pSubscription = pOperation->pSubscription;
+ uint16_t operationTopicLength = 0;
+ AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
/* Do nothing if this Shadow operation has persistent subscriptions. */
if( pSubscription->references[ type ] != AWS_IOT_PERSISTENT_SUBSCRIPTION )
@@ -379,9 +379,9 @@ void _AwsIotShadow_DecrementReferences( _shadowOperation_t * pOperation,
&operationTopicLength );
/* Set the parameters needed to remove subscriptions. */
- subscriptionInfo.mqttConnection = pOperation->mqttConnection;
- subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs;
- subscriptionInfo.pTopicFilterBase = pTopicBuffer;
+ subscriptionInfo.mqttConnection = pOperation->mqttConnection;
+ subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs;
+ subscriptionInfo.pTopicFilterBase = pTopicBuffer;
subscriptionInfo.topicFilterBaseLength = operationTopicLength;
( void ) AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync,
@@ -409,16 +409,16 @@ AwsIotShadowError_t AwsIotShadow_RemovePersistentSubscriptions( IotMqttConnectio
size_t thingNameLength,
uint32_t flags )
{
- uint32_t i = 0;
- uint16_t operationTopicLength = 0;
- AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
- IotMqttError_t unsubscribeStatus = IOT_MQTT_STATUS_PENDING;
- AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
- _shadowSubscription_t * pSubscription = NULL;
- IotLink_t * pSubscriptionLink = NULL;
- AwsIotThingName_t thingName = { 0 };
-
- thingName.pThingName = pThingName;
+ uint32_t i = 0;
+ uint16_t operationTopicLength = 0;
+ AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING;
+ IotMqttError_t unsubscribeStatus = IOT_MQTT_STATUS_PENDING;
+ AwsIotSubscriptionInfo_t subscriptionInfo = { 0 };
+ _shadowSubscription_t * pSubscription = NULL;
+ IotLink_t * pSubscriptionLink = NULL;
+ AwsIotThingName_t thingName = { 0 };
+
+ thingName.pThingName = pThingName;
thingName.thingNameLength = thingNameLength;
IotLogInfo( "Removing persistent subscriptions for %.*s.",
@@ -428,10 +428,10 @@ AwsIotShadowError_t AwsIotShadow_RemovePersistentSubscriptions( IotMqttConnectio
IotMutex_Lock( &( _AwsIotShadowSubscriptionsMutex ) );
/* Search the list for an existing subscription for Thing Name. */
- pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotShadowSubscriptions ),
- NULL,
- _shadowSubscription_match,
- &thingName );
+ pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotShadowSubscriptions ),
+ NULL,
+ _shadowSubscription_match,
+ &thingName );
/* Unsubscribe from operation subscriptions if found. */
if( pSubscriptionLink != NULL )
@@ -466,16 +466,16 @@ AwsIotShadowError_t AwsIotShadow_RemovePersistentSubscriptions( IotMqttConnectio
&operationTopicLength );
/* Set the parameters needed to remove subscriptions. */
- subscriptionInfo.mqttConnection = mqttConnection;
- subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs;
- subscriptionInfo.pTopicFilterBase = pSubscription->pTopicBuffer;
+ subscriptionInfo.mqttConnection = mqttConnection;
+ subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs;
+ subscriptionInfo.pTopicFilterBase = pSubscription->pTopicBuffer;
subscriptionInfo.topicFilterBaseLength = operationTopicLength;
- unsubscribeStatus = AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync,
- &subscriptionInfo );
+ unsubscribeStatus = AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync,
+ &subscriptionInfo );
/* Convert MQTT return code to Shadow return code. */
- status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( unsubscribeStatus );
+ status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( unsubscribeStatus );
if( status != AWS_IOT_SHADOW_SUCCESS )
{
@@ -484,7 +484,7 @@ AwsIotShadowError_t AwsIotShadow_RemovePersistentSubscriptions( IotMqttConnectio
/* Clear the persistent subscriptions flag and check if the
* subscription can be removed. */
- pSubscription->references[ i ] = 0;
+ pSubscription->references[ i ] = 0;
_AwsIotShadow_RemoveSubscription( pSubscription, NULL );
}
else
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h
index 2b9377dd6..6cd613cba 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h
@@ -377,11 +377,11 @@ typedef struct _shadowOperation
#endif
/* Declarations of variables for internal Shadow files. */
-extern uint32_t _AwsIotShadowMqttTimeoutMs;
-extern IotListDouble_t _AwsIotShadowPendingOperations;
-extern IotListDouble_t _AwsIotShadowSubscriptions;
-extern IotMutex_t _AwsIotShadowPendingOperationsMutex;
-extern IotMutex_t _AwsIotShadowSubscriptionsMutex;
+extern uint32_t _AwsIotShadowMqttTimeoutMs;
+extern IotListDouble_t _AwsIotShadowPendingOperations;
+extern IotListDouble_t _AwsIotShadowSubscriptions;
+extern IotMutex_t _AwsIotShadowPendingOperationsMutex;
+extern IotMutex_t _AwsIotShadowSubscriptionsMutex;
/*----------------------- Shadow operation functions ------------------------*/
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/platform/iot_threads.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/platform/iot_threads.h
index f3c65f37e..ed2501a07 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/platform/iot_threads.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/platform/iot_threads.h
@@ -146,7 +146,8 @@ bool Iot_CreateDetachedThread( IotThreadRoutine_t threadRoutine,
* @endcode
*/
/* @[declare_platform_threads_mutexcreate] */
-bool IotMutex_Create( IotMutex_t * pNewMutex, bool recursive );
+bool IotMutex_Create( IotMutex_t * pNewMutex,
+ bool recursive );
/* @[declare_platform_threads_mutexcreate] */
/**
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h
index 7f5bdf9bb..9af7e9552 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h
@@ -47,68 +47,68 @@
*/
#ifndef ATOMIC_H
-#define ATOMIC_H
+ #define ATOMIC_H
-#ifndef INC_FREERTOS_H
- #error "include FreeRTOS.h must appear in source files before include atomic.h"
-#endif
+ #ifndef INC_FREERTOS_H
+ #error "include FreeRTOS.h must appear in source files before include atomic.h"
+ #endif
/* Standard includes. */
-#include <stdint.h>
+ #include <stdint.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- /* Needed for __atomic_compare_exchange() weak=false. */
- #include <stdbool.h>
+/* Needed for __atomic_compare_exchange() weak=false. */
+ #include <stdbool.h>
- /* This branch is for GCC compiler and GCC compiler only. */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE inline __attribute__((always_inline))
- #endif
+/* This branch is for GCC compiler and GCC compiler only. */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE inline __attribute__( ( always_inline ) )
+ #endif
-#else
+ #else
- /* Port specific definitions -- entering/exiting critical section.
- * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
- *
- * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
- * ATOMIC_ENTER_CRITICAL().
- */
- #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
+/* Port specific definitions -- entering/exiting critical section.
+ * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
+ *
+ * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
+ * ATOMIC_ENTER_CRITICAL().
+ */
+ #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
- /* Nested interrupt scheme is supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() \
- UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
+/* Nested interrupt scheme is supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() \
+ UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
- #define ATOMIC_EXIT_CRITICAL() \
- portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
+ #define ATOMIC_EXIT_CRITICAL() \
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
- #else
+ #else
- /* Nested interrupt scheme is NOT supported in this port. */
- #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
- #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
+/* Nested interrupt scheme is NOT supported in this port. */
+ #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
+ #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
- #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
+ #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
- /* Port specific definition -- "always inline".
- * Inline is compiler specific, and may not always get inlined depending on your optimization level.
- * Also, inline is considered as performance optimization for atomic.
- * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
- * simply define it.
- */
- #ifndef portFORCE_INLINE
- #define portFORCE_INLINE
- #endif
+/* Port specific definition -- "always inline".
+ * Inline is compiler specific, and may not always get inlined depending on your optimization level.
+ * Also, inline is considered as performance optimization for atomic.
+ * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error,
+ * simply define it.
+ */
+ #ifndef portFORCE_INLINE
+ #define portFORCE_INLINE
+ #endif
-#endif /* configUSE_GCC_BUILTIN_ATOMICS */
+ #endif /* configUSE_GCC_BUILTIN_ATOMICS */
-#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
-#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
+ #define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
+ #define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
/*----------------------------- Swap && CAS ------------------------------*/
@@ -127,44 +127,36 @@ extern "C" {
* @note This function only swaps *pDestination with ulExchange, if previous
* *pDestination value equals ulComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
- uint32_t volatile * pDestination,
- uint32_t ulExchange,
- uint32_t ulComparand )
-{
-
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- if ( __atomic_compare_exchange( pDestination,
- &ulComparand,
- &ulExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pDestination,
+ uint32_t ulExchange,
+ uint32_t ulComparand )
{
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( pDestination,
+ &ulComparand,
+ &ulExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *pDestination == ulComparand )
+ {
+ *pDestination = ulExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *pDestination == ulComparand )
- {
- *pDestination = ulExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-
-}
-
/**
* Atomic swap (pointers)
*
@@ -177,30 +169,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32(
*
* @return The initial value of *ppDestination.
*/
-static portFORCE_INLINE void * Atomic_SwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange )
-{
- void * pReturnValue;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange )
+ {
+ void * pReturnValue;
- pReturnValue = *ppDestination;
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ __atomic_exchange( ppDestination, &pExchange, &pReturnValue, __ATOMIC_SEQ_CST );
+ #else
+ ATOMIC_ENTER_CRITICAL();
- *ppDestination = pExchange;
+ pReturnValue = *ppDestination;
- ATOMIC_EXIT_CRITICAL();
+ *ppDestination = pExchange;
-#endif
+ ATOMIC_EXIT_CRITICAL();
+ #endif
- return pReturnValue;
-}
+ return pReturnValue;
+ }
/**
* Atomic compare-and-swap (pointers)
@@ -218,40 +205,36 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32(
* @note This function only swaps *ppDestination with pExchange, if previous
* *ppDestination value equals pComparand.
*/
-static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
- void * volatile * ppDestination,
- void * pExchange, void * pComparand )
-{
- uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
-
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
- if ( __atomic_compare_exchange( ppDestination,
- &pComparand,
- &pExchange,
- false,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST ) )
- {
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
- }
-
-#else
-
- ATOMIC_ENTER_CRITICAL();
-
- if ( *ppDestination == pComparand )
+ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppDestination,
+ void * pExchange,
+ void * pComparand )
{
- *ppDestination = pExchange;
- ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
+
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ if( __atomic_compare_exchange( ppDestination,
+ &pComparand,
+ &pExchange,
+ false,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST ) )
+ {
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ #else
+ ATOMIC_ENTER_CRITICAL();
+
+ if( *ppDestination == pComparand )
+ {
+ *ppDestination = pExchange;
+ ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
+ }
+ ATOMIC_EXIT_CRITICAL();
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+
+ return ulReturnValue;
}
- ATOMIC_EXIT_CRITICAL();
-
-#endif
-
- return ulReturnValue;
-}
-
/*----------------------------- Arithmetic ------------------------------*/
@@ -266,30 +249,25 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Add_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic subtract
@@ -303,30 +281,25 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32(
*
* @return previous *pAddend value.
*/
-static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
- uint32_t volatile * pAddend,
- uint32_t ulCount )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, ulCount, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pAddend,
+ uint32_t ulCount )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, ulCount, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= ulCount;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= ulCount;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic increment
@@ -338,28 +311,24 @@ static portFORCE_INLINE uint32_t Atomic_Subtract_u32(
*
* @return *pAddend value before increment.
*/
-static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_add(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_add( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend += 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend += 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic decrement
@@ -371,28 +340,24 @@ static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAdde
*
* @return *pAddend value before decrement.
*/
-static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_sub(pAddend, 1, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_sub( pAddend, 1, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pAddend;
+ ATOMIC_ENTER_CRITICAL();
- *pAddend -= 1;
+ ulCurrent = *pAddend;
- ATOMIC_EXIT_CRITICAL();
+ *pAddend -= 1;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/*----------------------------- Bitwise Logical ------------------------------*/
@@ -407,30 +372,25 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_OR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_or(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_or( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination |= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination |= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic AND
@@ -443,30 +403,25 @@ static portFORCE_INLINE uint32_t Atomic_OR_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_AND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_and(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_and( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination &= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination &= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic NAND
@@ -479,30 +434,25 @@ static portFORCE_INLINE uint32_t Atomic_AND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_NAND_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_nand(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_nand( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination = ~(ulCurrent & ulValue);
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination = ~( ulCurrent & ulValue );
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
/**
* Atomic XOR
@@ -515,33 +465,28 @@ static portFORCE_INLINE uint32_t Atomic_NAND_u32(
*
* @return The original value of *pDestination.
*/
-static portFORCE_INLINE uint32_t Atomic_XOR_u32(
- uint32_t volatile * pDestination,
- uint32_t ulValue )
-{
-#if defined ( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
-
- return __atomic_fetch_xor(pDestination, ulValue, __ATOMIC_SEQ_CST);
-
-#else
-
- uint32_t ulCurrent;
-
- ATOMIC_ENTER_CRITICAL();
+ static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pDestination,
+ uint32_t ulValue )
+ {
+ #if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 )
+ return __atomic_fetch_xor( pDestination, ulValue, __ATOMIC_SEQ_CST );
+ #else
+ uint32_t ulCurrent;
- ulCurrent = *pDestination;
+ ATOMIC_ENTER_CRITICAL();
- *pDestination ^= ulValue;
+ ulCurrent = *pDestination;
- ATOMIC_EXIT_CRITICAL();
+ *pDestination ^= ulValue;
- return ulCurrent;
+ ATOMIC_EXIT_CRITICAL();
-#endif
-}
+ return ulCurrent;
+ #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */
+ }
-#ifdef __cplusplus
-}
-#endif
+ #ifdef __cplusplus
+ }
+ #endif
#endif /* ATOMIC_H */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_error.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_error.h
index 965d4b5bc..682beab92 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_error.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_error.h
@@ -50,7 +50,7 @@
* This macro should be placed at the end of a function and followed by
* #IOT_FUNCTION_CLEANUP_END.
*/
-#define IOT_FUNCTION_CLEANUP_BEGIN() iotCleanup:
+#define IOT_FUNCTION_CLEANUP_BEGIN() iotCleanup :
/**
* @brief Declares the end of a cleanup section.
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h
index 251ed94c8..ed9b6ed6e 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h
@@ -106,7 +106,7 @@ typedef IotLink_t IotDeQueue_t;
#error "Asserts are enabled for containers, but IotContainers_Assert is not defined"
#endif
#endif
-#else /* if IOT_CONTAINERS_ENABLE_ASSERTS == 1 */
+#else /* if IOT_CONTAINERS_ENABLE_ASSERTS == 1 */
#define IotContainers_Assert( expression )
#endif /* if IOT_CONTAINERS_ENABLE_ASSERTS == 1 */
@@ -243,7 +243,7 @@ static inline void IotListDouble_Create( IotListDouble_t * const pList )
/* An empty list is a link pointing to itself. */
pList->pPrevious = pList;
- pList->pNext = pList;
+ pList->pNext = pList;
}
/**
@@ -363,12 +363,12 @@ static inline void IotListDouble_InsertHead( IotListDouble_t * const pList,
IotLink_t * pHead = pList->pNext;
/* Place new element before list head. */
- pLink->pNext = pHead;
+ pLink->pNext = pHead;
pLink->pPrevious = pList;
/* Assign new list head. */
pHead->pPrevious = pLink;
- pList->pNext = pLink;
+ pList->pNext = pLink;
}
/**
@@ -389,11 +389,11 @@ static inline void IotListDouble_InsertTail( IotListDouble_t * const pList,
/* Save current list tail. */
IotLink_t * pTail = pList->pPrevious;
- pLink->pNext = pList;
+ pLink->pNext = pList;
pLink->pPrevious = pTail;
pList->pPrevious = pLink;
- pTail->pNext = pLink;
+ pTail->pNext = pLink;
}
/**
@@ -442,7 +442,7 @@ static inline void IotListDouble_InsertAfter( IotLink_t * const pElement,
/* @[declare_linear_containers_list_double_insertsorted] */
static inline void IotListDouble_InsertSorted( IotListDouble_t * const pList,
IotLink_t * const pLink,
- int32_t ( *compare )( const IotLink_t * const pParam1, const IotLink_t * const pParam2 ) )
+ int32_t ( * compare )( const IotLink_t * const pParam1, const IotLink_t * const pParam2 ) )
/* @[declare_linear_containers_list_double_insertsorted] */
{
/* This function must not be called with NULL parameters. */
@@ -457,7 +457,7 @@ static inline void IotListDouble_InsertSorted( IotListDouble_t * const pList,
}
else
{
- bool inserted = false;
+ bool inserted = false;
IotLink_t * pCurrent = pList->pNext;
/* Iterate through the list to find the correct position. */
@@ -500,8 +500,8 @@ static inline void IotListDouble_Remove( IotLink_t * const pLink )
pLink->pPrevious->pNext = pLink->pNext;
pLink->pNext->pPrevious = pLink->pPrevious;
- pLink->pPrevious = NULL;
- pLink->pNext = NULL;
+ pLink->pPrevious = NULL;
+ pLink->pNext = NULL;
}
/**
@@ -565,7 +565,7 @@ static inline IotLink_t * IotListDouble_RemoveTail( const IotListDouble_t * cons
*/
/* @[declare_linear_containers_list_double_removeall] */
static inline void IotListDouble_RemoveAll( const IotListDouble_t * const pList,
- void ( *freeElement )( void * pData ),
+ void ( * freeElement )( void * pData ),
size_t linkOffset )
/* @[declare_linear_containers_list_double_removeall] */
{
@@ -617,14 +617,14 @@ static inline void IotListDouble_RemoveAll( const IotListDouble_t * const pList,
/* @[declare_linear_containers_list_double_findfirstmatch] */
static inline IotLink_t * IotListDouble_FindFirstMatch( const IotListDouble_t * const pList,
const IotLink_t * const pStartPoint,
- bool ( *isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
+ bool ( * isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
void * pMatch )
/* @[declare_linear_containers_list_double_findfirstmatch] */
{
/* The const must be cast away to match this function's return value. Nevertheless,
* this function will respect the const-ness of pStartPoint. */
IotLink_t * pCurrent = ( IotLink_t * ) pStartPoint, * pMatchedLink = NULL;
- bool matchFound = false;
+ bool matchFound = false;
/* This function must not be called with a NULL pList parameter. */
IotContainers_Assert( pList != NULL );
@@ -684,7 +684,7 @@ static inline IotLink_t * IotListDouble_FindFirstMatch( const IotListDouble_t *
/* @[declare_linear_containers_list_double_removefirstmatch] */
static inline IotLink_t * IotListDouble_RemoveFirstMatch( const IotListDouble_t * const pList,
const IotLink_t * const pStartPoint,
- bool ( *isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
+ bool ( * isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
void * pMatch )
/* @[declare_linear_containers_list_double_removefirstmatch] */
{
@@ -719,9 +719,9 @@ static inline IotLink_t * IotListDouble_RemoveFirstMatch( const IotListDouble_t
*/
/* @[declare_linear_containers_list_double_removeallmatches] */
static inline void IotListDouble_RemoveAllMatches( const IotListDouble_t * const pList,
- bool ( *isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
+ bool ( * isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
void * pMatch,
- void ( *freeElement )( void * pData ),
+ void ( * freeElement )( void * pData ),
size_t linkOffset )
/* @[declare_linear_containers_list_double_removeallmatches] */
{
@@ -738,7 +738,7 @@ static inline void IotListDouble_RemoveAllMatches( const IotListDouble_t * const
if( pMatchedElement != NULL )
{
/* Save pointer to next element. */
- pNextElement = pMatchedElement->pNext;
+ pNextElement = pMatchedElement->pNext;
/* Match found; remove and free. */
IotListDouble_Remove( pMatchedElement );
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_logging_setup.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_logging_setup.h
index 308b6e1a0..0d975f831 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_logging_setup.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_logging_setup.h
@@ -166,12 +166,12 @@
*/
/* Check that LIBRARY_LOG_LEVEL is defined and has a valid value. */
-#if !defined( LIBRARY_LOG_LEVEL ) || \
- ( ( LIBRARY_LOG_LEVEL != IOT_LOG_NONE ) && \
- ( LIBRARY_LOG_LEVEL != IOT_LOG_ERROR ) && \
- ( LIBRARY_LOG_LEVEL != IOT_LOG_WARN ) && \
- ( LIBRARY_LOG_LEVEL != IOT_LOG_INFO ) && \
- ( LIBRARY_LOG_LEVEL != IOT_LOG_DEBUG ) )
+#if !defined( LIBRARY_LOG_LEVEL ) || \
+ ( ( LIBRARY_LOG_LEVEL != IOT_LOG_NONE ) && \
+ ( LIBRARY_LOG_LEVEL != IOT_LOG_ERROR ) && \
+ ( LIBRARY_LOG_LEVEL != IOT_LOG_WARN ) && \
+ ( LIBRARY_LOG_LEVEL != IOT_LOG_INFO ) && \
+ ( LIBRARY_LOG_LEVEL != IOT_LOG_DEBUG ) )
#error "Please define LIBRARY_LOG_LEVEL as either IOT_LOG_NONE, IOT_LOG_ERROR, IOT_LOG_WARN, IOT_LOG_INFO, or IOT_LOG_DEBUG."
/* Check that LIBRARY_LOG_NAME is defined and has a valid value. */
#elif !defined( LIBRARY_LOG_NAME )
@@ -179,42 +179,42 @@
#else
/* Define IotLog if the log level is greater than "none". */
#if LIBRARY_LOG_LEVEL > IOT_LOG_NONE
- #define IotLog( messageLevel, pLogConfig, ... ) \
- IotLog_Generic( LIBRARY_LOG_LEVEL, \
- LIBRARY_LOG_NAME, \
- messageLevel, \
- pLogConfig, \
- __VA_ARGS__ )
+ #define IotLog( messageLevel, pLogConfig, ... ) \
+ IotLog_Generic( LIBRARY_LOG_LEVEL, \
+ LIBRARY_LOG_NAME, \
+ messageLevel, \
+ pLogConfig, \
+ __VA_ARGS__ )
- /* Define the abbreviated logging macros. */
- #define IotLogError( ... ) IotLog( IOT_LOG_ERROR, NULL, __VA_ARGS__ )
- #define IotLogWarn( ... ) IotLog( IOT_LOG_WARN, NULL, __VA_ARGS__ )
- #define IotLogInfo( ... ) IotLog( IOT_LOG_INFO, NULL, __VA_ARGS__ )
- #define IotLogDebug( ... ) IotLog( IOT_LOG_DEBUG, NULL, __VA_ARGS__ )
+/* Define the abbreviated logging macros. */
+ #define IotLogError( ... ) IotLog( IOT_LOG_ERROR, NULL, __VA_ARGS__ )
+ #define IotLogWarn( ... ) IotLog( IOT_LOG_WARN, NULL, __VA_ARGS__ )
+ #define IotLogInfo( ... ) IotLog( IOT_LOG_INFO, NULL, __VA_ARGS__ )
+ #define IotLogDebug( ... ) IotLog( IOT_LOG_DEBUG, NULL, __VA_ARGS__ )
- /* If log level is DEBUG, enable the function to print buffers. */
+/* If log level is DEBUG, enable the function to print buffers. */
#if LIBRARY_LOG_LEVEL >= IOT_LOG_DEBUG
- #define IotLog_PrintBuffer( pHeader, pBuffer, bufferSize ) \
- IotLog_GenericPrintBuffer( LIBRARY_LOG_NAME, \
- pHeader, \
- pBuffer, \
- bufferSize )
+ #define IotLog_PrintBuffer( pHeader, pBuffer, bufferSize ) \
+ IotLog_GenericPrintBuffer( LIBRARY_LOG_NAME, \
+ pHeader, \
+ pBuffer, \
+ bufferSize )
#else
- #define IotLog_PrintBuffer( pHeader, pBuffer, bufferSize )
+ #define IotLog_PrintBuffer( pHeader, pBuffer, bufferSize )
#endif
- /* Remove references to IotLog from the source code if logging is disabled. */
- #else
+ /* Remove references to IotLog from the source code if logging is disabled. */
+ #else /* if LIBRARY_LOG_LEVEL > IOT_LOG_NONE */
/* @[declare_logging_log] */
#define IotLog( messageLevel, pLogConfig, ... )
/* @[declare_logging_log] */
/* @[declare_logging_printbuffer] */
#define IotLog_PrintBuffer( pHeader, pBuffer, bufferSize )
/* @[declare_logging_printbuffer] */
- #define IotLogError( ... )
+ #define IotLogError( ... )
#define IotLogWarn( ... )
#define IotLogInfo( ... )
#define IotLogDebug( ... )
- #endif
-#endif
+ #endif /* if LIBRARY_LOG_LEVEL > IOT_LOG_NONE */
+#endif /* if !defined( LIBRARY_LOG_LEVEL ) || ( ( LIBRARY_LOG_LEVEL != IOT_LOG_NONE ) && ( LIBRARY_LOG_LEVEL != IOT_LOG_ERROR ) && ( LIBRARY_LOG_LEVEL != IOT_LOG_WARN ) && ( LIBRARY_LOG_LEVEL != IOT_LOG_INFO ) && ( LIBRARY_LOG_LEVEL != IOT_LOG_DEBUG ) ) */
#endif /* ifndef IOT_LOGGING_SETUP_H_ */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c
index 932f4e8f0..4a97cb12b 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c
@@ -161,7 +161,7 @@ static const char * const _pLogLevelStrings[ 5 ] =
size_t newSize,
size_t oldSize )
{
- bool status = false;
+ bool status = false;
/* Allocate a new, larger buffer. */
void * pNewBuffer = IotLogging_Malloc( newSize );
@@ -176,7 +176,7 @@ static const char * const _pLogLevelStrings[ 5 ] =
IotLogging_Free( *pOldBuffer );
*pOldBuffer = pNewBuffer;
- status = true;
+ status = true;
}
return status;
@@ -192,10 +192,10 @@ void IotLog_Generic( int32_t libraryLogSetting,
const char * const pFormat,
... )
{
- int requiredMessageSize = 0;
- size_t bufferSize = 0,
- bufferPosition = 0, timestringLength = 0;
- char * pLoggingBuffer = NULL;
+ int requiredMessageSize = 0;
+ size_t bufferSize = 0,
+ bufferPosition = 0, timestringLength = 0;
+ char * pLoggingBuffer = NULL;
va_list args;
/* If the library's log level setting is lower than the message level,
@@ -225,7 +225,7 @@ void IotLog_Generic( int32_t libraryLogSetting,
}
/* Add 64 as an initial (arbitrary) guess for the length of the message. */
- bufferSize += 64;
+ bufferSize += 64;
/* In static memory mode, check that the log message will fit in the a
* static buffer. */
@@ -238,11 +238,11 @@ void IotLog_Generic( int32_t libraryLogSetting,
}
/* Otherwise, update the buffer size to the size of a static buffer. */
- bufferSize = IotLogging_StaticBufferSize();
+ bufferSize = IotLogging_StaticBufferSize();
#endif
/* Allocate memory for the logging buffer. */
- pLoggingBuffer = ( char * ) IotLogging_Malloc( bufferSize );
+ pLoggingBuffer = ( char * ) IotLogging_Malloc( bufferSize );
if( pLoggingBuffer == NULL )
{
@@ -270,7 +270,7 @@ void IotLog_Generic( int32_t libraryLogSetting,
}
/* Update the buffer position. */
- bufferPosition += ( size_t ) requiredMessageSize;
+ bufferPosition += ( size_t ) requiredMessageSize;
}
}
@@ -292,7 +292,7 @@ void IotLog_Generic( int32_t libraryLogSetting,
}
/* Update the buffer position. */
- bufferPosition += ( size_t ) requiredMessageSize;
+ bufferPosition += ( size_t ) requiredMessageSize;
}
/* Print the timestring if requested. */
@@ -308,7 +308,7 @@ void IotLog_Generic( int32_t libraryLogSetting,
&timestringLength ) == true )
{
/* If the timestring was successfully generated, add the closing "]". */
- bufferPosition += timestringLength;
+ bufferPosition += timestringLength;
pLoggingBuffer[ bufferPosition ] = ']';
bufferPosition++;
}
@@ -363,7 +363,7 @@ void IotLog_Generic( int32_t libraryLogSetting,
}
/* Reallocation successful, update buffer size. */
- bufferSize = ( size_t ) requiredMessageSize + bufferPosition + 1;
+ bufferSize = ( size_t ) requiredMessageSize + bufferPosition + 1;
/* Add the log message to the buffer. Now that the buffer has been
* reallocated, this should succeed. */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c
index 6fd53684b..dd3e79e36 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c
@@ -103,10 +103,10 @@
* internal request context, the HTTP formatted request line, the User-Agent header line, and the part of the Host
* header line.
*/
-const uint32_t requestUserBufferMinimumSize = sizeof( _httpsRequest_t ) +
- sizeof( HTTPS_PARTIAL_REQUEST_LINE ) +
- sizeof( HTTPS_USER_AGENT_HEADER_LINE ) +
- sizeof( HTTPS_PARTIAL_HOST_HEADER_LINE );
+const uint32_t requestUserBufferMinimumSize = sizeof( _httpsRequest_t ) +
+ sizeof( HTTPS_PARTIAL_REQUEST_LINE ) +
+ sizeof( HTTPS_USER_AGENT_HEADER_LINE ) +
+ sizeof( HTTPS_PARTIAL_HOST_HEADER_LINE );
/**
* @brief Minimum size of the response user buffer.
@@ -115,7 +115,7 @@ const uint32_t requestUserBufferMinimumSize = sizeof( _httpsRequest_t ) +
* of the response and then the response headers right after. This minimum size is calculated for the case if no bytes
* from the HTTP response headers are to be stored.
*/
-const uint32_t responseUserBufferMinimumSize = sizeof( _httpsResponse_t );
+const uint32_t responseUserBufferMinimumSize = sizeof( _httpsResponse_t );
/**
* @brief Minimum size of the connection user buffer.
@@ -640,7 +640,7 @@ static http_parser_settings _httpParserSettings = { 0 };
static int _httpParserOnMessageBeginCallback( http_parser * pHttpParser )
{
- int retVal = KEEP_PARSING;
+ int retVal = KEEP_PARSING;
IotLogDebug( "Parser: Start of HTTPS Response message." );
@@ -716,7 +716,7 @@ static int _httpParserOnHeaderValueCallback( http_parser * pHttpParser,
const char * pLoc,
size_t length )
{
- int retVal = KEEP_PARSING;
+ int retVal = KEEP_PARSING;
IotLogDebug( "Parser: HTTPS header value parsed %.*s", length, pLoc );
_httpsResponse_t * pHttpsResponse = ( _httpsResponse_t * ) ( pHttpParser->data );
@@ -733,10 +733,10 @@ static int _httpParserOnHeaderValueCallback( http_parser * pHttpParser,
{
if( pHttpsResponse->foundHeaderField )
{
- pHttpsResponse->pReadHeaderValue = ( char * ) ( pLoc );
+ pHttpsResponse->pReadHeaderValue = ( char * ) ( pLoc );
pHttpsResponse->readHeaderValueLength = length;
/* We found a header field so we don't want to keep parsing.*/
- retVal = STOP_PARSING;
+ retVal = STOP_PARSING;
}
}
@@ -749,7 +749,7 @@ static int _httpParserOnHeadersCompleteCallback( http_parser * pHttpParser )
{
IotLogDebug( "Parser: End of the headers reached." );
- int retVal = KEEP_PARSING;
+ int retVal = KEEP_PARSING;
_httpsResponse_t * pHttpsResponse = ( _httpsResponse_t * ) ( pHttpParser->data );
pHttpsResponse->parserState = PARSER_STATE_HEADERS_COMPLETE;
@@ -779,7 +779,7 @@ static int _httpParserOnHeadersCompleteCallback( http_parser * pHttpParser )
/* For a HEAD method, there is no body expected in the response, so we return 1 to skip body parsing. */
if( ( pHttpsResponse->method == IOT_HTTPS_METHOD_HEAD ) )
{
- retVal = STOP_PARSING;
+ retVal = STOP_PARSING;
/* Since the message is considered complete now for a HEAD response, then we set the parser state
* to the completed state. */
@@ -823,7 +823,7 @@ static int _httpParserOnBodyCallback( http_parser * pHttpParser,
*/
if( pHttpsResponse->pBodyInHeaderBuf == NULL )
{
- pHttpsResponse->pBodyInHeaderBuf = ( uint8_t * ) ( pLoc );
+ pHttpsResponse->pBodyInHeaderBuf = ( uint8_t * ) ( pLoc );
pHttpsResponse->pBodyCurInHeaderBuf = pHttpsResponse->pBodyInHeaderBuf;
}
@@ -1040,21 +1040,21 @@ static void _networkReceiveCallback( void * pNetworkConnection,
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- IotHttpsReturnCode_t flushStatus = IOT_HTTPS_OK;
- IotHttpsReturnCode_t disconnectStatus = IOT_HTTPS_OK;
- IotHttpsReturnCode_t scheduleStatus = IOT_HTTPS_OK;
- _httpsConnection_t * pHttpsConnection = ( _httpsConnection_t * ) pReceiveContext;
- _httpsResponse_t * pCurrentHttpsResponse = NULL;
- _httpsRequest_t * pNextHttpsRequest = NULL;
- IotLink_t * pQItem = NULL;
- bool fatalDisconnect = false;
+ IotHttpsReturnCode_t flushStatus = IOT_HTTPS_OK;
+ IotHttpsReturnCode_t disconnectStatus = IOT_HTTPS_OK;
+ IotHttpsReturnCode_t scheduleStatus = IOT_HTTPS_OK;
+ _httpsConnection_t * pHttpsConnection = ( _httpsConnection_t * ) pReceiveContext;
+ _httpsResponse_t * pCurrentHttpsResponse = NULL;
+ _httpsRequest_t * pNextHttpsRequest = NULL;
+ IotLink_t * pQItem = NULL;
+ bool fatalDisconnect = false;
/* The network connection is already in the connection context. */
( void ) pNetworkConnection;
/* Get the response from the response queue. */
IotMutex_Lock( &( pHttpsConnection->connectionMutex ) );
- pQItem = IotDeQueue_PeekHead( &( pHttpsConnection->respQ ) );
+ pQItem = IotDeQueue_PeekHead( &( pHttpsConnection->respQ ) );
IotMutex_Unlock( &( pHttpsConnection->connectionMutex ) );
/* If the receive callback is invoked and there is no response expected, then this a violation of the HTTP/1.1
@@ -1067,7 +1067,7 @@ static void _networkReceiveCallback( void * pNetworkConnection,
}
/* Set the current HTTP response context to use. */
- pCurrentHttpsResponse = IotLink_Container( _httpsResponse_t, pQItem, link );
+ pCurrentHttpsResponse = IotLink_Container( _httpsResponse_t, pQItem, link );
/* If the receive callback has invoked, but the request associated with this response has not finished sending
* to the server, then this is a violation of the HTTP/1.1 protocol. */
@@ -1091,7 +1091,7 @@ static void _networkReceiveCallback( void * pNetworkConnection,
/* Receive the response from the network. */
/* Receive the headers first. */
- status = _receiveHttpsHeaders( pHttpsConnection, pCurrentHttpsResponse );
+ status = _receiveHttpsHeaders( pHttpsConnection, pCurrentHttpsResponse );
if( HTTPS_FAILED( status ) )
{
@@ -1245,7 +1245,7 @@ static void _networkReceiveCallback( void * pNetworkConnection,
*
* All network errors are ignore here because network read will have read the data from network buffer despite
* errors. */
- flushStatus = _flushHttpsNetworkData( pHttpsConnection, pCurrentHttpsResponse );
+ flushStatus = _flushHttpsNetworkData( pHttpsConnection, pCurrentHttpsResponse );
if( flushStatus == IOT_HTTPS_PARSING_ERROR )
{
@@ -1258,7 +1258,7 @@ static void _networkReceiveCallback( void * pNetworkConnection,
IotMutex_Lock( &( pHttpsConnection->connectionMutex ) );
/* Get the next request to process. */
- pQItem = IotDeQueue_PeekHead( &( pHttpsConnection->reqQ ) );
+ pQItem = IotDeQueue_PeekHead( &( pHttpsConnection->reqQ ) );
IotMutex_Unlock( &( pHttpsConnection->connectionMutex ) );
/* If there is a next request to process, then create a taskpool job to send the request. */
@@ -1332,20 +1332,20 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- IotNetworkError_t networkStatus = IOT_NETWORK_SUCCESS;
+ IotNetworkError_t networkStatus = IOT_NETWORK_SUCCESS;
/* The maximum string length of the ALPN protocols is configured in IOT_HTTPS_MAX_ALPN_PROTOCOLS_LENGTH.
* The +1 is for the NULL terminator needed by IotNetworkCredentials_t.pAlpnProtos. */
- char pAlpnProtos[ IOT_HTTPS_MAX_ALPN_PROTOCOLS_LENGTH + 1 ] = { 0 };
+ char pAlpnProtos[ IOT_HTTPS_MAX_ALPN_PROTOCOLS_LENGTH + 1 ] = { 0 };
/* The maximum string length of the Server host name is configured in IOT_HTTPS_MAX_HOST_NAME_LENGTH.
* This +1 is for the NULL terminator needed by IotNetworkServerInfo_t.pHostName. */
- char pHostName[ IOT_HTTPS_MAX_HOST_NAME_LENGTH + 1 ] = { 0 };
- bool connectionMutexCreated = false;
- struct IotNetworkServerInfo networkServerInfo = { 0 };
- struct IotNetworkCredentials networkCredentials = { 0 };
- _httpsConnection_t * pHttpsConnection = NULL;
- IotNetworkCredentials_t pNetworkCredentials = NULL;
+ char pHostName[ IOT_HTTPS_MAX_HOST_NAME_LENGTH + 1 ] = { 0 };
+ bool connectionMutexCreated = false;
+ struct IotNetworkServerInfo networkServerInfo = { 0 };
+ struct IotNetworkCredentials networkCredentials = { 0 };
+ _httpsConnection_t * pHttpsConnection = NULL;
+ IotNetworkCredentials_t pNetworkCredentials = NULL;
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pConnInfo->userBuffer.pBuffer );
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pConnInfo->pNetworkInterface );
@@ -1373,13 +1373,13 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
pConnInfo->alpnProtocolsLen,
IOT_HTTPS_MAX_ALPN_PROTOCOLS_LENGTH );
- pHttpsConnection = ( _httpsConnection_t * ) ( pConnInfo->userBuffer.pBuffer );
+ pHttpsConnection = ( _httpsConnection_t * ) ( pConnInfo->userBuffer.pBuffer );
/* Start with the disconnected state. */
- pHttpsConnection->isConnected = false;
+ pHttpsConnection->isConnected = false;
/* Initialize disconnection state keeper. */
- pHttpsConnection->isDestroyed = false;
+ pHttpsConnection->isDestroyed = false;
/* Initialize the queue of responses and requests. */
IotDeQueue_Create( &( pHttpsConnection->reqQ ) );
@@ -1403,10 +1403,10 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
* is required in IotNetworkServerInfo_t.pHostName. IotNetworkServerInfo_t contains the server information needed
* by the network interface to create the connection. */
memcpy( pHostName, pConnInfo->pAddress, pConnInfo->addressLen );
- pHostName[ pConnInfo->addressLen ] = '\0';
+ pHostName[ pConnInfo->addressLen ] = '\0';
/* Set it in the IOT network abstractions server information parameter. */
- networkServerInfo.pHostName = pHostName;
- networkServerInfo.port = pConnInfo->port;
+ networkServerInfo.pHostName = pHostName;
+ networkServerInfo.port = pConnInfo->port;
/* If this is TLS connection, then set the network credentials. */
if( ( pConnInfo->flags & IOT_HTTPS_IS_NON_TLS_FLAG ) == 0 )
@@ -1427,7 +1427,7 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
* terminator. */
memcpy( pAlpnProtos, pConnInfo->pAlpnProtocols, pConnInfo->alpnProtocolsLen );
pAlpnProtos[ pConnInfo->alpnProtocolsLen ] = '\0';
- networkCredentials.pAlpnProtos = pAlpnProtos;
+ networkCredentials.pAlpnProtos = pAlpnProtos;
}
else
{
@@ -1437,14 +1437,14 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
/* If any of these are NULL a network error will result when trying to make the connection. Because there is
* no invalid memory access resulting from these configurations being NULL, it is not check at the start
* of the function. */
- networkCredentials.pRootCa = pConnInfo->pCaCert;
- networkCredentials.rootCaSize = pConnInfo->caCertLen;
- networkCredentials.pClientCert = pConnInfo->pClientCert;
+ networkCredentials.pRootCa = pConnInfo->pCaCert;
+ networkCredentials.rootCaSize = pConnInfo->caCertLen;
+ networkCredentials.pClientCert = pConnInfo->pClientCert;
networkCredentials.clientCertSize = pConnInfo->clientCertLen;
- networkCredentials.pPrivateKey = pConnInfo->pPrivateKey;
+ networkCredentials.pPrivateKey = pConnInfo->pPrivateKey;
networkCredentials.privateKeySize = pConnInfo->privateKeyLen;
- pNetworkCredentials = &networkCredentials;
+ pNetworkCredentials = &networkCredentials;
}
else
{
@@ -1454,9 +1454,9 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
/* create() will connect to the server specified in addition to creating other network layer
* specific resources. */
- networkStatus = pHttpsConnection->pNetworkInterface->create( &networkServerInfo,
- pNetworkCredentials,
- &( pHttpsConnection->pNetworkConnection ) );
+ networkStatus = pHttpsConnection->pNetworkInterface->create( &networkServerInfo,
+ pNetworkCredentials,
+ &( pHttpsConnection->pNetworkConnection ) );
/* Check to see if the network connection succeeded. If it did not succeed,
* then the output parameter pConnHandle will be used to return NULL and the
@@ -1472,13 +1472,13 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
}
/* The connection succeeded so set the state to connected. */
- pHttpsConnection->isConnected = true;
+ pHttpsConnection->isConnected = true;
/* The receive callback is invoked by the network layer when data is ready
* to be read from the network. */
- networkStatus = pHttpsConnection->pNetworkInterface->setReceiveCallback( pHttpsConnection->pNetworkConnection,
- _networkReceiveCallback,
- pHttpsConnection );
+ networkStatus = pHttpsConnection->pNetworkInterface->setReceiveCallback( pHttpsConnection->pNetworkConnection,
+ _networkReceiveCallback,
+ pHttpsConnection );
if( networkStatus != IOT_NETWORK_SUCCESS )
{
@@ -1488,7 +1488,7 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
/* Connection was successful, so create synchronization primitives. */
- connectionMutexCreated = IotMutex_Create( &( pHttpsConnection->connectionMutex ), false );
+ connectionMutexCreated = IotMutex_Create( &( pHttpsConnection->connectionMutex ), false );
if( !connectionMutexCreated )
{
@@ -1497,7 +1497,7 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t *
}
/* Return the new connection information. */
- *pConnHandle = pHttpsConnection;
+ *pConnHandle = pHttpsConnection;
HTTPS_FUNCTION_CLEANUP_BEGIN();
@@ -1561,8 +1561,8 @@ static IotHttpsReturnCode_t _addHeader( _httpsRequest_t * pHttpsRequest,
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- int headerFieldSeparatorLen = HTTPS_HEADER_FIELD_SEPARATOR_LENGTH;
- uint32_t additionalLength = nameLen + headerFieldSeparatorLen + valueLen + HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH;
+ int headerFieldSeparatorLen = HTTPS_HEADER_FIELD_SEPARATOR_LENGTH;
+ uint32_t additionalLength = nameLen + headerFieldSeparatorLen + valueLen + HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH;
uint32_t possibleLastHeaderAdditionalLength = HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH;
/* Check if there is enough space to add the header field and value
@@ -1602,15 +1602,15 @@ static IotHttpsReturnCode_t _networkSend( _httpsConnection_t * pHttpsConnection,
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- size_t numBytesSent = 0;
+ size_t numBytesSent = 0;
size_t numBytesSentTotal = 0;
- size_t sendLength = len;
+ size_t sendLength = len;
while( numBytesSentTotal < sendLength )
{
- numBytesSent = pHttpsConnection->pNetworkInterface->send( pHttpsConnection->pNetworkConnection,
- &( pBuf[ numBytesSentTotal ] ),
- sendLength - numBytesSentTotal );
+ numBytesSent = pHttpsConnection->pNetworkInterface->send( pHttpsConnection->pNetworkConnection,
+ &( pBuf[ numBytesSentTotal ] ),
+ sendLength - numBytesSentTotal );
/* pNetworkInterface->send returns 0 on error. */
if( numBytesSent == 0 )
@@ -1678,11 +1678,11 @@ static IotHttpsReturnCode_t _sendHttpsHeaders( _httpsConnection_t * pHttpsConnec
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- const char * connectionHeader = NULL;
- int numWritten = 0;
- int connectionHeaderLen = 0;
+ const char * connectionHeader = NULL;
+ int numWritten = 0;
+ int connectionHeaderLen = 0;
/* The Content-Length header of the form "Content-Length: N\r\n" with a NULL terminator for snprintf. */
- char contentLengthHeaderStr[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH + 1 ];
+ char contentLengthHeaderStr[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH + 1 ];
/* The HTTP headers to send after the headers in pHeadersBuf are the Content-Length and the Connection type and
* the final "\r\n" to indicate the end of the the header lines. Note that we are using
@@ -1692,7 +1692,7 @@ static IotHttpsReturnCode_t _sendHttpsHeaders( _httpsConnection_t * pHttpsConnec
char finalHeaders[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH + HTTPS_CONNECTION_KEEP_ALIVE_HEADER_LINE_LENGTH + HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH ] = { 0 };
/* Send the headers passed into this function first. These headers are not terminated with a second set of "\r\n". */
- status = _networkSend( pHttpsConnection, pHeadersBuf, headersLength );
+ status = _networkSend( pHttpsConnection, pHeadersBuf, headersLength );
if( HTTPS_FAILED( status ) )
{
@@ -1722,12 +1722,12 @@ static IotHttpsReturnCode_t _sendHttpsHeaders( _httpsConnection_t * pHttpsConnec
/* Write the connection persistence type to the final headers. */
if( isNonPersistent )
{
- connectionHeader = HTTPS_CONNECTION_CLOSE_HEADER_LINE;
+ connectionHeader = HTTPS_CONNECTION_CLOSE_HEADER_LINE;
connectionHeaderLen = FAST_MACRO_STRLEN( HTTPS_CONNECTION_CLOSE_HEADER_LINE );
}
else
{
- connectionHeader = HTTPS_CONNECTION_KEEP_ALIVE_HEADER_LINE;
+ connectionHeader = HTTPS_CONNECTION_KEEP_ALIVE_HEADER_LINE;
connectionHeaderLen = FAST_MACRO_STRLEN( HTTPS_CONNECTION_KEEP_ALIVE_HEADER_LINE );
}
@@ -1736,7 +1736,7 @@ static IotHttpsReturnCode_t _sendHttpsHeaders( _httpsConnection_t * pHttpsConnec
memcpy( &finalHeaders[ numWritten ], HTTPS_END_OF_HEADER_LINES_INDICATOR, HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH );
numWritten += HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH;
- status = _networkSend( pHttpsConnection, ( uint8_t * ) finalHeaders, numWritten );
+ status = _networkSend( pHttpsConnection, ( uint8_t * ) finalHeaders, numWritten );
if( HTTPS_FAILED( status ) )
{
@@ -1774,9 +1774,9 @@ static IotHttpsReturnCode_t _parseHttpsMessage( _httpParserInfo_t * pHttpParserI
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- size_t parsedBytes = 0;
- const char * pHttpParserErrorDescription = NULL;
- http_parser * pHttpParser = &( pHttpParserInfo->responseParser );
+ size_t parsedBytes = 0;
+ const char * pHttpParserErrorDescription = NULL;
+ http_parser * pHttpParser = &( pHttpParserInfo->responseParser );
IotLogDebug( "Now parsing HTTP message buffer to process a response." );
parsedBytes = pHttpParserInfo->parseFunc( pHttpParser, &_httpParserSettings, pBuf, len );
@@ -1950,13 +1950,13 @@ static IotHttpsReturnCode_t _receiveHttpsHeaders( _httpsConnection_t * pHttpsCon
IotLogDebug( "Now attempting to receive the HTTP response headers into a buffer with length %d.",
pHttpsResponse->pHeadersEnd - pHttpsResponse->pHeadersCur );
- status = _receiveHttpsMessage( pHttpsConnection,
- &( pHttpsResponse->httpParserInfo ),
- &( pHttpsResponse->parserState ),
- PARSER_STATE_HEADERS_COMPLETE,
- PROCESSING_STATE_FILLING_HEADER_BUFFER,
- &( pHttpsResponse->pHeadersCur ),
- &( pHttpsResponse->pHeadersEnd ) );
+ status = _receiveHttpsMessage( pHttpsConnection,
+ &( pHttpsResponse->httpParserInfo ),
+ &( pHttpsResponse->parserState ),
+ PARSER_STATE_HEADERS_COMPLETE,
+ PROCESSING_STATE_FILLING_HEADER_BUFFER,
+ &( pHttpsResponse->pHeadersCur ),
+ &( pHttpsResponse->pHeadersEnd ) );
if( HTTPS_FAILED( status ) )
{
@@ -1980,13 +1980,13 @@ static IotHttpsReturnCode_t _receiveHttpsBody( _httpsConnection_t * pHttpsConnec
pHttpsResponse->bufferProcessingState = PROCESSING_STATE_FILLING_BODY_BUFFER;
- status = _receiveHttpsMessage( pHttpsConnection,
- &( pHttpsResponse->httpParserInfo ),
- &( pHttpsResponse->parserState ),
- PARSER_STATE_BODY_COMPLETE,
- PROCESSING_STATE_FILLING_BODY_BUFFER,
- &( pHttpsResponse->pBodyCur ),
- &( pHttpsResponse->pBodyEnd ) );
+ status = _receiveHttpsMessage( pHttpsConnection,
+ &( pHttpsResponse->httpParserInfo ),
+ &( pHttpsResponse->parserState ),
+ PARSER_STATE_BODY_COMPLETE,
+ PROCESSING_STATE_FILLING_BODY_BUFFER,
+ &( pHttpsResponse->pBodyCur ),
+ &( pHttpsResponse->pBodyEnd ) );
if( HTTPS_FAILED( status ) )
{
@@ -2009,11 +2009,11 @@ static IotHttpsReturnCode_t _flushHttpsNetworkData( _httpsConnection_t * pHttpsC
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- static uint8_t flushBuffer[ IOT_HTTPS_MAX_FLUSH_BUFFER_SIZE ] = { 0 };
- const char * pHttpParserErrorDescription = NULL;
- IotHttpsReturnCode_t parserStatus = IOT_HTTPS_OK;
- IotHttpsReturnCode_t networkStatus = IOT_HTTPS_OK;
- size_t numBytesRecv = 0;
+ static uint8_t flushBuffer[ IOT_HTTPS_MAX_FLUSH_BUFFER_SIZE ] = { 0 };
+ const char * pHttpParserErrorDescription = NULL;
+ IotHttpsReturnCode_t parserStatus = IOT_HTTPS_OK;
+ IotHttpsReturnCode_t networkStatus = IOT_HTTPS_OK;
+ size_t numBytesRecv = 0;
/* Even if there is not body, the parser state will become body complete after the headers finish. */
while( pHttpsResponse->parserState < PARSER_STATE_BODY_COMPLETE )
@@ -2023,7 +2023,7 @@ static IotHttpsReturnCode_t _flushHttpsNetworkData( _httpsConnection_t * pHttpsC
/* Run this through the parser so that we can get the end of the HTTP message, instead of simply timing out the socket to stop.
* If we relied on the socket timeout to stop reading the network socket, then the server may close the connection. */
- parserStatus = _parseHttpsMessage( &( pHttpsResponse->httpParserInfo ), ( char * ) flushBuffer, numBytesRecv );
+ parserStatus = _parseHttpsMessage( &( pHttpsResponse->httpParserInfo ), ( char * ) flushBuffer, numBytesRecv );
if( HTTPS_FAILED( parserStatus ) )
{
@@ -2099,13 +2099,13 @@ static void _sendHttpsRequest( taskPoolJob_t * pJob,
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- _httpsRequest_t * pHttpsRequest = ( _httpsRequest_t * ) ( pUserContext );
- _httpsConnection_t * pHttpsConnection = pHttpsRequest->pHttpsConnection;
- _httpsResponse_t * pHttpsResponse = pHttpsRequest->pHttpsResponse;
- IotHttpsReturnCode_t disconnectStatus = IOT_HTTPS_OK;
- IotHttpsReturnCode_t scheduleStatus = IOT_HTTPS_OK;
- IotLink_t * pQItem = NULL;
- _httpsRequest_t * pNextHttpsRequest = NULL;
+ _httpsRequest_t * pHttpsRequest = ( _httpsRequest_t * ) ( pUserContext );
+ _httpsConnection_t * pHttpsConnection = pHttpsRequest->pHttpsConnection;
+ _httpsResponse_t * pHttpsResponse = pHttpsRequest->pHttpsResponse;
+ IotHttpsReturnCode_t disconnectStatus = IOT_HTTPS_OK;
+ IotHttpsReturnCode_t scheduleStatus = IOT_HTTPS_OK;
+ IotLink_t * pQItem = NULL;
+ _httpsRequest_t * pNextHttpsRequest = NULL;
( void ) pJob;
@@ -2298,7 +2298,7 @@ IotHttpsReturnCode_t _scheduleHttpsRequestSend( _httpsRequest_t * pHttpsRequest
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
+ taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
_httpsConnection_t * pHttpsConnection = pHttpsRequest->pHttpsConnection;
/* Set the request to scheduled even if scheduling fails. */
@@ -2308,7 +2308,7 @@ IotHttpsReturnCode_t _scheduleHttpsRequestSend( _httpsRequest_t * pHttpsRequest
( void * ) ( pHttpsRequest ),
&( pHttpsConnection->taskPoolJob ) );
- taskPoolStatus = taskPoolSchedule( &( pHttpsConnection->taskPoolJob ) );
+ taskPoolStatus = taskPoolSchedule( &( pHttpsConnection->taskPoolJob ) );
if( taskPoolStatus != TASKPOOL_SUCCESS )
{
@@ -2326,7 +2326,7 @@ IotHttpsReturnCode_t _addRequestToConnectionReqQ( _httpsRequest_t * pHttpsReques
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
_httpsConnection_t * pHttpsConnection = pHttpsRequest->pHttpsConnection;
- bool scheduleRequest = false;
+ bool scheduleRequest = false;
/* Log information about the request*/
IotLogDebug( "Now queueing request %d.", pHttpsRequest );
@@ -2414,24 +2414,24 @@ IotHttpsReturnCode_t IotHttpsClient_Init( void )
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
/* Initialize the task pool module, which is a dependency for the HTTPS library. */
- taskPoolCreateSystemTaskPool();
+ taskPoolCreateSystemTaskPool();
/* This sets all member in the _httpParserSettings to zero. It does not return any errors. */
http_parser_settings_init( &_httpParserSettings );
/* Set the http-parser callbacks. */
- _httpParserSettings.on_message_begin = _httpParserOnMessageBeginCallback;
- _httpParserSettings.on_status = _httpParserOnStatusCallback;
- _httpParserSettings.on_header_field = _httpParserOnHeaderFieldCallback;
- _httpParserSettings.on_header_value = _httpParserOnHeaderValueCallback;
- _httpParserSettings.on_headers_complete = _httpParserOnHeadersCompleteCallback;
- _httpParserSettings.on_body = _httpParserOnBodyCallback;
- _httpParserSettings.on_message_complete = _httpParserOnMessageCompleteCallback;
+ _httpParserSettings.on_message_begin = _httpParserOnMessageBeginCallback;
+ _httpParserSettings.on_status = _httpParserOnStatusCallback;
+ _httpParserSettings.on_header_field = _httpParserOnHeaderFieldCallback;
+ _httpParserSettings.on_header_value = _httpParserOnHeaderValueCallback;
+ _httpParserSettings.on_headers_complete = _httpParserOnHeadersCompleteCallback;
+ _httpParserSettings.on_body = _httpParserOnBodyCallback;
+ _httpParserSettings.on_message_complete = _httpParserOnMessageCompleteCallback;
/* This code prints debugging information and is, therefore, compiled only when
* log level is set to IOT_LOG_DEBUG. */
#if ( LIBRARY_LOG_LEVEL == IOT_LOG_DEBUG )
- _httpParserSettings.on_chunk_header = _httpParserOnChunkHeaderCallback;
+ _httpParserSettings.on_chunk_header = _httpParserOnChunkHeaderCallback;
_httpParserSettings.on_chunk_complete = _httpParserOnChunkCompleteCallback;
#endif
HTTPS_GOTO_CLEANUP();
@@ -2458,7 +2458,7 @@ static IotHttpsReturnCode_t _initializeResponse( IotHttpsResponseHandle_t * pRes
responseUserBufferMinimumSize );
/* Initialize the corresponding response to this request. */
- pHttpsResponse = ( _httpsResponse_t * ) ( pRespInfo->userBuffer.pBuffer );
+ pHttpsResponse = ( _httpsResponse_t * ) ( pRespInfo->userBuffer.pBuffer );
/* Clear out the response user buffer. This is important because we
* give the whole buffer to the parser as opposed to the actual content
@@ -2468,29 +2468,29 @@ static IotHttpsReturnCode_t _initializeResponse( IotHttpsResponseHandle_t * pRes
* the HTTP repose, we zero out the buffer here. */
memset( pRespInfo->userBuffer.pBuffer, 0, pRespInfo->userBuffer.bufferLen );
- pHttpsResponse->pHeaders = ( uint8_t * ) ( pHttpsResponse ) + sizeof( _httpsResponse_t );
- pHttpsResponse->pHeadersEnd = ( uint8_t * ) ( pHttpsResponse ) + pRespInfo->userBuffer.bufferLen;
- pHttpsResponse->pHeadersCur = pHttpsResponse->pHeaders;
+ pHttpsResponse->pHeaders = ( uint8_t * ) ( pHttpsResponse ) + sizeof( _httpsResponse_t );
+ pHttpsResponse->pHeadersEnd = ( uint8_t * ) ( pHttpsResponse ) + pRespInfo->userBuffer.bufferLen;
+ pHttpsResponse->pHeadersCur = pHttpsResponse->pHeaders;
if( pHttpsRequest->isAsync )
{
- pHttpsResponse->isAsync = true;
+ pHttpsResponse->isAsync = true;
/* For an asynchronous request the response body is provided by the application in the
* IotHttpsCallbacks_t.readReadyCallback(). These pointers will be updated when IotHttpsClient_ReadResponseBody()
* is invoked. */
- pHttpsResponse->pBody = NULL;
- pHttpsResponse->pBodyCur = NULL;
- pHttpsResponse->pBodyEnd = NULL;
+ pHttpsResponse->pBody = NULL;
+ pHttpsResponse->pBodyCur = NULL;
+ pHttpsResponse->pBodyEnd = NULL;
- pHttpsResponse->pCallbacks = pHttpsRequest->pCallbacks;
+ pHttpsResponse->pCallbacks = pHttpsRequest->pCallbacks;
pHttpsResponse->pUserPrivData = pHttpsRequest->pUserPrivData;
}
else
{
- pHttpsResponse->isAsync = false;
+ pHttpsResponse->isAsync = false;
/* The request body pointer is allowed to be NULL. u.pSyncInfo was checked for NULL earlier in this function. */
- pHttpsResponse->pBody = pRespInfo->pSyncInfo->pBody;
+ pHttpsResponse->pBody = pRespInfo->pSyncInfo->pBody;
pHttpsResponse->pBodyCur = pHttpsResponse->pBody;
pHttpsResponse->pBodyEnd = pHttpsResponse->pBody + pRespInfo->pSyncInfo->bodyLen;
@@ -2507,32 +2507,32 @@ static IotHttpsReturnCode_t _initializeResponse( IotHttpsResponseHandle_t * pRes
http_parser_init( &( pHttpsResponse->httpParserInfo.responseParser ), HTTP_RESPONSE );
http_parser_init( &( pHttpsResponse->httpParserInfo.readHeaderParser ), HTTP_RESPONSE );
/* Set the third party http parser function. */
- pHttpsResponse->httpParserInfo.parseFunc = http_parser_execute;
+ pHttpsResponse->httpParserInfo.parseFunc = http_parser_execute;
pHttpsResponse->httpParserInfo.readHeaderParser.data = ( void * ) ( pHttpsResponse );
- pHttpsResponse->httpParserInfo.responseParser.data = ( void * ) ( pHttpsResponse );
-
- pHttpsResponse->status = 0;
- pHttpsResponse->method = pHttpsRequest->method;
- pHttpsResponse->parserState = PARSER_STATE_NONE;
- pHttpsResponse->bufferProcessingState = PROCESSING_STATE_NONE;
- pHttpsResponse->pReadHeaderField = NULL;
- pHttpsResponse->readHeaderFieldLength = 0;
- pHttpsResponse->pReadHeaderValue = NULL;
- pHttpsResponse->readHeaderValueLength = 0;
- pHttpsResponse->foundHeaderField = 0;
- pHttpsResponse->pHttpsConnection = NULL;
-
- pHttpsResponse->pBodyInHeaderBuf = NULL;
- pHttpsResponse->pBodyCurInHeaderBuf = NULL;
- pHttpsResponse->bodyRxStatus = IOT_HTTPS_OK;
- pHttpsResponse->cancelled = false;
- pHttpsResponse->syncStatus = IOT_HTTPS_OK;
+ pHttpsResponse->httpParserInfo.responseParser.data = ( void * ) ( pHttpsResponse );
+
+ pHttpsResponse->status = 0;
+ pHttpsResponse->method = pHttpsRequest->method;
+ pHttpsResponse->parserState = PARSER_STATE_NONE;
+ pHttpsResponse->bufferProcessingState = PROCESSING_STATE_NONE;
+ pHttpsResponse->pReadHeaderField = NULL;
+ pHttpsResponse->readHeaderFieldLength = 0;
+ pHttpsResponse->pReadHeaderValue = NULL;
+ pHttpsResponse->readHeaderValueLength = 0;
+ pHttpsResponse->foundHeaderField = 0;
+ pHttpsResponse->pHttpsConnection = NULL;
+
+ pHttpsResponse->pBodyInHeaderBuf = NULL;
+ pHttpsResponse->pBodyCurInHeaderBuf = NULL;
+ pHttpsResponse->bodyRxStatus = IOT_HTTPS_OK;
+ pHttpsResponse->cancelled = false;
+ pHttpsResponse->syncStatus = IOT_HTTPS_OK;
/* There is no request associated with this response right now, so it is finished sending. */
- pHttpsResponse->reqFinishedSending = true;
- pHttpsResponse->isNonPersistent = pHttpsRequest->isNonPersistent;
+ pHttpsResponse->reqFinishedSending = true;
+ pHttpsResponse->isNonPersistent = pHttpsRequest->isNonPersistent;
/* Set the response handle to return. */
- *pRespHandle = pHttpsResponse;
+ *pRespHandle = pHttpsResponse;
HTTPS_FUNCTION_CLEANUP_BEGIN();
@@ -2597,10 +2597,10 @@ IotHttpsReturnCode_t IotHttpsClient_Disconnect( IotHttpsConnectionHandle_t connH
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- _httpsRequest_t * pHttpsRequest = NULL;
+ _httpsRequest_t * pHttpsRequest = NULL;
_httpsResponse_t * pHttpsResponse = NULL;
- IotLink_t * pRespItem = NULL;
- IotLink_t * pReqItem = NULL;
+ IotLink_t * pRespItem = NULL;
+ IotLink_t * pReqItem = NULL;
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( connHandle );
@@ -2631,7 +2631,7 @@ IotHttpsReturnCode_t IotHttpsClient_Disconnect( IotHttpsConnectionHandle_t connH
if( pHttpsResponse->reqFinishedSending == false )
{
IotLogError( "Connection is in use. Disconnected, but cannot destroy the connection." );
- status = IOT_HTTPS_BUSY;
+ status = IOT_HTTPS_BUSY;
/* The request is busy, to as quickly as possible allow a successful retry call of this function we must
* cancel the busy request which is the first in the queue. */
@@ -2696,12 +2696,12 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t *
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- _httpsRequest_t * pHttpsRequest = NULL;
- size_t additionalLength = 0;
- size_t spaceLen = 1;
- char * pSpace = " ";
- size_t httpsMethodLen = 0;
- size_t httpsProtocolVersionLen = FAST_MACRO_STRLEN( HTTPS_PROTOCOL_VERSION );
+ _httpsRequest_t * pHttpsRequest = NULL;
+ size_t additionalLength = 0;
+ size_t spaceLen = 1;
+ char * pSpace = " ";
+ size_t httpsMethodLen = 0;
+ size_t httpsProtocolVersionLen = FAST_MACRO_STRLEN( HTTPS_PROTOCOL_VERSION );
/* Check for NULL parameters in the public API. */
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pReqHandle );
@@ -2726,25 +2726,25 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t *
requestUserBufferMinimumSize );
/* Set the request contet to the start of the userbuffer. */
- pHttpsRequest = ( _httpsRequest_t * ) ( pReqInfo->userBuffer.pBuffer );
+ pHttpsRequest = ( _httpsRequest_t * ) ( pReqInfo->userBuffer.pBuffer );
/* Clear out the user buffer. */
memset( pReqInfo->userBuffer.pBuffer, 0, pReqInfo->userBuffer.bufferLen );
/* Set the start of the headers to the end of the request context in the user buffer. */
- pHttpsRequest->pHeaders = ( uint8_t * ) pHttpsRequest + sizeof( _httpsRequest_t );
- pHttpsRequest->pHeadersEnd = ( uint8_t * ) pHttpsRequest + pReqInfo->userBuffer.bufferLen;
- pHttpsRequest->pHeadersCur = pHttpsRequest->pHeaders;
+ pHttpsRequest->pHeaders = ( uint8_t * ) pHttpsRequest + sizeof( _httpsRequest_t );
+ pHttpsRequest->pHeadersEnd = ( uint8_t * ) pHttpsRequest + pReqInfo->userBuffer.bufferLen;
+ pHttpsRequest->pHeadersCur = pHttpsRequest->pHeaders;
/* Get the length of the HTTP method. */
- httpsMethodLen = strlen( _pHttpsMethodStrings[ pReqInfo->method ] );
+ httpsMethodLen = strlen( _pHttpsMethodStrings[ pReqInfo->method ] );
/* Add the request line to the header buffer. */
- additionalLength = httpsMethodLen + \
- spaceLen + \
- pReqInfo->pathLen + \
- spaceLen + \
- httpsProtocolVersionLen + \
- HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH;
+ additionalLength = httpsMethodLen + \
+ spaceLen + \
+ pReqInfo->pathLen + \
+ spaceLen + \
+ httpsProtocolVersionLen + \
+ HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH;
if( ( additionalLength + pHttpsRequest->pHeadersCur ) > ( pHttpsRequest->pHeadersEnd ) )
{
@@ -2758,27 +2758,27 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t *
/* Write "<METHOD> <PATH> HTTP/1.1\r\n" to the start of the header space. */
memcpy( pHttpsRequest->pHeadersCur, _pHttpsMethodStrings[ pReqInfo->method ], httpsMethodLen );
- pHttpsRequest->pHeadersCur += httpsMethodLen;
+ pHttpsRequest->pHeadersCur += httpsMethodLen;
memcpy( pHttpsRequest->pHeadersCur, pSpace, spaceLen );
- pHttpsRequest->pHeadersCur += spaceLen;
+ pHttpsRequest->pHeadersCur += spaceLen;
if( pReqInfo->pPath == NULL )
{
- pReqInfo->pPath = HTTPS_EMPTY_PATH;
+ pReqInfo->pPath = HTTPS_EMPTY_PATH;
pReqInfo->pathLen = FAST_MACRO_STRLEN( HTTPS_EMPTY_PATH );
}
memcpy( pHttpsRequest->pHeadersCur, pReqInfo->pPath, pReqInfo->pathLen );
- pHttpsRequest->pHeadersCur += pReqInfo->pathLen;
+ pHttpsRequest->pHeadersCur += pReqInfo->pathLen;
memcpy( pHttpsRequest->pHeadersCur, pSpace, spaceLen );
- pHttpsRequest->pHeadersCur += spaceLen;
+ pHttpsRequest->pHeadersCur += spaceLen;
memcpy( pHttpsRequest->pHeadersCur, HTTPS_PROTOCOL_VERSION, httpsProtocolVersionLen );
- pHttpsRequest->pHeadersCur += httpsProtocolVersionLen;
+ pHttpsRequest->pHeadersCur += httpsProtocolVersionLen;
memcpy( pHttpsRequest->pHeadersCur, HTTPS_END_OF_HEADER_LINES_INDICATOR, HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH );
- pHttpsRequest->pHeadersCur += HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH;
+ pHttpsRequest->pHeadersCur += HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH;
/* Add the User-Agent header. */
- status = _addHeader( pHttpsRequest, HTTPS_USER_AGENT_HEADER, FAST_MACRO_STRLEN( HTTPS_USER_AGENT_HEADER ), IOT_HTTPS_USER_AGENT, FAST_MACRO_STRLEN( IOT_HTTPS_USER_AGENT ) );
+ status = _addHeader( pHttpsRequest, HTTPS_USER_AGENT_HEADER, FAST_MACRO_STRLEN( HTTPS_USER_AGENT_HEADER ), IOT_HTTPS_USER_AGENT, FAST_MACRO_STRLEN( IOT_HTTPS_USER_AGENT ) );
if( HTTPS_FAILED( status ) )
{
@@ -2788,7 +2788,7 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t *
HTTPS_GOTO_CLEANUP();
}
- status = _addHeader( pHttpsRequest, HTTPS_HOST_HEADER, FAST_MACRO_STRLEN( HTTPS_HOST_HEADER ), pReqInfo->pHost, pReqInfo->hostLen );
+ status = _addHeader( pHttpsRequest, HTTPS_HOST_HEADER, FAST_MACRO_STRLEN( HTTPS_HOST_HEADER ), pReqInfo->pHost, pReqInfo->hostLen );
if( HTTPS_FAILED( status ) )
{
@@ -2801,35 +2801,35 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t *
if( pReqInfo->isAsync )
{
- pHttpsRequest->isAsync = true;
+ pHttpsRequest->isAsync = true;
/* If this is an asynchronous request then save the callbacks to use. */
- pHttpsRequest->pCallbacks = &( pReqInfo->u.pAsyncInfo->callbacks );
+ pHttpsRequest->pCallbacks = &( pReqInfo->u.pAsyncInfo->callbacks );
pHttpsRequest->pUserPrivData = pReqInfo->u.pAsyncInfo->pPrivData;
/* The body pointer and body length will be filled in when the application sends data in the writeCallback. */
- pHttpsRequest->pBody = NULL;
- pHttpsRequest->bodyLength = 0;
+ pHttpsRequest->pBody = NULL;
+ pHttpsRequest->bodyLength = 0;
}
else
{
- pHttpsRequest->isAsync = false;
+ pHttpsRequest->isAsync = false;
/* Set the HTTP request entity body. This is allowed to be NULL for no body like for a GET request. */
- pHttpsRequest->pBody = pReqInfo->u.pSyncInfo->pBody;
+ pHttpsRequest->pBody = pReqInfo->u.pSyncInfo->pBody;
pHttpsRequest->bodyLength = pReqInfo->u.pSyncInfo->bodyLen;
}
/* Save the method of this request. */
- pHttpsRequest->method = pReqInfo->method;
+ pHttpsRequest->method = pReqInfo->method;
/* Set the connection persistence flag for keeping the connection open after receiving a response. */
pHttpsRequest->isNonPersistent = pReqInfo->isNonPersistent;
/* Initialize the request cancellation. */
- pHttpsRequest->cancelled = false;
+ pHttpsRequest->cancelled = false;
/* Initialize the status of sending the body over the network in a possible asynchronous request. */
- pHttpsRequest->bodyTxStatus = IOT_HTTPS_OK;
+ pHttpsRequest->bodyTxStatus = IOT_HTTPS_OK;
/* This is a new request and therefore not scheduled yet. */
- pHttpsRequest->scheduled = false;
+ pHttpsRequest->scheduled = false;
/* Set the request handle to return. */
- *pReqHandle = pHttpsRequest;
+ *pReqHandle = pHttpsRequest;
HTTPS_FUNCTION_CLEANUP_BEGIN();
@@ -2919,8 +2919,8 @@ IotHttpsReturnCode_t IotHttpsClient_SendSync( IotHttpsConnectionHandle_t connHan
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- bool respFinishedSemCreated = false;
- _httpsResponse_t * pHttpsResponse = NULL;
+ bool respFinishedSemCreated = false;
+ _httpsResponse_t * pHttpsResponse = NULL;
/* Parameter checks. */
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( connHandle );
@@ -2938,7 +2938,7 @@ IotHttpsReturnCode_t IotHttpsClient_SendSync( IotHttpsConnectionHandle_t connHan
}
/* Initialize the response handle to return. */
- status = _initializeResponse( pRespHandle, pRespInfo, reqHandle );
+ status = _initializeResponse( pRespHandle, pRespInfo, reqHandle );
if( HTTPS_FAILED( status ) )
{
@@ -2947,14 +2947,14 @@ IotHttpsReturnCode_t IotHttpsClient_SendSync( IotHttpsConnectionHandle_t connHan
}
/* Set the internal response to use. */
- pHttpsResponse = *pRespHandle;
+ pHttpsResponse = *pRespHandle;
/* The implicit connection passed and we need to the set the connection handle in the request and response. */
- reqHandle->pHttpsConnection = connHandle;
+ reqHandle->pHttpsConnection = connHandle;
pHttpsResponse->pHttpsConnection = connHandle;
/* Create the semaphore used to wait on the response to finish being received. */
- respFinishedSemCreated = IotSemaphore_Create( &( pHttpsResponse->respFinishedSem ), 0 /* initialValue */, 1 /* maxValue */ );
+ respFinishedSemCreated = IotSemaphore_Create( &( pHttpsResponse->respFinishedSem ), 0 /* initialValue */, 1 /* maxValue */ );
if( respFinishedSemCreated == false )
{
@@ -2963,10 +2963,10 @@ IotHttpsReturnCode_t IotHttpsClient_SendSync( IotHttpsConnectionHandle_t connHan
}
/* Associate the response to the request so that we can schedule it to be received when the request gets scheduled to send. */
- reqHandle->pHttpsResponse = pHttpsResponse;
+ reqHandle->pHttpsResponse = pHttpsResponse;
/* Schedule this request to be sent by adding it to the connection's request queue. */
- status = _addRequestToConnectionReqQ( reqHandle );
+ status = _addRequestToConnectionReqQ( reqHandle );
if( HTTPS_FAILED( status ) )
{
@@ -3044,12 +3044,12 @@ IotHttpsReturnCode_t IotHttpsClient_WriteRequestBody( IotHttpsRequestHandle_t re
}
/* Set the pointer to the body and the length for the content-length calculation. */
- reqHandle->pBody = ( uint8_t * ) pBuf;
+ reqHandle->pBody = ( uint8_t * ) pBuf;
reqHandle->bodyLength = len;
/* We send the HTTPS headers and body in this function so that the application has the freedom to specify a body
* that may be buffer on stack. */
- status = _sendHttpsHeadersAndBody( reqHandle->pHttpsConnection, reqHandle );
+ status = _sendHttpsHeadersAndBody( reqHandle->pHttpsConnection, reqHandle );
if( HTTPS_FAILED( status ) )
{
@@ -3085,9 +3085,9 @@ IotHttpsReturnCode_t IotHttpsClient_ReadResponseBody( IotHttpsResponseHandle_t r
/* Set the current body in the respHandle to use in _receiveHttpsBody(). _receiveHttpsBody is generic
* to both async and sync request/response handling. In the sync version the body is configured during
* initializing the request. In the async version the body is given in this function on the fly. */
- respHandle->pBody = pBuf;
- respHandle->pBodyCur = respHandle->pBody;
- respHandle->pBodyEnd = respHandle->pBodyCur + *pLen;
+ respHandle->pBody = pBuf;
+ respHandle->pBodyCur = respHandle->pBody;
+ respHandle->pBodyEnd = respHandle->pBodyCur + *pLen;
/* When there is part of the body in the header pBuffer. We need to move that data to this body pBuffer
* provided in this function. */
@@ -3097,7 +3097,7 @@ IotHttpsReturnCode_t IotHttpsClient_ReadResponseBody( IotHttpsResponseHandle_t r
{
uint32_t copyLength = bodyLengthInHeaderBuf > *pLen ? *pLen : bodyLengthInHeaderBuf;
memcpy( respHandle->pBodyCur, respHandle->pBodyInHeaderBuf, copyLength );
- respHandle->pBodyCur += copyLength;
+ respHandle->pBodyCur += copyLength;
/* This function may be called multiple times until all of the body that may be present in the header buffer is
* moved out. */
@@ -3117,7 +3117,7 @@ IotHttpsReturnCode_t IotHttpsClient_ReadResponseBody( IotHttpsResponseHandle_t r
}
}
- *pLen = respHandle->pBodyCur - respHandle->pBody;
+ *pLen = respHandle->pBodyCur - respHandle->pBody;
HTTPS_FUNCTION_CLEANUP_BEGIN();
@@ -3174,7 +3174,7 @@ IotHttpsReturnCode_t IotHttpsClient_SendAsync( IotHttpsConnectionHandle_t connHa
HTTPS_ON_ARG_ERROR_GOTO_CLEANUP( connHandle->isConnected );
/* Initialize the response handle to return. */
- status = _initializeResponse( pRespHandle, pRespInfo, reqHandle );
+ status = _initializeResponse( pRespHandle, pRespInfo, reqHandle );
if( HTTPS_FAILED( status ) )
{
@@ -3183,16 +3183,16 @@ IotHttpsReturnCode_t IotHttpsClient_SendAsync( IotHttpsConnectionHandle_t connHa
}
/* Set the connection handle in the request handle so that we can use it in the _writeRequestBody() callback. */
- reqHandle->pHttpsConnection = connHandle;
+ reqHandle->pHttpsConnection = connHandle;
/* Set the connection handle in the response handle sp that we can use it in the _readReadyCallback() callback. */
( *pRespHandle )->pHttpsConnection = connHandle;
/* Associate the response to the request so that we can schedule it to be received when the request gets scheduled to send. */
- reqHandle->pHttpsResponse = *pRespHandle;
+ reqHandle->pHttpsResponse = *pRespHandle;
/* Add the request to the connection's request queue. */
- status = _addRequestToConnectionReqQ( reqHandle );
+ status = _addRequestToConnectionReqQ( reqHandle );
if( HTTPS_FAILED( status ) )
{
@@ -3232,10 +3232,10 @@ IotHttpsReturnCode_t IotHttpsClient_ReadHeader( IotHttpsResponseHandle_t respHan
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- const char * pHttpParserErrorDescription = NULL;
+ const char * pHttpParserErrorDescription = NULL;
IotHttpsResponseBufferState_t savedBufferState = PROCESSING_STATE_NONE;
IotHttpsResponseParserState_t savedParserState = PARSER_STATE_NONE;
- size_t numParsed = 0;
+ size_t numParsed = 0;
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( respHandle );
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pName );
@@ -3248,8 +3248,8 @@ IotHttpsReturnCode_t IotHttpsClient_ReadHeader( IotHttpsResponseHandle_t respHan
* changed in the response to wherever the parser is currently located in the response. If this function is called
* in the middle of processing a response (for example in readReadyCallback() routine of an asynchronous response),
* then parsing the response need to be able to start at the same place it was before calling this function. */
- savedBufferState = respHandle->bufferProcessingState;
- savedParserState = respHandle->parserState;
+ savedBufferState = respHandle->bufferProcessingState;
+ savedParserState = respHandle->parserState;
/* The header search parameters in the response handle are used as context in the http-parser callbacks. During
* the callback, pReadHeaderField is checked against the currently parsed header name. foundHeaderField is set to
@@ -3257,18 +3257,18 @@ IotHttpsReturnCode_t IotHttpsClient_ReadHeader( IotHttpsResponseHandle_t respHan
* to skip the logic pertaining to when the response is being parsed for the first time. pReadHeaderValue will store
* the header value found. readHeaderValueLength will store the length of the header value found from within the
* response headers. */
- respHandle->pReadHeaderField = pName;
+ respHandle->pReadHeaderField = pName;
respHandle->readHeaderFieldLength = nameLen;
- respHandle->foundHeaderField = false;
+ respHandle->foundHeaderField = false;
respHandle->bufferProcessingState = PROCESSING_STATE_SEARCHING_HEADER_BUFFER;
- respHandle->pReadHeaderValue = NULL;
+ respHandle->pReadHeaderValue = NULL;
respHandle->readHeaderValueLength = 0;
/* Start over the HTTP parser so that it will parser from the beginning of the message. */
http_parser_init( &( respHandle->httpParserInfo.readHeaderParser ), HTTP_RESPONSE );
IotLogDebug( "Now parsing HTTP Message buffer to read a header." );
- numParsed = respHandle->httpParserInfo.parseFunc( &( respHandle->httpParserInfo.readHeaderParser ), &_httpParserSettings, ( char * ) ( respHandle->pHeaders ), respHandle->pHeadersCur - respHandle->pHeaders );
+ numParsed = respHandle->httpParserInfo.parseFunc( &( respHandle->httpParserInfo.readHeaderParser ), &_httpParserSettings, ( char * ) ( respHandle->pHeaders ), respHandle->pHeadersCur - respHandle->pHeaders );
IotLogDebug( "Parsed %d characters in IotHttpsClient_ReadHeader().", numParsed );
/* There shouldn't be any errors parsing the response body given that the handle is from a validly
@@ -3312,7 +3312,7 @@ IotHttpsReturnCode_t IotHttpsClient_ReadHeader( IotHttpsResponseHandle_t respHan
if( respHandle != NULL )
{
respHandle->bufferProcessingState = savedBufferState;
- respHandle->parserState = savedParserState;
+ respHandle->parserState = savedParserState;
}
HTTPS_FUNCTION_CLEANUP_END();
@@ -3325,8 +3325,8 @@ IotHttpsReturnCode_t IotHttpsClient_ReadContentLength( IotHttpsResponseHandle_t
{
HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK );
- const int CONTENT_LENGTH_NUMBERIC_BASE = 10;
- char pContentLengthStr[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH ] = { 0 };
+ const int CONTENT_LENGTH_NUMBERIC_BASE = 10;
+ char pContentLengthStr[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH ] = { 0 };
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( respHandle );
HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pContentLength );
@@ -3334,7 +3334,7 @@ IotHttpsReturnCode_t IotHttpsClient_ReadContentLength( IotHttpsResponseHandle_t
/* If there is no content-length header or if we were not able to store it in the header buffer this will be
* invalid. We do not use the content-length member of the http-parser state structure to get the content
* length as this is a PRIVATE member. Because it is a PRIVATE member it can be any value. */
- status = IotHttpsClient_ReadHeader( respHandle, HTTPS_CONTENT_LENGTH_HEADER, FAST_MACRO_STRLEN( HTTPS_CONTENT_LENGTH_HEADER ), pContentLengthStr, HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH );
+ status = IotHttpsClient_ReadHeader( respHandle, HTTPS_CONTENT_LENGTH_HEADER, FAST_MACRO_STRLEN( HTTPS_CONTENT_LENGTH_HEADER ), pContentLengthStr, HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH );
if( HTTPS_FAILED( status ) )
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c
index 3b0b5e7c5..402b72673 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c
@@ -44,9 +44,9 @@ IotHttpsReturnCode_t IotHttpsClient_GetUrlPath( const char * pUrl,
size_t * pPathLen )
{
/* http-parser status. Initialized to 0 to signify success. */
- int parserStatus = 0;
+ int parserStatus = 0;
struct http_parser_url urlParser;
- IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK;
+ IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK;
/* Sets all members in urlParser to 0. */
http_parser_url_init( &urlParser );
@@ -75,7 +75,7 @@ IotHttpsReturnCode_t IotHttpsClient_GetUrlPath( const char * pUrl,
if( *pPathLen == 0 )
{
returnStatus = IOT_HTTPS_NOT_FOUND;
- *pPath = NULL;
+ *pPath = NULL;
}
else
{
@@ -94,9 +94,9 @@ IotHttpsReturnCode_t IotHttpsClient_GetUrlAddress( const char * pUrl,
size_t * pAddressLen )
{
/* http-parser status. Initialized to 0 to signify success. */
- int parserStatus = 0;
+ int parserStatus = 0;
struct http_parser_url urlParser;
- IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK;
+ IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK;
/* Sets all members in urlParser to 0. */
http_parser_url_init( &urlParser );
@@ -125,7 +125,7 @@ IotHttpsReturnCode_t IotHttpsClient_GetUrlAddress( const char * pUrl,
if( *pAddressLen == 0 )
{
returnStatus = IOT_HTTPS_NOT_FOUND;
- *pAddress = NULL;
+ *pAddress = NULL;
}
else
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/private/iot_https_internal.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/private/iot_https_internal.h
index a8e0526ef..006ee7889 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/private/iot_https_internal.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/private/iot_https_internal.h
@@ -381,11 +381,11 @@ typedef struct _httpsConnection
* disconnect with a network error, or an explicit disconnect with a call to @ref https_client_function_disconnect.
*/
bool isConnected;
- bool isDestroyed; /**< @brief true if the connection is already destroyed and we should call anymore */
- IotMutex_t connectionMutex; /**< @brief Mutex protecting operations on this entire connection context. */
- IotDeQueue_t reqQ; /**< @brief The queue for the requests that are not finished yet. */
- IotDeQueue_t respQ; /**< @brief The queue for the responses that are waiting to be processed. */
- taskPoolJob_t taskPoolJob; /**< @brief The task pool job identifier for an asynchronous request. */
+ bool isDestroyed; /**< @brief true if the connection is already destroyed and we should call anymore */
+ IotMutex_t connectionMutex; /**< @brief Mutex protecting operations on this entire connection context. */
+ IotDeQueue_t reqQ; /**< @brief The queue for the requests that are not finished yet. */
+ IotDeQueue_t respQ; /**< @brief The queue for the responses that are waiting to be processed. */
+ taskPoolJob_t taskPoolJob; /**< @brief The task pool job identifier for an asynchronous request. */
} _httpsConnection_t;
/**
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c
index 6f5b56fc7..6a5f933e6 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c
@@ -413,8 +413,8 @@ static void _mqttSubscription_tryDestroy( void * pData )
static void _mqttOperation_tryDestroy( void * pData )
{
- _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pData;
- taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
+ _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pData;
+ taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
/* Incoming PUBLISH operations may always be freed. */
if( pOperation->incomingPublish == true )
@@ -459,17 +459,17 @@ static bool _createKeepAliveOperation( const IotMqttNetworkInfo_t * pNetworkInfo
uint16_t keepAliveSeconds,
_mqttConnection_t * pMqttConnection )
{
- bool status = true;
+ bool status = true;
IotMqttError_t serializeStatus = IOT_MQTT_SUCCESS;
/* Network information is not used when MQTT packet serializers are disabled. */
( void ) pNetworkInfo;
/* Set PINGREQ operation members. */
- pMqttConnection->pingreq.u.operation.type = IOT_MQTT_PINGREQ;
+ pMqttConnection->pingreq.u.operation.type = IOT_MQTT_PINGREQ;
/* Convert the keep-alive interval to milliseconds. */
- pMqttConnection->pingreq.u.operation.periodic.ping.keepAliveMs = ( uint32_t ) keepAliveSeconds * 1000U;
+ pMqttConnection->pingreq.u.operation.periodic.ping.keepAliveMs = ( uint32_t ) keepAliveSeconds * 1000U;
pMqttConnection->pingreq.u.operation.periodic.ping.nextPeriodMs = ( uint32_t ) keepAliveSeconds * 1000U;
/* Generate a PINGREQ packet. */
@@ -534,7 +534,7 @@ static IotNetworkError_t _createNetworkConnection( const IotMqttNetworkInfo_t *
{
/* A connection already exists; the caller should not destroy
* it on cleanup. */
- *pNetworkConnection = pNetworkInfo->u.pNetworkConnection;
+ *pNetworkConnection = pNetworkInfo->u.pNetworkConnection;
*pCreatedNewNetworkConnection = false;
}
@@ -547,9 +547,9 @@ static _mqttConnection_t * _createMqttConnection( bool awsIotMqttMode,
const IotMqttNetworkInfo_t * pNetworkInfo,
uint16_t keepAliveSeconds )
{
- bool status = true;
+ bool status = true;
_mqttConnection_t * pMqttConnection = NULL;
- bool referencesMutexCreated = false, subscriptionMutexCreated = false;
+ bool referencesMutexCreated = false, subscriptionMutexCreated = false;
/* Allocate memory for the new MQTT connection. */
pMqttConnection = IotMqtt_MallocConnection( sizeof( _mqttConnection_t ) );
@@ -565,15 +565,15 @@ static _mqttConnection_t * _createMqttConnection( bool awsIotMqttMode,
/* Clear the MQTT connection, then copy the MQTT server mode, network
* interface, and disconnect callback. */
( void ) memset( pMqttConnection, 0x00, sizeof( _mqttConnection_t ) );
- pMqttConnection->awsIotMqttMode = awsIotMqttMode;
- pMqttConnection->pNetworkInterface = pNetworkInfo->pNetworkInterface;
+ pMqttConnection->awsIotMqttMode = awsIotMqttMode;
+ pMqttConnection->pNetworkInterface = pNetworkInfo->pNetworkInterface;
pMqttConnection->disconnectCallback = pNetworkInfo->disconnectCallback;
/* Start a new MQTT connection with a reference count of 1. */
- pMqttConnection->references = 1;
+ pMqttConnection->references = 1;
/* Create the references mutex for a new connection. It is a recursive mutex. */
- referencesMutexCreated = IotMutex_Create( &( pMqttConnection->referencesMutex ), true );
+ referencesMutexCreated = IotMutex_Create( &( pMqttConnection->referencesMutex ), true );
if( referencesMutexCreated == false )
{
@@ -649,8 +649,8 @@ static void _destroyMqttConnection( _mqttConnection_t * pMqttConnection )
/* Clear data about the keep-alive. */
pMqttConnection->pingreq.u.operation.periodic.ping.keepAliveMs = 0;
- pMqttConnection->pingreq.u.operation.pMqttPacket = NULL;
- pMqttConnection->pingreq.u.operation.packetSize = 0;
+ pMqttConnection->pingreq.u.operation.pMqttPacket = NULL;
+ pMqttConnection->pingreq.u.operation.packetSize = 0;
/* Decrement reference count. */
pMqttConnection->references--;
@@ -760,7 +760,7 @@ static IotMqttError_t _subscriptionCreateAndSerialize( IotMqttOperationType_t op
const IotMqttCallbackInfo_t * pCallbackInfo,
_mqttOperation_t ** ppSubscriptionOperation )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
_mqttOperation_t * pSubscriptionOperation = NULL;
/* Create a subscription operation. */
@@ -771,7 +771,7 @@ static IotMqttError_t _subscriptionCreateAndSerialize( IotMqttOperationType_t op
if( status == IOT_MQTT_SUCCESS )
{
- pSubscriptionOperation = ( *ppSubscriptionOperation );
+ pSubscriptionOperation = ( *ppSubscriptionOperation );
/* Check the subscription operation data and set the operation type. */
@@ -780,11 +780,11 @@ static IotMqttError_t _subscriptionCreateAndSerialize( IotMqttOperationType_t op
pSubscriptionOperation->u.operation.type = operation;
/* Generate a subscription packet from the subscription list. */
- status = serializeSubscription( pSubscriptionList,
- subscriptionCount,
- &( pSubscriptionOperation->u.operation.pMqttPacket ),
- &( pSubscriptionOperation->u.operation.packetSize ),
- &( pSubscriptionOperation->u.operation.packetIdentifier ) );
+ status = serializeSubscription( pSubscriptionList,
+ subscriptionCount,
+ &( pSubscriptionOperation->u.operation.pMqttPacket ),
+ &( pSubscriptionOperation->u.operation.packetSize ),
+ &( pSubscriptionOperation->u.operation.packetIdentifier ) );
}
if( status == IOT_MQTT_SUCCESS )
@@ -832,7 +832,7 @@ static IotMqttError_t _subscriptionCommon( IotMqttOperationType_t operation,
const IotMqttCallbackInfo_t * pCallbackInfo,
IotMqttOperation_t * const pOperationReference )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
_mqttOperation_t * pSubscriptionOperation = NULL;
/* Create and serialize the subscription operation. */
@@ -966,7 +966,7 @@ static IotMqttError_t _waitForOperation( IotMqttOperation_t operation,
static IotMqttError_t _scheduleKeepAlive( IotMqttConnection_t pMqttConnection )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
/* Check if a keep-alive job should be scheduled. */
@@ -1164,16 +1164,15 @@ void _IotMqtt_DecrementConnectionReferences( _mqttConnection_t * pMqttConnection
IotMqttError_t IotMqtt_Init( void )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- uint32_t allowInitialization = Atomic_CompareAndSwap_u32( &_initCalled,
- MQTT_LIBRARY_INITIALIZED,
- MQTT_LIBRARY_UNINITIALIZED );
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ uint32_t allowInitialization = Atomic_CompareAndSwap_u32( &_initCalled,
+ MQTT_LIBRARY_INITIALIZED,
+ MQTT_LIBRARY_UNINITIALIZED );
if( allowInitialization == 1U )
{
-
/* Initialize the task pool module, which is a dependency for the HTTPS library. */
- taskPoolCreateSystemTaskPool();
+ taskPoolCreateSystemTaskPool();
/* Call any additional serializer initialization function if serializer
* overrides are enabled. */
@@ -1235,12 +1234,12 @@ IotMqttError_t IotMqtt_Connect( const IotMqttNetworkInfo_t * pNetworkInfo,
uint32_t timeoutMs,
IotMqttConnection_t * const pMqttConnection )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- bool ownNetworkConnection = false;
- IotNetworkError_t networkStatus = IOT_NETWORK_SUCCESS;
- IotNetworkConnection_t pNetworkConnection = NULL;
- _mqttOperation_t * pOperation = NULL;
- _mqttConnection_t * pNewMqttConnection = NULL;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ bool ownNetworkConnection = false;
+ IotNetworkError_t networkStatus = IOT_NETWORK_SUCCESS;
+ IotNetworkConnection_t pNetworkConnection = NULL;
+ _mqttOperation_t * pOperation = NULL;
+ _mqttConnection_t * pNewMqttConnection = NULL;
/* Check that IotMqtt_Init was called. */
if( _checkInit() == false )
@@ -1283,19 +1282,19 @@ IotMqttError_t IotMqtt_Connect( const IotMqttNetworkInfo_t * pNetworkInfo,
if( status == IOT_MQTT_SUCCESS )
{
/* Set the network connection associated with the MQTT connection. */
- pNewMqttConnection->pNetworkConnection = pNetworkConnection;
+ pNewMqttConnection->pNetworkConnection = pNetworkConnection;
pNewMqttConnection->ownNetworkConnection = ownNetworkConnection;
/* Set the MQTT packet serializer overrides. */
#if IOT_MQTT_ENABLE_SERIALIZER_OVERRIDES == 1
- pNewMqttConnection->pSerializer = pNetworkInfo->pMqttSerializer;
+ pNewMqttConnection->pSerializer = pNetworkInfo->pMqttSerializer;
#else
- pNewMqttConnection->pSerializer = NULL;
+ pNewMqttConnection->pSerializer = NULL;
#endif
- networkStatus = pNewMqttConnection->pNetworkInterface->setReceiveCallback( pNetworkConnection,
- IotMqtt_ReceiveCallback,
- pNewMqttConnection );
+ networkStatus = pNewMqttConnection->pNetworkInterface->setReceiveCallback( pNetworkConnection,
+ IotMqtt_ReceiveCallback,
+ pNewMqttConnection );
if( networkStatus != IOT_NETWORK_SUCCESS )
{
@@ -1333,7 +1332,7 @@ IotMqttError_t IotMqtt_Connect( const IotMqttNetworkInfo_t * pNetworkInfo,
if( status == IOT_MQTT_SUCCESS )
{
/* Send the CONNECT packet */
- status = _sendConnectRequest( pOperation, timeoutMs );
+ status = _sendConnectRequest( pOperation, timeoutMs );
/* The call to wait inside _sendConnectRequest cleans up
* the CONNECT operation, so set the pointer to NULL. */
@@ -1373,8 +1372,8 @@ IotMqttError_t IotMqtt_Connect( const IotMqttNetworkInfo_t * pNetworkInfo,
void IotMqtt_Disconnect( IotMqttConnection_t mqttConnection,
uint32_t flags )
{
- bool disconnected = false, initCalled = false;
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ bool disconnected = false, initCalled = false;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
_mqttOperation_t * pOperation = NULL;
/* Check that IotMqtt_Init was called. */
@@ -1431,8 +1430,8 @@ void IotMqtt_Disconnect( IotMqttConnection_t mqttConnection,
pOperation->u.operation.type = IOT_MQTT_DISCONNECT;
/* Generate a DISCONNECT packet. */
- status = _getMqttDisconnectSerializer( mqttConnection->pSerializer )( &( pOperation->u.operation.pMqttPacket ),
- &( pOperation->u.operation.packetSize ) );
+ status = _getMqttDisconnectSerializer( mqttConnection->pSerializer )( &( pOperation->u.operation.pMqttPacket ),
+ &( pOperation->u.operation.packetSize ) );
}
}
@@ -1548,7 +1547,7 @@ IotMqttError_t IotMqtt_SubscribeSync( IotMqttConnection_t mqttConnection,
uint32_t flags,
uint32_t timeoutMs )
{
- IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
+ IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
IotMqttOperation_t subscribeOperation = IOT_MQTT_OPERATION_INITIALIZER;
/* Flags are not used, but the parameter is present for future compatibility. */
@@ -1618,7 +1617,7 @@ IotMqttError_t IotMqtt_UnsubscribeSync( IotMqttConnection_t mqttConnection,
uint32_t flags,
uint32_t timeoutMs )
{
- IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
+ IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
IotMqttOperation_t unsubscribeOperation = IOT_MQTT_OPERATION_INITIALIZER;
/* Flags are not used, but the parameter is present for future compatibility. */
@@ -1652,9 +1651,9 @@ IotMqttError_t IotMqtt_PublishAsync( IotMqttConnection_t mqttConnection,
const IotMqttCallbackInfo_t * pCallbackInfo,
IotMqttOperation_t * const pPublishOperation )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- _mqttOperation_t * pOperation = NULL;
- uint8_t ** pPacketIdentifierHigh = NULL;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ _mqttOperation_t * pOperation = NULL;
+ uint8_t ** pPacketIdentifierHigh = NULL;
/* Check that IotMqtt_Init was called. */
if( _checkInit() == false )
@@ -1691,11 +1690,11 @@ IotMqttError_t IotMqtt_PublishAsync( IotMqttConnection_t mqttConnection,
}
/* Generate a PUBLISH packet from pPublishInfo. */
- status = _getMqttPublishSerializer( mqttConnection->pSerializer )( pPublishInfo,
- &( pOperation->u.operation.pMqttPacket ),
- &( pOperation->u.operation.packetSize ),
- &( pOperation->u.operation.packetIdentifier ),
- pPacketIdentifierHigh );
+ status = _getMqttPublishSerializer( mqttConnection->pSerializer )( pPublishInfo,
+ &( pOperation->u.operation.pMqttPacket ),
+ &( pOperation->u.operation.packetSize ),
+ &( pOperation->u.operation.packetIdentifier ),
+ pPacketIdentifierHigh );
}
if( status == IOT_MQTT_SUCCESS )
@@ -1710,7 +1709,7 @@ IotMqttError_t IotMqtt_PublishAsync( IotMqttConnection_t mqttConnection,
/* A QoS 0 PUBLISH may not be retried. */
if( pPublishInfo->qos != IOT_MQTT_QOS_0 )
{
- pOperation->u.operation.periodic.retry.limit = pPublishInfo->retryLimit;
+ pOperation->u.operation.periodic.retry.limit = pPublishInfo->retryLimit;
pOperation->u.operation.periodic.retry.nextPeriodMs = pPublishInfo->retryMs;
}
}
@@ -1768,11 +1767,11 @@ IotMqttError_t IotMqtt_PublishSync( IotMqttConnection_t mqttConnection,
uint32_t flags,
uint32_t timeoutMs )
{
- IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
- IotMqttOperation_t publishOperation = IOT_MQTT_OPERATION_INITIALIZER,
+ IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
+ IotMqttOperation_t publishOperation = IOT_MQTT_OPERATION_INITIALIZER,
* pPublishOperation = NULL;
/* Set only the "serial" flag. */
- uint32_t syncFlags = MQTT_INTERNAL_FLAG_BLOCK_ON_SEND;
+ uint32_t syncFlags = MQTT_INTERNAL_FLAG_BLOCK_ON_SEND;
/* Flags are currently ignored. */
( void ) flags;
@@ -1780,7 +1779,7 @@ IotMqttError_t IotMqtt_PublishSync( IotMqttConnection_t mqttConnection,
/* Set the waitable flag and reference for QoS 1 PUBLISH. */
if( pPublishInfo->qos == IOT_MQTT_QOS_1 )
{
- syncFlags |= IOT_MQTT_FLAG_WAITABLE;
+ syncFlags |= IOT_MQTT_FLAG_WAITABLE;
pPublishOperation = &publishOperation;
}
@@ -1808,7 +1807,7 @@ IotMqttError_t IotMqtt_PublishSync( IotMqttConnection_t mqttConnection,
IotMqttError_t IotMqtt_Wait( IotMqttOperation_t operation,
uint32_t timeoutMs )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
_mqttConnection_t * pMqttConnection = NULL;
/* Check that IotMqtt_Init was called. */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c
index 8bf66e2f8..4e472ab6d 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c
@@ -135,7 +135,7 @@ static uint8_t * _encodeUserNameAndMetrics( uint8_t * pDestination,
* the function #_IotMqtt_RemainingLengthEncodedSize to avoid buffer overflows.
*/
static uint8_t * _encodeRemainingLength( uint8_t * pDestination,
- size_t length );
+ size_t length );
/**
* @brief Encode a username into a CONNECT packet, if necessary.
@@ -145,14 +145,14 @@ static uint8_t * _encodeRemainingLength( uint8_t * pDestination,
*
* @return Pointer to the end of the encoded string, which will be identical to
* `pDestination` if nothing was encoded.
- *
+ *
* @warning This function does not check the size of `pDestination`! To avoid a
* buffer overflow, ensure that `pDestination` is large enough to hold
* `pConnectInfo->userNameLength` bytes if a username is supplied, and/or
* #AWS_IOT_METRICS_USERNAME_LENGTH bytes if metrics are enabled.
*/
static uint8_t * _encodeUserName( uint8_t * pDestination,
- const IotMqttConnectInfo_t * pConnectInfo );
+ const IotMqttConnectInfo_t * pConnectInfo );
/**
* @brief Encode a C string as a UTF-8 string, per MQTT 3.1.1 spec.
@@ -169,8 +169,8 @@ static uint8_t * _encodeUserName( uint8_t * pDestination,
* overflow.
*/
static uint8_t * _encodeString( uint8_t * pDestination,
- const char * source,
- uint16_t sourceLength );
+ const char * source,
+ uint16_t sourceLength );
/*-----------------------------------------------------------*/
@@ -178,7 +178,7 @@ static uint8_t * _encodeUserNameAndMetrics( uint8_t * pDestination,
const IotMqttConnectInfo_t * pConnectInfo,
bool * pEncodedUserName )
{
- uint8_t * pBuffer = pDestination;
+ uint8_t * pBuffer = pDestination;
#if AWS_IOT_MQTT_ENABLE_METRICS == 1
const char * pMetricsUserName = AWS_IOT_METRICS_USERNAME;
@@ -188,35 +188,35 @@ static uint8_t * _encodeUserNameAndMetrics( uint8_t * pDestination,
if( ( pConnectInfo->userNameLength + AWS_IOT_METRICS_USERNAME_LENGTH ) <= ( ( uint16_t ) ( UINT16_MAX ) ) )
{
/* Write the high byte of the combined length. */
- pBuffer[ 0 ] = UINT16_HIGH_BYTE( ( pConnectInfo->userNameLength +
- AWS_IOT_METRICS_USERNAME_LENGTH ) );
+ pBuffer[ 0 ] = UINT16_HIGH_BYTE( ( pConnectInfo->userNameLength +
+ AWS_IOT_METRICS_USERNAME_LENGTH ) );
/* Write the low byte of the combined length. */
- pBuffer[ 1 ] = UINT16_LOW_BYTE( ( pConnectInfo->userNameLength +
- AWS_IOT_METRICS_USERNAME_LENGTH ) );
- pBuffer += 2;
+ pBuffer[ 1 ] = UINT16_LOW_BYTE( ( pConnectInfo->userNameLength +
+ AWS_IOT_METRICS_USERNAME_LENGTH ) );
+ pBuffer += 2;
/* Write the identity portion of the username.
* As the types of char and uint8_t are of the same size, this memcpy
* is acceptable. */
/* coverity[misra_c_2012_rule_21_15_violation] */
( void ) memcpy( pBuffer, pConnectInfo->pUserName, pConnectInfo->userNameLength );
- pBuffer += pConnectInfo->userNameLength;
+ pBuffer += pConnectInfo->userNameLength;
/* Write the metrics portion of the username.
* As the types of char and uint8_t are of the same size, this memcpy
* is acceptable. */
/* coverity[misra_c_2012_rule_21_15_violation] */
( void ) memcpy( pBuffer, pMetricsUserName, AWS_IOT_METRICS_USERNAME_LENGTH );
- pBuffer += AWS_IOT_METRICS_USERNAME_LENGTH;
+ pBuffer += AWS_IOT_METRICS_USERNAME_LENGTH;
*pEncodedUserName = true;
}
else
{
IotLogWarn( "Username length of %lu is larger than maximum %lu.",
- ( pConnectInfo->userNameLength + AWS_IOT_METRICS_USERNAME_LENGTH ),
- UINT16_MAX );
+ ( pConnectInfo->userNameLength + AWS_IOT_METRICS_USERNAME_LENGTH ),
+ UINT16_MAX );
}
#else /* if AWS_IOT_MQTT_ENABLE_METRICS == 1 */
/* Avoid unused variable warnings when AWS_IOT_MQTT_ENABLE_METRICS is set to 0. */
@@ -231,8 +231,8 @@ static uint8_t * _encodeUserNameAndMetrics( uint8_t * pDestination,
static uint8_t * _encodeUserName( uint8_t * pDestination,
const IotMqttConnectInfo_t * pConnectInfo )
{
- bool encodedUserName = false;
- uint8_t * pBuffer = pDestination;
+ bool encodedUserName = false;
+ uint8_t * pBuffer = pDestination;
/* If metrics are enabled, write the metrics username into the CONNECT packet.
* Otherwise, write the username and password only when not connecting to the
@@ -254,9 +254,9 @@ static uint8_t * _encodeUserName( uint8_t * pDestination,
{
/* The username is not being used for authentication, but
* metrics are enabled. */
- pBuffer = _encodeString( pBuffer,
- AWS_IOT_METRICS_USERNAME,
- AWS_IOT_METRICS_USERNAME_LENGTH );
+ pBuffer = _encodeString( pBuffer,
+ AWS_IOT_METRICS_USERNAME,
+ AWS_IOT_METRICS_USERNAME_LENGTH );
encodedUserName = true;
}
@@ -307,12 +307,12 @@ static uint8_t * _encodeRemainingLength( uint8_t * pDestination,
size_t length )
{
uint8_t lengthByte = 0, * pLengthEnd = pDestination;
- size_t remainingLength = length;
+ size_t remainingLength = length;
/* This algorithm is copied from the MQTT v3.1.1 spec. */
do
{
- lengthByte = ( uint8_t ) ( remainingLength % 128U );
+ lengthByte = ( uint8_t ) ( remainingLength % 128U );
remainingLength = remainingLength / 128U;
/* Set the high bit of this byte, indicating that there's more data. */
@@ -322,7 +322,7 @@ static uint8_t * _encodeRemainingLength( uint8_t * pDestination,
}
/* Output a single encoded byte. */
- *pLengthEnd = lengthByte;
+ *pLengthEnd = lengthByte;
pLengthEnd++;
} while( remainingLength > 0U );
@@ -385,8 +385,8 @@ bool _IotMqtt_ConnectPacketSize( const IotMqttConnectInfo_t * pConnectInfo,
size_t * pRemainingLength,
size_t * pPacketSize )
{
- bool status = true;
- bool encodedUserName = false;
+ bool status = true;
+ bool encodedUserName = false;
size_t connectPacketSize = 0, remainingLength = 0;
/* The CONNECT packet will always include a 10-byte variable header. */
@@ -409,7 +409,7 @@ bool _IotMqtt_ConnectPacketSize( const IotMqttConnectInfo_t * pConnectInfo,
#if AWS_IOT_MQTT_ENABLE_METRICS == 1
connectPacketSize += ( AWS_IOT_METRICS_USERNAME_LENGTH +
( size_t ) ( pConnectInfo->userNameLength ) + sizeof( uint16_t ) );
- encodedUserName = true;
+ encodedUserName = true;
#endif
}
@@ -427,7 +427,7 @@ bool _IotMqtt_ConnectPacketSize( const IotMqttConnectInfo_t * pConnectInfo,
/* At this point, the "Remaining Length" field of the MQTT CONNECT packet has
* been calculated. */
- remainingLength = connectPacketSize;
+ remainingLength = connectPacketSize;
/* Calculate the full size of the MQTT CONNECT packet by adding the size of
* the "Remaining Length" field plus 1 byte for the "Packet Type" field. */
@@ -441,7 +441,7 @@ bool _IotMqtt_ConnectPacketSize( const IotMqttConnectInfo_t * pConnectInfo,
else
{
*pRemainingLength = remainingLength;
- *pPacketSize = connectPacketSize;
+ *pPacketSize = connectPacketSize;
}
return status;
@@ -454,28 +454,28 @@ void _IotMqtt_SerializeConnectCommon( const IotMqttConnectInfo_t * pConnectInfo,
uint8_t * pPacket,
size_t connectPacketSize )
{
- uint8_t connectFlags = 0;
- uint8_t * pBuffer = pPacket;
+ uint8_t connectFlags = 0;
+ uint8_t * pBuffer = pPacket;
/* Avoid unused variable warning when logging and asserts are disabled. */
( void ) pPacket;
( void ) connectPacketSize;
/* The first byte in the CONNECT packet is the control packet type. */
- *pBuffer = MQTT_PACKET_TYPE_CONNECT;
+ *pBuffer = MQTT_PACKET_TYPE_CONNECT;
pBuffer++;
/* The remaining length of the CONNECT packet is encoded starting from the
* second byte. The remaining length does not include the length of the fixed
* header or the encoding of the remaining length. */
- pBuffer = _encodeRemainingLength( pBuffer, remainingLength );
+ pBuffer = _encodeRemainingLength( pBuffer, remainingLength );
/* The string "MQTT" is placed at the beginning of the CONNECT packet's variable
* header. This string is 4 bytes long. */
- pBuffer = _encodeString( pBuffer, "MQTT", 4 );
+ pBuffer = _encodeString( pBuffer, "MQTT", 4 );
/* The MQTT protocol version is the second byte of the variable header. */
- *pBuffer = MQTT_VERSION_3_1_1;
+ *pBuffer = MQTT_VERSION_3_1_1;
pBuffer++;
/* Set the CONNECT flags based on the given parameters. */
@@ -535,18 +535,18 @@ void _IotMqtt_SerializeConnectCommon( const IotMqttConnectInfo_t * pConnectInfo,
}
}
- *pBuffer = connectFlags;
+ *pBuffer = connectFlags;
pBuffer++;
/* Write the 2 bytes of the keep alive interval into the CONNECT packet. */
- *pBuffer = UINT16_HIGH_BYTE( pConnectInfo->keepAliveSeconds );
+ *pBuffer = UINT16_HIGH_BYTE( pConnectInfo->keepAliveSeconds );
*( pBuffer + 1 ) = UINT16_LOW_BYTE( pConnectInfo->keepAliveSeconds );
- pBuffer += 2;
+ pBuffer += 2;
/* Write the client identifier into the CONNECT packet. */
- pBuffer = _encodeString( pBuffer,
- pConnectInfo->pClientIdentifier,
- pConnectInfo->clientIdentifierLength );
+ pBuffer = _encodeString( pBuffer,
+ pConnectInfo->pClientIdentifier,
+ pConnectInfo->clientIdentifierLength );
/* Write the will topic name and message into the CONNECT packet if provided. */
if( pConnectInfo->pWillInfo != NULL )
@@ -561,7 +561,7 @@ void _IotMqtt_SerializeConnectCommon( const IotMqttConnectInfo_t * pConnectInfo,
}
/* Encode the username if there is one or metrics are enabled. */
- pBuffer = _encodeUserName( pBuffer, pConnectInfo );
+ pBuffer = _encodeUserName( pBuffer, pConnectInfo );
/* Encode the password field, if requested by the app. */
if( pConnectInfo->pPassword != NULL )
@@ -615,37 +615,37 @@ void _IotMqtt_SerializeSubscribeCommon( const IotMqttSubscription_t * pSubscript
uint8_t * pPacket,
size_t subscribePacketSize )
{
- uint16_t packetIdentifier = 0;
- size_t i = 0;
- uint8_t * pBuffer = pPacket;
+ uint16_t packetIdentifier = 0;
+ size_t i = 0;
+ uint8_t * pBuffer = pPacket;
/* Avoid unused variable warning when logging and asserts are disabled. */
( void ) pPacket;
( void ) subscribePacketSize;
/* The first byte in SUBSCRIBE is the packet type. */
- *pBuffer = MQTT_PACKET_TYPE_SUBSCRIBE;
+ *pBuffer = MQTT_PACKET_TYPE_SUBSCRIBE;
pBuffer++;
/* Encode the "Remaining length" starting from the second byte. */
- pBuffer = _encodeRemainingLength( pBuffer, remainingLength );
+ pBuffer = _encodeRemainingLength( pBuffer, remainingLength );
/* Get the next packet identifier. It should always be nonzero. */
- packetIdentifier = _IotMqtt_NextPacketIdentifier();
+ packetIdentifier = _IotMqtt_NextPacketIdentifier();
*pPacketIdentifier = packetIdentifier;
IotMqtt_Assert( packetIdentifier != 0U );
/* Place the packet identifier into the SUBSCRIBE packet. */
- *pBuffer = UINT16_HIGH_BYTE( packetIdentifier );
- *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier );
- pBuffer += 2;
+ *pBuffer = UINT16_HIGH_BYTE( packetIdentifier );
+ *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier );
+ pBuffer += 2;
/* Serialize each subscription topic filter and QoS. */
for( i = 0; i < subscriptionCount; i++ )
{
- pBuffer = _encodeString( pBuffer,
- pSubscriptionList[ i ].pTopicFilter,
- pSubscriptionList[ i ].topicFilterLength );
+ pBuffer = _encodeString( pBuffer,
+ pSubscriptionList[ i ].pTopicFilter,
+ pSubscriptionList[ i ].topicFilterLength );
/* Place the QoS in the SUBSCRIBE packet. */
*pBuffer = ( uint8_t ) ( pSubscriptionList[ i ].qos );
@@ -668,7 +668,7 @@ bool _IotMqtt_SubscriptionPacketSize( IotMqttOperationType_t type,
size_t * pRemainingLength,
size_t * pPacketSize )
{
- bool status = true;
+ bool status = true;
size_t i = 0, subscriptionPacketSize = 0;
/* Only SUBSCRIBE and UNSUBSCRIBE operations should call this function. */
@@ -701,13 +701,13 @@ bool _IotMqtt_SubscriptionPacketSize( IotMqttOperationType_t type,
}
else
{
- *pRemainingLength = subscriptionPacketSize;
+ *pRemainingLength = subscriptionPacketSize;
/* Calculate the full size of the subscription packet by adding the size of the
* "Remaining length" field plus 1 byte for the "Packet type" field. Set the
* pPacketSize output parameter. */
subscriptionPacketSize += 1U + _IotMqtt_RemainingLengthEncodedSize( subscriptionPacketSize );
- *pPacketSize = subscriptionPacketSize;
+ *pPacketSize = subscriptionPacketSize;
}
return status;
@@ -719,7 +719,7 @@ bool _IotMqtt_PublishPacketSize( const IotMqttPublishInfo_t * pPublishInfo,
size_t * pRemainingLength,
size_t * pPacketSize )
{
- bool status = true;
+ bool status = true;
size_t publishPacketSize = 0, payloadLimit = 0;
/* The variable header of a PUBLISH packet always contains the topic name. */
@@ -735,7 +735,7 @@ bool _IotMqtt_PublishPacketSize( const IotMqttPublishInfo_t * pPublishInfo,
/* Calculate the maximum allowed size of the payload for the given parameters.
* This calculation excludes the "Remaining length" encoding, whose size is not
* yet known. */
- payloadLimit = MQTT_MAX_REMAINING_LENGTH - publishPacketSize - 1U;
+ payloadLimit = MQTT_MAX_REMAINING_LENGTH - publishPacketSize - 1U;
/* Ensure that the given payload fits within the calculated limit. */
if( pPublishInfo->payloadLength > payloadLimit )
@@ -750,7 +750,7 @@ bool _IotMqtt_PublishPacketSize( const IotMqttPublishInfo_t * pPublishInfo,
/* Now that the "Remaining length" is known, recalculate the payload limit
* based on the size of its encoding. */
- payloadLimit -= _IotMqtt_RemainingLengthEncodedSize( publishPacketSize );
+ payloadLimit -= _IotMqtt_RemainingLengthEncodedSize( publishPacketSize );
/* Check that the given payload fits within the size allowed by MQTT spec. */
if( pPublishInfo->payloadLength > payloadLimit )
@@ -761,10 +761,10 @@ bool _IotMqtt_PublishPacketSize( const IotMqttPublishInfo_t * pPublishInfo,
{
/* Set the "Remaining length" output parameter and calculate the full
* size of the PUBLISH packet. */
- *pRemainingLength = publishPacketSize;
+ *pRemainingLength = publishPacketSize;
publishPacketSize += 1U + _IotMqtt_RemainingLengthEncodedSize( publishPacketSize );
- *pPacketSize = publishPacketSize;
+ *pPacketSize = publishPacketSize;
}
}
@@ -780,9 +780,9 @@ void _IotMqtt_SerializePublishCommon( const IotMqttPublishInfo_t * pPublishInfo,
uint8_t * pPacket,
size_t publishPacketSize )
{
- uint8_t publishFlags = 0;
- uint16_t packetIdentifier = 0;
- uint8_t * pBuffer = pPacket;
+ uint8_t publishFlags = 0;
+ uint16_t packetIdentifier = 0;
+ uint8_t * pBuffer = pPacket;
/* Avoid unused variable warning when logging and asserts are disabled. */
( void ) pPacket;
@@ -809,22 +809,22 @@ void _IotMqtt_SerializePublishCommon( const IotMqttPublishInfo_t * pPublishInfo,
UINT8_SET_BIT( publishFlags, MQTT_PUBLISH_FLAG_RETAIN );
}
- *pBuffer = publishFlags;
+ *pBuffer = publishFlags;
pBuffer++;
/* The "Remaining length" is encoded from the second byte. */
- pBuffer = _encodeRemainingLength( pBuffer, remainingLength );
+ pBuffer = _encodeRemainingLength( pBuffer, remainingLength );
/* The topic name is placed after the "Remaining length". */
- pBuffer = _encodeString( pBuffer,
- pPublishInfo->pTopicName,
- pPublishInfo->topicNameLength );
+ pBuffer = _encodeString( pBuffer,
+ pPublishInfo->pTopicName,
+ pPublishInfo->topicNameLength );
/* A packet identifier is required for QoS 1 and 2 messages. */
if( pPublishInfo->qos > IOT_MQTT_QOS_0 )
{
/* Get the next packet identifier. It should always be nonzero. */
- packetIdentifier = _IotMqtt_NextPacketIdentifier();
+ packetIdentifier = _IotMqtt_NextPacketIdentifier();
IotMqtt_Assert( packetIdentifier != 0U );
/* Set the packet identifier output parameters. */
@@ -836,9 +836,9 @@ void _IotMqtt_SerializePublishCommon( const IotMqttPublishInfo_t * pPublishInfo,
}
/* Place the packet identifier into the PUBLISH packet. */
- *pBuffer = UINT16_HIGH_BYTE( packetIdentifier );
- *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier );
- pBuffer += 2;
+ *pBuffer = UINT16_HIGH_BYTE( packetIdentifier );
+ *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier );
+ pBuffer += 2;
}
/* The payload is placed after the packet identifier. */
@@ -868,30 +868,30 @@ void _IotMqtt_SerializeUnsubscribeCommon( const IotMqttSubscription_t * pSubscri
uint8_t * pPacket,
size_t unsubscribePacketSize )
{
- uint16_t packetIdentifier = 0;
- size_t i = 0;
- uint8_t * pBuffer = pPacket;
+ uint16_t packetIdentifier = 0;
+ size_t i = 0;
+ uint8_t * pBuffer = pPacket;
/* Avoid unused variable warning when logging and asserts are disabled. */
( void ) pPacket;
( void ) unsubscribePacketSize;
/* The first byte in UNSUBSCRIBE is the packet type. */
- *pBuffer = MQTT_PACKET_TYPE_UNSUBSCRIBE;
+ *pBuffer = MQTT_PACKET_TYPE_UNSUBSCRIBE;
pBuffer++;
/* Encode the "Remaining length" starting from the second byte. */
- pBuffer = _encodeRemainingLength( pBuffer, remainingLength );
+ pBuffer = _encodeRemainingLength( pBuffer, remainingLength );
/* Get the next packet identifier. It should always be nonzero. */
- packetIdentifier = _IotMqtt_NextPacketIdentifier();
+ packetIdentifier = _IotMqtt_NextPacketIdentifier();
*pPacketIdentifier = packetIdentifier;
IotMqtt_Assert( packetIdentifier != 0U );
/* Place the packet identifier into the UNSUBSCRIBE packet. */
- *pBuffer = UINT16_HIGH_BYTE( packetIdentifier );
- *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier );
- pBuffer += 2;
+ *pBuffer = UINT16_HIGH_BYTE( packetIdentifier );
+ *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier );
+ pBuffer += 2;
/* Serialize each subscription topic filter. */
for( i = 0; i < subscriptionCount; i++ )
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c
index 3bbd3a5e2..2b6a85754 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c
@@ -210,9 +210,9 @@ static IotMqttError_t _checkPublishRemainingLength( const IotMqttPacketInfo_t *
static IotMqttError_t _readSubackStatus( size_t statusCount,
const uint8_t * pStatusStart )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- uint8_t subscriptionStatus = 0;
- size_t i = 0;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ uint8_t subscriptionStatus = 0;
+ size_t i = 0;
/* Iterate through each status byte in the SUBACK packet. */
for( i = 0; i < statusCount; i++ )
@@ -274,7 +274,7 @@ static size_t _getRemainingLength( IotNetworkConnection_t pNetworkConnection,
IotMqttGetNextByte_t getNextByte )
{
uint8_t encodedByte = 0;
- size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0;
+ size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0;
/* This algorithm is copied from the MQTT v3.1.1 spec. */
do
@@ -288,7 +288,7 @@ static size_t _getRemainingLength( IotNetworkConnection_t pNetworkConnection,
if( getNextByte( pNetworkConnection, &encodedByte ) == IOT_MQTT_SUCCESS )
{
remainingLength += ( ( size_t ) encodedByte & 0x7FU ) * multiplier;
- multiplier *= 128U;
+ multiplier *= 128U;
bytesDecoded++;
}
else
@@ -326,8 +326,8 @@ static size_t _getRemainingLength( IotNetworkConnection_t pNetworkConnection,
static IotMqttError_t _deserializeConnack( IotMqttPacketInfo_t * pConnack )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- const uint8_t * pRemainingData = pConnack->pRemainingData;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ const uint8_t * pRemainingData = pConnack->pRemainingData;
/* If logging is enabled, declare the CONNACK response code strings. The
* fourth byte of CONNACK indexes into this array for the corresponding response. */
@@ -416,8 +416,8 @@ static IotMqttError_t _deserializeConnack( IotMqttPacketInfo_t * pConnack )
static IotMqttError_t _deserializeSuback( IotMqttPacketInfo_t * pSuback )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- size_t remainingLength = pSuback->remainingLength;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ size_t remainingLength = pSuback->remainingLength;
const uint8_t * pVariableHeader = pSuback->pRemainingData;
/* A SUBACK must have a remaining length of at least 3 to accommodate the
@@ -434,8 +434,8 @@ static IotMqttError_t _deserializeSuback( IotMqttPacketInfo_t * pSuback )
IotLogDebug( "Packet identifier %hu.", pSuback->packetIdentifier );
- status = _readSubackStatus( remainingLength - sizeof( uint16_t ),
- pVariableHeader + sizeof( uint16_t ) );
+ status = _readSubackStatus( remainingLength - sizeof( uint16_t ),
+ pVariableHeader + sizeof( uint16_t ) );
}
return status;
@@ -528,15 +528,15 @@ static IotMqttError_t _deserializePuback( IotMqttPacketInfo_t * pPuback )
static IotMqttError_t _deserializePublish( IotMqttPacketInfo_t * pPublish )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
IotMqttPublishInfo_t * pOutput = &( pPublish->pubInfo );
- uint8_t publishFlags = 0;
- const uint8_t * pVariableHeader = pPublish->pRemainingData, * pPacketIdentifierHigh = NULL;
+ uint8_t publishFlags = 0;
+ const uint8_t * pVariableHeader = pPublish->pRemainingData, * pPacketIdentifierHigh = NULL;
/* The flags are the lower 4 bits of the first byte in PUBLISH. */
publishFlags = pPublish->type;
- status = _IotMqtt_ProcessPublishFlags( publishFlags, pOutput );
+ status = _IotMqtt_ProcessPublishFlags( publishFlags, pOutput );
if( status == IOT_MQTT_SUCCESS )
{
@@ -556,15 +556,15 @@ static IotMqttError_t _deserializePublish( IotMqttPacketInfo_t * pPublish )
/* Sanity checks for topic name length and "Remaining length". The remaining
* length must be at least as large as the variable length header. */
- status = _checkPublishRemainingLength( pPublish,
- pOutput->qos,
- pOutput->topicNameLength + sizeof( uint16_t ) );
+ status = _checkPublishRemainingLength( pPublish,
+ pOutput->qos,
+ pOutput->topicNameLength + sizeof( uint16_t ) );
}
if( status == IOT_MQTT_SUCCESS )
{
/* Parse the topic. */
- pOutput->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) );
+ pOutput->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) );
IotLogDebug( "Topic name length %hu: %.*s",
pOutput->topicNameLength,
@@ -596,12 +596,12 @@ static IotMqttError_t _deserializePublish( IotMqttPacketInfo_t * pPublish )
if( pOutput->qos == IOT_MQTT_QOS_0 )
{
pOutput->payloadLength = ( pPublish->remainingLength - pOutput->topicNameLength - sizeof( uint16_t ) );
- pOutput->pPayload = pPacketIdentifierHigh;
+ pOutput->pPayload = pPacketIdentifierHigh;
}
else
{
pOutput->payloadLength = ( pPublish->remainingLength - pOutput->topicNameLength - 2U * sizeof( uint16_t ) );
- pOutput->pPayload = pPacketIdentifierHigh + sizeof( uint16_t );
+ pOutput->pPayload = pPacketIdentifierHigh + sizeof( uint16_t );
}
IotLogDebug( "Payload length %hu.", pOutput->payloadLength );
@@ -1026,7 +1026,7 @@ IotMqttError_t IotMqtt_SerializePingreq( uint8_t * pBuffer,
IotMqttError_t IotMqtt_DeserializePublish( IotMqttPacketInfo_t * pMqttPacket )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
/* Internal MQTT packet structure */
IotMqttPacketInfo_t mqttPacket = { 0 };
@@ -1043,15 +1043,15 @@ IotMqttError_t IotMqtt_DeserializePublish( IotMqttPacketInfo_t * pMqttPacket )
else
{
/* Set internal mqtt packet parameters. */
- mqttPacket.pRemainingData = pMqttPacket->pRemainingData;
+ mqttPacket.pRemainingData = pMqttPacket->pRemainingData;
mqttPacket.remainingLength = pMqttPacket->remainingLength;
- mqttPacket.type = pMqttPacket->type;
- status = _deserializePublish( &mqttPacket );
+ mqttPacket.type = pMqttPacket->type;
+ status = _deserializePublish( &mqttPacket );
}
if( status == IOT_MQTT_SUCCESS )
{
- pMqttPacket->pubInfo = mqttPacket.pubInfo;
+ pMqttPacket->pubInfo = mqttPacket.pubInfo;
pMqttPacket->packetIdentifier = mqttPacket.packetIdentifier;
}
@@ -1062,7 +1062,7 @@ IotMqttError_t IotMqtt_DeserializePublish( IotMqttPacketInfo_t * pMqttPacket )
IotMqttError_t IotMqtt_DeserializeResponse( IotMqttPacketInfo_t * pMqttPacket )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
/* Internal MQTT packet structure */
IotMqttPacketInfo_t mqttPacket = { 0 };
@@ -1079,9 +1079,9 @@ IotMqttError_t IotMqtt_DeserializeResponse( IotMqttPacketInfo_t * pMqttPacket )
else
{
/* Set internal mqtt packet parameters. */
- mqttPacket.pRemainingData = pMqttPacket->pRemainingData;
+ mqttPacket.pRemainingData = pMqttPacket->pRemainingData;
mqttPacket.remainingLength = pMqttPacket->remainingLength;
- mqttPacket.type = pMqttPacket->type;
+ mqttPacket.type = pMqttPacket->type;
/* Make sure response packet is a valid packet */
switch( pMqttPacket->type & 0xf0U )
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c
index 1f9703322..8c3a61e55 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c
@@ -250,8 +250,8 @@ static IotMqttError_t _allocateAndReceivePacket( IotNetworkConnection_t pNetwork
const _mqttConnection_t * pMqttConnection,
_mqttPacket_t * pIncomingPacket )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- size_t dataBytesRead = 0;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ size_t dataBytesRead = 0;
IotMqtt_Assert( pMqttConnection != NULL );
IotMqtt_Assert( pIncomingPacket != NULL );
@@ -360,10 +360,10 @@ static IotMqttError_t _deserializeAck( _mqttConnection_t * pMqttConnection,
IotMqttOperationType_t opType,
const uint16_t * pPacketIdentifier )
{
- IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
+ IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
_mqttOperation_t * pOperation = NULL;
- status = _deserializer( pIncomingPacket );
+ status = _deserializer( pIncomingPacket );
pOperation = _IotMqtt_FindOperation( pMqttConnection,
opType,
@@ -383,7 +383,7 @@ static IotMqttError_t _deserializeAck( _mqttConnection_t * pMqttConnection,
static IotMqttError_t _deserializePublishPacket( _mqttConnection_t * pMqttConnection,
_mqttPacket_t * pIncomingPacket )
{
- IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
+ IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
_mqttOperation_t * pOperation = NULL;
/* Allocate memory to handle the incoming PUBLISH. */
@@ -398,11 +398,11 @@ static IotMqttError_t _deserializePublishPacket( _mqttConnection_t * pMqttConnec
{
/* Set the members of the incoming PUBLISH operation. */
( void ) memset( pOperation, 0x00, sizeof( _mqttOperation_t ) );
- pOperation->incomingPublish = true;
- pOperation->pMqttConnection = pMqttConnection;
+ pOperation->incomingPublish = true;
+ pOperation->pMqttConnection = pMqttConnection;
pIncomingPacket->u.pIncomingPublish = pOperation;
/* Deserialize incoming PUBLISH. */
- status = _getPublishDeserializer( pMqttConnection->pSerializer )( pIncomingPacket );
+ status = _getPublishDeserializer( pMqttConnection->pSerializer )( pIncomingPacket );
}
if( status == IOT_MQTT_SUCCESS )
@@ -415,7 +415,7 @@ static IotMqttError_t _deserializePublishPacket( _mqttConnection_t * pMqttConnec
/* Transfer ownership of the received MQTT packet to the PUBLISH operation. */
pOperation->u.publish.pReceivedData = pIncomingPacket->pRemainingData;
- pIncomingPacket->pRemainingData = NULL;
+ pIncomingPacket->pRemainingData = NULL;
/* Add the PUBLISH to the list of operations pending processing.
* Coverity finds a USE_AFTER_FREE error at this line. This is a false positive.
@@ -529,11 +529,11 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne
IotLogDebug( "(MQTT connection %p) CONNACK in data stream.", pMqttConnection );
/* Deserialize CONNACK and notify of result. */
- status = _deserializeAck( pMqttConnection,
- pIncomingPacket,
- _getConnackDeserializer( pMqttConnection->pSerializer ),
- IOT_MQTT_CONNECT,
- NULL );
+ status = _deserializeAck( pMqttConnection,
+ pIncomingPacket,
+ _getConnackDeserializer( pMqttConnection->pSerializer ),
+ IOT_MQTT_CONNECT,
+ NULL );
break;
@@ -541,7 +541,7 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne
IotLogDebug( "(MQTT connection %p) PUBLISH in data stream.", pMqttConnection );
/* Deserialize PUBLISH. */
- status = _deserializePublishPacket( pMqttConnection, pIncomingPacket );
+ status = _deserializePublishPacket( pMqttConnection, pIncomingPacket );
break;
@@ -549,11 +549,11 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne
IotLogDebug( "(MQTT connection %p) PUBACK in data stream.", pMqttConnection );
/* Deserialize PUBACK and notify of result. */
- status = _deserializeAck( pMqttConnection,
- pIncomingPacket,
- _getPubackDeserializer( pMqttConnection->pSerializer ),
- IOT_MQTT_PUBLISH_TO_SERVER,
- &( pIncomingPacket->packetIdentifier ) );
+ status = _deserializeAck( pMqttConnection,
+ pIncomingPacket,
+ _getPubackDeserializer( pMqttConnection->pSerializer ),
+ IOT_MQTT_PUBLISH_TO_SERVER,
+ &( pIncomingPacket->packetIdentifier ) );
break;
@@ -563,11 +563,11 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne
/* Deserialize SUBACK and notify of result. */
pIncomingPacket->u.pMqttConnection = pMqttConnection;
- status = _deserializeAck( pMqttConnection,
- pIncomingPacket,
- _getSubackDeserializer( pMqttConnection->pSerializer ),
- IOT_MQTT_SUBSCRIBE,
- &( pIncomingPacket->packetIdentifier ) );
+ status = _deserializeAck( pMqttConnection,
+ pIncomingPacket,
+ _getSubackDeserializer( pMqttConnection->pSerializer ),
+ IOT_MQTT_SUBSCRIBE,
+ &( pIncomingPacket->packetIdentifier ) );
break;
@@ -575,11 +575,11 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne
IotLogDebug( "(MQTT connection %p) UNSUBACK in data stream.", pMqttConnection );
/* Deserialize UNSUBACK and notify of result. */
- status = _deserializeAck( pMqttConnection,
- pIncomingPacket,
- _getUnsubackDeserializer( pMqttConnection->pSerializer ),
- IOT_MQTT_UNSUBSCRIBE,
- &( pIncomingPacket->packetIdentifier ) );
+ status = _deserializeAck( pMqttConnection,
+ pIncomingPacket,
+ _getUnsubackDeserializer( pMqttConnection->pSerializer ),
+ IOT_MQTT_UNSUBSCRIBE,
+ &( pIncomingPacket->packetIdentifier ) );
break;
@@ -590,7 +590,7 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne
IotLogDebug( "(MQTT connection %p) PINGRESP in data stream.", pMqttConnection );
/* Deserialize PINGRESP. */
- status = _deserializePingResp( pMqttConnection, pIncomingPacket );
+ status = _deserializePingResp( pMqttConnection, pIncomingPacket );
break;
}
@@ -626,7 +626,7 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne
static void _sendPuback( _mqttConnection_t * pMqttConnection,
uint16_t packetIdentifier )
{
- IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
+ IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
_mqttOperation_t * pPubackOperation = NULL;
IotLogDebug( "(MQTT connection %p) Sending PUBACK for received PUBLISH %hu.",
@@ -645,9 +645,9 @@ static void _sendPuback( _mqttConnection_t * pMqttConnection,
pPubackOperation->u.operation.type = IOT_MQTT_PUBACK;
/* Generate a PUBACK packet from the packet identifier. */
- status = _getMqttPubackSerializer( pMqttConnection->pSerializer )( packetIdentifier,
- &( pPubackOperation->u.operation.pMqttPacket ),
- &( pPubackOperation->u.operation.packetSize ) );
+ status = _getMqttPubackSerializer( pMqttConnection->pSerializer )( packetIdentifier,
+ &( pPubackOperation->u.operation.pMqttPacket ),
+ &( pPubackOperation->u.operation.packetSize ) );
if( status == IOT_MQTT_SUCCESS )
{
@@ -679,7 +679,7 @@ static void _flushPacket( IotNetworkConnection_t pNetworkConnection,
const _mqttConnection_t * pMqttConnection,
size_t length )
{
- size_t bytesFlushed = 0;
+ size_t bytesFlushed = 0;
uint8_t receivedByte = 0;
for( bytesFlushed = 0; bytesFlushed < length; bytesFlushed++ )
@@ -696,9 +696,9 @@ bool _IotMqtt_GetNextByte( IotNetworkConnection_t pNetworkConnection,
const IotNetworkInterface_t * pNetworkInterface,
uint8_t * pIncomingByte )
{
- bool status = false;
- uint8_t incomingByte = 0;
- size_t bytesReceived = 0;
+ bool status = false;
+ uint8_t incomingByte = 0;
+ size_t bytesReceived = 0;
/* Attempt to read 1 byte. */
bytesReceived = pNetworkInterface->receive( pNetworkConnection,
@@ -709,7 +709,7 @@ bool _IotMqtt_GetNextByte( IotNetworkConnection_t pNetworkConnection,
if( bytesReceived == 1U )
{
*pIncomingByte = incomingByte;
- status = true;
+ status = true;
}
else
{
@@ -725,15 +725,15 @@ bool _IotMqtt_GetNextByte( IotNetworkConnection_t pNetworkConnection,
void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason,
_mqttConnection_t * pMqttConnection )
{
- taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
- IotNetworkError_t closeStatus = IOT_NETWORK_SUCCESS;
+ taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
+ IotNetworkError_t closeStatus = IOT_NETWORK_SUCCESS;
IotMqttCallbackParam_t callbackParam = { .u.message = { 0 } };
IotNetworkConnection_t pNetworkConnection = NULL;
- void * pDisconnectCallbackContext = NULL;
+ void * pDisconnectCallbackContext = NULL;
/* Disconnect callback function. */
- void ( * disconnectCallback )( void * pContext,
- IotMqttCallbackParam_t * pParam ) = NULL;
+ void ( * disconnectCallback )( void * pContext,
+ IotMqttCallbackParam_t * pParam ) = NULL;
/* Network close function. */
IotNetworkError_t ( * closeConnection) ( IotNetworkConnection_t pConnection ) = NULL;
@@ -772,8 +772,8 @@ void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason
/* Clear data about the keep-alive. */
pMqttConnection->pingreq.u.operation.periodic.ping.keepAliveMs = 0U;
- pMqttConnection->pingreq.u.operation.pMqttPacket = NULL;
- pMqttConnection->pingreq.u.operation.packetSize = 0U;
+ pMqttConnection->pingreq.u.operation.pMqttPacket = NULL;
+ pMqttConnection->pingreq.u.operation.packetSize = 0U;
/* Keep-alive is cleaned up; decrement reference count. Since this
* function must be followed with a call to DISCONNECT, a check to
@@ -787,11 +787,11 @@ void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason
/* Copy the function pointers and contexts, as the MQTT connection may be
* modified after the mutex is released. */
- disconnectCallback = pMqttConnection->disconnectCallback.function;
- pDisconnectCallbackContext = pMqttConnection->disconnectCallback.pCallbackContext;
+ disconnectCallback = pMqttConnection->disconnectCallback.function;
+ pDisconnectCallbackContext = pMqttConnection->disconnectCallback.pCallbackContext;
- closeConnection = pMqttConnection->pNetworkInterface->close;
- pNetworkConnection = pMqttConnection->pNetworkConnection;
+ closeConnection = pMqttConnection->pNetworkInterface->close;
+ pNetworkConnection = pMqttConnection->pNetworkConnection;
IotMutex_Unlock( &( pMqttConnection->referencesMutex ) );
@@ -821,7 +821,7 @@ void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason
if( disconnectCallback != NULL )
{
/* Set the members of the callback parameter. */
- callbackParam.mqttConnection = pMqttConnection;
+ callbackParam.mqttConnection = pMqttConnection;
callbackParam.u.disconnectReason = disconnectReason;
disconnectCallback( pDisconnectCallbackContext,
@@ -834,8 +834,8 @@ void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason
void IotMqtt_ReceiveCallback( IotNetworkConnection_t pNetworkConnection,
void * pReceiveContext )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- _mqttPacket_t incomingPacket = { .u.pMqttConnection = NULL };
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ _mqttPacket_t incomingPacket = { .u.pMqttConnection = NULL };
/* Cast context to correct type. */
_mqttConnection_t * pMqttConnection = ( _mqttConnection_t * ) pReceiveContext;
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c
index 986441d43..d731e4501 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c
@@ -161,7 +161,7 @@ static bool _sendPingRequest( _mqttConnection_t * pMqttConnection );
static bool _mqttOperation_match( const IotLink_t * const pOperationLink,
void * pMatch )
{
- bool match = false;
+ bool match = false;
/* Because this function is called from a container function, the given link
* must never be NULL. */
@@ -174,10 +174,10 @@ static bool _mqttOperation_match( const IotLink_t * const pOperationLink,
/* coverity[misra_c_2012_rule_11_8_violation] */
/* coverity[misra_c_2012_rule_20_7_violation] */
/* coverity[caretline] */
- const _mqttOperation_t * pOperation = IotLink_Container( _mqttOperation_t,
- pOperationLink,
- link );
- const _operationMatchParam_t * pParam = ( _operationMatchParam_t * ) pMatch;
+ const _mqttOperation_t * pOperation = IotLink_Container( _mqttOperation_t,
+ pOperationLink,
+ link );
+ const _operationMatchParam_t * pParam = ( _operationMatchParam_t * ) pMatch;
/* Check for matching operations. */
if( pParam->type == pOperation->u.operation.type )
@@ -201,7 +201,7 @@ static bool _mqttOperation_match( const IotLink_t * const pOperationLink,
static bool _checkRetryLimit( _mqttOperation_t * pOperation )
{
_mqttConnection_t * pMqttConnection = pOperation->pMqttConnection;
- bool status = true, setDup = false;
+ bool status = true, setDup = false;
/* Only PUBLISH may be retried. */
IotMqtt_Assert( pOperation->u.operation.type == IOT_MQTT_PUBLISH_TO_SERVER );
@@ -268,9 +268,9 @@ static bool _checkRetryLimit( _mqttOperation_t * pOperation )
static bool _scheduleNextRetry( _mqttOperation_t * pOperation )
{
- bool firstRetry = false;
- uint32_t scheduleDelay = 0;
- IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
+ bool firstRetry = false;
+ uint32_t scheduleDelay = 0;
+ IotMqttError_t status = IOT_MQTT_STATUS_PENDING;
_mqttConnection_t * pMqttConnection = pOperation->pMqttConnection;
/* This function should never be called with retry count greater than
@@ -296,7 +296,7 @@ static bool _scheduleNextRetry( _mqttOperation_t * pOperation )
}
else
{
- scheduleDelay = pOperation->u.operation.periodic.retry.nextPeriodMs;
+ scheduleDelay = pOperation->u.operation.periodic.retry.nextPeriodMs;
/* Double the retry period, subject to a ceiling value. */
pOperation->u.operation.periodic.retry.nextPeriodMs *= 2U;
@@ -366,7 +366,7 @@ static bool _scheduleNextRetry( _mqttOperation_t * pOperation )
static IotMqttError_t _scheduleCallback( _mqttOperation_t * pOperation )
{
- IotMqttError_t status = IOT_MQTT_SCHEDULING_ERROR;
+ IotMqttError_t status = IOT_MQTT_SCHEDULING_ERROR;
_mqttConnection_t * pMqttConnection = pOperation->pMqttConnection;
/* Non-waitable operation should have job reference of 1. */
@@ -417,7 +417,7 @@ static IotMqttError_t _scheduleCallback( _mqttOperation_t * pOperation )
static bool _completePendingSend( _mqttOperation_t * pOperation,
bool * pDestroyOperation )
{
- bool networkPending = false, waitable = false;
+ bool networkPending = false, waitable = false;
_mqttConnection_t * pMqttConnection = pOperation->pMqttConnection;
/* Check if this operation is waitable. */
@@ -477,8 +477,8 @@ static IotMqttError_t _initializeOperation( _mqttConnection_t * pMqttConnection,
uint32_t flags,
const IotMqttCallbackInfo_t * pCallbackInfo )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- bool waitable = ( ( flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE );
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ bool waitable = ( ( flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE );
IotMqtt_Assert( pMqttConnection != NULL );
IotMqtt_Assert( pOperation != NULL );
@@ -487,10 +487,10 @@ static IotMqttError_t _initializeOperation( _mqttConnection_t * pMqttConnection,
( void ) memset( pOperation, 0x00, sizeof( _mqttOperation_t ) );
/* Initialize some members of the new operation. */
- pOperation->pMqttConnection = pMqttConnection;
+ pOperation->pMqttConnection = pMqttConnection;
pOperation->u.operation.jobReference = 1;
- pOperation->u.operation.flags = flags;
- pOperation->u.operation.status = IOT_MQTT_STATUS_PENDING;
+ pOperation->u.operation.flags = flags;
+ pOperation->u.operation.status = IOT_MQTT_STATUS_PENDING;
/* Check if the waitable flag is set. If it is, create a semaphore to
* wait on. */
@@ -529,9 +529,9 @@ static IotMqttError_t _initializeOperation( _mqttConnection_t * pMqttConnection,
static bool _sendPingRequest( _mqttConnection_t * pMqttConnection )
{
- size_t bytesSent = 0;
- bool status = true;
- uint32_t swapStatus = 0;
+ size_t bytesSent = 0;
+ bool status = true;
+ uint32_t swapStatus = 0;
_mqttOperation_t * pPingreqOperation = NULL;
IotMqtt_Assert( pMqttConnection != NULL );
@@ -543,9 +543,9 @@ static bool _sendPingRequest( _mqttConnection_t * pMqttConnection )
/* Because PINGREQ may be used to keep the MQTT connection alive, it is
* more important than other operations. Bypass the queue of jobs for
* operations by directly sending the PINGREQ in this job. */
- bytesSent = pMqttConnection->pNetworkInterface->send( pMqttConnection->pNetworkConnection,
- pPingreqOperation->u.operation.pMqttPacket,
- pPingreqOperation->u.operation.packetSize );
+ bytesSent = pMqttConnection->pNetworkInterface->send( pMqttConnection->pNetworkConnection,
+ pPingreqOperation->u.operation.pMqttPacket,
+ pPingreqOperation->u.operation.packetSize );
if( bytesSent != pPingreqOperation->u.operation.packetSize )
{
@@ -556,14 +556,14 @@ static bool _sendPingRequest( _mqttConnection_t * pMqttConnection )
{
/* Update the timestamp of the last message on successful transmission. */
IotMutex_Lock( &( pMqttConnection->referencesMutex ) );
- pMqttConnection->lastMessageTime = IotClock_GetTimeMs();
+ pMqttConnection->lastMessageTime = IotClock_GetTimeMs();
IotMutex_Unlock( &( pMqttConnection->referencesMutex ) );
/* Assume the keep-alive will fail. The network receive callback will
* clear the failure flag upon receiving a PINGRESP. */
- swapStatus = Atomic_CompareAndSwap_u32( &( pPingreqOperation->u.operation.periodic.ping.failure ),
- 1,
- 0 );
+ swapStatus = Atomic_CompareAndSwap_u32( &( pPingreqOperation->u.operation.periodic.ping.failure ),
+ 1,
+ 0 );
IotMqtt_Assert( swapStatus == 1U );
/* Set the period for scheduling a PINGRESP check. */
@@ -582,10 +582,10 @@ IotMqttError_t _IotMqtt_CreateOperation( _mqttConnection_t * pMqttConnection,
const IotMqttCallbackInfo_t * pCallbackInfo,
_mqttOperation_t ** pNewOperation )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- bool decrementOnError = false;
- _mqttOperation_t * pOperation = NULL;
- bool waitable = ( ( flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE );
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ bool decrementOnError = false;
+ _mqttOperation_t * pOperation = NULL;
+ bool waitable = ( ( flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE );
/* If the waitable flag is set, make sure that there's no callback. */
if( waitable == true )
@@ -675,9 +675,9 @@ IotMqttError_t _IotMqtt_CreateOperation( _mqttConnection_t * pMqttConnection,
bool _IotMqtt_DecrementOperationReferences( _mqttOperation_t * pOperation,
bool cancelJob )
{
- bool destroyOperation = false;
- taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
- _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection;
+ bool destroyOperation = false;
+ taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
+ _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection;
/* Attempt to cancel the operation's job. */
if( cancelJob == true )
@@ -822,14 +822,14 @@ void _IotMqtt_DestroyOperation( _mqttOperation_t * pOperation )
void _IotMqtt_ProcessKeepAlive( taskPoolJob_t * pKeepAliveJob,
void * pContext )
{
- bool status = true;
- taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
- uint32_t scheduleDelay = 0;
- uint64_t elapsedTime = 0;
+ bool status = true;
+ taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
+ uint32_t scheduleDelay = 0;
+ uint64_t elapsedTime = 0;
/* Retrieve the MQTT connection from the context. */
- _mqttConnection_t * pMqttConnection = ( _mqttConnection_t * ) pContext;
- _mqttOperation_t * pPingreqOperation = &( pMqttConnection->pingreq );
+ _mqttConnection_t * pMqttConnection = ( _mqttConnection_t * ) pContext;
+ _mqttOperation_t * pPingreqOperation = &( pMqttConnection->pingreq );
/* Check parameters. */
IotMqtt_Assert( pKeepAliveJob == &( pPingreqOperation->job ) );
@@ -851,7 +851,7 @@ void _IotMqtt_ProcessKeepAlive( taskPoolJob_t * pKeepAliveJob,
pPingreqOperation->u.operation.periodic.ping.keepAliveMs )
{
/* Only send the PINGREQ if the keep-alive period has elapsed since the connection
- * was last used. */
+ * was last used. */
IotMutex_Lock( &( pMqttConnection->referencesMutex ) );
elapsedTime = IotClock_GetTimeMs() - pMqttConnection->lastMessageTime;
IotMutex_Unlock( &( pMqttConnection->referencesMutex ) );
@@ -1006,7 +1006,7 @@ void _IotMqtt_ProcessKeepAlive( taskPoolJob_t * pKeepAliveJob,
void _IotMqtt_ProcessIncomingPublish( taskPoolJob_t * pPublishJob,
void * pContext )
{
- _mqttOperation_t * pOperation = pContext;
+ _mqttOperation_t * pOperation = pContext;
IotMqttCallbackParam_t callbackParam = { .mqttConnection = NULL };
/* Check parameters. The task pool and job parameter is not used when asserts
@@ -1044,9 +1044,9 @@ void _IotMqtt_ProcessIncomingPublish( taskPoolJob_t * pPublishJob,
void _IotMqtt_ProcessSend( taskPoolJob_t * pSendJob,
void * pContext )
{
- size_t bytesSent = 0;
- bool destroyOperation = false, waitable = false, networkPending = false;
- _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pContext;
+ size_t bytesSent = 0;
+ bool destroyOperation = false, waitable = false, networkPending = false;
+ _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pContext;
_mqttConnection_t * pMqttConnection = pOperation->pMqttConnection;
/* Check parameters. The task pool and job parameter is not used when asserts
@@ -1151,9 +1151,9 @@ void _IotMqtt_ProcessSend( taskPoolJob_t * pSendJob,
void _IotMqtt_ProcessCompletedOperation( taskPoolJob_t * pOperationJob,
void * pContext )
{
- bool destroyOperation = false;
- _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pContext;
- IotMqttCallbackParam_t callbackParam = { 0 };
+ bool destroyOperation = false;
+ _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pContext;
+ IotMqttCallbackParam_t callbackParam = { 0 };
/* Check parameters. The task pool and job parameter is not used when asserts
* are disabled. */
@@ -1164,10 +1164,10 @@ void _IotMqtt_ProcessCompletedOperation( taskPoolJob_t * pOperationJob,
IotMqtt_Assert( pOperation->u.operation.notify.callback.function != NULL );
IotMqtt_Assert( pOperation->u.operation.status != IOT_MQTT_STATUS_PENDING );
- callbackParam.mqttConnection = pOperation->pMqttConnection;
- callbackParam.u.operation.type = pOperation->u.operation.type;
+ callbackParam.mqttConnection = pOperation->pMqttConnection;
+ callbackParam.u.operation.type = pOperation->u.operation.type;
callbackParam.u.operation.reference = pOperation;
- callbackParam.u.operation.result = pOperation->u.operation.status;
+ callbackParam.u.operation.result = pOperation->u.operation.status;
/* Invoke the user callback function. */
pOperation->u.operation.notify.callback.function( pOperation->u.operation.notify.callback.pCallbackContext,
@@ -1175,7 +1175,7 @@ void _IotMqtt_ProcessCompletedOperation( taskPoolJob_t * pOperationJob,
/* Decrement the operation reference count. This function is at the end of the
* operation lifecycle, so the operation must be destroyed here. */
- destroyOperation = _IotMqtt_DecrementOperationReferences( pOperation, false );
+ destroyOperation = _IotMqtt_DecrementOperationReferences( pOperation, false );
IotMqtt_Assert( destroyOperation == true );
_IotMqtt_DestroyOperation( pOperation );
}
@@ -1186,7 +1186,7 @@ IotMqttError_t _IotMqtt_ScheduleOperation( _mqttOperation_t * pOperation,
taskPoolRoutine_t jobRoutine,
uint32_t delay )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
/* Check that job routine is valid. */
@@ -1231,16 +1231,16 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection,
IotMqttOperationType_t type,
const uint16_t * pPacketIdentifier )
{
- bool waitable = false;
- taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
- _mqttOperation_t * pResult = NULL;
- IotLink_t * pResultLink = NULL;
+ bool waitable = false;
+ taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS;
+ _mqttOperation_t * pResult = NULL;
+ IotLink_t * pResultLink = NULL;
_operationMatchParam_t operationMatchParams;
( void ) memset( &operationMatchParams, 0, sizeof( _operationMatchParam_t ) );
/* Set the members of the search parameter. */
- operationMatchParams.type = type;
+ operationMatchParams.type = type;
operationMatchParams.pPacketIdentifier = pPacketIdentifier;
IotLogDebug( "(MQTT connection %p) Searching for operation %s "
@@ -1251,10 +1251,10 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection,
/* Find and remove the first matching element in the list. */
IotMutex_Lock( &( pMqttConnection->referencesMutex ) );
- pResultLink = IotListDouble_FindFirstMatch( &( pMqttConnection->pendingResponse ),
- NULL,
- _mqttOperation_match,
- &operationMatchParams );
+ pResultLink = IotListDouble_FindFirstMatch( &( pMqttConnection->pendingResponse ),
+ NULL,
+ _mqttOperation_match,
+ &operationMatchParams );
/* Check if a match was found. */
if( pResultLink != NULL )
@@ -1265,7 +1265,7 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection,
* because it uses type-casting and offsetof, and would cause compiling errors. */
/* coverity[misra_c_2012_rule_20_7_violation] */
/* coverity[caretline] */
- pResult = IotLink_Container( _mqttOperation_t, pResultLink, link );
+ pResult = IotLink_Container( _mqttOperation_t, pResultLink, link );
waitable = ( pResult->u.operation.flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE;
/* Check if the matched operation is a PUBLISH with retry. If it is, cancel
@@ -1341,10 +1341,10 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection,
void _IotMqtt_Notify( _mqttOperation_t * pOperation )
{
- IotMqttError_t status = IOT_MQTT_SCHEDULING_ERROR;
+ IotMqttError_t status = IOT_MQTT_SCHEDULING_ERROR;
/* Check if operation is waitable. */
- bool waitable = ( pOperation->u.operation.flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE;
+ bool waitable = ( pOperation->u.operation.flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE;
/* Remove any lingering subscriptions if a SUBSCRIBE failed. Rejected
* subscriptions are removed by the deserializer, so not removed here. */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c
index cd2189a88..d6ebfc04b 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c
@@ -95,9 +95,9 @@ static IotMqttError_t _decodeSubackStatus( size_t statusCount,
const uint8_t * pStatusStart,
const _mqttPacket_t * pSuback )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- uint8_t subscriptionStatus = 0;
- size_t i = 0;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ uint8_t subscriptionStatus = 0;
+ size_t i = 0;
/* Iterate through each status byte in the SUBACK packet. */
for( i = 0; i < statusCount; i++ )
@@ -226,7 +226,7 @@ size_t _IotMqtt_GetRemainingLength( IotNetworkConnection_t pNetworkConnection,
const IotNetworkInterface_t * pNetworkInterface )
{
uint8_t encodedByte = 0;
- size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0;
+ size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0;
/* This algorithm is copied from the MQTT v3.1.1 spec. */
do
@@ -242,7 +242,7 @@ size_t _IotMqtt_GetRemainingLength( IotNetworkConnection_t pNetworkConnection,
&encodedByte ) == true )
{
remainingLength += ( ( size_t ) encodedByte & 0x7FU ) * multiplier;
- multiplier *= 128U;
+ multiplier *= 128U;
bytesDecoded++;
}
else
@@ -283,8 +283,8 @@ IotMqttError_t _IotMqtt_SerializeConnect( const IotMqttConnectInfo_t * pConnectI
size_t * pPacketSize )
{
IotMqttError_t status = IOT_MQTT_SUCCESS;
- size_t remainingLength = 0, connectPacketSize = 0;
- uint8_t * pBuffer = NULL;
+ size_t remainingLength = 0, connectPacketSize = 0;
+ uint8_t * pBuffer = NULL;
/* Calculate the "Remaining length" field and total packet size. If it exceeds
* what is allowed in the MQTT standard, return an error. */
@@ -317,7 +317,7 @@ IotMqttError_t _IotMqtt_SerializeConnect( const IotMqttConnectInfo_t * pConnectI
{
/* Set the output parameters. The remainder of this function always succeeds. */
*pConnectPacket = pBuffer;
- *pPacketSize = connectPacketSize;
+ *pPacketSize = connectPacketSize;
_IotMqtt_SerializeConnectCommon( pConnectInfo, remainingLength, pBuffer, connectPacketSize );
}
@@ -330,8 +330,8 @@ IotMqttError_t _IotMqtt_SerializeConnect( const IotMqttConnectInfo_t * pConnectI
IotMqttError_t _IotMqtt_DeserializeConnack( _mqttPacket_t * pConnack )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- const uint8_t * pRemainingData = pConnack->pRemainingData;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ const uint8_t * pRemainingData = pConnack->pRemainingData;
/* If logging is enabled, declare the CONNACK response code strings. The
* fourth byte of CONNACK indexes into this array for the corresponding response. */
@@ -449,8 +449,8 @@ IotMqttError_t _IotMqtt_SerializePublish( const IotMqttPublishInfo_t * pPublishI
uint8_t ** pPacketIdentifierHigh )
{
IotMqttError_t status = IOT_MQTT_SUCCESS;
- size_t remainingLength = 0, publishPacketSize = 0;
- uint8_t * pBuffer = NULL;
+ size_t remainingLength = 0, publishPacketSize = 0;
+ uint8_t * pBuffer = NULL;
/* Calculate the "Remaining length" field and total packet size. If it exceeds
* what is allowed in the MQTT standard, return an error. */
@@ -483,7 +483,7 @@ IotMqttError_t _IotMqtt_SerializePublish( const IotMqttPublishInfo_t * pPublishI
{
/* Set the output parameters. The remainder of this function always succeeds. */
*pPublishPacket = pBuffer;
- *pPacketSize = publishPacketSize;
+ *pPacketSize = publishPacketSize;
/* Serialize publish into buffer pointed to by pBuffer */
_IotMqtt_SerializePublishCommon( pPublishInfo,
@@ -513,16 +513,16 @@ void _IotMqtt_PublishSetDup( uint8_t * pPublishPacket,
IotMqtt_Assert( pNewPacketIdentifier != NULL );
/* Generate a new packet identifier. */
- newPacketIdentifier = _IotMqtt_NextPacketIdentifier();
+ newPacketIdentifier = _IotMqtt_NextPacketIdentifier();
IotLogDebug( "Changing PUBLISH packet identifier %hu to %hu.",
UINT16_DECODE( pPacketIdentifierHigh ),
newPacketIdentifier );
/* Replace the packet identifier. */
- *pPacketIdentifierHigh = UINT16_HIGH_BYTE( newPacketIdentifier );
+ *pPacketIdentifierHigh = UINT16_HIGH_BYTE( newPacketIdentifier );
*( pPacketIdentifierHigh + 1 ) = UINT16_LOW_BYTE( newPacketIdentifier );
- *pNewPacketIdentifier = newPacketIdentifier;
+ *pNewPacketIdentifier = newPacketIdentifier;
}
else
{
@@ -537,15 +537,15 @@ void _IotMqtt_PublishSetDup( uint8_t * pPublishPacket,
IotMqttError_t _IotMqtt_DeserializePublish( _mqttPacket_t * pPublish )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
IotMqttPublishInfo_t * pOutput = &( pPublish->u.pIncomingPublish->u.publish.publishInfo );
- uint8_t publishFlags = 0;
- const uint8_t * pVariableHeader = pPublish->pRemainingData, * pPacketIdentifierHigh = NULL;
+ uint8_t publishFlags = 0;
+ const uint8_t * pVariableHeader = pPublish->pRemainingData, * pPacketIdentifierHigh = NULL;
/* The flags are the lower 4 bits of the first byte in PUBLISH. */
publishFlags = pPublish->type;
- status = _IotMqtt_ProcessPublishFlags( publishFlags, pOutput );
+ status = _IotMqtt_ProcessPublishFlags( publishFlags, pOutput );
if( status == IOT_MQTT_SUCCESS )
{
@@ -565,15 +565,15 @@ IotMqttError_t _IotMqtt_DeserializePublish( _mqttPacket_t * pPublish )
/* Sanity checks for topic name length and "Remaining length". The remaining
* length must be at least as large as the variable length header. */
- status = _checkRemainingLength( pPublish,
- pOutput->qos,
- pOutput->topicNameLength + sizeof( uint16_t ) );
+ status = _checkRemainingLength( pPublish,
+ pOutput->qos,
+ pOutput->topicNameLength + sizeof( uint16_t ) );
}
if( status == IOT_MQTT_SUCCESS )
{
/* Parse the topic. */
- pOutput->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) );
+ pOutput->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) );
IotLog( IOT_LOG_DEBUG,
&_logHideAll,
@@ -609,12 +609,12 @@ IotMqttError_t _IotMqtt_DeserializePublish( _mqttPacket_t * pPublish )
if( pOutput->qos == IOT_MQTT_QOS_0 )
{
pOutput->payloadLength = ( pPublish->remainingLength - pOutput->topicNameLength - sizeof( uint16_t ) );
- pOutput->pPayload = pPacketIdentifierHigh;
+ pOutput->pPayload = pPacketIdentifierHigh;
}
else
{
pOutput->payloadLength = ( pPublish->remainingLength - pOutput->topicNameLength - 2U * sizeof( uint16_t ) );
- pOutput->pPayload = pPacketIdentifierHigh + sizeof( uint16_t );
+ pOutput->pPayload = pPacketIdentifierHigh + sizeof( uint16_t );
}
IotLog( IOT_LOG_DEBUG,
@@ -631,10 +631,10 @@ IotMqttError_t _IotMqtt_SerializePuback( uint16_t packetIdentifier,
uint8_t ** pPubackPacket,
size_t * pPacketSize )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
/* Allocate memory for PUBACK. */
- uint8_t * pBuffer = IotMqtt_MallocMessage( MQTT_PACKET_PUBACK_SIZE );
+ uint8_t * pBuffer = IotMqtt_MallocMessage( MQTT_PACKET_PUBACK_SIZE );
if( pBuffer == NULL )
{
@@ -646,13 +646,13 @@ IotMqttError_t _IotMqtt_SerializePuback( uint16_t packetIdentifier,
{
/* Set the output parameters. The remainder of this function always succeeds. */
*pPubackPacket = pBuffer;
- *pPacketSize = MQTT_PACKET_PUBACK_SIZE;
+ *pPacketSize = MQTT_PACKET_PUBACK_SIZE;
/* Set the 4 bytes in PUBACK. */
- pBuffer[ 0 ] = MQTT_PACKET_TYPE_PUBACK;
- pBuffer[ 1 ] = MQTT_PACKET_PUBACK_REMAINING_LENGTH;
- pBuffer[ 2 ] = UINT16_HIGH_BYTE( packetIdentifier );
- pBuffer[ 3 ] = UINT16_LOW_BYTE( packetIdentifier );
+ pBuffer[ 0 ] = MQTT_PACKET_TYPE_PUBACK;
+ pBuffer[ 1 ] = MQTT_PACKET_PUBACK_REMAINING_LENGTH;
+ pBuffer[ 2 ] = UINT16_HIGH_BYTE( packetIdentifier );
+ pBuffer[ 3 ] = UINT16_LOW_BYTE( packetIdentifier );
/* Print out the serialized PUBACK packet for debugging purposes. */
IotLog_PrintBuffer( "MQTT PUBACK packet:", *pPubackPacket, MQTT_PACKET_PUBACK_SIZE );
@@ -719,8 +719,8 @@ IotMqttError_t _IotMqtt_SerializeSubscribe( const IotMqttSubscription_t * pSubsc
uint16_t * pPacketIdentifier )
{
IotMqttError_t status = IOT_MQTT_SUCCESS;
- size_t subscribePacketSize = 0, remainingLength = 0;
- uint8_t * pBuffer = NULL;
+ size_t subscribePacketSize = 0, remainingLength = 0;
+ uint8_t * pBuffer = NULL;
/* Calculate the "Remaining length" field and total packet size. If it exceeds
* what is allowed in the MQTT standard, return an error. */
@@ -756,7 +756,7 @@ IotMqttError_t _IotMqtt_SerializeSubscribe( const IotMqttSubscription_t * pSubsc
{
/* Set the output parameters. The remainder of this function always succeeds. */
*pSubscribePacket = pBuffer;
- *pPacketSize = subscribePacketSize;
+ *pPacketSize = subscribePacketSize;
/* Serialize subscribe into buffer pointed to by pBuffer */
_IotMqtt_SerializeSubscribeCommon( pSubscriptionList,
@@ -775,8 +775,8 @@ IotMqttError_t _IotMqtt_SerializeSubscribe( const IotMqttSubscription_t * pSubsc
IotMqttError_t _IotMqtt_DeserializeSuback( _mqttPacket_t * pSuback )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- size_t remainingLength = pSuback->remainingLength;
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ size_t remainingLength = pSuback->remainingLength;
const uint8_t * pVariableHeader = pSuback->pRemainingData;
/* A SUBACK must have a remaining length of at least 3 to accommodate the
@@ -829,8 +829,8 @@ IotMqttError_t _IotMqtt_SerializeUnsubscribe( const IotMqttSubscription_t * pSub
uint16_t * pPacketIdentifier )
{
IotMqttError_t status = IOT_MQTT_SUCCESS;
- size_t unsubscribePacketSize = 0, remainingLength = 0;
- uint8_t * pBuffer = NULL;
+ size_t unsubscribePacketSize = 0, remainingLength = 0;
+ uint8_t * pBuffer = NULL;
/* Calculate the "Remaining length" field and total packet size. If it exceeds
* what is allowed in the MQTT standard, return an error. */
@@ -866,7 +866,7 @@ IotMqttError_t _IotMqtt_SerializeUnsubscribe( const IotMqttSubscription_t * pSub
{
/* Set the output parameters. The remainder of this function always succeeds. */
*pUnsubscribePacket = pBuffer;
- *pPacketSize = unsubscribePacketSize;
+ *pPacketSize = unsubscribePacketSize;
/* Serialize unsubscribe into buffer pointed to by pBuffer */
_IotMqtt_SerializeUnsubscribeCommon( pSubscriptionList,
@@ -950,7 +950,7 @@ IotMqttError_t _IotMqtt_SerializePingreq( uint8_t ** pPingreqPacket,
/* Set the output parameters. */
*pPingreqPacket = ( uint8_t * ) pPingreq;
- *pPacketSize = MQTT_PACKET_PINGREQ_SIZE;
+ *pPacketSize = MQTT_PACKET_PINGREQ_SIZE;
/* Print out the PINGREQ packet for debugging purposes. */
IotLog_PrintBuffer( "MQTT PINGREQ packet:", pPingreq, MQTT_PACKET_PINGREQ_SIZE );
@@ -1011,7 +1011,7 @@ IotMqttError_t _IotMqtt_SerializeDisconnect( uint8_t ** pDisconnectPacket,
/* Set the output parameters. */
*pDisconnectPacket = ( uint8_t * ) pDisconnect;
- *pPacketSize = MQTT_PACKET_DISCONNECT_SIZE;
+ *pPacketSize = MQTT_PACKET_DISCONNECT_SIZE;
/* Print out the DISCONNECT packet for debugging purposes. */
IotLog_PrintBuffer( "MQTT DISCONNECT packet:", pDisconnect, MQTT_PACKET_DISCONNECT_SIZE );
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c
index 87b117550..57ed52b7d 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c
@@ -32,14 +32,14 @@
#if IOT_STATIC_MEMORY_ONLY == 1
/* Standard includes. */
-#include <stddef.h>
-#include <string.h>
+ #include <stddef.h>
+ #include <string.h>
/* Static memory include. */
-#include "iot_static_memory.h"
+ #include "iot_static_memory.h"
/* MQTT internal include. */
-#include "private/iot_mqtt_internal.h"
+ #include "private/iot_mqtt_internal.h"
/*-----------------------------------------------------------*/
@@ -49,27 +49,27 @@
*
* Provide default values for undefined configuration constants.
*/
-#ifndef IOT_MQTT_CONNECTIONS
- #define IOT_MQTT_CONNECTIONS ( 1 )
-#endif
-#ifndef IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS
- #define IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ( 10 )
-#endif
-#ifndef IOT_MQTT_SUBSCRIPTIONS
- #define IOT_MQTT_SUBSCRIPTIONS ( 8 )
-#endif
+ #ifndef IOT_MQTT_CONNECTIONS
+ #define IOT_MQTT_CONNECTIONS ( 1 )
+ #endif
+ #ifndef IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS
+ #define IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ( 10 )
+ #endif
+ #ifndef IOT_MQTT_SUBSCRIPTIONS
+ #define IOT_MQTT_SUBSCRIPTIONS ( 8 )
+ #endif
/** @endcond */
/* Validate static memory configuration settings. */
-#if IOT_MQTT_CONNECTIONS <= 0
- #error "IOT_MQTT_CONNECTIONS cannot be 0 or negative."
-#endif
-#if IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS <= 0
- #error "IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS cannot be 0 or negative."
-#endif
-#if IOT_MQTT_SUBSCRIPTIONS <= 0
- #error "IOT_MQTT_SUBSCRIPTIONS cannot be 0 or negative."
-#endif
+ #if IOT_MQTT_CONNECTIONS <= 0
+ #error "IOT_MQTT_CONNECTIONS cannot be 0 or negative."
+ #endif
+ #if IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS <= 0
+ #error "IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS cannot be 0 or negative."
+ #endif
+ #if IOT_MQTT_SUBSCRIPTIONS <= 0
+ #error "IOT_MQTT_SUBSCRIPTIONS cannot be 0 or negative."
+ #endif
/**
* @brief The size of a static memory MQTT subscription.
@@ -78,126 +78,126 @@
* #AWS_IOT_MQTT_SERVER_MAX_TOPIC_LENGTH is used for the length of
* #_mqttSubscription_t.pTopicFilter.
*/
-#define MQTT_SUBSCRIPTION_SIZE ( sizeof( _mqttSubscription_t ) + AWS_IOT_MQTT_SERVER_MAX_TOPIC_LENGTH )
+ #define MQTT_SUBSCRIPTION_SIZE ( sizeof( _mqttSubscription_t ) + AWS_IOT_MQTT_SERVER_MAX_TOPIC_LENGTH )
/*-----------------------------------------------------------*/
/*
* Static memory buffers and flags, allocated and zeroed at compile-time.
*/
-static uint32_t _pInUseMqttConnections[ IOT_MQTT_CONNECTIONS ]; /**< @brief MQTT connection in-use flags. */
-static _mqttConnection_t _pMqttConnections[ IOT_MQTT_CONNECTIONS ]; /**< @brief MQTT connections. */
+ static uint32_t _pInUseMqttConnections[ IOT_MQTT_CONNECTIONS ]; /**< @brief MQTT connection in-use flags. */
+ static _mqttConnection_t _pMqttConnections[ IOT_MQTT_CONNECTIONS ]; /**< @brief MQTT connections. */
-static uint32_t _pInUseMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ]; /**< @brief MQTT operation in-use flags. */
-static _mqttOperation_t _pMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ]; /**< @brief MQTT operations. */
+ static uint32_t _pInUseMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ]; /**< @brief MQTT operation in-use flags. */
+ static _mqttOperation_t _pMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ]; /**< @brief MQTT operations. */
-static uint32_t _pInUseMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ]; /**< @brief MQTT subscription in-use flags. */
-static char _pMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ][ MQTT_SUBSCRIPTION_SIZE ]; /**< @brief MQTT subscriptions. */
+ static uint32_t _pInUseMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ]; /**< @brief MQTT subscription in-use flags. */
+ static char _pMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ][ MQTT_SUBSCRIPTION_SIZE ]; /**< @brief MQTT subscriptions. */
/*-----------------------------------------------------------*/
-void * IotMqtt_MallocConnection( size_t size )
-{
- int32_t freeIndex = -1;
- void * pNewConnection = NULL;
-
- /* Check size argument. */
- if( size == sizeof( _mqttConnection_t ) )
+ void * IotMqtt_MallocConnection( size_t size )
{
- /* Find a free MQTT connection. */
- freeIndex = IotStaticMemory_FindFree( _pInUseMqttConnections,
- IOT_MQTT_CONNECTIONS );
+ int32_t freeIndex = -1;
+ void * pNewConnection = NULL;
- if( freeIndex != -1 )
+ /* Check size argument. */
+ if( size == sizeof( _mqttConnection_t ) )
{
- pNewConnection = &( _pMqttConnections[ freeIndex ] );
+ /* Find a free MQTT connection. */
+ freeIndex = IotStaticMemory_FindFree( _pInUseMqttConnections,
+ IOT_MQTT_CONNECTIONS );
+
+ if( freeIndex != -1 )
+ {
+ pNewConnection = &( _pMqttConnections[ freeIndex ] );
+ }
}
- }
- return pNewConnection;
-}
+ return pNewConnection;
+ }
/*-----------------------------------------------------------*/
-void IotMqtt_FreeConnection( void * ptr )
-{
- /* Return the in-use MQTT connection. */
- IotStaticMemory_ReturnInUse( ptr,
- _pMqttConnections,
- _pInUseMqttConnections,
- IOT_MQTT_CONNECTIONS,
- sizeof( _mqttConnection_t ) );
-}
+ void IotMqtt_FreeConnection( void * ptr )
+ {
+ /* Return the in-use MQTT connection. */
+ IotStaticMemory_ReturnInUse( ptr,
+ _pMqttConnections,
+ _pInUseMqttConnections,
+ IOT_MQTT_CONNECTIONS,
+ sizeof( _mqttConnection_t ) );
+ }
/*-----------------------------------------------------------*/
-void * IotMqtt_MallocOperation( size_t size )
-{
- int32_t freeIndex = -1;
- void * pNewOperation = NULL;
-
- /* Check size argument. */
- if( size == sizeof( _mqttOperation_t ) )
+ void * IotMqtt_MallocOperation( size_t size )
{
- /* Find a free MQTT operation. */
- freeIndex = IotStaticMemory_FindFree( _pInUseMqttOperations,
- IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS );
+ int32_t freeIndex = -1;
+ void * pNewOperation = NULL;
- if( freeIndex != -1 )
+ /* Check size argument. */
+ if( size == sizeof( _mqttOperation_t ) )
{
- pNewOperation = &( _pMqttOperations[ freeIndex ] );
+ /* Find a free MQTT operation. */
+ freeIndex = IotStaticMemory_FindFree( _pInUseMqttOperations,
+ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS );
+
+ if( freeIndex != -1 )
+ {
+ pNewOperation = &( _pMqttOperations[ freeIndex ] );
+ }
}
- }
- return pNewOperation;
-}
+ return pNewOperation;
+ }
/*-----------------------------------------------------------*/
-void IotMqtt_FreeOperation( void * ptr )
-{
- /* Return the in-use MQTT operation. */
- IotStaticMemory_ReturnInUse( ptr,
- _pMqttOperations,
- _pInUseMqttOperations,
- IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS,
- sizeof( _mqttOperation_t ) );
-}
+ void IotMqtt_FreeOperation( void * ptr )
+ {
+ /* Return the in-use MQTT operation. */
+ IotStaticMemory_ReturnInUse( ptr,
+ _pMqttOperations,
+ _pInUseMqttOperations,
+ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS,
+ sizeof( _mqttOperation_t ) );
+ }
/*-----------------------------------------------------------*/
-void * IotMqtt_MallocSubscription( size_t size )
-{
- int32_t freeIndex = -1;
- void * pNewSubscription = NULL;
-
- if( size <= MQTT_SUBSCRIPTION_SIZE )
+ void * IotMqtt_MallocSubscription( size_t size )
{
- /* Get the index of a free MQTT subscription. */
- freeIndex = IotStaticMemory_FindFree( _pInUseMqttSubscriptions,
- IOT_MQTT_SUBSCRIPTIONS );
+ int32_t freeIndex = -1;
+ void * pNewSubscription = NULL;
- if( freeIndex != -1 )
+ if( size <= MQTT_SUBSCRIPTION_SIZE )
{
- pNewSubscription = &( _pMqttSubscriptions[ freeIndex ][ 0 ] );
+ /* Get the index of a free MQTT subscription. */
+ freeIndex = IotStaticMemory_FindFree( _pInUseMqttSubscriptions,
+ IOT_MQTT_SUBSCRIPTIONS );
+
+ if( freeIndex != -1 )
+ {
+ pNewSubscription = &( _pMqttSubscriptions[ freeIndex ][ 0 ] );
+ }
}
- }
- return pNewSubscription;
-}
+ return pNewSubscription;
+ }
/*-----------------------------------------------------------*/
-void IotMqtt_FreeSubscription( void * ptr )
-{
- /* Return the in-use MQTT subscription. */
- IotStaticMemory_ReturnInUse( ptr,
- _pMqttSubscriptions,
- _pInUseMqttSubscriptions,
- IOT_MQTT_SUBSCRIPTIONS,
- MQTT_SUBSCRIPTION_SIZE );
-}
+ void IotMqtt_FreeSubscription( void * ptr )
+ {
+ /* Return the in-use MQTT subscription. */
+ IotStaticMemory_ReturnInUse( ptr,
+ _pMqttSubscriptions,
+ _pInUseMqttSubscriptions,
+ IOT_MQTT_SUBSCRIPTIONS,
+ MQTT_SUBSCRIPTION_SIZE );
+ }
/*-----------------------------------------------------------*/
-#endif
+#endif /* if IOT_STATIC_MEMORY_ONLY == 1 */
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c
index 37b6c6384..c2d2a7b17 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c
@@ -210,14 +210,14 @@ static bool _matchWildcards( const char * pTopicFilter,
/* Subsequent characters don't need to be checked for the
* multi-level wildcard. */
*pMatch = true;
- status = true;
+ status = true;
}
else
{
/* Any character mismatch other than '+' or '#' means the topic
* name does not match the topic filter. */
*pMatch = false;
- status = true;
+ status = true;
}
return status;
@@ -230,7 +230,7 @@ static bool _topicFilterMatch( const char * pTopicName,
const char * pTopicFilter,
uint16_t topicFilterLength )
{
- bool status = false, matchFound = false;
+ bool status = false, matchFound = false;
uint16_t nameIndex = 0, filterIndex = 0;
while( ( nameIndex < topicNameLength ) && ( filterIndex < topicFilterLength ) )
@@ -283,7 +283,7 @@ static bool _topicFilterMatch( const char * pTopicName,
static bool _topicMatch( const IotLink_t * const pSubscriptionLink,
void * pMatch )
{
- bool status = false;
+ bool status = false;
/* This function is called from a container function; the caller
* will never pass NULL. */
@@ -296,16 +296,16 @@ static bool _topicMatch( const IotLink_t * const pSubscriptionLink,
/* coverity[misra_c_2012_rule_11_8_violation] */
/* coverity[misra_c_2012_rule_20_7_violation] */
/* coverity[caretline] */
- const _mqttSubscription_t * pSubscription = IotLink_Container( _mqttSubscription_t,
- pSubscriptionLink,
- link );
- const _topicMatchParams_t * pParam = ( _topicMatchParams_t * ) pMatch;
+ const _mqttSubscription_t * pSubscription = IotLink_Container( _mqttSubscription_t,
+ pSubscriptionLink,
+ link );
+ const _topicMatchParams_t * pParam = ( _topicMatchParams_t * ) pMatch;
/* Extract the relevant strings and lengths from parameters. */
- const char * pTopicName = pParam->pTopicName;
- const char * pTopicFilter = pSubscription->pTopicFilter;
- const uint16_t topicNameLength = pParam->topicNameLength;
- const uint16_t topicFilterLength = pSubscription->topicFilterLength;
+ const char * pTopicName = pParam->pTopicName;
+ const char * pTopicFilter = pSubscription->pTopicFilter;
+ const uint16_t topicNameLength = pParam->topicNameLength;
+ const uint16_t topicFilterLength = pSubscription->topicFilterLength;
/* Check for an exact match. */
if( topicNameLength == topicFilterLength )
@@ -328,7 +328,7 @@ static bool _topicMatch( const IotLink_t * const pSubscriptionLink,
static bool _packetMatch( const IotLink_t * const pSubscriptionLink,
void * pMatch )
{
- bool match = false;
+ bool match = false;
/* Because this function is called from a container function, the given link
* must never be NULL. */
@@ -341,10 +341,10 @@ static bool _packetMatch( const IotLink_t * const pSubscriptionLink,
/* coverity[misra_c_2012_rule_11_8_violation] */
/* coverity[misra_c_2012_rule_20_7_violation] */
/* coverity[caretline] */
- _mqttSubscription_t * pSubscription = IotLink_Container( _mqttSubscription_t,
- pSubscriptionLink,
- link );
- const _packetMatchParams_t * pParam = ( _packetMatchParams_t * ) pMatch;
+ _mqttSubscription_t * pSubscription = IotLink_Container( _mqttSubscription_t,
+ pSubscriptionLink,
+ link );
+ const _packetMatchParams_t * pParam = ( _packetMatchParams_t * ) pMatch;
/* Compare packet identifiers. */
if( pParam->packetIdentifier == pSubscription->packetInfo.identifier )
@@ -370,7 +370,7 @@ static bool _packetMatch( const IotLink_t * const pSubscriptionLink,
* removed yet because there are subscription callbacks using it. */
if( pSubscription->references > 0 )
{
- match = false;
+ match = false;
/* Set the unsubscribed flag. The last active subscription callback
* will remove and clean up this subscription. */
@@ -388,23 +388,23 @@ IotMqttError_t _IotMqtt_AddSubscriptions( _mqttConnection_t * pMqttConnection,
const IotMqttSubscription_t * pSubscriptionList,
size_t subscriptionCount )
{
- IotMqttError_t status = IOT_MQTT_SUCCESS;
- size_t i = 0;
- _mqttSubscription_t * pNewSubscription = NULL;
- IotLink_t * pSubscriptionLink = NULL;
- _topicMatchParams_t topicMatchParams = { .exactMatchOnly = true };
+ IotMqttError_t status = IOT_MQTT_SUCCESS;
+ size_t i = 0;
+ _mqttSubscription_t * pNewSubscription = NULL;
+ IotLink_t * pSubscriptionLink = NULL;
+ _topicMatchParams_t topicMatchParams = { .exactMatchOnly = true };
IotMutex_Lock( &( pMqttConnection->subscriptionMutex ) );
for( i = 0; i < subscriptionCount; i++ )
{
/* Check if this topic filter is already registered. */
- topicMatchParams.pTopicName = pSubscriptionList[ i ].pTopicFilter;
+ topicMatchParams.pTopicName = pSubscriptionList[ i ].pTopicFilter;
topicMatchParams.topicNameLength = pSubscriptionList[ i ].topicFilterLength;
- pSubscriptionLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ),
- NULL,
- _topicMatch,
- &topicMatchParams );
+ pSubscriptionLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ),
+ NULL,
+ _topicMatch,
+ &topicMatchParams );
if( pSubscriptionLink != NULL )
{
@@ -412,21 +412,21 @@ IotMqttError_t _IotMqtt_AddSubscriptions( _mqttConnection_t * pMqttConnection,
* because it uses type-casting and offsetof, and would cause compiling errors. */
/* coverity[misra_c_2012_rule_20_7_violation] */
/* coverity[caretline] */
- pNewSubscription = IotLink_Container( _mqttSubscription_t, pSubscriptionLink, link );
+ pNewSubscription = IotLink_Container( _mqttSubscription_t, pSubscriptionLink, link );
/* The lengths of exactly matching topic filters must match. */
IotMqtt_Assert( pNewSubscription->topicFilterLength == pSubscriptionList[ i ].topicFilterLength );
/* Replace the callback and packet info with the new parameters. */
- pNewSubscription->callback = pSubscriptionList[ i ].callback;
+ pNewSubscription->callback = pSubscriptionList[ i ].callback;
pNewSubscription->packetInfo.identifier = subscribePacketIdentifier;
- pNewSubscription->packetInfo.order = i;
+ pNewSubscription->packetInfo.order = i;
}
else
{
/* Allocate memory for a new subscription. */
- pNewSubscription = IotMqtt_MallocSubscription( sizeof( _mqttSubscription_t ) +
- pSubscriptionList[ i ].topicFilterLength );
+ pNewSubscription = IotMqtt_MallocSubscription( sizeof( _mqttSubscription_t ) +
+ pSubscriptionList[ i ].topicFilterLength );
if( pNewSubscription == NULL )
{
@@ -441,9 +441,9 @@ IotMqttError_t _IotMqtt_AddSubscriptions( _mqttConnection_t * pMqttConnection,
/* Set the members of the new subscription and add it to the list. */
pNewSubscription->packetInfo.identifier = subscribePacketIdentifier;
- pNewSubscription->packetInfo.order = i;
- pNewSubscription->callback = pSubscriptionList[ i ].callback;
- pNewSubscription->topicFilterLength = pSubscriptionList[ i ].topicFilterLength;
+ pNewSubscription->packetInfo.order = i;
+ pNewSubscription->callback = pSubscriptionList[ i ].callback;
+ pNewSubscription->topicFilterLength = pSubscriptionList[ i ].topicFilterLength;
( void ) memcpy( pNewSubscription->pTopicFilter,
pSubscriptionList[ i ].pTopicFilter,
( size_t ) ( pSubscriptionList[ i ].topicFilterLength ) );
@@ -472,17 +472,17 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection,
IotMqttCallbackParam_t * pCallbackParam )
{
_mqttSubscription_t * pSubscription = NULL;
- IotLink_t * pCurrentLink = NULL, * pNextLink = NULL;
- void * pCallbackContext = NULL;
+ IotLink_t * pCurrentLink = NULL, * pNextLink = NULL;
+ void * pCallbackContext = NULL;
- void ( * callbackFunction )( void * pContext,
- IotMqttCallbackParam_t * pParam ) = NULL;
- _topicMatchParams_t topicMatchParams = { 0 };
+ void ( * callbackFunction )( void * pContext,
+ IotMqttCallbackParam_t * pParam ) = NULL;
+ _topicMatchParams_t topicMatchParams = { 0 };
/* Set the members of the search parameter. */
- topicMatchParams.pTopicName = pCallbackParam->u.message.info.pTopicName;
+ topicMatchParams.pTopicName = pCallbackParam->u.message.info.pTopicName;
topicMatchParams.topicNameLength = pCallbackParam->u.message.info.topicNameLength;
- topicMatchParams.exactMatchOnly = false;
+ topicMatchParams.exactMatchOnly = false;
/* Prevent any other thread from modifying the subscription list while this
* function is searching. */
@@ -492,10 +492,10 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection,
* the list head. */
while( true )
{
- pCurrentLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ),
- pCurrentLink,
- _topicMatch,
- &topicMatchParams );
+ pCurrentLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ),
+ pCurrentLink,
+ _topicMatch,
+ &topicMatchParams );
/* No subscription found. Exit loop. */
if( pCurrentLink == NULL )
@@ -509,7 +509,7 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection,
* because it uses type-casting and offsetof, and would cause compiling errors. */
/* coverity[misra_c_2012_rule_20_7_violation] */
/* coverity[caretline] */
- pSubscription = IotLink_Container( _mqttSubscription_t, pCurrentLink, link );
+ pSubscription = IotLink_Container( _mqttSubscription_t, pCurrentLink, link );
/* Subscription validation should not have allowed a NULL callback function. */
IotMqtt_Assert( pSubscription->callback.function != NULL );
@@ -519,15 +519,15 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection,
/* Copy the necessary members of the subscription before releasing the
* subscription list mutex. */
- pCallbackContext = pSubscription->callback.pCallbackContext;
- callbackFunction = pSubscription->callback.function;
+ pCallbackContext = pSubscription->callback.pCallbackContext;
+ callbackFunction = pSubscription->callback.function;
/* Unlock the subscription list mutex. */
IotMutex_Unlock( &( pMqttConnection->subscriptionMutex ) );
/* Set the members of the callback parameter. */
- pCallbackParam->mqttConnection = pMqttConnection;
- pCallbackParam->u.message.pTopicFilter = pSubscription->pTopicFilter;
+ pCallbackParam->mqttConnection = pMqttConnection;
+ pCallbackParam->u.message.pTopicFilter = pSubscription->pTopicFilter;
pCallbackParam->u.message.topicFilterLength = pSubscription->topicFilterLength;
/* Invoke the subscription callback. */
@@ -541,7 +541,7 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection,
IotMqtt_Assert( pSubscription->references >= 0 );
/* Save the pointer to the next link in case this subscription is freed. */
- pNextLink = pCurrentLink->pNext;
+ pNextLink = pCurrentLink->pNext;
/* Remove this subscription if it has no references and the unsubscribed
* flag is set. */
@@ -558,7 +558,7 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection,
}
/* Move current link pointer. */
- pCurrentLink = pNextLink;
+ pCurrentLink = pNextLink;
}
IotMutex_Unlock( &( pMqttConnection->subscriptionMutex ) );
@@ -576,7 +576,7 @@ void _IotMqtt_RemoveSubscriptionByPacket( _mqttConnection_t * pMqttConnection,
/* Set the members of the search parameter. */
packetMatchParams.packetIdentifier = packetIdentifier;
- packetMatchParams.order = order;
+ packetMatchParams.order = order;
IotMutex_Lock( &( pMqttConnection->subscriptionMutex ) );
IotListDouble_RemoveAllMatches( &( pMqttConnection->subscriptionList ),
@@ -593,10 +593,10 @@ void _IotMqtt_RemoveSubscriptionByTopicFilter( _mqttConnection_t * pMqttConnecti
const IotMqttSubscription_t * pSubscriptionList,
size_t subscriptionCount )
{
- size_t i = 0;
- _mqttSubscription_t * pSubscription = NULL;
- IotLink_t * pSubscriptionLink = NULL;
- _topicMatchParams_t topicMatchParams = { 0 };
+ size_t i = 0;
+ _mqttSubscription_t * pSubscription = NULL;
+ IotLink_t * pSubscriptionLink = NULL;
+ _topicMatchParams_t topicMatchParams = { 0 };
/* Prevent any other thread from modifying the subscription list while this
* function is running. */
@@ -605,14 +605,14 @@ void _IotMqtt_RemoveSubscriptionByTopicFilter( _mqttConnection_t * pMqttConnecti
/* Find and remove each topic filter from the list. */
for( i = 0; i < subscriptionCount; i++ )
{
- topicMatchParams.pTopicName = pSubscriptionList[ i ].pTopicFilter;
+ topicMatchParams.pTopicName = pSubscriptionList[ i ].pTopicFilter;
topicMatchParams.topicNameLength = pSubscriptionList[ i ].topicFilterLength;
- topicMatchParams.exactMatchOnly = true;
+ topicMatchParams.exactMatchOnly = true;
- pSubscriptionLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ),
- NULL,
- _topicMatch,
- &topicMatchParams );
+ pSubscriptionLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ),
+ NULL,
+ _topicMatch,
+ &topicMatchParams );
if( pSubscriptionLink != NULL )
{
@@ -654,25 +654,25 @@ bool IotMqtt_IsSubscribed( IotMqttConnection_t mqttConnection,
uint16_t topicFilterLength,
IotMqttSubscription_t * const pCurrentSubscription )
{
- bool status = false;
- const _mqttSubscription_t * pSubscription = NULL;
- const IotLink_t * pSubscriptionLink = NULL;
- _topicMatchParams_t topicMatchParams = { 0 };
+ bool status = false;
+ const _mqttSubscription_t * pSubscription = NULL;
+ const IotLink_t * pSubscriptionLink = NULL;
+ _topicMatchParams_t topicMatchParams = { 0 };
/* Set the members of the search parameter. */
- topicMatchParams.pTopicName = pTopicFilter;
+ topicMatchParams.pTopicName = pTopicFilter;
topicMatchParams.topicNameLength = topicFilterLength;
- topicMatchParams.exactMatchOnly = true;
+ topicMatchParams.exactMatchOnly = true;
/* Prevent any other thread from modifying the subscription list while this
* function is running. */
IotMutex_Lock( &( mqttConnection->subscriptionMutex ) );
/* Search for a matching subscription. */
- pSubscriptionLink = IotListDouble_FindFirstMatch( &( mqttConnection->subscriptionList ),
- NULL,
- _topicMatch,
- &topicMatchParams );
+ pSubscriptionLink = IotListDouble_FindFirstMatch( &( mqttConnection->subscriptionList ),
+ NULL,
+ _topicMatch,
+ &topicMatchParams );
/* Check if a matching subscription was found. */
if( pSubscriptionLink != NULL )
@@ -689,13 +689,13 @@ bool IotMqtt_IsSubscribed( IotMqttConnection_t mqttConnection,
/* Copy the matching subscription to the output parameter. */
if( pCurrentSubscription != NULL )
{
- pCurrentSubscription->pTopicFilter = pTopicFilter;
+ pCurrentSubscription->pTopicFilter = pTopicFilter;
pCurrentSubscription->topicFilterLength = topicFilterLength;
- pCurrentSubscription->qos = IOT_MQTT_QOS_0;
- pCurrentSubscription->callback = pSubscription->callback;
+ pCurrentSubscription->qos = IOT_MQTT_QOS_0;
+ pCurrentSubscription->callback = pSubscription->callback;
}
- status = true;
+ status = true;
}
IotMutex_Unlock( &( mqttConnection->subscriptionMutex ) );
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c
index cdcca62f0..cb8434799 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c
@@ -348,8 +348,8 @@ static bool _validateSubscription( bool awsIotMqttMode,
IotMqttOperationType_t operation,
const IotMqttSubscription_t * pSubscription )
{
- bool status = true;
- uint16_t i = 0;
+ bool status = true;
+ uint16_t i = 0;
/* Check for a valid QoS and callback function when subscribing. */
if( operation == IOT_MQTT_SUBSCRIBE )
@@ -499,9 +499,9 @@ static bool _validateWildcardHash( uint16_t index,
static bool _validateClientId( const IotMqttConnectInfo_t * pConnectInfo )
{
- bool status = true;
- uint16_t maxClientIdLength = MQTT_SERVER_MAX_CLIENTID_LENGTH;
- bool enforceMaxClientIdLength = false;
+ bool status = true;
+ uint16_t maxClientIdLength = MQTT_SERVER_MAX_CLIENTID_LENGTH;
+ bool enforceMaxClientIdLength = false;
/* Check that a client identifier was set. */
if( pConnectInfo->pClientIdentifier == NULL )
@@ -531,7 +531,7 @@ static bool _validateClientId( const IotMqttConnectInfo_t * pConnectInfo )
/* The AWS IoT MQTT service enforces a client ID length limit. */
if( pConnectInfo->awsIotMqttMode == true )
{
- maxClientIdLength = AWS_IOT_MQTT_SERVER_MAX_CLIENTID_LENGTH;
+ maxClientIdLength = AWS_IOT_MQTT_SERVER_MAX_CLIENTID_LENGTH;
enforceMaxClientIdLength = true;
}
@@ -635,7 +635,7 @@ bool _IotMqtt_ValidatePublish( bool awsIotMqttMode,
const IotMqttCallbackInfo_t * pCallbackInfo,
const IotMqttOperation_t * const pPublishOperation )
{
- bool status = true;
+ bool status = true;
size_t maximumPayloadLength = MQTT_SERVER_MAX_PUBLISH_PAYLOAD_LENGTH;
if( awsIotMqttMode == true )
@@ -736,8 +736,8 @@ bool _IotMqtt_ValidateSubscriptionList( IotMqttOperationType_t operation,
const IotMqttSubscription_t * pListStart,
size_t listSize )
{
- bool status = true;
- size_t i = 0;
+ bool status = true;
+ size_t i = 0;
/* Operation must be either subscribe or unsubscribe. */
IotMqtt_Assert( ( operation == IOT_MQTT_SUBSCRIBE ) ||
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_helper.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_helper.h
index 519670df0..8de8eb2c2 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_helper.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_helper.h
@@ -71,7 +71,7 @@
* @param[in] x The unsigned int to check.
* @param[in] position Which bit to check.
*/
-#define UINT8_CHECK_BIT( x, position ) ( ( ( x ) &( 0x01U << ( position ) ) ) == ( 0x01U << ( position ) ) )
+#define UINT8_CHECK_BIT( x, position ) ( ( ( x ) & ( 0x01U << ( position ) ) ) == ( 0x01U << ( position ) ) )
/**
* @cond DOXYGEN_IGNORE
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_internal.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_internal.h
index 20d950a87..6da45efd2 100755..100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_internal.h
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/private/iot_mqtt_internal.h
@@ -564,6 +564,7 @@ uint8_t _IotMqtt_GetPacketType( IotNetworkConnection_t pNetworkConnection,
*/
size_t _IotMqtt_GetRemainingLength( IotNetworkConnection_t pNetworkConnection,
const IotNetworkInterface_t * pNetworkInterface );
+
/**
* @brief Generate a CONNECT packet from the given parameters.
*
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt.c
index 9efe1b618..fb8d61fc9 100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt.c
@@ -308,9 +308,9 @@ static int32_t sendPacket( MQTTContext_t * pContext,
size_t bytesToSend )
{
const uint8_t * pIndex = pBufferToSend;
- size_t bytesRemaining = bytesToSend;
- int32_t totalBytesSent = 0, bytesSent;
- uint32_t sendTime = 0U;
+ size_t bytesRemaining = bytesToSend;
+ int32_t totalBytesSent = 0, bytesSent;
+ uint32_t sendTime = 0U;
assert( pContext != NULL );
assert( pContext->callbacks.getTime != NULL );
@@ -318,7 +318,7 @@ static int32_t sendPacket( MQTTContext_t * pContext,
bytesRemaining = bytesToSend;
/* Record the time of transmission. */
- sendTime = pContext->callbacks.getTime();
+ sendTime = pContext->callbacks.getTime();
/* Loop until the entire packet is sent. */
while( bytesRemaining > 0UL )
@@ -331,7 +331,7 @@ static int32_t sendPacket( MQTTContext_t * pContext,
{
bytesRemaining -= ( size_t ) bytesSent;
totalBytesSent += bytesSent;
- pIndex += bytesSent;
+ pIndex += bytesSent;
LogDebug( ( "Bytes sent=%d, bytes remaining=%ul,"
"total bytes sent=%d.",
bytesSent,
@@ -404,41 +404,41 @@ static int32_t recvExact( const MQTTContext_t * pContext,
size_t bytesToRecv,
uint32_t timeoutMs )
{
- uint8_t * pIndex = NULL;
- size_t bytesRemaining = bytesToRecv;
- int32_t totalBytesRecvd = 0, bytesRecvd;
- uint32_t entryTimeMs = 0U, elapsedTimeMs = 0U;
- MQTTTransportRecvFunc_t recvFunc = NULL;
+ uint8_t * pIndex = NULL;
+ size_t bytesRemaining = bytesToRecv;
+ int32_t totalBytesRecvd = 0, bytesRecvd;
+ uint32_t entryTimeMs = 0U, elapsedTimeMs = 0U;
+ MQTTTransportRecvFunc_t recvFunc = NULL;
MQTTGetCurrentTimeFunc_t getTimeStampMs = NULL;
- bool receiveError = false;
+ bool receiveError = false;
assert( pContext != NULL );
assert( bytesToRecv <= pContext->networkBuffer.size );
assert( pContext->callbacks.getTime != NULL );
- pIndex = pContext->networkBuffer.pBuffer;
- recvFunc = pContext->transportInterface.recv;
+ pIndex = pContext->networkBuffer.pBuffer;
+ recvFunc = pContext->transportInterface.recv;
getTimeStampMs = pContext->callbacks.getTime;
- entryTimeMs = getTimeStampMs();
+ entryTimeMs = getTimeStampMs();
while( ( bytesRemaining > 0U ) && ( receiveError == false ) )
{
- bytesRecvd = recvFunc( pContext->transportInterface.networkContext,
- pIndex,
- bytesRemaining );
+ bytesRecvd = recvFunc( pContext->transportInterface.networkContext,
+ pIndex,
+ bytesRemaining );
if( bytesRecvd >= 0 )
{
- bytesRemaining -= ( size_t ) bytesRecvd;
+ bytesRemaining -= ( size_t ) bytesRecvd;
totalBytesRecvd += ( int32_t ) bytesRecvd;
- pIndex += bytesRecvd;
+ pIndex += bytesRecvd;
}
else
{
LogError( ( "Network error while receiving packet: ReturnCode=%d",
bytesRecvd ) );
totalBytesRecvd = bytesRecvd;
- receiveError = true;
+ receiveError = true;
}
elapsedTimeMs = calculateElapsedTime( getTimeStampMs(), entryTimeMs );
@@ -459,20 +459,20 @@ static MQTTStatus_t discardPacket( const MQTTContext_t * pContext,
size_t remainingLength,
uint32_t timeoutMs )
{
- MQTTStatus_t status = MQTTRecvFailed;
- int32_t bytesReceived = 0;
- size_t bytesToReceive = 0U;
- uint32_t totalBytesReceived = 0U, entryTimeMs = 0U, elapsedTimeMs = 0U;
- uint32_t remainingTimeMs = timeoutMs;
- MQTTGetCurrentTimeFunc_t getTimeStampMs = NULL;
- bool receiveError = false;
+ MQTTStatus_t status = MQTTRecvFailed;
+ int32_t bytesReceived = 0;
+ size_t bytesToReceive = 0U;
+ uint32_t totalBytesReceived = 0U, entryTimeMs = 0U, elapsedTimeMs = 0U;
+ uint32_t remainingTimeMs = timeoutMs;
+ MQTTGetCurrentTimeFunc_t getTimeStampMs = NULL;
+ bool receiveError = false;
assert( pContext != NULL );
assert( pContext->callbacks.getTime != NULL );
bytesToReceive = pContext->networkBuffer.size;
getTimeStampMs = pContext->callbacks.getTime;
- entryTimeMs = getTimeStampMs();
+ entryTimeMs = getTimeStampMs();
while( ( totalBytesReceived < remainingLength ) && ( receiveError == false ) )
{
@@ -495,7 +495,7 @@ static MQTTStatus_t discardPacket( const MQTTContext_t * pContext,
{
totalBytesReceived += ( uint32_t ) bytesReceived;
- elapsedTimeMs = calculateElapsedTime( getTimeStampMs(), entryTimeMs );
+ elapsedTimeMs = calculateElapsedTime( getTimeStampMs(), entryTimeMs );
/* Update remaining time and check for timeout. */
if( elapsedTimeMs < timeoutMs )
@@ -527,9 +527,9 @@ static MQTTStatus_t receivePacket( const MQTTContext_t * pContext,
MQTTPacketInfo_t incomingPacket,
uint32_t remainingTimeMs )
{
- MQTTStatus_t status = MQTTSuccess;
- int32_t bytesReceived = 0;
- size_t bytesToReceive = 0U;
+ MQTTStatus_t status = MQTTSuccess;
+ int32_t bytesReceived = 0;
+ size_t bytesToReceive = 0U;
assert( pContext != NULL );
@@ -547,7 +547,7 @@ static MQTTStatus_t receivePacket( const MQTTContext_t * pContext,
else
{
bytesToReceive = incomingPacket.remainingLength;
- bytesReceived = recvExact( pContext, bytesToReceive, remainingTimeMs );
+ bytesReceived = recvExact( pContext, bytesToReceive, remainingTimeMs );
if( bytesReceived == ( int32_t ) bytesToReceive )
{
@@ -606,11 +606,11 @@ static MQTTStatus_t sendPublishAcks( MQTTContext_t * pContext,
uint16_t packetId,
MQTTPublishState_t publishState )
{
- MQTTStatus_t status = MQTTSuccess;
- MQTTPublishState_t newState = MQTTStateNull;
- int32_t bytesSent = 0;
- uint8_t packetTypeByte = 0U;
- MQTTPubAckType_t packetType;
+ MQTTStatus_t status = MQTTSuccess;
+ MQTTPublishState_t newState = MQTTStateNull;
+ int32_t bytesSent = 0;
+ uint8_t packetTypeByte = 0U;
+ MQTTPubAckType_t packetType;
assert( pContext != NULL );
@@ -620,9 +620,9 @@ static MQTTStatus_t sendPublishAcks( MQTTContext_t * pContext,
{
packetType = getAckFromPacketType( packetTypeByte );
- status = MQTT_SerializeAck( &( pContext->networkBuffer ),
- packetTypeByte,
- packetId );
+ status = MQTT_SerializeAck( &( pContext->networkBuffer ),
+ packetTypeByte,
+ packetId );
if( status == MQTTSuccess )
{
@@ -634,11 +634,11 @@ static MQTTStatus_t sendPublishAcks( MQTTContext_t * pContext,
if( bytesSent == ( int32_t ) MQTT_PUBLISH_ACK_PACKET_SIZE )
{
pContext->controlPacketSent = true;
- status = MQTT_UpdateStateAck( pContext,
- packetId,
- packetType,
- MQTT_SEND,
- &newState );
+ status = MQTT_UpdateStateAck( pContext,
+ packetId,
+ packetType,
+ MQTT_SEND,
+ &newState );
if( status != MQTTSuccess )
{
@@ -665,10 +665,10 @@ static MQTTStatus_t sendPublishAcks( MQTTContext_t * pContext,
static MQTTStatus_t handleKeepAlive( MQTTContext_t * pContext )
{
MQTTStatus_t status = MQTTSuccess;
- uint32_t now = 0U, keepAliveMs = 0U;
+ uint32_t now = 0U, keepAliveMs = 0U;
assert( pContext != NULL );
- now = pContext->callbacks.getTime();
+ now = pContext->callbacks.getTime();
keepAliveMs = 1000U * ( uint32_t ) pContext->keepAliveIntervalSec;
/* If keep alive interval is 0, it is disabled. */
@@ -698,11 +698,11 @@ static MQTTStatus_t handleKeepAlive( MQTTContext_t * pContext )
static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext,
MQTTPacketInfo_t * pIncomingPacket )
{
- MQTTStatus_t status = MQTTBadParameter;
+ MQTTStatus_t status = MQTTBadParameter;
MQTTPublishState_t publishRecordState = MQTTStateNull;
- uint16_t packetIdentifier = 0U;
- MQTTPublishInfo_t publishInfo;
- bool duplicatePublish = false;
+ uint16_t packetIdentifier = 0U;
+ MQTTPublishInfo_t publishInfo;
+ bool duplicatePublish = false;
assert( pContext != NULL );
assert( pIncomingPacket != NULL );
@@ -752,8 +752,8 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext,
* data is not passed to the application. */
else if( ( status == MQTTStateCollision ) && ( publishInfo.dup == true ) )
{
- status = MQTTSuccess;
- duplicatePublish = true;
+ status = MQTTSuccess;
+ duplicatePublish = true;
/* Calculate the state for the ack packet that needs to be sent out
* for the duplicate incoming publish. */
@@ -799,10 +799,10 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext,
static MQTTStatus_t handlePublishAcks( MQTTContext_t * pContext,
MQTTPacketInfo_t * pIncomingPacket )
{
- MQTTStatus_t status = MQTTBadResponse;
- MQTTPublishState_t publishRecordState = MQTTStateNull;
- uint16_t packetIdentifier;
- MQTTPubAckType_t ackType;
+ MQTTStatus_t status = MQTTBadResponse;
+ MQTTPublishState_t publishRecordState = MQTTStateNull;
+ uint16_t packetIdentifier;
+ MQTTPubAckType_t ackType;
MQTTEventCallback_t appCallback;
assert( pContext != NULL );
@@ -811,8 +811,8 @@ static MQTTStatus_t handlePublishAcks( MQTTContext_t * pContext,
appCallback = pContext->callbacks.appCallback;
- ackType = getAckFromPacketType( pIncomingPacket->type );
- status = MQTT_DeserializeAck( pIncomingPacket, &packetIdentifier, NULL );
+ ackType = getAckFromPacketType( pIncomingPacket->type );
+ status = MQTT_DeserializeAck( pIncomingPacket, &packetIdentifier, NULL );
LogInfo( ( "Ack packet deserialized with result: %s.",
MQTT_Status_strerror( status ) ) );
@@ -859,18 +859,18 @@ static MQTTStatus_t handleIncomingAck( MQTTContext_t * pContext,
MQTTPacketInfo_t * pIncomingPacket,
bool manageKeepAlive )
{
- MQTTStatus_t status = MQTTBadResponse;
- uint16_t packetIdentifier;
+ MQTTStatus_t status = MQTTBadResponse;
+ uint16_t packetIdentifier;
/* Need a dummy variable for MQTT_DeserializeAck(). */
- bool sessionPresent = false;
+ bool sessionPresent = false;
/* We should always invoke the app callback unless we receive a PINGRESP
* and are managing keep alive, or if we receive an unknown packet. We
* initialize this to false since the callback must be invoked before
* sending any PUBREL or PUBCOMP. However, for other cases, we invoke it
* at the end to reduce the complexity of this function. */
- bool invokeAppCallback = false;
- MQTTEventCallback_t appCallback = NULL;
+ bool invokeAppCallback = false;
+ MQTTEventCallback_t appCallback = NULL;
assert( pContext != NULL );
assert( pIncomingPacket != NULL );
@@ -885,12 +885,12 @@ static MQTTStatus_t handleIncomingAck( MQTTContext_t * pContext,
case MQTT_PACKET_TYPE_PUBCOMP:
/* Handle all the publish acks. */
- status = handlePublishAcks( pContext, pIncomingPacket );
+ status = handlePublishAcks( pContext, pIncomingPacket );
break;
case MQTT_PACKET_TYPE_PINGRESP:
- status = MQTT_DeserializeAck( pIncomingPacket, &packetIdentifier, &sessionPresent );
+ status = MQTT_DeserializeAck( pIncomingPacket, &packetIdentifier, &sessionPresent );
invokeAppCallback = ( manageKeepAlive == true ) ? false : true;
if( ( status == MQTTSuccess ) && ( manageKeepAlive == true ) )
@@ -903,7 +903,7 @@ static MQTTStatus_t handleIncomingAck( MQTTContext_t * pContext,
case MQTT_PACKET_TYPE_SUBACK:
case MQTT_PACKET_TYPE_UNSUBACK:
/* Deserialize and give these to the app provided callback. */
- status = MQTT_DeserializeAck( pIncomingPacket, &packetIdentifier, &sessionPresent );
+ status = MQTT_DeserializeAck( pIncomingPacket, &packetIdentifier, &sessionPresent );
invokeAppCallback = true;
break;
@@ -911,7 +911,7 @@ static MQTTStatus_t handleIncomingAck( MQTTContext_t * pContext,
/* Bad response from the server. */
LogError( ( "Unexpected packet type from server: PacketType=%02x.",
pIncomingPacket->type ) );
- status = MQTTBadResponse;
+ status = MQTTBadResponse;
break;
}
@@ -929,7 +929,7 @@ static MQTTStatus_t receiveSingleIteration( MQTTContext_t * pContext,
uint32_t remainingTimeMs,
bool manageKeepAlive )
{
- MQTTStatus_t status = MQTTSuccess;
+ MQTTStatus_t status = MQTTSuccess;
MQTTPacketInfo_t incomingPacket;
assert( pContext != NULL );
@@ -1035,8 +1035,8 @@ static MQTTStatus_t sendPublish( MQTTContext_t * pContext,
const MQTTPublishInfo_t * pPublishInfo,
size_t headerSize )
{
- MQTTStatus_t status = MQTTSuccess;
- int32_t bytesSent = 0;
+ MQTTStatus_t status = MQTTSuccess;
+ int32_t bytesSent = 0;
assert( pContext != NULL );
assert( pPublishInfo != NULL );
@@ -1085,11 +1085,11 @@ static MQTTStatus_t receiveConnack( const MQTTContext_t * pContext,
MQTTPacketInfo_t * pIncomingPacket,
bool * pSessionPresent )
{
- MQTTStatus_t status = MQTTSuccess;
+ MQTTStatus_t status = MQTTSuccess;
MQTTGetCurrentTimeFunc_t getTimeStamp = NULL;
- uint32_t entryTimeMs = 0U, remainingTimeMs = 0U, timeTakenMs = 0U;
- bool breakFromLoop = false;
- uint16_t loopCount = 0U;
+ uint32_t entryTimeMs = 0U, remainingTimeMs = 0U, timeTakenMs = 0U;
+ bool breakFromLoop = false;
+ uint16_t loopCount = 0U;
assert( pContext != NULL );
assert( pIncomingPacket != NULL );
@@ -1098,7 +1098,7 @@ static MQTTStatus_t receiveConnack( const MQTTContext_t * pContext,
getTimeStamp = pContext->callbacks.getTime;
/* Get the entry time for the function. */
- entryTimeMs = getTimeStamp();
+ entryTimeMs = getTimeStamp();
do
{
@@ -1173,7 +1173,7 @@ static MQTTStatus_t receiveConnack( const MQTTContext_t * pContext,
pIncomingPacket->pRemainingData = pContext->networkBuffer.pBuffer;
/* Deserialize CONNACK. */
- status = MQTT_DeserializeAck( pIncomingPacket, NULL, pSessionPresent );
+ status = MQTT_DeserializeAck( pIncomingPacket, NULL, pSessionPresent );
}
/* If a clean session is requested, a session present should not be set by
@@ -1205,10 +1205,10 @@ static MQTTStatus_t receiveConnack( const MQTTContext_t * pContext,
static MQTTStatus_t resendPendingAcks( MQTTContext_t * pContext )
{
- MQTTStatus_t status = MQTTSuccess;
- MQTTStateCursor_t cursor = MQTT_STATE_CURSOR_INITIALIZER;
- uint16_t packetId = MQTT_PACKET_ID_INVALID;
- MQTTPublishState_t state = MQTTStateNull;
+ MQTTStatus_t status = MQTTSuccess;
+ MQTTStateCursor_t cursor = MQTT_STATE_CURSOR_INITIALIZER;
+ uint16_t packetId = MQTT_PACKET_ID_INVALID;
+ MQTTPublishState_t state = MQTTStateNull;
assert( pContext != NULL );
@@ -1219,7 +1219,7 @@ static MQTTStatus_t resendPendingAcks( MQTTContext_t * pContext )
while( ( packetId != MQTT_PACKET_ID_INVALID ) &&
( status == MQTTSuccess ) )
{
- status = sendPublishAcks( pContext, packetId, state );
+ status = sendPublishAcks( pContext, packetId, state );
packetId = MQTT_PubrelToResend( pContext, &cursor, &state );
}
@@ -1235,7 +1235,7 @@ static MQTTStatus_t serializePublish( const MQTTContext_t * pContext,
size_t * const pHeaderSize )
{
MQTTStatus_t status = MQTTSuccess;
- size_t remainingLength = 0UL, packetSize = 0UL;
+ size_t remainingLength = 0UL, packetSize = 0UL;
assert( pContext != NULL );
assert( pPublishInfo != NULL );
@@ -1331,13 +1331,13 @@ MQTTStatus_t MQTT_Init( MQTTContext_t * pContext,
{
( void ) memset( pContext, 0x00, sizeof( MQTTContext_t ) );
- pContext->connectStatus = MQTTNotConnected;
+ pContext->connectStatus = MQTTNotConnected;
pContext->transportInterface = *pTransportInterface;
- pContext->callbacks = *pCallbacks;
- pContext->networkBuffer = *pNetworkBuffer;
+ pContext->callbacks = *pCallbacks;
+ pContext->networkBuffer = *pNetworkBuffer;
/* Zero is not a valid packet ID per MQTT spec. Start from 1. */
- pContext->nextPacketId = 1;
+ pContext->nextPacketId = 1;
}
return status;
@@ -1351,9 +1351,9 @@ MQTTStatus_t MQTT_Connect( MQTTContext_t * pContext,
uint32_t timeoutMs,
bool * pSessionPresent )
{
- size_t remainingLength = 0UL, packetSize = 0UL;
- int32_t bytesSent;
- MQTTStatus_t status = MQTTSuccess;
+ size_t remainingLength = 0UL, packetSize = 0UL;
+ int32_t bytesSent;
+ MQTTStatus_t status = MQTTSuccess;
MQTTPacketInfo_t incomingPacket = { 0 };
incomingPacket.type = ( uint8_t ) 0;
@@ -1443,14 +1443,14 @@ MQTTStatus_t MQTT_Subscribe( MQTTContext_t * pContext,
size_t subscriptionCount,
uint16_t packetId )
{
- size_t remainingLength = 0UL, packetSize = 0UL;
- int32_t bytesSent = 0;
+ size_t remainingLength = 0UL, packetSize = 0UL;
+ int32_t bytesSent = 0;
/* Validate arguments. */
- MQTTStatus_t status = validateSubscribeUnsubscribeParams( pContext,
- pSubscriptionList,
- subscriptionCount,
- packetId );
+ MQTTStatus_t status = validateSubscribeUnsubscribeParams( pContext,
+ pSubscriptionList,
+ subscriptionCount,
+ packetId );
if( status == MQTTSuccess )
{
@@ -1502,11 +1502,11 @@ MQTTStatus_t MQTT_Publish( MQTTContext_t * pContext,
const MQTTPublishInfo_t * pPublishInfo,
uint16_t packetId )
{
- size_t headerSize = 0UL;
+ size_t headerSize = 0UL;
MQTTPublishState_t publishStatus = MQTTStateNull;
/* Validate arguments. */
- MQTTStatus_t status = validatePublishParams( pContext, pPublishInfo, packetId );
+ MQTTStatus_t status = validatePublishParams( pContext, pPublishInfo, packetId );
if( status == MQTTSuccess )
{
@@ -1574,9 +1574,9 @@ MQTTStatus_t MQTT_Publish( MQTTContext_t * pContext,
MQTTStatus_t MQTT_Ping( MQTTContext_t * pContext )
{
- int32_t bytesSent = 0;
- MQTTStatus_t status = MQTTSuccess;
- size_t packetSize;
+ int32_t bytesSent = 0;
+ MQTTStatus_t status = MQTTSuccess;
+ size_t packetSize;
if( pContext == NULL )
{
@@ -1620,7 +1620,7 @@ MQTTStatus_t MQTT_Ping( MQTTContext_t * pContext )
}
else
{
- pContext->pingReqSendTimeMs = pContext->lastPacketTime;
+ pContext->pingReqSendTimeMs = pContext->lastPacketTime;
pContext->waitingForPingResp = true;
LogDebug( ( "Sent %d bytes of PINGREQ packet.",
bytesSent ) );
@@ -1637,14 +1637,14 @@ MQTTStatus_t MQTT_Unsubscribe( MQTTContext_t * pContext,
size_t subscriptionCount,
uint16_t packetId )
{
- size_t remainingLength = 0UL, packetSize = 0UL;
- int32_t bytesSent = 0;
+ size_t remainingLength = 0UL, packetSize = 0UL;
+ int32_t bytesSent = 0;
/* Validate arguments. */
- MQTTStatus_t status = validateSubscribeUnsubscribeParams( pContext,
- pSubscriptionList,
- subscriptionCount,
- packetId );
+ MQTTStatus_t status = validateSubscribeUnsubscribeParams( pContext,
+ pSubscriptionList,
+ subscriptionCount,
+ packetId );
if( status == MQTTSuccess )
{
@@ -1694,8 +1694,8 @@ MQTTStatus_t MQTT_Unsubscribe( MQTTContext_t * pContext,
MQTTStatus_t MQTT_Disconnect( MQTTContext_t * pContext )
{
- size_t packetSize;
- int32_t bytesSent;
+ size_t packetSize;
+ int32_t bytesSent;
MQTTStatus_t status = MQTTSuccess;
/* Validate arguments. */
@@ -1751,15 +1751,15 @@ MQTTStatus_t MQTT_Disconnect( MQTTContext_t * pContext )
MQTTStatus_t MQTT_ProcessLoop( MQTTContext_t * pContext,
uint32_t timeoutMs )
{
- MQTTStatus_t status = MQTTBadParameter;
+ MQTTStatus_t status = MQTTBadParameter;
MQTTGetCurrentTimeFunc_t getTimeStampMs = NULL;
- uint32_t entryTimeMs = 0U, remainingTimeMs = timeoutMs, elapsedTimeMs = 0U;
+ uint32_t entryTimeMs = 0U, remainingTimeMs = timeoutMs, elapsedTimeMs = 0U;
if( ( pContext != NULL ) && ( pContext->callbacks.getTime != NULL ) )
{
- getTimeStampMs = pContext->callbacks.getTime;
- entryTimeMs = getTimeStampMs();
- status = MQTTSuccess;
+ getTimeStampMs = pContext->callbacks.getTime;
+ entryTimeMs = getTimeStampMs();
+ status = MQTTSuccess;
pContext->controlPacketSent = false;
}
else if( pContext == NULL )
@@ -1786,7 +1786,7 @@ MQTTStatus_t MQTT_ProcessLoop( MQTTContext_t * pContext,
{
/* Recalculate remaining time and check if loop should exit. This is
* done at the end so the loop will run at least a single iteration. */
- elapsedTimeMs = calculateElapsedTime( getTimeStampMs(), entryTimeMs );
+ elapsedTimeMs = calculateElapsedTime( getTimeStampMs(), entryTimeMs );
if( elapsedTimeMs > timeoutMs )
{
@@ -1805,15 +1805,15 @@ MQTTStatus_t MQTT_ProcessLoop( MQTTContext_t * pContext,
MQTTStatus_t MQTT_ReceiveLoop( MQTTContext_t * pContext,
uint32_t timeoutMs )
{
- MQTTStatus_t status = MQTTBadParameter;
+ MQTTStatus_t status = MQTTBadParameter;
MQTTGetCurrentTimeFunc_t getTimeStampMs = NULL;
- uint32_t entryTimeMs = 0U, remainingTimeMs = timeoutMs, elapsedTimeMs = 0U;
+ uint32_t entryTimeMs = 0U, remainingTimeMs = timeoutMs, elapsedTimeMs = 0U;
if( ( pContext != NULL ) && ( pContext->callbacks.getTime != NULL ) )
{
getTimeStampMs = pContext->callbacks.getTime;
- entryTimeMs = getTimeStampMs();
- status = MQTTSuccess;
+ entryTimeMs = getTimeStampMs();
+ status = MQTTSuccess;
}
else if( pContext == NULL )
{
@@ -1839,7 +1839,7 @@ MQTTStatus_t MQTT_ReceiveLoop( MQTTContext_t * pContext,
{
/* Recalculate remaining time and check if loop should exit. This is
* done at the end so the loop will run at least a single iteration. */
- elapsedTimeMs = calculateElapsedTime( getTimeStampMs(), entryTimeMs );
+ elapsedTimeMs = calculateElapsedTime( getTimeStampMs(), entryTimeMs );
if( elapsedTimeMs >= timeoutMs )
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_lightweight.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_lightweight.c
index 302dd6f1b..3dba351f9 100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_lightweight.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_lightweight.c
@@ -283,9 +283,9 @@ static size_t remainingLengthEncodedSize( size_t length )
static uint8_t * encodeRemainingLength( uint8_t * pDestination,
size_t length )
{
- uint8_t lengthByte;
- uint8_t * pLengthEnd = NULL;
- size_t remainingLength = length;
+ uint8_t lengthByte;
+ uint8_t * pLengthEnd = NULL;
+ size_t remainingLength = length;
assert( pDestination != NULL );
@@ -294,7 +294,7 @@ static uint8_t * encodeRemainingLength( uint8_t * pDestination,
/* This algorithm is copied from the MQTT v3.1.1 spec. */
do
{
- lengthByte = ( uint8_t ) ( remainingLength % 128U );
+ lengthByte = ( uint8_t ) ( remainingLength % 128U );
remainingLength = remainingLength / 128U;
/* Set the high bit of this byte, indicating that there's more data. */
@@ -304,7 +304,7 @@ static uint8_t * encodeRemainingLength( uint8_t * pDestination,
}
/* Output a single encoded byte. */
- *pLengthEnd = lengthByte;
+ *pLengthEnd = lengthByte;
pLengthEnd++;
} while( remainingLength > 0U );
@@ -317,7 +317,7 @@ static uint8_t * encodeString( uint8_t * pDestination,
const char * source,
uint16_t sourceLength )
{
- uint8_t * pBuffer = NULL;
+ uint8_t * pBuffer = NULL;
/* Typecast const char * typed source buffer to const uint8_t *.
* This is to use same type buffers in memcpy. */
@@ -325,7 +325,7 @@ static uint8_t * encodeString( uint8_t * pDestination,
assert( pDestination != NULL );
- pBuffer = pDestination;
+ pBuffer = pDestination;
/* The first byte of a UTF-8 string is the high byte of the string length. */
*pBuffer = UINT16_HIGH_BYTE( sourceLength );
@@ -353,7 +353,7 @@ static bool calculatePublishPacketSize( const MQTTPublishInfo_t * pPublishInfo,
size_t * pRemainingLength,
size_t * pPacketSize )
{
- bool status = true;
+ bool status = true;
size_t packetSize = 0, payloadLimit = 0;
assert( pPublishInfo != NULL );
@@ -363,7 +363,7 @@ static bool calculatePublishPacketSize( const MQTTPublishInfo_t * pPublishInfo,
/* The variable header of a PUBLISH packet always contains the topic name.
* The first 2 bytes of UTF-8 string contains length of the string.
*/
- packetSize += pPublishInfo->topicNameLength + sizeof( uint16_t );
+ packetSize += pPublishInfo->topicNameLength + sizeof( uint16_t );
/* The variable header of a QoS 1 or 2 PUBLISH packet contains a 2-byte
* packet identifier. */
@@ -392,7 +392,7 @@ static bool calculatePublishPacketSize( const MQTTPublishInfo_t * pPublishInfo,
{
/* Add the length of the PUBLISH payload. At this point, the "Remaining length"
* has been calculated. */
- packetSize += pPublishInfo->payloadLength;
+ packetSize += pPublishInfo->payloadLength;
/* Now that the "Remaining length" is known, recalculate the payload limit
* based on the size of its encoding. */
@@ -415,8 +415,8 @@ static bool calculatePublishPacketSize( const MQTTPublishInfo_t * pPublishInfo,
* size of the PUBLISH packet. */
*pRemainingLength = packetSize;
- packetSize += 1U + remainingLengthEncodedSize( packetSize );
- *pPacketSize = packetSize;
+ packetSize += 1U + remainingLengthEncodedSize( packetSize );
+ *pPacketSize = packetSize;
}
}
@@ -434,11 +434,11 @@ static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo,
const MQTTFixedBuffer_t * pFixedBuffer,
bool serializePayload )
{
- uint8_t * pIndex = NULL;
+ uint8_t * pIndex = NULL;
const uint8_t * pPayloadBuffer = NULL;
/* The first byte of a PUBLISH packet contains the packet type and flags. */
- uint8_t publishFlags = MQTT_PACKET_TYPE_PUBLISH;
+ uint8_t publishFlags = MQTT_PACKET_TYPE_PUBLISH;
assert( pPublishInfo != NULL );
assert( pFixedBuffer != NULL );
@@ -448,7 +448,7 @@ static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo,
assert( ( !pPublishInfo->dup ) || ( pPublishInfo->qos > MQTTQoS0 ) );
/* Get the start address of the buffer. */
- pIndex = pFixedBuffer->pBuffer;
+ pIndex = pFixedBuffer->pBuffer;
if( pPublishInfo->qos == MQTTQoS1 )
{
@@ -481,21 +481,21 @@ static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo,
pIndex++;
/* The "Remaining length" is encoded from the second byte. */
- pIndex = encodeRemainingLength( pIndex, remainingLength );
+ pIndex = encodeRemainingLength( pIndex, remainingLength );
/* The topic name is placed after the "Remaining length". */
- pIndex = encodeString( pIndex,
- pPublishInfo->pTopicName,
- pPublishInfo->topicNameLength );
+ pIndex = encodeString( pIndex,
+ pPublishInfo->pTopicName,
+ pPublishInfo->topicNameLength );
/* A packet identifier is required for QoS 1 and 2 messages. */
if( pPublishInfo->qos > MQTTQoS0 )
{
LogDebug( ( "Adding packet Id in PUBLISH packet." ) );
/* Place the packet identifier into the PUBLISH packet. */
- *pIndex = UINT16_HIGH_BYTE( packetIdentifier );
+ *pIndex = UINT16_HIGH_BYTE( packetIdentifier );
*( pIndex + 1 ) = UINT16_LOW_BYTE( packetIdentifier );
- pIndex += 2;
+ pIndex += 2;
}
/* The payload is placed after the packet identifier.
@@ -513,7 +513,7 @@ static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo,
pPayloadBuffer = ( const uint8_t * ) pPublishInfo->pPayload;
( void ) memcpy( pIndex, pPayloadBuffer, pPublishInfo->payloadLength );
- pIndex += pPublishInfo->payloadLength;
+ pIndex += pPublishInfo->payloadLength;
}
/* Ensure that the difference between the end and beginning of the buffer
@@ -524,8 +524,8 @@ static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo,
static size_t getRemainingLength( MQTTTransportRecvFunc_t recvFunc,
NetworkContext_t networkContext )
{
- size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0;
- uint8_t encodedByte = 0;
+ size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0;
+ uint8_t encodedByte = 0;
int32_t bytesReceived = 0;
/* This algorithm is copied from the MQTT v3.1.1 spec. */
@@ -542,7 +542,7 @@ static size_t getRemainingLength( MQTTTransportRecvFunc_t recvFunc,
if( bytesReceived == 1 )
{
remainingLength += ( ( size_t ) encodedByte & 0x7FU ) * multiplier;
- multiplier *= 128U;
+ multiplier *= 128U;
bytesDecoded++;
}
else
@@ -694,7 +694,7 @@ static MQTTStatus_t processPublishFlags( uint8_t publishFlags,
LogDebug( ( "Retain bit is %d.", pPublishInfo->retain ) );
/* Parse the DUP bit. */
- pPublishInfo->dup = ( UINT8_CHECK_BIT( publishFlags, MQTT_PUBLISH_FLAG_DUP ) ) ? true : false;
+ pPublishInfo->dup = ( UINT8_CHECK_BIT( publishFlags, MQTT_PUBLISH_FLAG_DUP ) ) ? true : false;
LogDebug( ( "DUP bit is %d.", pPublishInfo->dup ) );
}
@@ -739,7 +739,7 @@ static void logConnackResponse( uint8_t responseCode )
static MQTTStatus_t deserializeConnack( const MQTTPacketInfo_t * pConnack,
bool * pSessionPresent )
{
- MQTTStatus_t status = MQTTSuccess;
+ MQTTStatus_t status = MQTTSuccess;
const uint8_t * pRemainingData = NULL;
assert( pConnack != NULL );
@@ -823,7 +823,7 @@ static MQTTStatus_t calculateSubscriptionPacketSize( const MQTTSubscribeInfo_t *
MQTTSubscriptionType_t subscriptionType )
{
MQTTStatus_t status = MQTTSuccess;
- size_t i = 0, packetSize = 0;
+ size_t i = 0, packetSize = 0;
assert( pSubscriptionList != NULL );
assert( subscriptionCount != 0U );
@@ -867,10 +867,10 @@ static MQTTStatus_t calculateSubscriptionPacketSize( const MQTTSubscribeInfo_t *
/* Calculate the full size of the subscription packet by adding
* number of bytes required to encode the "Remaining length" field
* plus 1 byte for the "Packet type" field. */
- packetSize += 1U + remainingLengthEncodedSize( packetSize );
+ packetSize += 1U + remainingLengthEncodedSize( packetSize );
/*Set the pPacketSize output parameter. */
- *pPacketSize = packetSize;
+ *pPacketSize = packetSize;
}
LogDebug( ( "Subscription packet remaining length=%lu and packet size=%lu.",
@@ -885,9 +885,9 @@ static MQTTStatus_t calculateSubscriptionPacketSize( const MQTTSubscribeInfo_t *
static MQTTStatus_t readSubackStatus( size_t statusCount,
const uint8_t * pStatusStart )
{
- MQTTStatus_t status = MQTTSuccess;
- uint8_t subscriptionStatus = 0;
- size_t i = 0;
+ MQTTStatus_t status = MQTTSuccess;
+ uint8_t subscriptionStatus = 0;
+ size_t i = 0;
assert( pStatusStart != NULL );
@@ -940,8 +940,8 @@ static MQTTStatus_t readSubackStatus( size_t statusCount,
static MQTTStatus_t deserializeSuback( const MQTTPacketInfo_t * pSuback,
uint16_t * pPacketIdentifier )
{
- MQTTStatus_t status = MQTTSuccess;
- size_t remainingLength;
+ MQTTStatus_t status = MQTTSuccess;
+ size_t remainingLength;
const uint8_t * pVariableHeader = NULL;
assert( pSuback != NULL );
@@ -964,8 +964,8 @@ static MQTTStatus_t deserializeSuback( const MQTTPacketInfo_t * pSuback,
LogDebug( ( "Packet identifier %hu.", *pPacketIdentifier ) );
- status = readSubackStatus( remainingLength - sizeof( uint16_t ),
- pVariableHeader + sizeof( uint16_t ) );
+ status = readSubackStatus( remainingLength - sizeof( uint16_t ),
+ pVariableHeader + sizeof( uint16_t ) );
}
return status;
@@ -984,8 +984,8 @@ static MQTTStatus_t validateSubscriptionSerializeParams( const MQTTSubscribeInfo
/* The serialized packet size = First byte
* + length of encoded size of remaining length
* + remaining length. */
- size_t packetSize = 1U + remainingLengthEncodedSize( remainingLength )
- + remainingLength;
+ size_t packetSize = 1U + remainingLengthEncodedSize( remainingLength )
+ + remainingLength;
/* Validate all the parameters. */
if( ( pBuffer == NULL ) || ( pSubscriptionList == NULL ) )
@@ -1028,7 +1028,7 @@ static MQTTStatus_t deserializePublish( const MQTTPacketInfo_t * pIncomingPacket
uint16_t * pPacketId,
MQTTPublishInfo_t * pPublishInfo )
{
- MQTTStatus_t status = MQTTSuccess;
+ MQTTStatus_t status = MQTTSuccess;
const uint8_t * pVariableHeader, * pPacketIdentifierHigh;
assert( pIncomingPacket != NULL );
@@ -1036,7 +1036,7 @@ static MQTTStatus_t deserializePublish( const MQTTPacketInfo_t * pIncomingPacket
assert( pPublishInfo != NULL );
pVariableHeader = pIncomingPacket->pRemainingData;
/* The flags are the lower 4 bits of the first byte in PUBLISH. */
- status = processPublishFlags( ( pIncomingPacket->type & 0x0FU ), pPublishInfo );
+ status = processPublishFlags( ( pIncomingPacket->type & 0x0FU ), pPublishInfo );
if( status == MQTTSuccess )
{
@@ -1058,9 +1058,9 @@ static MQTTStatus_t deserializePublish( const MQTTPacketInfo_t * pIncomingPacket
/* Sanity checks for topic name length and "Remaining length". The remaining
* length must be at least as large as the variable length header. */
- status = checkPublishRemainingLength( pIncomingPacket->remainingLength,
- pPublishInfo->qos,
- pPublishInfo->topicNameLength + sizeof( uint16_t ) );
+ status = checkPublishRemainingLength( pIncomingPacket->remainingLength,
+ pPublishInfo->qos,
+ pPublishInfo->topicNameLength + sizeof( uint16_t ) );
}
if( status == MQTTSuccess )
@@ -1074,7 +1074,7 @@ static MQTTStatus_t deserializePublish( const MQTTPacketInfo_t * pIncomingPacket
/* Extract the packet identifier for QoS 1 or 2 PUBLISH packets. Packet
* identifier starts immediately after the topic name. */
- pPacketIdentifierHigh = ( const uint8_t * ) ( pPublishInfo->pTopicName + pPublishInfo->topicNameLength );
+ pPacketIdentifierHigh = ( const uint8_t * ) ( pPublishInfo->pTopicName + pPublishInfo->topicNameLength );
if( pPublishInfo->qos > MQTTQoS0 )
{
@@ -1097,12 +1097,12 @@ static MQTTStatus_t deserializePublish( const MQTTPacketInfo_t * pIncomingPacket
if( pPublishInfo->qos == MQTTQoS0 )
{
pPublishInfo->payloadLength = ( pIncomingPacket->remainingLength - pPublishInfo->topicNameLength - sizeof( uint16_t ) );
- pPublishInfo->pPayload = pPacketIdentifierHigh;
+ pPublishInfo->pPayload = pPacketIdentifierHigh;
}
else
{
pPublishInfo->payloadLength = ( pIncomingPacket->remainingLength - pPublishInfo->topicNameLength - 2U * sizeof( uint16_t ) );
- pPublishInfo->pPayload = pPacketIdentifierHigh + sizeof( uint16_t );
+ pPublishInfo->pPayload = pPacketIdentifierHigh + sizeof( uint16_t );
}
LogDebug( ( "Payload length %hu.", pPublishInfo->payloadLength ) );
@@ -1173,28 +1173,28 @@ static void serializeConnectPacket( const MQTTConnectInfo_t * pConnectInfo,
size_t remainingLength,
const MQTTFixedBuffer_t * pBuffer )
{
- uint8_t connectFlags = 0U;
- uint8_t * pIndex = NULL;
+ uint8_t connectFlags = 0U;
+ uint8_t * pIndex = NULL;
assert( pConnectInfo != NULL );
assert( pBuffer != NULL );
- pIndex = pBuffer->pBuffer;
+ pIndex = pBuffer->pBuffer;
/* The first byte in the CONNECT packet is the control packet type. */
- *pIndex = MQTT_PACKET_TYPE_CONNECT;
+ *pIndex = MQTT_PACKET_TYPE_CONNECT;
pIndex++;
/* The remaining length of the CONNECT packet is encoded starting from the
* second byte. The remaining length does not include the length of the fixed
* header or the encoding of the remaining length. */
- pIndex = encodeRemainingLength( pIndex, remainingLength );
+ pIndex = encodeRemainingLength( pIndex, remainingLength );
/* The string "MQTT" is placed at the beginning of the CONNECT packet's variable
* header. This string is 4 bytes long. */
- pIndex = encodeString( pIndex, "MQTT", 4 );
+ pIndex = encodeString( pIndex, "MQTT", 4 );
/* The MQTT protocol version is the second field of the variable header. */
- *pIndex = MQTT_VERSION_3_1_1;
+ *pIndex = MQTT_VERSION_3_1_1;
pIndex++;
/* Set the clean session flag if needed. */
@@ -1239,18 +1239,18 @@ static void serializeConnectPacket( const MQTTConnectInfo_t * pConnectInfo,
}
}
- *pIndex = connectFlags;
+ *pIndex = connectFlags;
pIndex++;
/* Write the 2 bytes of the keep alive interval into the CONNECT packet. */
- *pIndex = UINT16_HIGH_BYTE( pConnectInfo->keepAliveSeconds );
+ *pIndex = UINT16_HIGH_BYTE( pConnectInfo->keepAliveSeconds );
*( pIndex + 1 ) = UINT16_LOW_BYTE( pConnectInfo->keepAliveSeconds );
- pIndex += 2;
+ pIndex += 2;
/* Write the client identifier into the CONNECT packet. */
- pIndex = encodeString( pIndex,
- pConnectInfo->pClientIdentifier,
- pConnectInfo->clientIdentifierLength );
+ pIndex = encodeString( pIndex,
+ pConnectInfo->pClientIdentifier,
+ pConnectInfo->clientIdentifierLength );
/* Write the will topic name and message into the CONNECT packet if provided. */
if( pWillInfo != NULL )
@@ -1291,11 +1291,11 @@ MQTTStatus_t MQTT_GetConnectPacketSize( const MQTTConnectInfo_t * pConnectInfo,
size_t * pRemainingLength,
size_t * pPacketSize )
{
- MQTTStatus_t status = MQTTSuccess;
- size_t remainingLength;
+ MQTTStatus_t status = MQTTSuccess;
+ size_t remainingLength;
/* The CONNECT packet will always include a 10-byte variable header. */
- size_t connectPacketSize = MQTT_PACKET_CONNECT_HEADER_SIZE;
+ size_t connectPacketSize = MQTT_PACKET_CONNECT_HEADER_SIZE;
/* Validate arguments. */
if( ( pConnectInfo == NULL ) || ( pRemainingLength == NULL ) ||
@@ -1338,7 +1338,7 @@ MQTTStatus_t MQTT_GetConnectPacketSize( const MQTTConnectInfo_t * pConnectInfo,
/* At this point, the "Remaining Length" field of the MQTT CONNECT packet has
* been calculated. */
- remainingLength = connectPacketSize;
+ remainingLength = connectPacketSize;
/* Calculate the full size of the MQTT CONNECT packet by adding the size of
* the "Remaining Length" field plus 1 byte for the "Packet Type" field. */
@@ -1352,7 +1352,7 @@ MQTTStatus_t MQTT_GetConnectPacketSize( const MQTTConnectInfo_t * pConnectInfo,
else
{
*pRemainingLength = remainingLength;
- *pPacketSize = connectPacketSize;
+ *pPacketSize = connectPacketSize;
}
LogDebug( ( "CONNECT packet remaining length=%lu and packet size=%lu.",
@@ -1370,10 +1370,10 @@ MQTTStatus_t MQTT_SerializeConnect( const MQTTConnectInfo_t * pConnectInfo,
size_t remainingLength,
const MQTTFixedBuffer_t * pBuffer )
{
- MQTTStatus_t status = MQTTSuccess;
+ MQTTStatus_t status = MQTTSuccess;
/* Calculate CONNECT packet size. */
- size_t connectPacketSize = remainingLength + remainingLengthEncodedSize( remainingLength ) + 1U;
+ size_t connectPacketSize = remainingLength + remainingLengthEncodedSize( remainingLength ) + 1U;
/* Validate arguments. */
if( ( pConnectInfo == NULL ) || ( pBuffer == NULL ) )
@@ -1462,8 +1462,8 @@ MQTTStatus_t MQTT_SerializeSubscribe( const MQTTSubscribeInfo_t * pSubscriptionL
size_t remainingLength,
const MQTTFixedBuffer_t * pBuffer )
{
- size_t i = 0;
- uint8_t * pIndex = NULL;
+ size_t i = 0;
+ uint8_t * pIndex = NULL;
/* Validate all the parameters. */
MQTTStatus_t status =
@@ -1475,26 +1475,26 @@ MQTTStatus_t MQTT_SerializeSubscribe( const MQTTSubscribeInfo_t * pSubscriptionL
if( status == MQTTSuccess )
{
- pIndex = pBuffer->pBuffer;
+ pIndex = pBuffer->pBuffer;
/* The first byte in SUBSCRIBE is the packet type. */
- *pIndex = MQTT_PACKET_TYPE_SUBSCRIBE;
+ *pIndex = MQTT_PACKET_TYPE_SUBSCRIBE;
pIndex++;
/* Encode the "Remaining length" starting from the second byte. */
- pIndex = encodeRemainingLength( pIndex, remainingLength );
+ pIndex = encodeRemainingLength( pIndex, remainingLength );
/* Place the packet identifier into the SUBSCRIBE packet. */
- *pIndex = UINT16_HIGH_BYTE( packetId );
+ *pIndex = UINT16_HIGH_BYTE( packetId );
*( pIndex + 1 ) = UINT16_LOW_BYTE( packetId );
- pIndex += 2;
+ pIndex += 2;
/* Serialize each subscription topic filter and QoS. */
for( i = 0; i < subscriptionCount; i++ )
{
- pIndex = encodeString( pIndex,
- pSubscriptionList[ i ].pTopicFilter,
- pSubscriptionList[ i ].topicFilterLength );
+ pIndex = encodeString( pIndex,
+ pSubscriptionList[ i ].pTopicFilter,
+ pSubscriptionList[ i ].topicFilterLength );
/* Place the QoS in the SUBSCRIBE packet. */
*pIndex = ( uint8_t ) ( pSubscriptionList[ i ].qos );
@@ -1562,8 +1562,8 @@ MQTTStatus_t MQTT_SerializeUnsubscribe( const MQTTSubscribeInfo_t * pSubscriptio
const MQTTFixedBuffer_t * pBuffer )
{
MQTTStatus_t status = MQTTSuccess;
- size_t i = 0;
- uint8_t * pIndex = NULL;
+ size_t i = 0;
+ uint8_t * pIndex = NULL;
/* Validate all the parameters. */
status = validateSubscriptionSerializeParams( pSubscriptionList,
@@ -1575,19 +1575,19 @@ MQTTStatus_t MQTT_SerializeUnsubscribe( const MQTTSubscribeInfo_t * pSubscriptio
if( status == MQTTSuccess )
{
/* Get the start of the buffer to the iterator variable. */
- pIndex = pBuffer->pBuffer;
+ pIndex = pBuffer->pBuffer;
/* The first byte in UNSUBSCRIBE is the packet type. */
- *pIndex = MQTT_PACKET_TYPE_UNSUBSCRIBE;
+ *pIndex = MQTT_PACKET_TYPE_UNSUBSCRIBE;
pIndex++;
/* Encode the "Remaining length" starting from the second byte. */
- pIndex = encodeRemainingLength( pIndex, remainingLength );
+ pIndex = encodeRemainingLength( pIndex, remainingLength );
/* Place the packet identifier into the UNSUBSCRIBE packet. */
- *pIndex = UINT16_HIGH_BYTE( packetId );
+ *pIndex = UINT16_HIGH_BYTE( packetId );
*( pIndex + 1 ) = UINT16_LOW_BYTE( packetId );
- pIndex += 2;
+ pIndex += 2;
/* Serialize each subscription topic filter. */
for( i = 0; i < subscriptionCount; i++ )
@@ -1657,8 +1657,8 @@ MQTTStatus_t MQTT_SerializePublish( const MQTTPublishInfo_t * pPublishInfo,
/* Length of serialized packet = First byte
* + Length of encoded remaining length
* + Remaining length. */
- size_t packetSize = 1U + remainingLengthEncodedSize( remainingLength )
- + remainingLength;
+ size_t packetSize = 1U + remainingLengthEncodedSize( remainingLength )
+ + remainingLength;
if( ( pBuffer == NULL ) || ( pPublishInfo == NULL ) )
{
@@ -1719,8 +1719,8 @@ MQTTStatus_t MQTT_SerializePublishHeader( const MQTTPublishInfo_t * pPublishInfo
* - Payload Length.
* Payload length will be subtracted after verifying pPublishInfo parameter.
*/
- size_t packetSize = 1U + remainingLengthEncodedSize( remainingLength )
- + remainingLength;
+ size_t packetSize = 1U + remainingLengthEncodedSize( remainingLength )
+ + remainingLength;
if( ( pBuffer == NULL ) || ( pPublishInfo == NULL ) ||
( pHeaderSize == NULL ) )
@@ -1814,7 +1814,7 @@ MQTTStatus_t MQTT_SerializeAck( const MQTTFixedBuffer_t * pBuffer,
default:
LogError( ( "Packet type is not a publish ACK: Packet type=%02x",
packetType ) );
- status = MQTTBadParameter;
+ status = MQTTBadParameter;
break;
}
}
@@ -2039,8 +2039,8 @@ MQTTStatus_t MQTT_GetIncomingPacketTypeAndLength( MQTTTransportRecvFunc_t readFu
NetworkContext_t networkContext,
MQTTPacketInfo_t * pIncomingPacket )
{
- MQTTStatus_t status = MQTTSuccess;
- int32_t bytesReceived = 0;
+ MQTTStatus_t status = MQTTSuccess;
+ int32_t bytesReceived = 0;
if( pIncomingPacket == NULL )
{
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_state.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_state.c
index 8afd93050..1f94e5fba 100644
--- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_state.c
+++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta2/c_sdk/standard/mqtt/src/mqtt_state.c
@@ -430,7 +430,7 @@ static size_t findInRecord( const MQTTPubAckInfo_t * records,
{
if( records[ index ].packetId == packetId )
{
- *pQos = records[ index ].qos;
+ *pQos = records[ index ].qos;
*pCurrentState = records[ index ].publishState;
break;
}
@@ -445,7 +445,7 @@ static size_t findInRecord( const MQTTPubAckInfo_t * records,
static void compactRecords( MQTTPubAckInfo_t * records,
size_t recordCount )
{
- size_t index = 0;
+ size_t index = 0;
size_t emptyIndex = MQTT_STATE_ARRAY_MAX_COUNT;
assert( records != NULL );
@@ -466,12 +466,12 @@ static void compactRecords( MQTTPubAckInfo_t * records,
if( emptyIndex != MQTT_STATE_ARRAY_MAX_COUNT )
{
/* Copy over the contents at non empty index to empty index. */
- records[ emptyIndex ].packetId = records[ index ].packetId;
- records[ emptyIndex ].qos = records[ index ].qos;
+ records[ emptyIndex ].packetId = records[ index ].packetId;
+ records[ emptyIndex ].qos = records[ index ].qos;
records[ emptyIndex ].publishState = records[ index ].publishState;
/* Mark the record at current non empty index as invalid. */
- records[ index ].packetId = MQTT_PACKET_ID_INVALID;
+ records[ index ].packetId = MQTT_PACKET_ID_INVALID;
/* Advance the emptyIndex. */
emptyIndex++;
@@ -488,10 +488,10 @@ static MQTTStatus_t addRecord( MQTTPubAckInfo_t * records,
MQTTQoS_t qos,
MQTTPublishState_t publishState )
{
- MQTTStatus_t status = MQTTNoMemory;
- int32_t index = 0;
- size_t availableIndex = recordCount;
- bool validEntryFound = false;
+ MQTTStatus_t status = MQTTNoMemory;
+ int32_t index = 0;
+ size_t availableIndex = recordCount;
+ bool validEntryFound = false;
assert( packetId != MQTT_PACKET_ID_INVALID );
assert( qos != MQTTQoS0 );
@@ -529,7 +529,7 @@ static MQTTStatus_t addRecord( MQTTPubAckInfo_t * records,
packetId,
index ) );
- status = MQTTStateCollision;
+ status = MQTTStateCollision;
availableIndex = recordCount;
break;
}
@@ -538,10 +538,10 @@ static MQTTStatus_t addRecord( MQTTPubAckInfo_t * records,
if( availableIndex < recordCount )
{
- records[ availableIndex ].packetId = packetId;
- records[ availableIndex ].qos = qos;
+ records[ availableIndex ].packetId = packetId;
+ records[ availableIndex ].qos = qos;
records[ availableIndex ].publishState = publishState;
- status = MQTTSuccess;
+ status = MQTTSuccess;
}
return status;
@@ -573,10 +573,10 @@ static uint16_t stateSelect( const MQTTContext_t * pMqttContext,
uint16_t searchStates,
MQTTStateCursor_t * pCursor )
{
- uint16_t packetId = MQTT_PACKET_ID_INVALID;
- uint16_t outgoingStates = 0U;
+ uint16_t packetId = MQTT_PACKET_ID_INVALID;
+ uint16_t outgoingStates = 0U;
const MQTTPubAckInfo_t * records = NULL;
- bool stateCheck = false;
+ bool stateCheck = false;
assert( pMqttContext != NULL );
assert( searchStates != 0U );
@@ -621,12 +621,12 @@ MQTTPublishState_t MQTT_CalculateStateAck( MQTTPubAckType_t packetType,
{
MQTTPublishState_t calculatedState = MQTTStateNull;
/* There are more QoS2 cases than QoS1, so initialize to that. */
- bool qosValid = ( qos == MQTTQoS2 ) ? true : false;
+ bool qosValid = ( qos == MQTTQoS2 ) ? true : false;
switch( packetType )
{
case MQTTPuback:
- qosValid = ( qos == MQTTQoS1 ) ? true : false;
+ qosValid = ( qos == MQTTQoS1 ) ? true : false;
calculatedState = MQTTPublishDone;
break;
@@ -670,9 +670,9 @@ static MQTTStatus_t updateStateAck( MQTTPubAckInfo_t * records,
MQTTPublishState_t currentState,
MQTTPublishState_t newState )
{
- MQTTStatus_t status = MQTTIllegalState;
- bool shouldDeleteRecord = false;
- bool isTransitionValid = false;
+ MQTTStatus_t status = MQTTIllegalState;
+ bool shouldDeleteRecord = false;
+ bool isTransitionValid = false;
assert( records != NULL );
@@ -681,7 +681,7 @@ static MQTTStatus_t updateStateAck( MQTTPubAckInfo_t * records,
* record is deleted and added back to the end of the records to maintain
* ordering for PUBRELs. */
shouldDeleteRecord = ( ( newState == MQTTPublishDone ) || ( newState == MQTTPubRelSend ) ) ? true : false;
- isTransitionValid = validateTransitionAck( currentState, newState );
+ isTransitionValid = validateTransitionAck( currentState, newState );
if( isTransitionValid == true )
{
@@ -732,8 +732,8 @@ static MQTTStatus_t updateStatePublish( MQTTContext_t * pMqttContext,
MQTTPublishState_t currentState,
MQTTPublishState_t newState )
{
- MQTTStatus_t status = MQTTSuccess;
- bool isTransitionValid = false;
+ MQTTStatus_t status = MQTTSuccess;
+ bool isTransitionValid = false;
assert( pMqttContext != NULL );
assert( packetId != MQTT_PACKET_ID_INVALID );
@@ -843,11 +843,11 @@ MQTTStatus_t MQTT_UpdateStatePublish( MQTTContext_t * pMqttContext,
MQTTQoS_t qos,
MQTTPublishState_t * pNewState )
{
- MQTTPublishState_t newState = MQTTStateNull;
+ MQTTPublishState_t newState = MQTTStateNull;
MQTTPublishState_t currentState = MQTTStateNull;
- MQTTStatus_t mqttStatus = MQTTSuccess;
- size_t recordIndex = MQTT_STATE_ARRAY_MAX_COUNT;
- MQTTQoS_t foundQoS = MQTTQoS0;
+ MQTTStatus_t mqttStatus = MQTTSuccess;
+ size_t recordIndex = MQTT_STATE_ARRAY_MAX_COUNT;
+ MQTTQoS_t foundQoS = MQTTQoS0;
if( ( pMqttContext == NULL ) || ( pNewState == NULL ) )
{
@@ -889,7 +889,7 @@ MQTTStatus_t MQTT_UpdateStatePublish( MQTTContext_t * pMqttContext,
if( ( qos != MQTTQoS0 ) && ( mqttStatus == MQTTSuccess ) )
{
- newState = MQTT_CalculateStatePublish( opType, qos );
+ newState = MQTT_CalculateStatePublish( opType, qos );
/* Validate state transition and update state records. */
mqttStatus = updateStatePublish( pMqttContext,
recordIndex,
@@ -917,13 +917,13 @@ MQTTStatus_t MQTT_UpdateStateAck( MQTTContext_t * pMqttContext,
MQTTStateOperation_t opType,
MQTTPublishState_t * pNewState )
{
- MQTTPublishState_t newState = MQTTStateNull;
- MQTTPublishState_t currentState = MQTTStateNull;
- bool isOutgoingPublish = isPublishOutgoing( packetType, opType );
- MQTTQoS_t qos = MQTTQoS0;
- size_t recordIndex = MQTT_STATE_ARRAY_MAX_COUNT;
- MQTTPubAckInfo_t * records = NULL;
- MQTTStatus_t status = MQTTBadParameter;
+ MQTTPublishState_t newState = MQTTStateNull;
+ MQTTPublishState_t currentState = MQTTStateNull;
+ bool isOutgoingPublish = isPublishOutgoing( packetType, opType );
+ MQTTQoS_t qos = MQTTQoS0;
+ size_t recordIndex = MQTT_STATE_ARRAY_MAX_COUNT;
+ MQTTPubAckInfo_t * records = NULL;
+ MQTTStatus_t status = MQTTBadParameter;
if( ( pMqttContext == NULL ) || ( pNewState == NULL ) )
{
@@ -954,7 +954,7 @@ MQTTStatus_t MQTT_UpdateStateAck( MQTTContext_t * pMqttContext,
newState = MQTT_CalculateStateAck( packetType, opType, qos );
/* Validate state transition and update state record. */
- status = updateStateAck( records, recordIndex, packetId, currentState, newState );
+ status = updateStateAck( records, recordIndex, packetId, currentState, newState );
/* Update the output parameter. */
if( status == MQTTSuccess )
@@ -976,7 +976,7 @@ uint16_t MQTT_PubrelToResend( const MQTTContext_t * pMqttContext,
MQTTStateCursor_t * pCursor,
MQTTPublishState_t * pState )
{
- uint16_t packetId = MQTT_PACKET_ID_INVALID;
+ uint16_t packetId = MQTT_PACKET_ID_INVALID;
uint16_t searchStates = 0U;
/* Validate arguments. */
@@ -1011,7 +1011,7 @@ uint16_t MQTT_PubrelToResend( const MQTTContext_t * pMqttContext,
uint16_t MQTT_PublishToResend( const MQTTContext_t * pMqttContext,
MQTTStateCursor_t * pCursor )
{
- uint16_t packetId = MQTT_PACKET_ID_INVALID;
+ uint16_t packetId = MQTT_PACKET_ID_INVALID;
uint16_t searchStates = 0U;
/* Validate arguments. */
diff --git a/tools/git/hooks/src/pre_commit.py b/tools/git/hooks/src/pre_commit.py
new file mode 100644
index 000000000..a2e70b0c9
--- /dev/null
+++ b/tools/git/hooks/src/pre_commit.py
@@ -0,0 +1,194 @@
+#!/usr/bin/python
+
+import os.path
+import re
+import subprocess
+import sys
+import tempfile
+import argparse
+
+def main(): # pragma: no cover
+ args = parse_args()
+
+ if args['uncrustify_all_files']:
+ file_names = get_all_files()
+ files_to_check = filter_checkable_files(file_names)
+ check_uncrustify(files_to_check, uncrustify=True)
+ elif args['uncrustify']:
+ file_names = args['files']
+ if not file_names:
+ file_names = get_modified_files()
+
+ files_to_check = filter_checkable_files(file_names)
+ check_uncrustify(files_to_check, uncrustify=True)
+ else:
+ failed_files = commit_is_ready(args['files'])
+ if failed_files:
+ print("\nYou may run the following command to repeat the check: python tools/git/hooks/src/pre_commit.py")
+ print("\nYou may run the following command to uncrustify staged files: python tools/git/hooks/src/pre_commit.py --uncrustify")
+ print("\nYou may run the following command to uncrustify a list of files: python tools/git/hooks/src/pre_commit.py --uncrustify <files>")
+ print("\nYou may run the following command to uncrustify all files: python tools/git/hooks/src/pre_commit.py --uncrustify-all-files")
+ print("Hint: You may need to be at the repository's root directory.")
+ print('Aborting Commit.')
+ sys.exit(1)
+ sys.exit(0)
+
+
+def parse_args():
+ parser = argparse.ArgumentParser(description='pre-commit checks')
+
+ parser.add_argument('--uncrustify', default = False, action='store_true', help='Uncrustify modified files.')
+ parser.add_argument('--uncrustify-all-files', default = False, action='store_true', help='Uncrustify all files.')
+ parser.add_argument('files', nargs='*', help='List of files to check.')
+
+ args = parser.parse_args()
+ return vars(args)
+
+
+def commit_is_ready(file_names=None):
+ """Return False if not ready. Return True if commit is ready"""
+ if not file_names:
+ file_names = get_modified_files()
+
+ files_to_check = filter_checkable_files(file_names)
+
+ checks = [
+ check_secrets,
+ check_uncrustify,
+ check_whitespace,
+ ]
+
+ # If there is no file to check, return. This can happen if all the modified
+ # files are ignored as defined in is_ignored_file_pattern.
+ if files_to_check:
+ for check in checks:
+ failed_files = check(files_to_check)
+ if failed_files:
+ return failed_files
+ return []
+
+
+def filter_checkable_files(file_names):
+ files_to_check = [f for f in file_names if file_exists(f) and file_is_checkable(f)]
+ return files_to_check
+
+
+def get_all_files():
+ file_names = []
+ for root, dirs, files in os.walk("."):
+ for f in files:
+ file_names.append(os.path.join(root, f))
+ return file_names
+
+
+def get_modified_files():
+ changed_files = subprocess.check_output(
+ "git diff-index --name-only --cached HEAD", shell=True)
+ if type(changed_files) is not str:
+ changed_files = changed_files.decode('utf-8')
+ file_names = changed_files.split('\n')
+ return file_names
+
+
+def file_is_checkable(file_name):
+ return (
+ is_source_file(file_name)
+ and is_checked_file_pattern(file_name)
+ and not is_ignored_file_pattern(file_name)
+ )
+
+
+def file_exists(file_name):
+ return os.path.isfile(file_name)
+
+
+def is_source_file(file_name):
+ if re.findall(r'\.[ch]$', file_name):
+ return True
+ return False
+
+
+def is_checked_file_pattern(file_name):
+ checked_patterns = [
+ r"FreeRTOS-Plus/",
+ ]
+ for checked_pattern in checked_patterns:
+ if re.findall(checked_pattern, file_name):
+ return True
+ return False
+
+
+def is_ignored_file_pattern(file_name):
+ ignored_patterns = [
+ "FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP",
+ "FreeRTOS-Plus/Source/http-parser",
+ "FreeRTOS-Plus/Source/jsmn",
+ "FreeRTOS-Plus/Source/mbedtls",
+ "FreeRTOS-Plus/Source/mbedtls-utils",
+ "FreeRTOS-Plus/Source/pkcs11",
+ "FreeRTOS-Plus/Source/tinycbor",
+ "FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace",
+ "FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/https/common/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/jobs/jobs_notify_next/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/pkcs11/pkcs11_mqtt_tls_mutual_auth/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/common/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/shadow/shadow_device_operations/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/ota/common/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/WinPCap",
+ "FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/WinPCap",
+ "tools",
+ ]
+ for ignored_pattern in ignored_patterns:
+ if re.findall(ignored_pattern, file_name):
+ return True
+ return False
+
+
+def check_secrets(changed_files):
+ if not changed_files:
+ return []
+ if subprocess.call("git secrets --scan " + " ".join(changed_files), shell=True):
+ return ['git_secrets']
+ return []
+
+
+def check_whitespace(changed_files):
+ """Return True if check failed. Return False if check passed"""
+ if subprocess.call("git diff-index --check --cached HEAD", shell=True):
+ return ['whitespace']
+ return []
+
+def check_uncrustify(changed_files, uncrustify=False):
+ """Return True if check failed. Return False if check passed"""
+ if "" == changed_files:
+ return False
+ failed_files = []
+ for changed_file in changed_files:
+ if subprocess.call(
+ (
+ "uncrustify --check -q -c tools/uncrustify.cfg " +
+ changed_file
+ ), shell=True
+ ):
+ failed_files.append(changed_file)
+
+ if failed_files and uncrustify:
+ run_uncrustify(changed_files)
+
+ return failed_files
+
+
+def run_uncrustify(changed_files):
+ """Run uncrustify to fix formatting in a set of files"""
+ for file in changed_files:
+ format_call = ( 'uncrustify -q -c tools/uncrustify.cfg -f {} -o {}'.format(file, file) )
+ subprocess.check_output(format_call, shell=True)
+
+
+if __name__ == "__main__": # pragma: no cover
+ main()
+
diff --git a/tools/uncrustify.cfg b/tools/uncrustify.cfg
new file mode 100644
index 000000000..bfd147d54
--- /dev/null
+++ b/tools/uncrustify.cfg
@@ -0,0 +1,167 @@
+# Uncrustify-0.67
+input_tab_size = 4 # unsigned number
+output_tab_size = 4 # unsigned number
+sp_arith = force # ignore/add/remove/force
+sp_assign = force # ignore/add/remove/force
+sp_assign_default = force # ignore/add/remove/force
+sp_before_assign = force # ignore/add/remove/force
+sp_after_assign = force # ignore/add/remove/force
+sp_enum_assign = force # ignore/add/remove/force
+sp_enum_before_assign = force # ignore/add/remove/force
+sp_enum_after_assign = force # ignore/add/remove/force
+sp_pp_stringify = add # ignore/add/remove/force
+sp_bool = force # ignore/add/remove/force
+sp_compare = force # ignore/add/remove/force
+sp_inside_paren = force # ignore/add/remove/force
+sp_paren_paren = force # ignore/add/remove/force
+sp_paren_brace = force # ignore/add/remove/force
+sp_before_ptr_star = force # ignore/add/remove/force
+sp_before_unnamed_ptr_star = force # ignore/add/remove/force
+sp_between_ptr_star = remove # ignore/add/remove/force
+sp_after_ptr_star = force # ignore/add/remove/force
+sp_before_byref = force # ignore/add/remove/force
+sp_after_byref = remove # ignore/add/remove/force
+sp_after_byref_func = remove # ignore/add/remove/force
+sp_before_angle = remove # ignore/add/remove/force
+sp_inside_angle = remove # ignore/add/remove/force
+sp_after_angle = force # ignore/add/remove/force
+sp_before_sparen = remove # ignore/add/remove/force
+sp_inside_sparen = force # ignore/add/remove/force
+sp_after_sparen = force # ignore/add/remove/force
+sp_sparen_brace = force # ignore/add/remove/force
+sp_before_semi_for = remove # ignore/add/remove/force
+sp_before_semi_for_empty = add # ignore/add/remove/force
+sp_after_semi_for_empty = force # ignore/add/remove/force
+sp_before_square = remove # ignore/add/remove/force
+sp_before_squares = remove # ignore/add/remove/force
+sp_inside_square = force # ignore/add/remove/force
+sp_after_comma = force # ignore/add/remove/force
+sp_after_cast = force # ignore/add/remove/force
+sp_inside_paren_cast = force # ignore/add/remove/force
+sp_sizeof_paren = remove # ignore/add/remove/force
+sp_inside_braces_enum = force # ignore/add/remove/force
+sp_inside_braces_struct = force # ignore/add/remove/force
+sp_inside_braces = force # ignore/add/remove/force
+sp_inside_braces_empty = remove # ignore/add/remove/force
+sp_type_func = force # ignore/add/remove/force
+sp_func_proto_paren = remove # ignore/add/remove/force
+sp_func_def_paren = remove # ignore/add/remove/force
+sp_inside_fparens = remove # ignore/add/remove/force
+sp_inside_fparen = force # ignore/add/remove/force
+sp_fparen_brace = add # ignore/add/remove/force
+sp_func_call_paren = remove # ignore/add/remove/force
+sp_func_class_paren = remove # ignore/add/remove/force
+sp_return_paren = remove # ignore/add/remove/force
+sp_attribute_paren = remove # ignore/add/remove/force
+sp_defined_paren = remove # ignore/add/remove/force
+sp_macro = force # ignore/add/remove/force
+sp_macro_func = force # ignore/add/remove/force
+sp_brace_typedef = force # ignore/add/remove/force
+sp_before_dc = remove # ignore/add/remove/force
+sp_after_dc = remove # ignore/add/remove/force
+sp_cond_colon = force # ignore/add/remove/force
+sp_cond_question = force # ignore/add/remove/force
+sp_case_label = force # ignore/add/remove/force
+sp_endif_cmt = force # ignore/add/remove/force
+sp_before_tr_emb_cmt = force # ignore/add/remove/force
+sp_num_before_tr_emb_cmt = 1 # unsigned number
+indent_columns = 4 # unsigned number
+indent_with_tabs = 0 # unsigned number
+indent_align_string = true # false/true
+indent_class = true # false/true
+indent_class_colon = true # false/true
+indent_member = 3 # unsigned number
+indent_switch_case = 4 # unsigned number
+indent_case_brace = 3 # number
+nl_assign_leave_one_liners = true # false/true
+nl_class_leave_one_liners = true # false/true
+nl_start_of_file = remove # ignore/add/remove/force
+nl_end_of_file = force # ignore/add/remove/force
+nl_end_of_file_min = 1 # unsigned number
+nl_assign_brace = add # ignore/add/remove/force
+nl_func_var_def_blk = 1 # unsigned number
+nl_fcall_brace = add # ignore/add/remove/force
+nl_enum_brace = force # ignore/add/remove/force
+nl_struct_brace = force # ignore/add/remove/force
+nl_union_brace = force # ignore/add/remove/force
+nl_if_brace = add # ignore/add/remove/force
+nl_brace_else = add # ignore/add/remove/force
+nl_else_brace = add # ignore/add/remove/force
+nl_getset_brace = force # ignore/add/remove/force
+nl_for_brace = add # ignore/add/remove/force
+nl_while_brace = add # ignore/add/remove/force
+nl_do_brace = add # ignore/add/remove/force
+nl_switch_brace = add # ignore/add/remove/force
+nl_multi_line_define = true # false/true
+nl_before_case = true # false/true
+nl_after_case = true # false/true
+nl_func_type_name = remove # ignore/add/remove/force
+nl_func_proto_type_name = remove # ignore/add/remove/force
+nl_func_paren = remove # ignore/add/remove/force
+nl_func_def_paren = remove # ignore/add/remove/force
+nl_func_decl_start = remove # ignore/add/remove/force
+nl_func_def_start = remove # ignore/add/remove/force
+nl_func_decl_args = add # ignore/add/remove/force
+nl_func_def_args = add # ignore/add/remove/force
+nl_func_decl_end = remove # ignore/add/remove/force
+nl_func_def_end = remove # ignore/add/remove/force
+nl_fdef_brace = add # ignore/add/remove/force
+nl_after_semicolon = true # false/true
+nl_after_brace_open = true # false/true
+nl_after_brace_close = true # false/true
+nl_squeeze_ifdef = true # false/true
+nl_before_if = force # ignore/add/remove/force
+nl_after_if = force # ignore/add/remove/force
+nl_before_for = force # ignore/add/remove/force
+nl_after_for = force # ignore/add/remove/force
+nl_before_while = force # ignore/add/remove/force
+nl_after_while = force # ignore/add/remove/force
+nl_before_switch = force # ignore/add/remove/force
+nl_after_switch = force # ignore/add/remove/force
+nl_before_do = force # ignore/add/remove/force
+nl_after_do = force # ignore/add/remove/force
+nl_max = 4 # unsigned number
+nl_after_func_proto_group = 1 # unsigned number
+nl_after_func_body_class = 2 # unsigned number
+nl_before_block_comment = 2 # unsigned number
+eat_blanks_after_open_brace = true # false/true
+eat_blanks_before_close_brace = true # false/true
+nl_after_return = true # false/true
+pos_bool = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force
+align_var_def_amp_style = 1 # unsigned number
+align_var_def_thresh = 16 # unsigned number
+align_assign_thresh = 12 # unsigned number
+align_struct_init_span = 3 # unsigned number
+align_typedef_gap = 3 # unsigned number
+align_typedef_span = 5 # unsigned number
+align_typedef_star_style = 1 # unsigned number
+align_typedef_amp_style = 1 # unsigned number
+align_right_cmt_span = 3 # unsigned number
+align_nl_cont = true # false/true
+align_pp_define_gap = 4 # unsigned number
+align_pp_define_span = 3 # unsigned number
+cmt_cpp_to_c = true # false/true
+cmt_star_cont = true # false/true
+mod_full_brace_do = add # ignore/add/remove/force
+mod_full_brace_for = add # ignore/add/remove/force
+mod_full_brace_if = add # ignore/add/remove/force
+mod_full_brace_while = add # ignore/add/remove/force
+mod_full_paren_if_bool = true # false/true
+mod_remove_extra_semicolon = true # false/true
+mod_add_long_ifdef_endif_comment = 10 # unsigned number
+mod_add_long_ifdef_else_comment = 10 # unsigned number
+mod_case_brace = remove # ignore/add/remove/force
+mod_remove_empty_return = true # false/true
+pp_indent = force # ignore/add/remove/force
+pp_indent_at_level = true # false/true
+pp_indent_count = 4 # unsigned number
+pp_space = remove # ignore/add/remove/force
+pp_if_indent_code = true # false/true
+
+align_var_def_span = 4 # align variable name and type
+align_assign_span = 80
+align_var_def_gap = 1 # space between type and variable name
+align_assign_thresh = 40 # align up to a certain size
+
+
+# option(s) with 'not default' value: 158