esp_wps.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright 2015-2016 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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_WPS_H__
  14. #define __ESP_WPS_H__
  15. #include <stdbool.h>
  16. #include "esp_err.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /** \defgroup WiFi_APIs WiFi Related APIs
  21. * @brief WiFi APIs
  22. */
  23. /** @addtogroup WiFi_APIs
  24. * @{
  25. */
  26. /** \defgroup WPS_APIs WPS APIs
  27. * @brief ESP32 WPS APIs
  28. *
  29. * WPS can only be used when ESP32 station is enabled.
  30. *
  31. */
  32. /** @addtogroup WPS_APIs
  33. * @{
  34. */
  35. #define ESP_ERR_WIFI_REGISTRAR (ESP_ERR_WIFI_BASE + 51) /*!< WPS registrar is not supported */
  36. #define ESP_ERR_WIFI_WPS_TYPE (ESP_ERR_WIFI_BASE + 52) /*!< WPS type error */
  37. #define ESP_ERR_WIFI_WPS_SM (ESP_ERR_WIFI_BASE + 53) /*!< WPS state machine is not initialized */
  38. typedef enum wps_type {
  39. WPS_TYPE_DISABLE = 0,
  40. WPS_TYPE_PBC,
  41. WPS_TYPE_PIN,
  42. WPS_TYPE_MAX,
  43. } wps_type_t;
  44. /**
  45. * @brief Enable Wi-Fi WPS function.
  46. *
  47. * @attention WPS can only be used when ESP32 station is enabled.
  48. *
  49. * @param wps_type_t wps_type : WPS type, so far only WPS_TYPE_PBC and WPS_TYPE_PIN is supported
  50. *
  51. * @return
  52. * - ESP_OK : succeed
  53. * - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
  54. * - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
  55. * - ESP_ERR_WIFI_FAIL : wps initialization fails
  56. */
  57. esp_err_t esp_wifi_wps_enable(wps_type_t wps_type);
  58. /**
  59. * @brief Disable Wi-Fi WPS function and release resource it taken.
  60. *
  61. * @param null
  62. *
  63. * @return
  64. * - ESP_OK : succeed
  65. * - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
  66. */
  67. esp_err_t esp_wifi_wps_disable(void);
  68. /**
  69. * @brief WPS starts to work.
  70. *
  71. * @attention WPS can only be used when ESP32 station is enabled.
  72. *
  73. * @param timeout_ms : maximum blocking time before API return.
  74. * - 0 : non-blocking
  75. * - 1~120000 : blocking time (not supported in IDF v1.0)
  76. *
  77. * @return
  78. * - ESP_OK : succeed
  79. * - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
  80. * - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
  81. * - ESP_ERR_WIFI_WPS_SM : wps state machine is not initialized
  82. * - ESP_ERR_WIFI_FAIL : wps initialization fails
  83. */
  84. esp_err_t esp_wifi_wps_start(int timeout_ms);
  85. /**
  86. * @}
  87. */
  88. /**
  89. * @}
  90. */
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* __ESP_WPS_H__ */