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:
Sat Apr 20 05:03:57 2013 +0000
Revision:
12:efe841863fc8
Parent:
core/driver/flash/LPC17xx_IAP.cpp@4:909dc70956e7
MiMic r218

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nyatla 0:142ee8b12fef 1 /*
nyatla 0:142ee8b12fef 2 * LPC17xx_IAP.c
nyatla 0:142ee8b12fef 3 *
nyatla 0:142ee8b12fef 4 * Created on: 2011/10/17
nyatla 0:142ee8b12fef 5 * Author: nyatla
nyatla 0:142ee8b12fef 6 */
nyatla 0:142ee8b12fef 7
nyatla 0:142ee8b12fef 8 #include "LPC17xx_IAP.h"
nyatla 0:142ee8b12fef 9
nyatla 2:b96c1e90d120 10 /**
nyatla 2:b96c1e90d120 11 * IPAに通知するCPUクロック。
nyatla 2:b96c1e90d120 12 * ここで指定したクロック以上で動作させないでください。
nyatla 2:b96c1e90d120 13 */
nyatla 4:909dc70956e7 14 #define IPA_CPU_FREQ_IN_HZ ( ( unsigned long ) 100000000 )
nyatla 0:142ee8b12fef 15 #define LPC17xx_FLASH_SECTOR_ADDR_16 ((void*)0x00010000)
nyatla 0:142ee8b12fef 16
nyatla 0:142ee8b12fef 17 //Define data structure or pointers to pass IAP command table and result table to the IAP
nyatla 0:142ee8b12fef 18 #define IAP_LOCATION 0x1FFF1FF1;
nyatla 0:142ee8b12fef 19 /**
nyatla 0:142ee8b12fef 20 * @param command
nyatla 0:142ee8b12fef 21 *
nyatla 0:142ee8b12fef 22 * @param result
nyatla 0:142ee8b12fef 23 */
nyatla 0:142ee8b12fef 24 typedef void (*_LPCXpresso_IAP_FUNC)(unsigned long command[],unsigned long result[]);
nyatla 0:142ee8b12fef 25 /**
nyatla 0:142ee8b12fef 26 *
nyatla 0:142ee8b12fef 27 */
nyatla 0:142ee8b12fef 28 _LPCXpresso_IAP_FUNC LPCXpresso_iap_entry=(_LPCXpresso_IAP_FUNC) IAP_LOCATION;
nyatla 0:142ee8b12fef 29
nyatla 0:142ee8b12fef 30
nyatla 0:142ee8b12fef 31 /**
nyatla 0:142ee8b12fef 32 * アドレスをフラッシュメモリのセクタ番号へ変換する。
nyatla 0:142ee8b12fef 33 */
nyatla 0:142ee8b12fef 34 int LPC17xx_IAP_addr2Sector(const void* addr,unsigned long* o_sector)
nyatla 0:142ee8b12fef 35 {
nyatla 0:142ee8b12fef 36 unsigned long t;
nyatla 0:142ee8b12fef 37 if(addr>=LPC17xx_FLASH_SECTOR_ADDR_16){
nyatla 0:142ee8b12fef 38 t=((((unsigned long)addr)-((unsigned long)LPC17xx_FLASH_SECTOR_ADDR_16))/0x8000)+16;
nyatla 0:142ee8b12fef 39 if(t>29){
nyatla 0:142ee8b12fef 40 return LPC17xx_IAP_FALSE;//Error
nyatla 0:142ee8b12fef 41 }
nyatla 0:142ee8b12fef 42 *o_sector=t;
nyatla 0:142ee8b12fef 43 }else{
nyatla 0:142ee8b12fef 44 *o_sector=((unsigned long)addr)/0x1000;
nyatla 0:142ee8b12fef 45 }
nyatla 0:142ee8b12fef 46 return LPC17xx_IAP_TRUE;//Error
nyatla 0:142ee8b12fef 47 }
nyatla 0:142ee8b12fef 48 /**
nyatla 0:142ee8b12fef 49 * セクタ番号をフラッシュメモリのアドレスへ変換する。
nyatla 0:142ee8b12fef 50 */
nyatla 0:142ee8b12fef 51 int LPC17xx_IAP_sector2Addr(unsigned int i_sector,void** o_addr)
nyatla 0:142ee8b12fef 52 {
nyatla 0:142ee8b12fef 53 if(i_sector<16){
nyatla 0:142ee8b12fef 54 *o_addr=(void*)(0x1000*i_sector);
nyatla 0:142ee8b12fef 55 }else if(i_sector>29){
nyatla 0:142ee8b12fef 56 return LPC17xx_IAP_FALSE;
nyatla 0:142ee8b12fef 57 }else{
nyatla 0:142ee8b12fef 58 *o_addr=(void*)(((unsigned int)LPC17xx_FLASH_SECTOR_ADDR_16)+(i_sector-16)*0x8000);
nyatla 0:142ee8b12fef 59 }
nyatla 0:142ee8b12fef 60 return LPC17xx_IAP_TRUE;
nyatla 0:142ee8b12fef 61 }
nyatla 0:142ee8b12fef 62
nyatla 0:142ee8b12fef 63
nyatla 0:142ee8b12fef 64 unsigned long LPC17xx_IAP_getSectorSize(unsigned int i_sector)
nyatla 0:142ee8b12fef 65 {
nyatla 0:142ee8b12fef 66 if(i_sector<16){
nyatla 0:142ee8b12fef 67 return 0x1000;
nyatla 0:142ee8b12fef 68 }else if(i_sector>29){
nyatla 0:142ee8b12fef 69 return 0;
nyatla 0:142ee8b12fef 70 }else{
nyatla 0:142ee8b12fef 71 return 0x8000;
nyatla 0:142ee8b12fef 72 }
nyatla 0:142ee8b12fef 73 }
nyatla 0:142ee8b12fef 74 /**
nyatla 0:142ee8b12fef 75 * IAPのprepareコマンドを実行
nyatla 0:142ee8b12fef 76 */
nyatla 0:142ee8b12fef 77 unsigned long LPC17xx_IAP_prepare(unsigned long i_start,unsigned long i_end)
nyatla 0:142ee8b12fef 78 {
nyatla 0:142ee8b12fef 79 unsigned long b[8];
nyatla 0:142ee8b12fef 80 unsigned long c[5];
nyatla 0:142ee8b12fef 81 unsigned long r[5];
nyatla 0:142ee8b12fef 82 c[0]=50;
nyatla 0:142ee8b12fef 83 c[1]=i_start;
nyatla 0:142ee8b12fef 84 c[2]=i_end;
nyatla 0:142ee8b12fef 85 memcpy(b,(void*)0x10000000,32);
nyatla 0:142ee8b12fef 86 LPCXpresso_iap_entry(c,r);
nyatla 0:142ee8b12fef 87 memcpy((void*)0x10000000,b,32);
nyatla 0:142ee8b12fef 88 return r[0];
nyatla 0:142ee8b12fef 89 }
nyatla 0:142ee8b12fef 90 /**
nyatla 0:142ee8b12fef 91 * IAPのcopy ram to flashコマンドを実行。
nyatla 0:142ee8b12fef 92 */
nyatla 2:b96c1e90d120 93 unsigned long LPC17xx_IAP_copyRam2Flash(const void* i_flash_addr,const void* i_src_addr,unsigned long i_size)
nyatla 0:142ee8b12fef 94 {
nyatla 0:142ee8b12fef 95 unsigned long b[8];
nyatla 0:142ee8b12fef 96 unsigned long c[5];
nyatla 0:142ee8b12fef 97 unsigned long r[5];
nyatla 0:142ee8b12fef 98 c[0]=51;
nyatla 0:142ee8b12fef 99 c[1]=(unsigned long)i_flash_addr;
nyatla 0:142ee8b12fef 100 c[2]=(unsigned long)i_src_addr;
nyatla 0:142ee8b12fef 101 c[3]=i_size;
nyatla 2:b96c1e90d120 102 c[4]=IPA_CPU_FREQ_IN_HZ/1000;
nyatla 0:142ee8b12fef 103 memcpy(b,(void*)0x10000000,32);
nyatla 0:142ee8b12fef 104 LPCXpresso_iap_entry(c,r);
nyatla 0:142ee8b12fef 105 memcpy((void*)0x10000000,b,32);
nyatla 0:142ee8b12fef 106 return r[0];
nyatla 0:142ee8b12fef 107 }
nyatla 0:142ee8b12fef 108 /**
nyatla 0:142ee8b12fef 109 * IAPのeraseコマンドを実行
nyatla 0:142ee8b12fef 110 */
nyatla 2:b96c1e90d120 111 unsigned long LPC17xx_IAP_erase(unsigned long i_start,unsigned long i_end)
nyatla 0:142ee8b12fef 112 {
nyatla 0:142ee8b12fef 113 unsigned long b[8];
nyatla 0:142ee8b12fef 114 unsigned long c[5];
nyatla 0:142ee8b12fef 115 unsigned long r[5];
nyatla 0:142ee8b12fef 116 c[0]=52;
nyatla 0:142ee8b12fef 117 c[1]=i_start;
nyatla 0:142ee8b12fef 118 c[2]=i_end;
nyatla 2:b96c1e90d120 119 c[3]=IPA_CPU_FREQ_IN_HZ/1000;
nyatla 0:142ee8b12fef 120 memcpy(b,(void*)0x10000000,32);
nyatla 0:142ee8b12fef 121 LPCXpresso_iap_entry(c,r);
nyatla 0:142ee8b12fef 122 memcpy((void*)0x10000000,b,32);
nyatla 0:142ee8b12fef 123 return r[0];
nyatla 0:142ee8b12fef 124 }