wifi_connect.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* wifi_connect.h
  2. *
  3. * Copyright (C) 2006-2024 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifndef _WIFI_CONNECT_H_
  22. #define _WIFI_CONNECT_H_
  23. /* ESP lwip */
  24. #define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY
  25. #define TLS_SMP_WIFI_SSID CONFIG_WIFI_SSID
  26. #define TLS_SMP_WIFI_PASS CONFIG_WIFI_PASSWORD
  27. #define USE_WIFI_EXAMPLE
  28. #ifdef USE_WIFI_EXAMPLE
  29. #include "esp_netif.h"
  30. #include "protocol_examples_common.h" /* see project CMakeLists.txt */
  31. #endif
  32. /**
  33. ******************************************************************************
  34. ******************************************************************************
  35. ** USER APPLICATION SETTINGS BEGIN
  36. ******************************************************************************
  37. ******************************************************************************
  38. **/
  39. /* when using a private config with plain text passwords,
  40. * file my_private_config.h should be excluded from git updates */
  41. /* #define USE_MY_PRIVATE_CONFIG */
  42. /* Note that IntelliSense may not work properly in the next section for the
  43. * Espressif SDK 3.4 on the ESP8266. Macros should still be defined.
  44. * See the project-level Makefile. Example found in:
  45. * https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template
  46. *
  47. * The USE_MY_PRIVATE_[OS]_CONFIG is typically an environment variable that
  48. * triggers the make (not cmake) to add compiler defines.
  49. */
  50. #if defined(USE_MY_PRIVATE_WINDOWS_CONFIG)
  51. #include "/workspace/my_private_config.h"
  52. #elif defined(USE_MY_PRIVATE_WSL_CONFIG)
  53. #include "/mnt/c/workspace/my_private_config.h"
  54. #elif defined(USE_MY_PRIVATE_LINUX_CONFIG)
  55. #include "~/workspace/my_private_config.h"
  56. #elif defined(USE_MY_PRIVATE_MAC_CONFIG)
  57. #include "~/Documents/my_private_config.h"
  58. #elif defined(USE_MY_PRIVATE_CONFIG)
  59. /* This section works best with cmake & non-environment variable setting */
  60. #if defined(WOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS)
  61. #define WOLFSSL_CMAKE
  62. #include "/workspace/my_private_config.h"
  63. #elif defined(WOLFSSL_MAKE_SYSTEM_NAME_WINDOWS)
  64. #define WOLFSSL_MAKE
  65. #include "/workspace/my_private_config.h"
  66. #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_WSL)
  67. #define WOLFSSL_CMAKE
  68. #include "/mnt/c/workspace/my_private_config.h"
  69. #elif defined(WOLFSSL_MAKE_SYSTEM_NAME_WSL)
  70. #define WOLFSSL_MAKE
  71. #include "/mnt/c/workspace/my_private_config.h"
  72. #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_LINUX)
  73. #define WOLFSSL_CMAKE
  74. #include "~/workspace/my_private_config.h"
  75. #elif defined(WOLFSSL_MAKE_SYSTEM_NAME_LINUX)
  76. #define WOLFSSL_MAKE
  77. #include "~/workspace/my_private_config.h"
  78. #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_APPLE)
  79. #include "~/Documents/my_private_config.h"
  80. #elif defined(WOLFSSL_MAKE_SYSTEM_NAME_APPLE)
  81. #define WOLFSSL_MAKE
  82. #include "~/Documents/my_private_config.h"
  83. #elif defined(OS_WINDOWS)
  84. #include "/workspace/my_private_config.h"
  85. #else
  86. /* Edit as needed for your private config: */
  87. #warning "default private config using /workspace/my_private_config.h"
  88. #include "/workspace/my_private_config.h"
  89. #endif
  90. #else
  91. /*
  92. ** The examples use WiFi configuration that you can set via project
  93. ** configuration menu
  94. **
  95. ** If you'd rather not, just change the below entries to strings with
  96. ** the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
  97. */
  98. #if defined(CONFIG_ESP_WIFI_SSID)
  99. /* tyically from ESP32 with ESP-IDF v4 to v5 */
  100. #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID
  101. #elif defined(CONFIG_EXAMPLE_WIFI_SSID)
  102. /* typically from ESP8266 rtos-sdk/v3.4 */
  103. #define EXAMPLE_ESP_WIFI_SSID CONFIG_EXAMPLE_WIFI_SSID
  104. #else
  105. /* See new esp-sdk-lib.h helpers: */
  106. #ifndef EXAMPLE_ESP_WIFI_SSID
  107. #define EXAMPLE_ESP_WIFI_SSID "MYSSID_WIFI_CONNECT"
  108. #endif
  109. #endif
  110. #if defined(CONFIG_ESP_WIFI_PASSWORD)
  111. /* tyically from ESP32 with ESP-IDF v4 or v5 */
  112. #define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
  113. #elif defined(CONFIG_EXAMPLE_WIFI_SSID)
  114. /* typically from ESP8266 rtos-sdk/v3.4 */
  115. #define EXAMPLE_ESP_WIFI_PASS CONFIG_EXAMPLE_WIFI_PASSWORD
  116. #else
  117. /* See new esp-sdk-lib.h helpers: */
  118. #ifndef EXAMPLE_ESP_WIFI_PASS
  119. #define EXAMPLE_ESP_WIFI_PASS "MYPASSWORD_WIFI_CONNECT"
  120. #endif
  121. #endif
  122. #endif
  123. /* ESP lwip */
  124. #define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY
  125. int wifi_init_sta(void);
  126. int wifi_show_ip(void);
  127. #endif /* _WIFI_CONNECT_H_ */