mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-29 21:08:24 +00:00
Unbreak esp32 device dashboard build
This commit is contained in:
1 parent
6b51666248
commit
bcb6c2675f
8 files changed
+18
-25
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
THISDIR = $(realpath $(CURDIR))
|
THISDIR = $(realpath $(CURDIR))
|
||||||
ROOTDIR = $(realpath $(CURDIR)/../..)
|
ROOTDIR = $(realpath $(CURDIR)/../../..)
|
||||||
|
|
||||||
all: example
|
all: example
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
idf_component_register(SRCS "main.c"
|
idf_component_register(SRCS "main.c"
|
||||||
"wifi.c"
|
"wifi.c"
|
||||||
|
"net.c"
|
||||||
|
"packed_fs.c"
|
||||||
"mongoose.c")
|
"mongoose.c")
|
||||||
component_compile_options(-DMG_ENABLE_LINES)
|
component_compile_options(-DMG_ENABLE_LINES)
|
||||||
|
component_compile_options(-DMG_ENABLE_PACKED_FS)
|
||||||
@@ -2,27 +2,15 @@
|
|||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
#include "esp_spiffs.h"
|
#include "esp_spiffs.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
//#include "freertos/FreeRTOS.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
|
|
||||||
#define WIFI_SSID "VMDF554B9" // SET THIS!
|
const char *s_listening_url = "http://0.0.0.0:80";
|
||||||
#define WIFI_PASS "Mp7wjmamPafa" // SET THIS!
|
void device_dashboard_fn(struct mg_connection *, int, void *, void *);
|
||||||
#define FS_ROOT "/spiffs"
|
|
||||||
|
|
||||||
// Event handler for an server (accepted) connection. Implemented endpoints:
|
#define WIFI_SSID "YOUR_WIFI_NETWORK_NAME" // SET THIS!
|
||||||
// /api/stats - return JSON object with ESP32 stats (free RAM)
|
#define WIFI_PASS "YOUR_WIFI_PASSWORD" // SET THIS!
|
||||||
// any other - serve files from the filesystem
|
#define FS_ROOT "/spiffs"
|
||||||
static void cb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
|
||||||
if (ev == MG_EV_HTTP_MSG) {
|
|
||||||
struct mg_http_message *hm = ev_data;
|
|
||||||
if (mg_http_match_uri(hm, "/api/stats")) {
|
|
||||||
mg_http_reply(c, 200, "", "{\"ram\": %lu}\n", xPortGetFreeHeapSize());
|
|
||||||
} else {
|
|
||||||
struct mg_http_serve_opts opts = {.root_dir = FS_ROOT};
|
|
||||||
mg_http_serve_dir(c, hm, &opts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
// Mount filesystem
|
// Mount filesystem
|
||||||
@@ -39,9 +27,9 @@ void app_main(void) {
|
|||||||
|
|
||||||
// Connected to WiFi, now start HTTP server
|
// Connected to WiFi, now start HTTP server
|
||||||
struct mg_mgr mgr;
|
struct mg_mgr mgr;
|
||||||
mg_log_set("4");
|
mg_log_set("3");
|
||||||
mg_mgr_init(&mgr);
|
mg_mgr_init(&mgr);
|
||||||
mg_http_listen(&mgr, "http://0.0.0.0:80", cb, &mgr); // Listening server
|
MG_INFO(("Mongoose v%s on %s", MG_VERSION, s_listening_url));
|
||||||
MG_INFO(("Starting Mongoose web server v%s", MG_VERSION));
|
mg_http_listen(&mgr, s_listening_url, device_dashboard_fn, &mgr);
|
||||||
for (;;) mg_mgr_poll(&mgr, 1000); // Infinite event loop
|
for (;;) mg_mgr_poll(&mgr, 1000); // Infinite event loop
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
../../../mongoose.c
|
../../../../mongoose.c
|
||||||
@@ -1 +1 @@
|
|||||||
../../../mongoose.h
|
../../../../mongoose.h
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../device-dashboard/net.c
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../device-dashboard/packed_fs.c
|
||||||
@@ -42,7 +42,7 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
|||||||
MG_ERROR(("connect to the AP fail"));
|
MG_ERROR(("connect to the AP fail"));
|
||||||
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
|
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
|
||||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
|
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
|
||||||
MG_INFO(("got ip:" IPSTR, IP2STR(&event->ip_info.ip)));
|
MG_INFO(("IP ADDRESS:" IPSTR, IP2STR(&event->ip_info.ip)));
|
||||||
s_retry_num = 0;
|
s_retry_num = 0;
|
||||||
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user