mongoose challenge

linuxpaul
Posts: 43
Joined: Thu Jul 20, 2017 6:10 pm

mongoose challenge

Postby linuxpaul » Thu Aug 10, 2017 8:45 pm

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

linuxpaul
Posts: 43
Joined: Thu Jul 20, 2017 6:10 pm

Re: mongoose challenge

Postby linuxpaul » Sun Aug 13, 2017 9:23 pm

Ok ok, this is c language basic stuff, sorry for this.
:)

linuxpaul
Posts: 43
Joined: Thu Jul 20, 2017 6:10 pm

Re: mongoose challenge

Postby linuxpaul » Tue Aug 15, 2017 7:09 pm

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?

linuxpaul
Posts: 43
Joined: Thu Jul 20, 2017 6:10 pm

Re: mongoose challenge

Postby linuxpaul » Wed Aug 16, 2017 6:39 pm

.... not the linker, it seems that the compiler skips this function.
The other symbols like mg_mgr_poll are mapped.
:)

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: mongoose challenge

Postby WiFive » Wed Aug 16, 2017 9:25 pm

Any reason you are not using mongooseOS instead of bare mongoose?

linuxpaul
Posts: 43
Joined: Thu Jul 20, 2017 6:10 pm

Re: mongoose challenge

Postby linuxpaul » Wed Aug 16, 2017 11:03 pm

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. :?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: mongoose challenge

Postby WiFive » Wed Aug 16, 2017 11:07 pm

I see well mongooseOS has official support for esp32, a nice UI, examples, and you can code in JavaScript.

linuxpaul
Posts: 43
Joined: Thu Jul 20, 2017 6:10 pm

Re: mongoose challenge

Postby linuxpaul » Wed Aug 16, 2017 11:16 pm

Thank you WiFive,
I'll keep it in my mind.
:)

squonk11
Posts: 69
Joined: Wed Mar 01, 2017 6:53 pm
Location: Germany

Re: mongoose challenge

Postby squonk11 » Wed Sep 06, 2017 2:32 pm

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?
"Whoever believes to be someone has stopped becoming someone"
Sokrates

linuxpaul
Posts: 43
Joined: Thu Jul 20, 2017 6:10 pm

Re: mongoose challenge

Postby linuxpaul » Wed Sep 06, 2017 5:32 pm

Hello squonk11,

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

:)
linuxpaul

Who is online

Users browsing this forum: EG1966 and 96 guests