From 0e586a4cdfc85c0f0f9b690fb13b7290844cd02a Mon Sep 17 00:00:00 2001 From: Liu Zhi Fu Date: Fri, 13 Oct 2017 09:47:19 +0800 Subject: [PATCH] esp32: add const for some WiFi api Add const if the pointer parameter is const --- components/esp32/include/esp_wifi.h | 12 ++++++------ components/esp32/include/esp_wifi_internal.h | 2 +- components/esp32/include/esp_wpa2.h | 12 ++++++------ components/esp32/wifi_init.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/esp32/include/esp_wifi.h b/components/esp32/include/esp_wifi.h index 0ca0dd95a..0ae0644ea 100755 --- a/components/esp32/include/esp_wifi.h +++ b/components/esp32/include/esp_wifi.h @@ -181,14 +181,14 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; * which are set by WIFI_INIT_CONFIG_DEFAULT, please be notified that the field 'magic' of * wifi_init_config_t should always be WIFI_INIT_CONFIG_MAGIC! * - * @param config provide WiFi init configuration + * @param config pointer to WiFi init configuration structure; can point to a temporary variable. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NO_MEM: out of memory * - others: refer to error code esp_err.h */ -esp_err_t esp_wifi_init(wifi_init_config_t *config); +esp_err_t esp_wifi_init(const wifi_init_config_t *config); /** * @brief Deinit WiFi @@ -341,7 +341,7 @@ esp_err_t esp_wifi_deauth_sta(uint16_t aid); * - ESP_ERR_WIFI_TIMEOUT: blocking scan is timeout * - others: refer to error code in esp_err.h */ -esp_err_t esp_wifi_scan_start(wifi_scan_config_t *config, bool block); +esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, bool block); /** * @brief Stop the scan in process @@ -539,7 +539,7 @@ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second); * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_ARG: invalid argument */ -esp_err_t esp_wifi_set_country(wifi_country_t *country); +esp_err_t esp_wifi_set_country(const wifi_country_t *country); /** * @brief get the current country info @@ -574,7 +574,7 @@ esp_err_t esp_wifi_get_country(wifi_country_t *country); * - ESP_ERR_WIFI_MODE: WiFi mode is wrong * - others: refer to error codes in esp_err.h */ -esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, uint8_t mac[6]); +esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]); /** * @brief Get mac of specified interface @@ -682,7 +682,7 @@ esp_err_t esp_wifi_get_promiscuous_filter(wifi_promiscuous_filter_t *filter); * - ESP_ERR_WIFI_NVS: WiFi internal NVS error * - others: refer to the erro code in esp_err.h */ -esp_err_t esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf); +esp_err_t esp_wifi_set_config(wifi_interface_t ifx, const wifi_config_t *conf); /** * @brief Get configuration of specified interface diff --git a/components/esp32/include/esp_wifi_internal.h b/components/esp32/include/esp_wifi_internal.h index 6627636df..f48b20652 100644 --- a/components/esp32/include/esp_wifi_internal.h +++ b/components/esp32/include/esp_wifi_internal.h @@ -58,7 +58,7 @@ extern "C" { * - ESP_ERR_WIFI_NO_MEM: out of memory * - others: refer to error code esp_err.h */ -esp_err_t esp_wifi_init_internal(wifi_init_config_t *config); +esp_err_t esp_wifi_init_internal(const wifi_init_config_t *config); /** * @brief get whether the wifi driver is allowed to transmit data or not diff --git a/components/esp32/include/esp_wpa2.h b/components/esp32/include/esp_wpa2.h index 6628bd1c9..c704e81c7 100644 --- a/components/esp32/include/esp_wpa2.h +++ b/components/esp32/include/esp_wpa2.h @@ -68,7 +68,7 @@ esp_err_t esp_wifi_sta_wpa2_ent_disable(void); * - ESP_ERR_WIFI_ARG: fail(len <= 0 or len >= 128) * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail) */ -esp_err_t esp_wifi_sta_wpa2_ent_set_identity(unsigned char *identity, int len); +esp_err_t esp_wifi_sta_wpa2_ent_set_identity(const unsigned char *identity, int len); /** * @brief Clear identity for PEAP/TTLS method. @@ -88,7 +88,7 @@ void esp_wifi_sta_wpa2_ent_clear_identity(void); * - ESP_ERR_WIFI_ARG: fail(len <= 0 or len >= 128) * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail) */ -esp_err_t esp_wifi_sta_wpa2_ent_set_username(unsigned char *username, int len); +esp_err_t esp_wifi_sta_wpa2_ent_set_username(const unsigned char *username, int len); /** * @brief Clear username for PEAP/TTLS method. @@ -108,7 +108,7 @@ void esp_wifi_sta_wpa2_ent_clear_username(void); * - ESP_ERR_WIFI_ARG: fail(len <= 0) * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail) */ -esp_err_t esp_wifi_sta_wpa2_ent_set_password(unsigned char *password, int len); +esp_err_t esp_wifi_sta_wpa2_ent_set_password(const unsigned char *password, int len); /** * @brief Clear password for PEAP/TTLS method.. @@ -130,7 +130,7 @@ void esp_wifi_sta_wpa2_ent_clear_password(void); * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail) */ -esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(unsigned char *password, int len); +esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(const unsigned char *password, int len); /** * @brief Clear new password for MSCHAPv2 method.. @@ -149,7 +149,7 @@ void esp_wifi_sta_wpa2_ent_clear_new_password(void); * @return * - ESP_ERR_WIFI_OK: succeed */ -esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(unsigned char *ca_cert, int len); +esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(const unsigned char *ca_cert, int len); /** * @brief Clear CA certificate for PEAP/TTLS method. @@ -172,7 +172,7 @@ void esp_wifi_sta_wpa2_ent_clear_ca_cert(void); * @return * - ESP_ERR_WIFI_OK: succeed */ -esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(unsigned char *client_cert, int client_cert_len, unsigned char *private_key, int private_key_len, unsigned char *private_key_passwd, int private_key_passwd_len); +esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(const unsigned char *client_cert, int client_cert_len, const unsigned char *private_key, int private_key_len, const unsigned char *private_key_passwd, int private_key_passwd_len); /** * @brief Clear client certificate and key. diff --git a/components/esp32/wifi_init.c b/components/esp32/wifi_init.c index dd155d8f1..e0f21b615 100644 --- a/components/esp32/wifi_init.c +++ b/components/esp32/wifi_init.c @@ -16,7 +16,7 @@ #include #include "esp_wifi_internal.h" -esp_err_t esp_wifi_init(wifi_init_config_t *config) +esp_err_t esp_wifi_init(const wifi_init_config_t *config) { esp_event_set_default_wifi_handlers(); return esp_wifi_init_internal(config);