1 /*
2  * FreeRTOS V202212.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * https://www.FreeRTOS.org
23  * https://github.com/FreeRTOS
24  *
25  */
26 
27 #ifndef DEMO_CONFIG_H
28 #define DEMO_CONFIG_H
29 
30 /**************************************************/
31 /******* DO NOT CHANGE the following order ********/
32 /**************************************************/
33 
34 /* Include logging header files and define logging macros in the following order:
35  * 1. Include the header file "logging_levels.h".
36  * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on
37  * the logging configuration for DEMO.
38  * 3. Include the header file "logging_stack.h", if logging is enabled for DEMO.
39  */
40 
41 #include "logging_levels.h"
42 
43 /* Logging configuration for the Demo. */
44 #ifndef LIBRARY_LOG_NAME
45     #define LIBRARY_LOG_NAME    "FLEET_PROVISIONING_DEMO"
46 #endif
47 
48 #ifndef LIBRARY_LOG_LEVEL
49     #define LIBRARY_LOG_LEVEL    LOG_INFO
50 #endif
51 
52 /* Prototype for the function used to print to console on Windows simulator
53  * of FreeRTOS.
54  * The function prints to the console before the network is connected;
55  * then a UDP port after the network has connected. */
56 extern void vLoggingPrintf( const char * pcFormatString,
57                             ... );
58 
59 /* Map the SdkLog macro to the logging function to enable logging
60  * on Windows simulator. */
61 #ifndef SdkLog
62     #define SdkLog( message )    vLoggingPrintf message
63 #endif
64 
65 #include "logging_stack.h"
66 
67 /************ End of logging configuration ****************/
68 
69 /**
70  * @brief The unique ID used by the demo to differentiate instances.
71  *
72  *!!! Please note a #defined constant is used for convenience of demonstration
73  *!!! only.  Production devices can use something unique to the device that can
74  *!!! be read by software, such as a production serial number, instead of a
75  *!!! hard coded constant.
76  */
77 #define democonfigFP_DEMO_ID    "FPDemoID"__TIME__
78 
79 /**
80  * @brief The MQTT client identifier used in this example.  Each client identifier
81  * must be unique so edit as required to ensure no two clients connecting to the
82  * same broker use the same client identifier.
83  *
84  * @note Appending __TIME__ to the client id string will reduce the possibility of a
85  * client id collision in the broker. Note that the appended time is the compilation
86  * time. This client id can cause collision, if more than one instance of the same
87  * binary is used at the same time to connect to the broker.
88  */
89 #ifndef democonfigCLIENT_IDENTIFIER
90     #define democonfigCLIENT_IDENTIFIER    "client"democonfigFP_DEMO_ID
91 #endif
92 
93 /**
94  * @brief Details of the MQTT broker to connect to.
95  *
96  * This is the Claim's Rest API Endpoint for AWS IoT.
97  *
98  * @note Your AWS IoT Core endpoint can be found in the AWS IoT console under
99  * Settings/Custom Endpoint, or using the describe-endpoint API.
100  *
101  * #define democonfigMQTT_BROKER_ENDPOINT     "...insert here..."
102  */
103 
104 /**
105  * @brief AWS IoT MQTT broker port number.
106  *
107  * In general, port 8883 is for secured MQTT connections.
108  *
109  * @note Port 443 requires use of the ALPN TLS extension with the ALPN protocol
110  * name. When using port 8883, ALPN is not required.
111  */
112 #define democonfigMQTT_BROKER_PORT    ( 8883 )
113 
114 /**
115  * @brief Server's root CA certificate.
116  *
117  * For AWS IoT MQTT broker, this certificate is used to identify the AWS IoT
118  * server and is publicly available. Refer to the AWS documentation available
119  * in the link below.
120  * https://docs.aws.amazon.com/iot/latest/developerguide/server-authentication.html#server-authentication-certs
121  *
122  * @note This certificate should be PEM-encoded.
123  *
124  * Must include the PEM header and footer:
125  * "-----BEGIN CERTIFICATE-----\n"\
126  * "...base64 data...\n"\
127  * "-----END CERTIFICATE-----\n"
128  *
129  * #define democonfigROOT_CA_PEM    "...insert here..."
130  */
131 
132 /**
133  * @brief Name of the provisioning template to use for the RegisterThing
134  * portion of the Fleet Provisioning workflow.
135  *
136  * For information about provisioning templates, see the following AWS documentation:
137  * https://docs.aws.amazon.com/iot/latest/developerguide/provision-template.html#fleet-provision-template
138  *
139  * The example template used for this demo is available in the
140  * example_demo_template.json file in the DemoSetup directory. In the example,
141  * replace <provisioned-thing-policy> with the policy provisioned devices
142  * should have.  The demo template uses Fn::Join to construct the Thing name by
143  * concatenating fp_demo_ and the serial number sent by the demo.
144  *
145  * @note The provisioning template MUST be created in AWS IoT before running the
146  * demo.
147  *
148  * @note If you followed the manual setup steps on https://freertos.org/iot-fleet-provisioning/demo.html,
149  * the provisioning template name is "FleetProvisioningDemoTemplate".
150  * However, if you used CloudFormation to set up the demo, the template name is "CF_FleetProvisioningDemoTemplate"
151  *
152  * #define democonfigPROVISIONING_TEMPLATE_NAME    "...insert here..."
153  */
154 
155 /**
156  * @brief Subject name to use when creating the certificate signing request (CSR)
157  * for provisioning the demo client with using the Fleet Provisioning
158  * CreateCertificateFromCsr APIs.
159  *
160  * This is passed to MbedTLS; see https://tls.mbed.org/api/x509__csr_8h.html#a954eae166b125cea2115b7db8c896e90
161  */
162 #ifndef democonfigCSR_SUBJECT_NAME
163     #define democonfigCSR_SUBJECT_NAME    "CN="democonfigFP_DEMO_ID
164 #endif
165 
166 /**
167  * @brief Set the stack size of the main demo task.
168  *
169  * In the Windows port, this stack only holds a structure. The actual
170  * stack is created by an operating system thread.
171  *
172  * @note This demo runs on WinSim and the minimal stack size is functional.
173  * However, if you are porting components of this demo to other platforms,
174  * the stack size may need to be increased to accommodate the size of the
175  * buffers used when generating new keys and certificates.
176  *
177  */
178 #define democonfigDEMO_STACKSIZE            configMINIMAL_STACK_SIZE
179 
180 /**
181  * @brief Size of the network buffer for MQTT packets. Must be large enough to
182  * hold the GetCertificateFromCsr response, which, among other things, includes
183  * a PEM encoded certificate.
184  */
185 #define democonfigNETWORK_BUFFER_SIZE       ( 2048U )
186 
187 /**
188  * @brief The name of the operating system that the application is running on.
189  * The current value is given as an example. Please update for your specific
190  * operating system.
191  */
192 #define democonfigOS_NAME                   "FreeRTOS"
193 
194 /**
195  * @brief The version of the operating system that the application is running
196  * on. The current value is given as an example. Please update for your specific
197  * operating system version.
198  */
199 #define democonfigOS_VERSION                tskKERNEL_VERSION_NUMBER
200 
201 /**
202  * @brief The name of the hardware platform the application is running on. The
203  * current value is given as an example. Please update for your specific
204  * hardware platform.
205  */
206 #define democonfigHARDWARE_PLATFORM_NAME    "WinSim"
207 
208 /**
209  * @brief The name of the MQTT library used and its version, following an "@"
210  * symbol.
211  */
212 #include "core_mqtt.h" /* Include coreMQTT header for MQTT_LIBRARY_VERSION macro. */
213 #define democonfigMQTT_LIB    "core-mqtt@"MQTT_LIBRARY_VERSION
214 
215 #endif /* DEMO_CONFIG_H */
216