Page 1 of 2

mongoose challenge

Posted: Thu Aug 10, 2017 8:45 pm
by linuxpaul
Hello,

after playing around with some basics I'd like serve an index.html from spiffs with mongoose.
I started with an example from mongoose docs.

Code: Select all

.....
#define MG_ENABLE_FILESYSTEM  1
#include "mongoose.h"
....
void mongoose_event_handler(struct mg_connection *nc, int ev, void *evData) {
	struct http_message *hm = (struct http_message *) evData;
	struct mg_serve_http_opts opts = { .document_root = "/spiffs/" };
	switch (ev) {
	    case MG_EV_HTTP_REQUEST:
	      mg_serve_http(nc, hm, opts);
	      break;
	    default:
	      break;
	  }
}
To my surprise, mg_serve_http_opts and mg_serve_http are unresolved, at first.
After taking a look to mongoose.h, i found an if statement upon mg_serve_http_opts
which leeds me to define MG_ENABLE_FILESYSTEM.

mg_serve_http still stays unreserved and it seems there is no other switch for this.
I didn't see using defines for running mongoose before,
whats going wrong?

regards,
linuxpaul

Re: mongoose challenge

Posted: Sun Aug 13, 2017 9:23 pm
by linuxpaul
Ok ok, this is c language basic stuff, sorry for this.
:)

Re: mongoose challenge

Posted: Tue Aug 15, 2017 7:09 pm
by linuxpaul
another attempt ...

the behavior of mongoose should be controlled by CFLAGS in component.mk next to main.c ?
Is there a hint to find out a proper combination for ESP32 running this example?
Chip detection may work, because -DESP_PLATFORM=1 didn't solve the problem.
-DMG_ENABLE_FILESYSTEM=1 give me the mg_serve_http_opts but mg_serve_http
is still missing. MG_ENABLE_HTTP seems also enabled by default.

:)
linuxpaul

Edit:
mg_serve_http is shown as undefined reference, but .o was built during make.
Just a linker difficult?

Re: mongoose challenge

Posted: Wed Aug 16, 2017 6:39 pm
by linuxpaul
.... not the linker, it seems that the compiler skips this function.
The other symbols like mg_mgr_poll are mapped.
:)

Re: mongoose challenge

Posted: Wed Aug 16, 2017 9:25 pm
by WiFive
Any reason you are not using mongooseOS instead of bare mongoose?

Re: mongoose challenge

Posted: Wed Aug 16, 2017 11:03 pm
by linuxpaul
less experience?
I have some c programming basic knowledge and I never wrote programs for
embeded systems before starting with ESP32.
My orientation is the basic stuff and its combinations at the moment,
aligned by ESP-IDF docs and Kolbans book
So I didn't gave attention to mongoose OS till yet.

So far I didn't get the trouble with mongoose.c.
I wrote some code using eclipse and it looks fine.
No warning, no error, mongoose.h shows the references and the compiler translate
all but mg_serve_http. Looking to the result in build dir, mg_serve_http is shown greyed.
Crazy stuff. :?

Re: mongoose challenge

Posted: Wed Aug 16, 2017 11:07 pm
by WiFive
I see well mongooseOS has official support for esp32, a nice UI, examples, and you can code in JavaScript.

Re: mongoose challenge

Posted: Wed Aug 16, 2017 11:16 pm
by linuxpaul
Thank you WiFive,
I'll keep it in my mind.
:)

Re: mongoose challenge

Posted: Wed Sep 06, 2017 2:32 pm
by squonk11
Hi linuxpaul,

did You find a solution for Your problem? I am running into the same difficulties with:

Code: Select all

undefined reference to `mg_serve_http'
Does anybody else have a clue?

Re: mongoose challenge

Posted: Wed Sep 06, 2017 5:32 pm
by linuxpaul
Hello squonk11,

in my opinion it is solved, here's the link:
viewtopic.php?f=2&t=2768

:)
linuxpaul