The program publishes files at local directory and SD filesystem. It is a full-fledged webServer somewhat.

Dependencies:   libMiMic mbed-rtos mbed NyFileSystems

English

This program is simple webserver to provides contents on local file system and SD card through HTTP to network. The application is demonstration of libMiMic library that includes uIP based TCP/IP stack and fast httpd server.

It has auto platform detection function. It works on mbed and LPCXpresso1769 both platform in the same binary.

/media/uploads/nyatla/this_server.jpg

Feature

  • Automatic platform detection. for mbed and LPCXpresso.
  • SD card/LlocalFileSystem support. LocalfileSystem is accessable when mbed. Otherwise ignored.
  • Mbed RTOS based Multithread.
  • Original TCP/IP stack(MiMicIP). It is based on uIP.
  • Fast HTTPD (HTTP/1.1 , Persistent connection , RTT<=10ms , Maximum throughput 8Mbps ,SDCard throughput 600Kbps , Chunked encoding, Maximum content size 4GB)
  • RAM usage 16KB+16KB(AHB SRAM - bank 0)
  • ROM 70KB

Demonstration

This is temporary demonstration website. Mmedwebserver demonstration.

The server hosted MiMicRemoteMCU-for-Mbed sample content. You can browse sample pages.

Getting started

  • Connect to mbed Ethernet connector. See also. (SD card is optional)
  • Import program to mbed Compiler and compile it.
  • Copy bin file to mbed.
  • Write configuration to "mimic.cfg" and save it to mbed local file system. (If nothing, Setting is 192.168.0.39,255.255.255.0,192.168.0.254,[mbed mac address]) See also

sample of mimic.cfg

ipaddr=192.168.0.40
netmask=255.255.255.0
gateway=192.168.0.254
macaddr=02:01:02:03:04:05

Any values can be omit. If omit elements,on-chip values is used.

  • Reset mbed.
  • Open "http://[address]/" via Browser(do not use Internet exproler!), You can browse index page.

Appendix

How to connect to SD card.

Check http://www.eleki-jack.com/arm/2010/12/mbed-5.html (Japanese) Maximum length of path name is 512 characters.

How to run on LPCXpresso1769.

MbedFileServer binary file is run on LPCXpresso as is. LocalFileSystem(semihosting SVC) is ignored and LAN peripheral is detected automatically. Mac Address and setting will be on-chip setting. If you want set configuration by file, connect SD card and save "mimic.cfg" to root directory.

日本語

このプログラムは、SDカードとmbedLocalFileSystemにあるファイルを公開するシンプルなWebサーバです。 このWebサーバはlibMiMicライブラリを使用した高速なHTTPDのデモンストレーションです。

MbedFileServerは実行時にmbedとLPCXpressoを自動で認識できます。mbedコンパイラで作成したバイナリファイルをそのままLPCXpressoで動作させることが出来ます。

/media/uploads/nyatla/this_server.jpg

仕様

  • 自動プラットフォーム認識機能(mbed ,LPCXpresso1769)
  • SDカード、 LlocalFileSystem サポート。(LocalFileSystemはmbedの時だけ使用できます。LPCXpressoでは無視されます。)
  • Mbed RTOS ベースのマルチスレッドが利用できます。
  • uIPベースの独自 TCP/IP stack(MiMicIP)を搭載しています。
  • 高速なHTTPDサーバを搭載しています。(HTTP/1.1 , 持続性接続 ,同時セッション数4, RTT<=10ms , 最大転送速度 8Mbps ,SDCard 経由の転送速度 600Kbps , Chunked encoding, 最大コンテンツ転送サイズ 4GB)
  • RAM使用量 16KB+16KB(AHB SRAM - bank 0)
  • ROM使用量 70KB

デモサイト

不定期でMiMicRemoteMCU-for-Mbedのデモサイトを公開しています。http://nyatla3939.no-ip.biz/sd/index.html

このデモサイトはSDカードに保存したコンテンツを、MbedFileServerでホストしています。

Getting started

  • mbedにイーサネットコネクタを接続します。参考。SDカードは無くても動きます。
  • プログラムをImportしてコンパイルします。
  • binファイルをmbedにインストールします。
  • 初期IPアドレスの設定ファイルを書いて、"mimic.cfg"の名前でmbedドライブのルートディレクトリに入れます。 (ファイルの無い場合の設定値は、192.168.0.39,255.255.255.0,192.168.0.254,[mbed内蔵MACアドレス]になります。)参考

mimic.cfg

ipaddr=192.168.0.40
netmask=255.255.255.0
gateway=192.168.0.254
macaddr=02:01:02:03:04:05

設定値は省略できます。省略した場合は、オンチップコンフィギュレーションの値が使われます。

追加資料

SDカードの接続方法

こちらの方法でお願いします。 SDカードのサブディレクトリには対応していますが、URLが512文字以上にならないようにしてください。

LPCXpresso1769で実行する場合

MbedFileServerのバイナリはそのままLPCXpresso1769で動作します。 LocalFileSystem(semihosting SVC) の無効化とLANペリフェラルの認識は起動時に自動的に行われます。 Mac Addressはオンチップコンフィギュレーションの値が設定されます。もしファイルによって値を変更したい場合は、SDカードを接続して、"mimic.cfg" をルートディレクトリに保存してください。

See also

Files at this revision

API Documentation at this revision

Comitter:
nyatla
Date:
Sun May 05 03:32:31 2013 +0000
Parent:
9:e3de48c39ffd
Child:
11:9f5f3ee2dc63
Commit message:
update libMiMic; Add platform auto detection.; The completely same binary runs on mbed and LPCXpresso1769.;

Changed in this revision

libMiMic.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/libMiMic.lib	Mon Apr 29 08:26:22 2013 +0000
+++ b/libMiMic.lib	Sun May 05 03:32:31 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/nyatla/code/libMiMic/#1a13899a5a1c
+http://mbed.org/users/nyatla/code/libMiMic/#87fecac39b9f
--- a/main.cpp	Mon Apr 29 08:26:22 2013 +0000
+++ b/main.cpp	Sun May 05 03:32:31 2013 +0000
@@ -11,14 +11,15 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
 #include "mimic.h"
-
+#include "utils/PlatformInfo.h"
+DigitalOut mbedled(LED1);
+DigitalOut lpcxled(P0_22);
 
 /**
  * local filesystem support.
  */
-LocalFileSystem lf("local");
+LocalFileSystem2 lf("local");
 SDFileSystem sd(p5, p6, p7, p8,"sd");
-DigitalOut led1(LED1);
 unsigned int p;
 /**
  * MiMic RemoteMCU httpd.<br/>
@@ -43,7 +44,14 @@
     virtual void onRequest(HttpdConnection& i_connection)
     {
         p++;
-        led1=p%2;
+        switch(PlatformInfo::getPlatformType()){
+        case PlatformInfo::PF_MBED:
+            mbedled = p%2;
+            break;
+        case PlatformInfo::PF_LPCXPRESSO:        
+            lpcxled = p%2;
+            break;
+        }
         //try to ModLocalFileSystem
         if(this->modlocal.execute(i_connection)){
             return;
@@ -76,6 +84,7 @@
     Net net(cfg);  //create a net instance.
     //try to override setting by local file.
     if(!cfg.loadFromFile("/local/mimic.cfg")){
+        wait_ms(1000);
         cfg.loadFromFile("/sd/mimic.cfg");
     }    
     FsHttpd httpd; //create a httpd instance.