Does anybody know how to create an lwIP embedded web server & download a file from it?

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone,
Am currently working on a lwIP embedded web server.
So far, I have succeeded in creating the embedded web server.
But my current requirement is to download a file from the embedded web server.
How to do that?

Silly beans are always silly
:)

Last Edited: Wed. Nov 16, 2016 - 04:03 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Where do we store the download file in the embedded web server?

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is it possible to store it inside internal flash & make it downloadable as well.

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

You need a romfilesystem and there's an app to convert the files to C arrays.
Just googled lwip romfs
Seems the file fs.c is part of the lwip distribution

Last Edited: Wed. Nov 9, 2016 - 07:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I'm using the lwip stuff exactly the way mentioned above. Note that the ATMEL ASF 3.32 contains a FAT file system demo which by default uses ram for storage. But you can write some code to use nonvolatile memory instead. IMHO this would be more flexible and comfortable and it is possible to modify the hosted files without firmware update.

SAME newbie

Last Edited: Wed. Nov 9, 2016 - 08:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That is great.
Could you give some insight regarding the program.
 

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

There are many HTTP servers based on lwip around e.g. with/without RTOS for almost any ATMEL device. Just grab one from the ASF that fits your requirements best and start. If you use Atmel Studio create a new demo project using lwip and step thru the code. Check out the lwip docs and Atmel application notes on the net, e.g. AT04055: Using the lwIP Network Stack. Note the differences between RAW and NETCONN API. I'll try to answer your questions.

 

 

SAME newbie

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I'll get back after referring these.

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, am trying to stream data to the client PC. It should greatly reduce RAM usage.

Theoretically it is possible.

Am not sure how things will out.

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got the logic working.
Now I can take encoded file from flash & can stream chunks of decoded data to client PC.

Problem solved.

The HTML code keeps the comm port open until a specific data of format is received.

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But now am stuck with new question.

My download files is expected to be around 1MB. but currently am able to download only 6kB file even if I try to stream more number of bytes.

The web page is also supposed to dynamically update certain values using ajax.

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Normal web servers are supposed to sleep periodically while doing heavy application to handle pending requests.
But in our SAM E70, without RTOS implemented, how can we do this?

When we are trying to download a bulk data from the server, it seems like the server is getting overwhelmed by the ajax requests and finally the server is getting stalled.

Silly beans are always silly
:)

Last Edited: Wed. Nov 16, 2016 - 04:02 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I'd suggest you investigate what is really happening. How many concurrent connections have you got or accept? How is your stack/heap?
If you emply an event driven technique, you should be able to move plenty of data as well as handle ajax requests. Nevertheless for your application, aRTOS might be warranted.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I started using raw lwip but experienced timeouts in browser requests. Wiresharc showed me that web browser open multiple connections in parallel which cannot be handled by my raw lwip in time. Maybe this seems to be overkill but then I switched to netconn API and multiple http tasks under FreeRTOS. You might want to check out the lwip netconn API demo.

SAME newbie

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I managed the issue by sending small chunks or data packets & hence the connection need not be open whole the time while sending a large file.

By now, I have managed to send 7MB plus file without any issue.

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But am using a global variable to keep track of the number of packets sent.

So, the issue is that I can let multiple file download at the same time.

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got wasted...
All the time & effort put on this task got wasted, now have been notified that a microchip made Ethernet module will be used in our project as per the client requirement & as a result we are supposed to configure the new module from the scratch.

crying

 

Sorry guys...

Silly beans are always silly
:)