mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/wifi_prov_ext_httpd' into 'master'
wifi_provisioning_softap: Allow applications to start webserver externally See merge request espressif/esp-idf!6860
This commit is contained in:
commit
b3eb4395c9
@ -29,6 +29,19 @@ extern "C" {
|
||||
*/
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_softap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Provide HTTPD Server handle externally.
|
||||
*
|
||||
* Useful in cases wherein applications need the webserver for some
|
||||
* different operations, and do not want the wifi provisioning component
|
||||
* to start/stop a new instance.
|
||||
*
|
||||
* @note This API should be called before wifi_prov_mgr_start_provisioning()
|
||||
*
|
||||
* @param[in] handle Handle to HTTPD server instance
|
||||
*/
|
||||
void wifi_prov_scheme_softap_set_httpd_handle(void *handle);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -33,7 +33,7 @@ typedef struct softap_config {
|
||||
static const char *TAG = "wifi_prov_scheme_softap";
|
||||
|
||||
extern const wifi_prov_scheme_t wifi_prov_scheme_softap;
|
||||
|
||||
static void *scheme_softap_prov_httpd_handle;
|
||||
static esp_err_t start_wifi_ap(const char *ssid, const char *pass)
|
||||
{
|
||||
/* Build Wi-Fi configuration for AP mode */
|
||||
@ -85,6 +85,11 @@ static esp_err_t prov_start(protocomm_t *pc, void *config)
|
||||
|
||||
protocomm_httpd_config_t *httpd_config = &softap_config->httpd_config;
|
||||
|
||||
if (scheme_softap_prov_httpd_handle) {
|
||||
httpd_config->ext_handle_provided = true;
|
||||
httpd_config->data.handle = scheme_softap_prov_httpd_handle;
|
||||
}
|
||||
|
||||
/* Start protocomm server on top of HTTP */
|
||||
esp_err_t err = protocomm_httpd_start(pc, httpd_config);
|
||||
if (err != ESP_OK) {
|
||||
@ -186,6 +191,11 @@ static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, ui
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void wifi_prov_scheme_softap_set_httpd_handle(void *handle)
|
||||
{
|
||||
scheme_softap_prov_httpd_handle = handle;
|
||||
}
|
||||
|
||||
const wifi_prov_scheme_t wifi_prov_scheme_softap = {
|
||||
.prov_start = prov_start,
|
||||
.prov_stop = prov_stop,
|
||||
|
Loading…
x
Reference in New Issue
Block a user