-
Notifications
You must be signed in to change notification settings - Fork 29
/
ota_config.h
225 lines (190 loc) · 8.71 KB
/
ota_config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
* Lab-Project-coreMQTT-Agent 201206
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file ota_config.h
* @brief OTA user configurable settings.
*/
#ifndef OTA_CONFIG_H_
#define OTA_CONFIG_H_
#include "logging_levels.h"
/* define LOG_LEVEL here if you want to modify the logging level from the default */
#ifndef LOG_LEVEL
#define LOG_LEVEL LOG_INFO
#endif
#include "logging.h"
#include "test_param_config.h"
#include "test_execution_config.h"
/**
* @brief The version for the firmware which is running. OTA agent uses this
* version number to perform anti-rollback validation. The firmware version for the
* download image should be higher than the current version, otherwise the new image is
* rejected in self test phase.1
*/
#define TEST_AUTOMATION_INTEGRATION ( 0 )
/* Note: If TEST_AUTOMATION_INTEGRATION == 1 (in ota_config.h), settings below will be forcedly used
* in runtime. Please set to 0 or "" to skip them if you want to use the value in flash. */
#if ( TEST_AUTOMATION_INTEGRATION == 1 )
#if ( OTA_E2E_TEST_ENABLED == 1 )
#define otapalconfigCODE_SIGNING_CERTIFICATE ""
#define keyCLIENT_CERTIFICATE_PEM ""
#define keyCLIENT_PRIVATE_KEY_PEM ""
#define keyCA_ROOT_CERT_PEM ""
#elif ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 )
#define keyCLIENT_CERTIFICATE_PEM "" /* Use the certificate stored in secure element. */
#define keyCLIENT_PRIVATE_KEY_PEM "" /* Use the key stored in secure element. */
#define keyCA_ROOT_CERT_PEM ECHO_SERVER_ROOT_CA
#elif ( OTA_PAL_TEST_ENABLED == 1 )
#define otapalconfigCODE_SIGNING_CERTIFICATE \
"-----BEGIN PUBLIC KEY-----\n" \
"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEyza/tGLVbVxhL41iYtC8D6tGEvAH\n" \
"u498gNtqDtPsKaoR3t5xQx+6zdWiCi32fgFT2vkeVAmX3pf/Gl8nIP48Zg==\n" \
"-----END PUBLIC KEY-----\n"
#endif /* ( OTA_E2E_TEST_ENABLED == 1 ) */
#endif /* if ( TEST_AUTOMATION_INTEGRATION == 1 ) */
#if !defined( otapalconfigCODE_SIGNING_CERTIFICATE )
#define otapalconfigCODE_SIGNING_CERTIFICATE ""
#endif /* !defined ( otapalconfigCODE_SIGNING_CERTIFICATE ) */
#if !defined( keyCLIENT_CERTIFICATE_PEM )
#define keyCLIENT_CERTIFICATE_PEM ""
#endif /* !defined ( keyCLIENT_CERTIFICATE_PEM ) */
#if !defined( keyCLIENT_PRIVATE_KEY_PEM )
#define keyCLIENT_PRIVATE_KEY_PEM ""
#endif /* !defined ( keyCLIENT_PRIVATE_KEY_PEM ) */
#if !defined( keyCA_ROOT_CERT_PEM )
#define keyCA_ROOT_CERT_PEM ""
#endif /* !defined ( keyCA_ROOT_CERT_PEM ) */
/**
* @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 11UL
/**
* @brief Size of the file data block message (excluding the header).
*
*/
#define otaconfigFILE_BLOCK_SIZE ( 1UL << otaconfigLOG2_FILE_BLOCK_SIZE )
/**
* @brief Milliseconds to wait for the self test phase to succeed before we force reset.
*/
#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 60000U
/**
* @brief Milliseconds to wait before requesting data blocks from the OTA service if nothing is happening.
*
* 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
/**
* @brief The maximum allowed length of the thing name used by the OTA agent.
*
* AWS IoT requires Thing names to be unique for each device that connects to the broker.
* Likewise, the OTA agent requires the developer to construct and pass in the Thing name when
* 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 128U
/**
* @brief The maximum number of data blocks requested from OTA streaming service.
*
* This configuration parameter is sent with data requests and represents the maximum number of
* data blocks the service will send in response. The maximum limit for this must be calculated
* from the maximum data response limit (128 KB from service) divided by the block size.
* For example if block size is set as 1 KB then the maximum number of data blocks that we can
* request is 128/1 = 128 blocks. Configure this parameter to this maximum limit or lower based on
* how many data blocks response is expected for each data requests.
* Please note that this must be set larger than zero.
*
*/
#define otaconfigMAX_NUM_BLOCKS_REQUEST 2U
/**
* @brief The maximum number of requests allowed to send without a response before we abort.
*
* This configuration parameter sets the maximum number of times the requests are made over
* the selected communication channel before aborting and returning error.
*
*/
#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U
/**
* @brief The number of data buffers reserved by the OTA agent.
*
* 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 ( otaconfigMAX_NUM_BLOCKS_REQUEST + 1 )
/**
* @brief How frequently the device will report its OTA progress to the cloud.
*
* Device will update the job status with the number of blocks it has received every certain
* number of blocks it receives. For example, 25 means device will update job status every 25 blocks
* it receives.
*/
#define otaconfigOTA_UPDATE_STATUS_FREQUENCY 25U
/**
* @brief Allow update to same or lower version.
*
* Set this to 1 to allow downgrade or same version update.This configurations parameter
* disables version check and allows update to a same or lower version.This is provided for
* testing purpose and it is recommended to always update to higher version and keep this
* configuration disabled.
*/
#ifdef TFM_PSA_API
/**
* Use PSA PAL version validation of secure/non secure image instead of OTA Agent library version validation.
*/
#define otaconfigAllowDowngrade 1U
#else
#define otaconfigAllowDowngrade 0U
#endif
/**
* @brief The protocol selected for OTA control operations.
*
* This configurations parameter sets the default protocol for all the OTA control
* operations like requesting OTA job, updating the job status etc.
*
* Note - Only MQTT is supported at this time for control operations.
*/
#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT )
/**
* @brief The protocol selected for OTA data operations.
*
* This configurations parameter sets the protocols selected for the data operations
* like requesting file blocks from the service.
*
* Note - Both MQTT and HTTP is supported for data transfer. This configuration parameter
* can be set to following -
* Enable data over MQTT - ( OTA_DATA_OVER_MQTT )
* 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 )
/**
* @brief The preferred protocol selected for OTA data operations.
*
* Primary data protocol will be the protocol used for downloading file if more than
* one protocol is selected while creating OTA job. Default primary data protocol is MQTT
* and following update here to switch to HTTP as primary.
*
* Note - use OTA_DATA_OVER_HTTP for HTTP as primary data protocol.
*/
#define configOTA_PRIMARY_DATA_PROTOCOL OTA_DATA_OVER_MQTT
#endif /* OTA_CONFIG_H_ */