This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

libMiMic(MiMic library for mbed)は、WebService機能を提供するSDKです。 mbedでWebAPIに対応したネットワークデバイスを簡単に作ることが出来ます。

libMiMicはMiMic projectで開発しています。MiMic projectについてはこちらをご覧ください。 http://nyatla.jp/mimic/wp/

構成

libMiMicはmbedRTOS上で動作し、ユーザアプリケーションにAPIを提供します。コアAPIはC言語で記述されていますが、使用頻度の高いものについてはmbed向けのC++APIが準備されています。

/media/uploads/nyatla/libmimic-sdk.png

※libMiMicはmbedの標準イーサネットドライバをしようしていません。

標準イーサネットドライバと同時に使用することはできません。

  • MiMicIP - IPv4スタックです。レテンシとメモリ消費量を抑えたuipベースのライブラリです。
  • ARP/ICMP/UDP/TCP - 基礎的なソケットAPIを提供します。APIは独自です。
  • HTTP/1.1 Server - HTTP/1.1に対応したサーバです。マルチセッション・Chunked・持続性接続に対応しています。
  • HTTP Modules - HTTP/1.1の機能モジュールです。以下のモジュールがあります。
    • ROM file provider - ROMに格納したファイルイメージを公開します。
    • File system provider - mbedファイルシステムを公開します。
    • Onchip configuration - プログラムフラッシュを利用して設定を保存します。
    • MiMicVM processor - RPCリクエスト(MiMicVM)を処理します。
    • FileUpload - ファイルアップロードを受け取ります。
    • URL decoder - HTTPリクエストを解析します。
    • UPnP handler -UPnPメッセージを処理します。
    • WebSocket - Websocketサーバです。
  • mDNS - マルチキャストDNSサービスです。
  • UPnP - UPnP/1.0の機能を提供します。UPnP handlerと協調して動作します。(現在はデバイス探索(SSDP)・デスクリプション(Description)のみ実装してあります。)
  • DHCP/APIPA - ゼロコンフィギュレーション用のモジュールです。
  • HTTP/1.1 Client
  • mbed C++ class library - mbed向けのC++CPIです。C言語のものより簡単です。

対応機種

  • mbed(mbed LPC1768)
  • LPCXpresso1769

プログラム

Import programMiMicRemoteMCU-for-Mbed

MiMic RemoteMCU for mbed. This program provides MCU control API over REST API. It can control MCU from Javascript,PHP or any HTTP rest client directly. And, The application has self development environment.

Import programMbedFileServer

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

サンプル

Import programMiMicSimpleHttpd

This is a simplest HTTP server made ​​of libMiMic. It will echo back a request path.

Import programUPnPBasicDevice

Simplest UPnP basic device example. This program to run UPnP basic device on the mbed.

Import programWebSocketSample

MiMicSDK Websocket module sample program.

Import programHttpClientSamlpe

A http client sample program.

Import programTcpSocketClientSamlpe

MiMicSDK Tcp client socket sample program.

Import programUdpSocketSamlpe

Udp socket sample program. This program will send back the received packet.

チュートリアル

English

libMiMic(MiMic library for mbed) is SDK which provides Webservice functions. It can be created networking device easily using mbed.

See more MiMic information, See MiMic project website. http://nyatla.jp/mimic/wp/

Structure

libMiMic run on mbed RTOS and provides networking API to user application. This library has C++ class API for the mbed, and low-level C language API.

/media/uploads/nyatla/libmimic-sdk.png

For WebService general, it can be written in a simple C + + API.

libMiMic does not have the standard Ethernet driver of mbed. It is not possible that will be used with the standard Ethernet driver.

  • MiMicIP - IPv4 protocol stack. This is based uip which is reduced memory and latency.
  • ARP / ICMP / UDP / TCP - Those are provide basic IP protocols.
  • HTTP/1.1 Server - The Http server compatible HTTP/1.1. It supports multi-session, chunked transport, persistent connection.
  • HTTP Modules - There are addon-module for HTTP server. The following modules.
    • ROM file module - Publish the file images in ROM.
    • File system module - Publish thefiles in mbed file system.
    • Onchip configuration module - To save the network settings to the program flash via REST.
    • MiMicVM module - To handle the (MiMicVM) RPC request.
    • FileUpload module - Accept a file via HTTP POST.
    • URL dedoce module - A versatility URL decoder.
    • UPnP handle module - To handle UPnP messages.
    • UPnP - This provides UPnP/1.0 device functions. It works together with UPnP handler.
    • Websocket - websocket (version13) server
  • mDNS Service - DNS-SD protocol server.
  • UPnP - This provides UPnP/1.0 device functions which works with UPnP handler. (You have been implemented (SSDP) ? description only (Description) device search now.) It is a module zero configuration for - DHCP / APIPA. mbed C + + class library - C of mbed for + + is the CPI. It is simple than that of the C language.
  • DHCP/APIPA - It support zero-cpnfigulation.
  • mbed C++ class library. Almost APIs for Web applications are available.
  • HTTP/1.1 Client

Supported target

  • mbed(mbed LPC1768)
  • LPCXpresso1769

Application

Import programMiMicRemoteMCU-for-Mbed

MiMic RemoteMCU for mbed. This program provides MCU control API over REST API. It can control MCU from Javascript,PHP or any HTTP rest client directly. And, The application has self development environment.

Import programMbedFileServer

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

Sample

Import programMiMicSimpleHttpd

This is a simplest HTTP server made ​​of libMiMic. It will echo back a request path.

Import programUPnPBasicDevice

Simplest UPnP basic device example. This program to run UPnP basic device on the mbed.

Import programWebSocketSample

MiMicSDK Websocket module sample program.

Import programHttpClientSamlpe

A http client sample program.

Import programTcpSocketClientSamlpe

MiMicSDK Tcp client socket sample program.

Import programUdpSocketSamlpe

Udp socket sample program. This program will send back the received packet.

Tutorial

Committer:
nyatla
Date:
Thu May 22 12:59:50 2014 +0000
Revision:
68:f7def7eb5504
Child:
69:8c5f220441f5
MiMic-core ?344???;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nyatla 68:f7def7eb5504 1 /*
nyatla 68:f7def7eb5504 2 * NyLPC_IEthernetDevice.h
nyatla 68:f7def7eb5504 3 *
nyatla 68:f7def7eb5504 4 * Created on: 2011/12/06
nyatla 68:f7def7eb5504 5 * MiMicのイーサネットドライバインタフェイスを定義する。
nyatla 68:f7def7eb5504 6 */
nyatla 68:f7def7eb5504 7 #ifndef NyLPC_IEthernetDevice_h
nyatla 68:f7def7eb5504 8 #define NyLPC_IEthernetDevice_h
nyatla 68:f7def7eb5504 9 #include "NyLPC_stdlib.h"
nyatla 68:f7def7eb5504 10 #include "NyLPC_uipService.h"
nyatla 68:f7def7eb5504 11
nyatla 68:f7def7eb5504 12 #ifdef __cplusplus
nyatla 68:f7def7eb5504 13 extern "C" {
nyatla 68:f7def7eb5504 14 #endif /* __cplusplus */
nyatla 68:f7def7eb5504 15
nyatla 68:f7def7eb5504 16 typedef struct NyLPC_TiEthernetDevice NyLPC_TiEthernetDevice_t;
nyatla 68:f7def7eb5504 17
nyatla 68:f7def7eb5504 18 /**非同期イベントのメッセージタイプ*/
nyatla 68:f7def7eb5504 19 typedef unsigned int NyLPC_TiEthernetDevice_EVENT;
nyatla 68:f7def7eb5504 20 /**TXが到達した*/
nyatla 68:f7def7eb5504 21 #define NyLPC_TiEthernetDevice_EVENT_ON_TX 1
nyatla 68:f7def7eb5504 22 /**RXが到達した*/
nyatla 68:f7def7eb5504 23 #define NyLPC_TiEthernetDevice_EVENT_ON_RX 2
nyatla 68:f7def7eb5504 24
nyatla 68:f7def7eb5504 25
nyatla 68:f7def7eb5504 26 typedef void (*NyLPC_TiEthernetDevice_onEvent)(void* i_param,NyLPC_TiEthernetDevice_EVENT i_type);
nyatla 68:f7def7eb5504 27
nyatla 68:f7def7eb5504 28 /**
nyatla 68:f7def7eb5504 29 * 送信バッフメモリのヘッダ。
nyatla 68:f7def7eb5504 30 * この構造体は、TXバッファメモリブロックのヘッダーです。
nyatla 68:f7def7eb5504 31 * TXバッファメモリブロックは、この構造体の後ろに、sizeに一致したメモリを連結したもので表現します。
nyatla 68:f7def7eb5504 32 * <pre>
nyatla 68:f7def7eb5504 33 * buffer=[struct NyLPC_TTxBufferHeader][n]
nyatla 68:f7def7eb5504 34 * </pre>
nyatla 68:f7def7eb5504 35 */
nyatla 68:f7def7eb5504 36 struct NyLPC_TTxBufferHeader
nyatla 68:f7def7eb5504 37 {
nyatla 68:f7def7eb5504 38 //メモリブロックの参照カウンタ。
nyatla 68:f7def7eb5504 39 NyLPC_TInt8 ref;
nyatla 68:f7def7eb5504 40 //送信用にロックしたかを示すフラグ
nyatla 68:f7def7eb5504 41 NyLPC_TUInt8 is_lock;
nyatla 68:f7def7eb5504 42 //32ビット境界に合わせるためのパディング。
nyatla 68:f7def7eb5504 43 NyLPC_TUInt16 padding;
nyatla 68:f7def7eb5504 44 };
nyatla 68:f7def7eb5504 45
nyatla 68:f7def7eb5504 46
nyatla 68:f7def7eb5504 47
nyatla 68:f7def7eb5504 48 /**
nyatla 68:f7def7eb5504 49 * 受信キューの先頭にあるデータを返す。
nyatla 68:f7def7eb5504 50 * 関数は、受信キューのポインタを操作しない。続けて読み出したとしても、同じポインターを返す。
nyatla 68:f7def7eb5504 51 * 次のデータを得るには、nextRxEthFrameを呼び出す。
nyatla 68:f7def7eb5504 52 * #制限として、返却したポインタの内容は、一時的に書き換え可としてください。(この制限は将来削除します。)
nyatla 68:f7def7eb5504 53 * @return
nyatla 68:f7def7eb5504 54 * 成功した場合、受信データを格納したバッファポインタ。返却値は、nextRxEthFrameをコールするまで有効である。
nyatla 68:f7def7eb5504 55 * 存在しない場合NULL。
nyatla 68:f7def7eb5504 56 */
nyatla 68:f7def7eb5504 57 #define NyLPC_iEthernetDevice_getRxEthFrame(i,p) (i)->getRxEthFrame(p)
nyatla 68:f7def7eb5504 58 typedef void* (*NyLPC_TiEthernetDevice_getRxEthFrame)(unsigned short* o_len_of_data);
nyatla 68:f7def7eb5504 59
nyatla 68:f7def7eb5504 60
nyatla 68:f7def7eb5504 61
nyatla 68:f7def7eb5504 62 /**
nyatla 68:f7def7eb5504 63 * getRxEthFrameで得たメモリを破棄して、次のRXデータを準備する。
nyatla 68:f7def7eb5504 64 * getRxEthFrameで返したメモリの内容の有効期間はここで終了するので注意すること。
nyatla 68:f7def7eb5504 65 */
nyatla 68:f7def7eb5504 66 #define NyLPC_iEthernetDevice_nextRxEthFrame(i) (i)->nextRxEthFrame()
nyatla 68:f7def7eb5504 67 typedef void (*NyLPC_TiEthernetDevice_nextRxEthFrame)(void);
nyatla 68:f7def7eb5504 68
nyatla 68:f7def7eb5504 69
nyatla 68:f7def7eb5504 70 /**
nyatla 68:f7def7eb5504 71 * 送信バッファを得る。
nyatla 68:f7def7eb5504 72 * 関数は、i_hintで示されるサイズのメモリブロックを確保しようとするが、実際にはそれよりも小さいことがある。
nyatla 68:f7def7eb5504 73 * @param i_hint
nyatla 68:f7def7eb5504 74 * 確保してほしいメモリサイズ
nyatla 68:f7def7eb5504 75 * @param o_size
nyatla 68:f7def7eb5504 76 * 実際に割り当てたメモリのサイズ
nyatla 68:f7def7eb5504 77 * @return
nyatla 68:f7def7eb5504 78 * 割り当てたメモリブロックのヘッダ。
nyatla 68:f7def7eb5504 79 */
nyatla 68:f7def7eb5504 80 #define NyLPC_iEthernetDevice_allocTxBuf(i,h,s) (i)->allocTxBuf((h),(s))
nyatla 68:f7def7eb5504 81 typedef struct NyLPC_TTxBufferHeader* (*NyLPC_TiEthernetDevice_allocTxBuf)(NyLPC_TUInt16 i_hint,NyLPC_TUInt16* o_size);
nyatla 68:f7def7eb5504 82
nyatla 68:f7def7eb5504 83
nyatla 68:f7def7eb5504 84 /**
nyatla 68:f7def7eb5504 85 * alloc_TxBufで得た送信バッファを開放する。
nyatla 68:f7def7eb5504 86 * 関数は、メモリブロックの参照カウンタを1減算する。
nyatla 68:f7def7eb5504 87 */
nyatla 68:f7def7eb5504 88 #define NyLPC_iEthernetDevice_releaseTxBuf(i,b) (i)->releaseTxBuf(b)
nyatla 68:f7def7eb5504 89 typedef void (*NyLPC_TiEthernetDevice_releaseTxBuf)(struct NyLPC_TTxBufferHeader* i_buf);
nyatla 68:f7def7eb5504 90
nyatla 68:f7def7eb5504 91
nyatla 68:f7def7eb5504 92
nyatla 68:f7def7eb5504 93 /**
nyatla 68:f7def7eb5504 94 * イーサネットパケット構造体i_bufの内容を送信する。
nyatla 68:f7def7eb5504 95 * @param i_buf
nyatla 68:f7def7eb5504 96 * allocTxBufで得たメモリか、初期化したNyLPC_TTxBufferHeaderメモリブロックを指定する。
nyatla 68:f7def7eb5504 97 * 送信が終わるまでの間、メモリを開放してはならない。
nyatla 68:f7def7eb5504 98 * #外部で確保したメモリについては、利用不能なケースがあるかもしれない。現在のMiMicでは、使用できることを前提としている。
nyatla 68:f7def7eb5504 99 * @oaram i_size
nyatla 68:f7def7eb5504 100 * i_bufの後ろに連結されているデータメモリの長さ
nyatla 68:f7def7eb5504 101 */
nyatla 68:f7def7eb5504 102 #define NyLPC_iEthernetDevice_sendTxEthFrame(i,b,s) (i)->sendTxEthFrame((b),(s))
nyatla 68:f7def7eb5504 103 typedef void (*NyLPC_TiEthernetDevice_sendTxEthFrame)(struct NyLPC_TTxBufferHeader* i_buf,unsigned short i_size);
nyatla 68:f7def7eb5504 104
nyatla 68:f7def7eb5504 105
nyatla 68:f7def7eb5504 106 /**
nyatla 68:f7def7eb5504 107 * この関数は、送信キューの状態を進行させるタイミングを与える。
nyatla 68:f7def7eb5504 108 * 外部関数が、送信キューにセットしたパケットの送信待ちをするときに呼び出す。
nyatla 68:f7def7eb5504 109 */
nyatla 68:f7def7eb5504 110 #define NyLPC_iEthernetDevice_processTx(i) (i)->processTx()
nyatla 68:f7def7eb5504 111 typedef void (*NyLPC_TiEthernetDevice_processTx)(void);
nyatla 68:f7def7eb5504 112
nyatla 68:f7def7eb5504 113
nyatla 68:f7def7eb5504 114
nyatla 68:f7def7eb5504 115 /**
nyatla 68:f7def7eb5504 116 * この関数は、ドライバを開始します。
nyatla 68:f7def7eb5504 117 * @param i_eth_addr
nyatla 68:f7def7eb5504 118 * イーサネットアドレス
nyatla 68:f7def7eb5504 119 * @param i_handler
nyatla 68:f7def7eb5504 120 * 通知ハンドラ
nyatla 68:f7def7eb5504 121 * @param i_param
nyatla 68:f7def7eb5504 122 * 通知ハンドラに渡るパラメータ
nyatla 68:f7def7eb5504 123 */
nyatla 68:f7def7eb5504 124 #define NyLPC_iEthernetDevice_start(i,a,h,p) (i)->start((a),(h),(p))
nyatla 68:f7def7eb5504 125 typedef NyLPC_TBool(*NyLPC_TiEthernetDevice_start)(const struct NyLPC_TEthAddr* i_eth_addr,NyLPC_TiEthernetDevice_onEvent i_handler,void* i_param);
nyatla 68:f7def7eb5504 126
nyatla 68:f7def7eb5504 127
nyatla 68:f7def7eb5504 128 /**
nyatla 68:f7def7eb5504 129 * この関数はドライバを停止します。
nyatla 68:f7def7eb5504 130 */
nyatla 68:f7def7eb5504 131 #define NyLPC_iEthernetDevice_stop(i) (i)->stop()
nyatla 68:f7def7eb5504 132 typedef void(*NyLPC_TiEthernetDevice_stop)(void);
nyatla 68:f7def7eb5504 133
nyatla 68:f7def7eb5504 134
nyatla 68:f7def7eb5504 135 /**
nyatla 68:f7def7eb5504 136 * デバイス名を返します。
nyatla 68:f7def7eb5504 137 */
nyatla 68:f7def7eb5504 138 #define NyLPC_iEthernetDevice_getDevicName(i) ((i)->_device_name)
nyatla 68:f7def7eb5504 139
nyatla 68:f7def7eb5504 140 /**
nyatla 68:f7def7eb5504 141 * イーサネットデバイスのアクセスインターフェイス
nyatla 68:f7def7eb5504 142 * イーサネットデバイスの管理するメモリブロック、ペリフェラル制御のインタフェイスを提供する。
nyatla 68:f7def7eb5504 143 *
nyatla 68:f7def7eb5504 144 */
nyatla 68:f7def7eb5504 145 struct TiEthernetDevice
nyatla 68:f7def7eb5504 146 {
nyatla 68:f7def7eb5504 147 /** NyLPC_iEthernetDevice_getDevicNameで返却する値*/
nyatla 68:f7def7eb5504 148 const char* _device_name;//pointer to device name.
nyatla 68:f7def7eb5504 149 NyLPC_TiEthernetDevice_start start;
nyatla 68:f7def7eb5504 150 NyLPC_TiEthernetDevice_stop stop;
nyatla 68:f7def7eb5504 151 NyLPC_TiEthernetDevice_getRxEthFrame getRxEthFrame;
nyatla 68:f7def7eb5504 152 NyLPC_TiEthernetDevice_nextRxEthFrame nextRxEthFrame; //nextRxEthFrame;
nyatla 68:f7def7eb5504 153 NyLPC_TiEthernetDevice_allocTxBuf allocTxBuf;
nyatla 68:f7def7eb5504 154 NyLPC_TiEthernetDevice_releaseTxBuf releaseTxBuf;
nyatla 68:f7def7eb5504 155 NyLPC_TiEthernetDevice_sendTxEthFrame sendTxEthFrame;
nyatla 68:f7def7eb5504 156 NyLPC_TiEthernetDevice_processTx processTx;
nyatla 68:f7def7eb5504 157 };
nyatla 68:f7def7eb5504 158
nyatla 68:f7def7eb5504 159
nyatla 68:f7def7eb5504 160
nyatla 68:f7def7eb5504 161
nyatla 68:f7def7eb5504 162 #ifdef __cplusplus
nyatla 68:f7def7eb5504 163 }
nyatla 68:f7def7eb5504 164 #endif /* __cplusplus */
nyatla 68:f7def7eb5504 165
nyatla 68:f7def7eb5504 166 #endif
nyatla 68:f7def7eb5504 167