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:
Wed Nov 19 14:45:17 2014 +0000
Revision:
109:18f12ac01097
Parent:
91:db8279c869d3
Child:
114:f6aef16d4e60
new MiMicIP API;

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