1 /***************************************************************************/ /**
2  * @file
3  *******************************************************************************
4  * # License
5  * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
6  *******************************************************************************
7  *
8  * SPDX-License-Identifier: Zlib
9  *
10  * The licensor of this software is Silicon Laboratories Inc.
11  *
12  * This software is provided 'as-is', without any express or implied
13  * warranty. In no event will the authors be held liable for any damages
14  * arising from the use of this software.
15  *
16  * Permission is granted to anyone to use this software for any purpose,
17  * including commercial applications, and to alter it and redistribute it
18  * freely, subject to the following restrictions:
19  *
20  * 1. The origin of this software must not be misrepresented; you must not
21  *    claim that you wrote the original software. If you use this software
22  *    in a product, an acknowledgment in the product documentation would be
23  *    appreciated but is not required.
24  * 2. Altered source versions must be plainly marked as such, and must not be
25  *    misrepresented as being the original software.
26  * 3. This notice may not be removed or altered from any source distribution.
27  *
28  ******************************************************************************/
29 
30 #ifndef SL_WIFI_CREDENTIALS_H
31 #define SL_WIFI_CREDENTIALS_H
32 
33 #include "sl_wifi_types.h"
34 
35 /**
36  * \addtogroup WIFI_CREDENTIAL_FUNCTIONS Wi-Fi Credential
37  * \ingroup SL_WIFI_FUNCTIONS
38  * @{ */
39 
40 /***************************************************************************/ /**
41  * @brief
42  *   Store a credential in specified credential identifier.
43  *
44  * @details
45  *   This function stores the credential type and data for the specified credential ID.
46  *   The credential data can include client credentials, access point credentials and user credentials.
47  *
48  *   Repeatedly calling this API with the same ID will overwrite the existing credential type and data.
49  *
50  * @pre Pre-conditions:
51  * - @ref sl_wifi_init should be called before this API.
52  *
53  * @param[in] id
54  *   Credential identifier as identified by @ref sl_wifi_credential_id_t.
55  *
56  * @param[in] type
57  *   Credential type as identified by @ref sl_wifi_credential_type_t.
58  *
59  * @param[in] credential
60  *   Pointer to the credential data object.
61  *
62  * @param[in] credential_length
63  *   Length of the credential data object.
64  *
65  * @return
66  *   sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details.
67  ******************************************************************************/
68 sl_status_t sl_wifi_set_credential(sl_wifi_credential_id_t id,
69                                    sl_wifi_credential_type_t type,
70                                    const void *credential,
71                                    uint32_t credential_length);
72 
73 /***************************************************************************/ /**
74  * @brief
75  *   Retrieve a stored credential.
76  *
77  * @details
78  *   This function retrieves the credential data for the specified credential ID.
79  *   The retrieved credential data is stored in the provided credential object.
80  *
81  * @pre Pre-conditions:
82  * - @ref sl_wifi_init should be called before this API.
83  *
84  * @param[in] id
85  *   Credential identifier as identified by @ref sl_wifi_credential_id_t.
86  *
87  * @param[out] type
88  *   Credential type as identified by @ref sl_wifi_credential_type_t.
89  *
90  * @param[out] credential
91  *   Pointer to location where credential data is stored.
92  *
93  * @param[in,out] credential_length
94  *   in: Number of bytes available at credential,
95  *   out: Number of bytes written.
96  *
97  * @return
98  *   sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details.
99  ******************************************************************************/
100 sl_status_t sl_wifi_get_credential(sl_wifi_credential_id_t id,
101                                    sl_wifi_credential_type_t *type,
102                                    void *credential,
103                                    uint32_t *credential_length);
104 
105 /***************************************************************************/ /**
106  * @brief
107  *   Delete a stored credential.
108  *
109  * @details
110  *   This function deletes the credential data for the specified credential ID and type.
111  *   Once deleted, the credential cannot be used for any operations.
112  *
113  * @pre Pre-conditions:
114  * -
115  *   @ref sl_wifi_init should be called before this API.
116  *
117  * @param[in] id
118  *   Credential identifier as identified by @ref sl_wifi_credential_id_t.
119  *
120  * @return
121  *   sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details.
122  ******************************************************************************/
123 sl_status_t sl_wifi_delete_credential(sl_wifi_credential_id_t id);
124 
125 /** @} */
126 
127 #endif //SL_WIFI_CREDENTIALS_H
128