|
1 | | -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD |
2 | | -// |
3 | | -// Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | -// you may not use this file except in compliance with the License. |
5 | | -// You may obtain a copy of the License at |
6 | | -// |
7 | | -// http://www.apache.org/licenses/LICENSE-2.0 |
8 | | -// |
9 | | -// Unless required by applicable law or agreed to in writing, software |
10 | | -// distributed under the License is distributed on an "AS IS" BASIS, |
11 | | -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | -// See the License for the specific language governing permissions and |
13 | | -// limitations under the License. |
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
14 | 7 | #pragma once |
| 8 | + |
15 | 9 | #include <stdint.h> |
16 | 10 | #include <stdbool.h> |
17 | 11 | #include <esp_err.h> |
@@ -1129,6 +1123,50 @@ esp_err_t esp_rmaker_param_report_simple_ts_data(const esp_rmaker_param_t *param |
1129 | 1123 | * @return ESP_OK on success, appropriate error on failure. |
1130 | 1124 | */ |
1131 | 1125 | esp_err_t esp_rmaker_cmd_response_publish(void *output, size_t output_len); |
| 1126 | + |
| 1127 | +/** |
| 1128 | + * @brief Structure to hold AWS temporary credentials. |
| 1129 | + */ |
| 1130 | +typedef struct { |
| 1131 | + char *access_key; /*!< AWS Access Key ID (null-terminated string, heap-allocated) */ |
| 1132 | + uint32_t access_key_len; /*!< Length of the access key string (excluding null terminator) */ |
| 1133 | + char *secret_key; /*!< AWS Secret Access Key (null-terminated string, heap-allocated) */ |
| 1134 | + uint32_t secret_key_len; /*!< Length of the secret key string (excluding null terminator) */ |
| 1135 | + char *session_token; /*!< AWS Session Token (null-terminated string, heap-allocated) */ |
| 1136 | + uint32_t session_token_len; /*!< Length of the session token string (excluding null terminator) */ |
| 1137 | + uint32_t expiration; /*!< Expiration time of the credentials (seconds from now) */ |
| 1138 | +} esp_rmaker_aws_credentials_t; |
| 1139 | + |
| 1140 | +/** Get AWS region from credential endpoint |
| 1141 | + * |
| 1142 | + * This function extracts the AWS region from the credential endpoint stored in factory. |
| 1143 | + * The region string is allocated on the heap and should be freed by the caller. |
| 1144 | + * |
| 1145 | + * @return Pointer to allocated region string on success |
| 1146 | + * @return NULL on failure |
| 1147 | + */ |
| 1148 | +char* esp_rmaker_get_aws_region(void); |
| 1149 | + |
| 1150 | +/** Get AWS security token credentials |
| 1151 | + * |
| 1152 | + * This function fetches AWS temporary credentials by assuming the specified role alias. |
| 1153 | + * The credentials are allocated on the heap and should be freed using esp_rmaker_free_aws_credentials(). |
| 1154 | + * |
| 1155 | + * @param[in] role_alias AWS IoT role alias to assume |
| 1156 | + * |
| 1157 | + * @return Pointer to allocated credentials structure on success |
| 1158 | + * @return NULL on failure |
| 1159 | + */ |
| 1160 | +esp_rmaker_aws_credentials_t* esp_rmaker_get_aws_security_token(const char *role_alias); |
| 1161 | + |
| 1162 | +/** Free AWS credentials structure |
| 1163 | + * |
| 1164 | + * This function frees the memory allocated for AWS credentials structure and all its members. |
| 1165 | + * |
| 1166 | + * @param[in] credentials Pointer to credentials structure to free |
| 1167 | + */ |
| 1168 | +void esp_rmaker_free_aws_credentials(esp_rmaker_aws_credentials_t *credentials); |
| 1169 | + |
1132 | 1170 | #ifdef __cplusplus |
1133 | 1171 | } |
1134 | 1172 | #endif |
0 commit comments