mirror of
https://github.com/peterantypas/maiana.git
synced 2025-06-08 02:30:21 -07:00
55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
#include "http_server.h"
|
|
#include <stdlib.h>
|
|
#include <esp_http_server.h>
|
|
#include <esp_event.h>
|
|
#include <esp_log.h>
|
|
#include <esp_system.h>
|
|
#include <sys/param.h>
|
|
#include "configuration.h"
|
|
|
|
static httpd_handle_t __handle = NULL;
|
|
|
|
static const char *TAG = "httpd";
|
|
|
|
extern void register_http_web_handlers(httpd_handle_t);
|
|
extern void register_wifi_api_handlers(httpd_handle_t);
|
|
extern void register_ais_api_handlers(httpd_handle_t);
|
|
extern void register_nmea_api_handlers(httpd_handle_t);
|
|
extern void register_sys_api_handlers(httpd_handle_t);
|
|
|
|
void start_httpd()
|
|
{
|
|
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
|
config.uri_match_fn = httpd_uri_match_wildcard;
|
|
config.max_uri_handlers = 20;
|
|
|
|
if (httpd_start(&__handle, &config) == ESP_OK)
|
|
{
|
|
register_http_web_handlers(__handle);
|
|
register_wifi_api_handlers(__handle);
|
|
register_ais_api_handlers(__handle);
|
|
register_nmea_api_handlers(__handle);
|
|
register_sys_api_handlers(__handle);
|
|
ESP_LOGI(TAG, "Started HTTPD");
|
|
}
|
|
}
|
|
|
|
void stop_httpd()
|
|
{
|
|
if (__handle)
|
|
{
|
|
httpd_stop(__handle);
|
|
__handle = NULL;
|
|
ESP_LOGI(TAG, "Stopped HTTPD");
|
|
}
|
|
}
|
|
|
|
bool is_httpd_running()
|
|
{
|
|
return __handle != NULL;
|
|
}
|
|
|
|
|
|
|
|
|