mongoose challenge

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

Re: mongoose challenge

Postby squonk11 » Thu Sep 07, 2017 11:39 am

Hi linuxpaul,

thank You for Your hint on the defines:
-DESP_PLATFORM=1 -DMG_ENABLE_HTTP=1 -DMG_ENABLE_FILESYSTEM=1
and the longcalls switch
-mlongcalls
--> You diserve a beer!
I make a Makefile.projbuild as You suggested. But it did not work - maybe because I am working with Eclipse? In Eclipse I modified the compiler invoacation in order to include the above mentioned switches. The compiler line now is:

Code: Select all

xtensa-esp32-elf-gcc -std=gnu99 -Og -ggdb -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -DWITH_POSIX -mlongcalls -DESP_PLATFORM=1 -DMG_ENABLE_HTTP=1 -DMG_ENABLE_FILESYSTEM=1 -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H -DESP_PLATFORM -D IDF_VER=\"v2.0-rc1-1314-g9314bf0d-dirty\" -MMD -MP  ...
But still I get the linker error:

Code: Select all

E:/msys32/opt/devel/nk_wifi/main/mgWebserver.cpp:99: undefined reference to `mg_http_serve_file'
E:/msys32/opt/devel/nk_wifi/main/mgWebserver.cpp:101: undefined reference to `mg_serve_http'
Do You have any more hints for me?

Regards

Edit: Now the problem is solved: I cleaned the project in eclipse and made a complete build.
"Whoever believes to be someone has stopped becoming someone"
Sokrates

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

Re: mongoose challenge

Postby squonk11 » Thu Sep 07, 2017 1:03 pm

Unfortunately now, I am running into another problem:
mongoose pretty well serves a PNG file but when I want to serve a simple html-page it does not work:
http://192.168.0.20/logo.png shows the logo but http://192.168.0.20/index.html shows "not found". When I invoke just http://192.168.0.20 the browser shows "ok". But the logo.png and index.html files are both available in the same directory.
weired ...
Does anybody have a hint for me?

Best regards
"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 » Thu Sep 07, 2017 2:58 pm

Hello squonk11,

I also use eclipse but on Windows with Msys2 and I never changed the default compiler settings.
I did very basic stuff to find out what happend, so I started with:

Code: Select all

xtensa-esp32-elf-gcc -mlongcalls -I/d/Source/esp/esp-idf/components/vfs/include -I/d/Source/esp/esp-idf/components/lwip/include/lwip  -I/d/Source/esp/esp-idf/components/lwip/include/lwip/port -I/d/Source/esp/esp-idf/components/esp32/include -I/d/Source/esp/webserver/build/include -I /d/Source/esp/esp-idf/components/freertos/include -I/d/Source/esp/esp-idf/components/soc/esp32/include -DESP_PLATFORM=1 -DMG_ENABLE_HTTP=1 -DMG_ENABLE_FILESYSTEM=1 -c mongoose.c -o mongoose.o
and

Code: Select all

xtensa-esp32-elf-ar -rcs libmongoose.a mongoose.o
from msys2 command line. This is a pretty simple build just with includes and the previous shown switches.

After that I copied the build results in the project build dir and run make all from eclipse.
Since I created the Makefile.projbuild in <projectdir> > components > mongoose I never got difficults with this.

Did I else something special with eclipse?
> My project dirs are outsite the workspace and I always import an existing Source with Makefile
> The Path env of my eclipse project properties > c/c++ Build > evironment just shows

Code: Select all

D:\Source\msys32\usr\bin;D:\Source\msys32\mingw32\bin;D:\Source\msys32\opt\xtensa-esp32-elf\bin
regarding to the esp32 eclipse manual
The default ist the windows full PATH env which leads (in my case) to a different python and points to an/the empty dirent.h.

Mybe I'll upload my mongoose examples to bitbucket this evening.

:)
linuxpaul

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

Re: mongoose challenge

Postby squonk11 » Thu Sep 07, 2017 3:47 pm

Thank You, linuxpaul.
Now I am also able to compile the sources. I think finally I just needed to include the defines (-D switches) in Eclipse under: C/C++General / Paths and Symbols / Symbols.
My webserver is working now, but I discovered that obviously the esp fat driver supports 8.3 filenames only. Is this related to an incompatibility of the filesystem on my SD card or is it possible to chnage this behaviour by a dedicated setting?

Best regards
"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 » Thu Sep 07, 2017 5:20 pm

I never tested something with fat, I'm using spiffs from
https://github.com/loboris/ESP32_spiffs_example.git
and use index.html.
The example files from loboris also left the 8.3 format :)

I'm using spiffs like this:

Code: Select all

 
 ...
#include "spiffs_vfs.h"
#include "esp_vfs.h"
#include "esp_vfs_fat.h"

static struct mg_connection *nc;
static struct mg_serve_http_opts s_opts;
...
<main>
vfs_spiffs_register();
if (spiffs_is_mounted) { printf("==== spiffs mounted .... ====\r\n"); }
...
<mongoose>
s_opts.document_root= "/spiffs/";
s_opts.index_files = "index.html";
...
<mongoose event handler>
static void mongoose_event_handler(struct mg_connection *nc, int ev, void *evData)
{
struct http_message *hm = (struct http_message *) evData;
	switch (ev) {
		case MG_EV_HTTP_REQUEST: {
	    	mg_serve_http(nc, hm, s_opts);
	    	break;
		}
....
s_opts.document_root points to "." by default so I think I need to change this.
s_opts.index_files = "index.html" is not a must if you are using "index.html" as start page.

I don't figured out if all above header are needed in fact, the includes are copied from a spiffs example.

:)
linuxpaul

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

Re: mongoose challenge

Postby squonk11 » Thu Sep 07, 2017 5:42 pm

probably a stupid question: is it possible to use SPIFFS in combination with a real SDcard?
I would like to use SSI and therefore the filename needs to be .shtml; so FAT with 8.3 is a problem.
"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 » Thu Sep 07, 2017 6:06 pm

sorry, I don't know this at present, I never used a sdcard till yet.

But, have you tried this?
esp_vfs_fat_sdmmc_mount?

Kolban says:
Mount an SD card as a posix file system.
esp_err_t esp_vfs_fat_sdmmc_mount(
const char *base_path,
const sdmmc_host_t *host_config,
const sdmmc_slot_config_t *slot_config,
const esp_vfs_fat_sdmmc_mount_config_t *mount_config,
sdmmc_card_t **out_card)
The base_path is the path in the POSIX file system which acts as the mount point for
the files hosted in the FAT32 file system contained on the card. A common example is
"/sdcard".

:)
linuxpaul

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

Re: mongoose challenge

Postby squonk11 » Thu Sep 07, 2017 7:36 pm

Intetrsting point. Iwill try and post the result.
"Whoever believes to be someone has stopped becoming someone"
Sokrates

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

Re: mongoose challenge

Postby squonk11 » Fri Sep 08, 2017 9:31 am

@linuxpaul: I received Your PN. For sure there is some interesting stuff included.
Concerning my problem with the limitation to 8.3 filenames: this could be solved via menuconfig by activating long filenames. Now I am able to access index.shtml including SSI calls.
Best regards
"Whoever believes to be someone has stopped becoming someone"
Sokrates

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 87 guests