Skip to content

Commit 736fbd6

Browse files
committed
IOT credential: Make it configurable via Kconfig
- Also moved AWS config options from examples to app_common Kconfig
1 parent 43d3228 commit 736fbd6

File tree

5 files changed

+48
-35
lines changed

5 files changed

+48
-35
lines changed

esp_port/examples/app_common/Kconfig.projbuild

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,33 +230,73 @@ menu "Common Configs (Wi-Fi, SD-Card, Camera)"
230230
endmenu
231231

232232
menu "AWS IoT Core Credentials"
233+
config IOT_CORE_ENABLE_CREDENTIALS
234+
bool "Enable AWS IoT Core credentials for authentication"
235+
default y
236+
help
237+
Enable this option to use AWS IoT Core credentials for authentication.
238+
When enabled, the application will use the AWS IoT Core credentials provider
239+
to obtain temporary credentials for accessing AWS services.
240+
If disabled, application should set access key instead
241+
233242
config AWS_IOT_CORE_CREDENTIAL_ENDPOINT
234243
string "AWS IoT Core Credential Endpoint"
235244
default "credential-endpoint.credentials.iot.us-east-1.amazonaws.com"
245+
depends on IOT_CORE_ENABLE_CREDENTIALS
236246
help
237247
AWS IoT Core credential endpoint to use for credential provider. This is the endpoint used for the AWS IoT credential provider.
238248

239249
config AWS_IOT_CORE_CERT
240250
string "AWS IoT Core Certificate"
241251
default "/spiffs/certs/iot-certificate.pem.crt"
252+
depends on IOT_CORE_ENABLE_CREDENTIALS
242253
help
243254
Path to the AWS IoT Core certificate file. This certificate is used for authenticating with AWS IoT Core.
244255

245256
config AWS_IOT_CORE_PRIVATE_KEY
246257
string "AWS IoT Core Private Key"
247258
default "/spiffs/certs/iot-private.pem.key"
259+
depends on IOT_CORE_ENABLE_CREDENTIALS
248260
help
249261
Path to the AWS IoT Core private key file. This key is used for authenticating with AWS IoT Core.
250262

251263
config AWS_IOT_CORE_ROLE_ALIAS
252264
string "AWS IoT Core Role Alias"
253265
default "KVS-WebRTC-Role-Alias"
266+
depends on IOT_CORE_ENABLE_CREDENTIALS
254267
help
255268
AWS IoT Core role alias to use for credential provider. This role alias is used to assume a role with the necessary permissions.
256269

257270
config AWS_IOT_CORE_THING_NAME
258271
string "AWS IoT Core Thing Name"
259272
default "ESP32-WebRTC-Camera"
273+
depends on IOT_CORE_ENABLE_CREDENTIALS
260274
help
261275
AWS IoT Core thing name. This identifies your device in AWS IoT Core.
276+
277+
config AWS_KVS_CHANNEL_NAME
278+
string "KVS Channel Name"
279+
default "ESP32Channel"
280+
help
281+
The name of the signaling channel to use for WebRTC communication.
282+
283+
config AWS_ACCESS_KEY_ID
284+
string "AWS Access Key ID"
285+
default ""
286+
depends on !IOT_CORE_ENABLE_CREDENTIALS
287+
help
288+
AWS Access Key ID for KVS access. Used when not using IoT Core credentials.
289+
290+
config AWS_SECRET_ACCESS_KEY
291+
string "AWS Secret Access Key"
292+
default ""
293+
depends on !IOT_CORE_ENABLE_CREDENTIALS
294+
help
295+
AWS Secret Access Key for KVS access. Used when not using IoT Core credentials.
296+
297+
config AWS_DEFAULT_REGION
298+
string "AWS Region"
299+
default "us-east-1"
300+
help
301+
AWS Region for KVS service.
262302
endmenu

esp_port/examples/app_common/include/sample_config.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ extern "C" {
1212

1313
#include <com/amazonaws/kinesis/video/webrtcclient/Include.h>
1414

15-
#define IOT_CORE_ENABLE_CREDENTIALS 1
16-
1715
#define NUMBER_OF_H264_FRAME_FILES 60 //1500
1816
#define NUMBER_OF_H265_FRAME_FILES 1500
1917
#define NUMBER_OF_OPUS_FRAME_FILES 618

esp_port/examples/app_common/src/sample_config.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
#include "sample_config.h"
33

4-
#ifdef IOT_CORE_ENABLE_CREDENTIALS
4+
#include "sdkconfig.h"
5+
6+
#ifdef CONFIG_IOT_CORE_ENABLE_CREDENTIALS
57
#include "iot_credential_provider.h"
68
#endif
79

@@ -917,7 +919,7 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE
917919

918920
CHK(NULL != (pSampleConfiguration = (PSampleConfiguration) MEMCALLOC(1, SIZEOF(SampleConfiguration))), STATUS_NOT_ENOUGH_MEMORY);
919921

920-
#ifdef IOT_CORE_ENABLE_CREDENTIALS
922+
#ifdef CONFIG_IOT_CORE_ENABLE_CREDENTIALS
921923
PCHAR pIotCoreCredentialEndPoint, pIotCoreCert, pIotCorePrivateKey, pIotCoreRoleAlias, pIotCoreCertificateId, pIotCoreThingName;
922924
CHK_ERR((pIotCoreCredentialEndPoint = GETENV(IOT_CORE_CREDENTIAL_ENDPOINT)) != NULL, STATUS_INVALID_OPERATION,
923925
"AWS_IOT_CORE_CREDENTIAL_ENDPOINT must be set");
@@ -967,9 +969,9 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE
967969
// CHK_STATUS(lookForSslCert(&pSampleConfiguration));
968970
pSampleConfiguration->pCaCertPath = DEFAULT_KVS_CACERT_PATH;
969971

970-
#ifdef IOT_CORE_ENABLE_CREDENTIALS
972+
#ifdef CONFIG_IOT_CORE_ENABLE_CREDENTIALS
971973
CHK_STATUS(createIotCredentialProvider(pIotCoreCredentialEndPoint, pIotCoreCert, pIotCorePrivateKey, pSampleConfiguration->pCaCertPath,
972-
pIotCoreRoleAlias, pIotCoreThingName, &pSampleConfiguration->pCredentialProvider));
974+
pIotCoreRoleAlias, pIotCoreThingName, &pSampleConfiguration->pCredentialProvider));
973975
#else
974976
CHK_STATUS(
975977
createStaticCredentialProvider(pAccessKey, 0, pSecretKey, 0, pSessionToken, 0, MAX_UINT64, &pSampleConfiguration->pCredentialProvider));
@@ -992,7 +994,7 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE
992994

993995
pSampleConfiguration->channelInfo.version = CHANNEL_INFO_CURRENT_VERSION;
994996
pSampleConfiguration->channelInfo.pChannelName = channelName;
995-
#ifdef IOT_CORE_ENABLE_CREDENTIALS
997+
#ifdef CONFIG_IOT_CORE_ENABLE_CREDENTIALS
996998
if ((pIotCoreCertificateId = GETENV(IOT_CORE_CERTIFICATE_ID)) != NULL) {
997999
pSampleConfiguration->channelInfo.pChannelName = pIotCoreCertificateId;
9981000
}

esp_port/examples/webrtc_classic/main/Kconfig.projbuild

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,4 @@ menu "WebRTC Example Configuration"
1212
help
1313
WiFi password (WPA or WPA2) for the example to use.
1414

15-
config AWS_KVS_CHANNEL_NAME
16-
string "KVS Channel Name"
17-
default "ESP32Channel"
18-
help
19-
The name of the signaling channel to use.
20-
21-
config AWS_ACCESS_KEY_ID
22-
string "AWS Access Key ID"
23-
default ""
24-
help
25-
AWS Access Key ID for KVS access.
26-
27-
config AWS_SECRET_ACCESS_KEY
28-
string "AWS Secret Access Key"
29-
default ""
30-
help
31-
AWS Secret Access Key for KVS access.
32-
33-
config AWS_DEFAULT_REGION
34-
string "AWS Region"
35-
default "us-west-2"
36-
help
37-
AWS Region for KVS service.
38-
3915
endmenu

esp_port/examples/webrtc_classic/main/webrtc_main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@ void app_main(void)
202202
PCHAR pChannelName = CONFIG_AWS_KVS_CHANNEL_NAME;
203203

204204
// Set AWS credentials
205-
setenv("AWS_KVS_LOG_LEVEL", "1", 1);
206-
setenv("AWS_DEFAULT_REGION", "us-east-1", 1);
207-
208-
#if IOT_CORE_ENABLE_CREDENTIALS
205+
#ifdef CONFIG_IOT_CORE_ENABLE_CREDENTIALS
209206
setenv("AWS_IOT_CORE_CREDENTIAL_ENDPOINT", CONFIG_AWS_IOT_CORE_CREDENTIAL_ENDPOINT, 1);
210207
setenv("AWS_IOT_CORE_CERT", CONFIG_AWS_IOT_CORE_CERT, 1);
211208
setenv("AWS_IOT_CORE_PRIVATE_KEY", CONFIG_AWS_IOT_CORE_PRIVATE_KEY, 1);

0 commit comments

Comments
 (0)