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

Files at this revision

API Documentation at this revision

Comitter:
nyatla
Date:
Fri Jun 20 15:38:30 2014 +0000
Parent:
76:b375b3d750d8
Child:
78:8cdb8fc7eda8
Commit message:
MiMicCore??363????; mbed/jsonrpc?????????

Changed in this revision

core/NyLPC_cMiMicEnv.c Show annotated file Show diff for this revision Revisions of this file
core/http/json/NyLPC_cJsonRpcParser.h Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/MbedJsApi.h Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/PortIn.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/PortOut.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/PwmOut.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/RpcAnalogIn.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/RpcAnalogOut.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/RpcBusIn.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/RpcBusInOut.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/RpcBusOut.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/RpcDigitalIn.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/RpcDigitalOut.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/RpcHandlerBase.h Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/SPI.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/SPISlave.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/TargetTypes.h Show annotated file Show diff for this revision Revisions of this file
mbed/jsonrpc/Target_LPC176x.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/core/NyLPC_cMiMicEnv.c	Sat Jun 14 17:42:11 2014 +0000
+++ b/core/NyLPC_cMiMicEnv.c	Fri Jun 20 15:38:30 2014 +0000
@@ -1,7 +1,7 @@
 #include "NyLPC_cMiMicEnv.h"
 #include "../uip/NyLPC_cUipService_protected.h"
 
-const static char* VERSION="MiMic/1.5.5";
+const static char* VERSION="MiMic/1.5.6";
 
 #if NyLPC_MCU==NyLPC_MCU_LPC4088
 const static char* MCU="LPC4088";
--- a/core/http/json/NyLPC_cJsonRpcParser.h	Sat Jun 14 17:42:11 2014 +0000
+++ b/core/http/json/NyLPC_cJsonRpcParser.h	Fri Jun 20 15:38:30 2014 +0000
@@ -71,12 +71,12 @@
 #define NyLPC_TJsonRpcParserResult_TYPE_METHOD	2
 
 /** NyLPC_TJsonRpcParserResultが格納できる引数の最大数。パラメータの最大数に等しくなります。*/
-#define NyLPC_TJsonRpcParserResult_NUMBER_OF_PARAM_INDEX 16
+#define NyLPC_TJsonRpcParserResult_NUMBER_OF_PARAM_INDEX 32
 /**
  * NyLPC_TJsonRpcParserResultが格納できるパラメータの総バイト数。
  * (文字数+1)+(uint32|int32)*4+uint8の合計値です。
  */
-#define NyLPC_TJsonRpcParserResult_PARAM_BUF 128
+#define NyLPC_TJsonRpcParserResult_PARAM_BUF 256
 
 /**
  * JSONRPC構文のパース結果を格納します。
--- a/mbed/jsonrpc/MbedJsApi.h	Sat Jun 14 17:42:11 2014 +0000
+++ b/mbed/jsonrpc/MbedJsApi.h	Fri Jun 20 15:38:30 2014 +0000
@@ -5,11 +5,17 @@
 {
     class MbedJsApi{
     public:
-        /**
-         * MiMicRPCの定義するピンIDをmbedピンIDへ変換します。
-         */
-        static PinName pinId2PinName(unsigned int i_id);
-    public:
         const static struct NyLPC_TJsonRpcClassDef RPC_MBED_DIGITAL_OUT;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_DIGITAL_IN;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_ANALOG_IN;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_ANALOG_OUT;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_BUS_IN;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_BUS_OUT;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_BUS_IN_OUT;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_PWM_OUT;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_PORT_OUT;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_PORT_IN;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_SPI;
+        const static struct NyLPC_TJsonRpcClassDef RPC_MBED_SPI_SLAVE;
     };
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/PortIn.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,48 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class PortInHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//ud
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            unsigned int port;
+            int mask;
+            if(getParamUInt(mod,i_rpc,port,0)){
+                if(getParamInt(mod,i_rpc,mask,1)){
+                 	addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<PortIn>(new PortIn(portId2PortName(port),mask)));
+                }
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PortIn* inst=(PortIn*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"	,"ud"   ,PortInHandler::new1},
+    { "read"	,"d"	,PortInHandler::read},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_PORT_IN={
+    "mbedJS","PortIn",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/PortOut.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,63 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class PortOutHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//ud
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            unsigned int port;
+            int mask;
+            if(getParamUInt(mod,i_rpc,port,0)){
+                if(getParamInt(mod,i_rpc,mask,1)){
+                 	addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<PortOut>(new PortOut(portId2PortName(port),mask)));
+                }
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PortOut* inst=(PortOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool write(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PortOut* inst=(PortOut*)getObjectBatch(mod,i_rpc);
+            if(inst!=NULL){
+            	int v;
+				if(getParamInt(mod,i_rpc,v,1)){
+					inst->write(v);
+					mod->putResult(i_rpc->method.id,"");
+				}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"	,"ud"   ,PortOutHandler::new1},
+    { "read"	,"d"	,PortOutHandler::read},
+    { "write"	,"dd"	,PortOutHandler::write},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_PORT_OUT={
+    "mbedJS","PortOut",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/PwmOut.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,151 @@
+#include "RpcHandlerBase.h"
+
+namespace MiMic
+{
+    class PwmOutHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//u
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin;
+            if(getParamsAsPin(mod,i_rpc,&pin,1)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<PwmOut>(new PwmOut(pin)));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool write_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PwmOut* inst=(PwmOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->write((float)v/10000.f);
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PwmOut* inst=(PwmOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()*10000));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool period_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PwmOut* inst=(PwmOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->period((float)v/10000.f);
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool period_ms(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PwmOut* inst=(PwmOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->period_ms(v);
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool period_us(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PwmOut* inst=(PwmOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->period_us(v);
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool pulsewidth_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PwmOut* inst=(PwmOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->pulsewidth((float)v/10000.0f);
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool pulsewidth_ms(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PwmOut* inst=(PwmOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->pulsewidth_ms(v);
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool pulsewidth_us(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PwmOut* inst=(PwmOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->pulsewidth_us(v);
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"   		,"u"    ,PwmOutHandler::new1},
+    { "write_fx"		,"dd"   ,PwmOutHandler::write_fx},
+    { "read_fx"      	,"d"    ,PwmOutHandler::read_fx},
+    { "period"    		,"dd"   ,PwmOutHandler::period_fx},
+    { "period_ms"		,"dd"   ,PwmOutHandler::period_ms},
+    { "period_us"		,"dd"	,PwmOutHandler::period_us},
+    { "pulsewidth_fx"	,"dd"   ,PwmOutHandler::pulsewidth_fx},
+    { "pulsewidth_ms"	,"dd"   ,PwmOutHandler::pulsewidth_ms},
+    { "pulsewidth_us"	,"dd"	,PwmOutHandler::pulsewidth_us},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_PWM_OUT={
+    "mbedJS","PwmOut",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcAnalogIn.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,57 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class AnalogInHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//u
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin;
+            if(getParamsAsPin(mod,i_rpc,&pin,1)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<AnalogIn>(new AnalogIn(pin)));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read_u16(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            AnalogIn* inst=(AnalogIn*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read_u16()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        /** 10000倍したread()の値を返す*/
+        static NyLPC_TBool read_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            AnalogIn* inst=(AnalogIn*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()*10000));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"		,"u"    ,AnalogInHandler::new1},
+    { "read_u16"	,"d"	,AnalogInHandler::read_u16},
+    { "read_fx"	,"d"		,AnalogInHandler::read_fx},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_ANALOG_IN={
+    "mbedJS","AnalogIn",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcAnalogOut.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,75 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class AnalogOutHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//u
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin;
+            if(getParamsAsPin(mod,i_rpc,&pin,1)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<AnalogOut>(new AnalogOut(pin)));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        /** 10000倍したread()の値を返す*/
+        static NyLPC_TBool read_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            AnalogOut* inst=(AnalogOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()*10000));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool write_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            AnalogOut* inst=(AnalogOut*)getObjectBatch(mod,i_rpc);
+            if(inst!=NULL){
+            	int v;
+				if(getParamInt(mod,i_rpc,v,1)){
+					inst->write((float)v/10000.0f);
+					mod->putResult(i_rpc->method.id,"");
+				}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool write_u16(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            AnalogOut* inst=(AnalogOut*)getObjectBatch(mod,i_rpc);
+            if(inst!=NULL){
+            	unsigned int v;
+				if(getParamUInt(mod,i_rpc,v,1)){
+					inst->write((unsigned int)v);
+					mod->putResult(i_rpc->method.id,"");
+				}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"		,"u"    ,AnalogOutHandler::new1},
+    { "read_fx"		,"d"	,AnalogOutHandler::read_fx},
+    { "write_fx"	,"dd"	,AnalogOutHandler::write_fx},
+    { "write_u16"	,"du"	,AnalogOutHandler::write_u16},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_ANALOG_OUT={
+    "mbedJS","AnalogOut",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcBusIn.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,60 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class BusInHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//uuuuuuuuuuuuuuuu
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin[16];
+            if(getParamsAsPin(mod,i_rpc,pin,16)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<BusIn>(new BusIn(pin)));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusIn* inst=(BusIn*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool mode(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusIn* inst=(BusIn*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->mode(pinmodeId2PinMode(v));
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"	,"uuuuuuuuuuuuuuuu",BusInHandler::new1},
+    { "read"	,"d"	,BusInHandler::read},
+    { "mode"	,"dd"	,BusInHandler::mode},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_BUS_IN={
+    "mbedJS","BusIn",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcBusInOut.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,99 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class BusInOutHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//uuuuuuuuuuuuuuuu
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin[16];
+            if(getParamsAsPin(mod,i_rpc,pin,16)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<BusInOut>(new BusInOut(pin)));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusInOut* inst=(BusInOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool write(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusInOut* inst=(BusInOut*)getObjectBatch(mod,i_rpc);
+            if(inst!=NULL){
+            	int v;
+				if(getParamInt(mod,i_rpc,v,1)){
+					inst->write(v);
+					mod->putResult(i_rpc->method.id,"");
+				}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool output(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusInOut* inst=(BusInOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				inst->output();
+				mod->putResult(i_rpc->method.id,"");
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool input(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusInOut* inst=(BusInOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				inst->input();
+				mod->putResult(i_rpc->method.id,"");
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool mode(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusInOut* inst=(BusInOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->mode(pinmodeId2PinMode(v));
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"	,"uuuuuuuuuuuuuuuu"    ,BusInOutHandler::new1},
+    { "read"	,"d"	,BusInOutHandler::read},
+    { "write"	,"dd"	,BusInOutHandler::write},
+    { "output"	,"d"	,BusInOutHandler::output},
+    { "input"	,"d"	,BusInOutHandler::input},
+    { "mode"	,"dd"	,BusInOutHandler::mode},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_BUS_IN_OUT={
+    "mbedJS","BusInOut",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcBusOut.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,61 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class BusOutHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//uuuuuuuuuuuuuuuu
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin[16];
+            if(getParamsAsPin(mod,i_rpc,pin,16)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<BusOut>(new BusOut(pin)));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+
+        static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusOut* inst=(BusOut*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool write(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            BusOut* inst=(BusOut*)getObjectBatch(mod,i_rpc);
+            if(inst!=NULL){
+            	int v;
+				if(getParamInt(mod,i_rpc,v,1)){
+					inst->write(v);
+					mod->putResult(i_rpc->method.id,"");
+				}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"	,"uuuuuuuuuuuuuuuu"    ,BusOutHandler::new1},
+    { "read"	,"d"	,BusOutHandler::read},
+    { "write"	,"dd"	,BusOutHandler::write},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_BUS_OUT={
+    "mbedJS","BusOut",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcDigitalIn.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,61 @@
+#include "RpcHandlerBase.h"
+
+namespace MiMic
+{
+    class DigitalInHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//u
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin;
+            if(getParamsAsPin(mod,i_rpc,&pin,1)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<DigitalIn>(new DigitalIn(pin)));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            DigitalIn* inst=(DigitalIn*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool mode(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            DigitalIn* inst=(DigitalIn*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->mode(pinmodeId2PinMode(v));
+					mod->putResult(i_rpc->method.id,"");
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"   ,"u"    ,DigitalInHandler::new1},
+    { "read"    ,"d"    ,DigitalInHandler::read},
+    { "mode"   ,"dd"	,DigitalInHandler::mode},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_DIGITAL_IN={
+    "mbedJS","DigitalIn",func_table
+};
+
+
+
+}
+
--- a/mbed/jsonrpc/RpcDigitalOut.cpp	Sat Jun 14 17:42:11 2014 +0000
+++ b/mbed/jsonrpc/RpcDigitalOut.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -1,75 +1,42 @@
-#include "mod/ModJsonRpc.h"
-#include "MbedJsApi.h"
-#include "mbed.h"
+#include "RpcHandlerBase.h"
+
 namespace MiMic
 {
-
-
-    class RpcHandlerBase
-    {
-    public:
-        static void addNewObjectBatch(ModJsonRpc& i_mod,unsigned int i_id,ModJsonRpc::BasicRpcObject* i_new_object)
-        {
-            int i=i_mod.addObject(i_new_object);
-            if(i<0){
-                delete i_new_object;
-                i_mod.putError(i_id,ModJsonRpc::INVALID_PARAMS);
-                return;
-            }
-            i_mod.putResult(i_id,"%d",i);
-            return;
-        }
-        static void* getObjectBatch(ModJsonRpc& i_mod,unsigned int i_id,int i_iid)
-        {
-            void* ret=i_mod.getObject(i_iid);
-            if(ret==NULL){
-                i_mod.putError(i_id,ModJsonRpc::INTERNAL_ERROR);
-            }
-            return ret;
-        }
-    };
-    
     class DigitalOutHandler :RpcHandlerBase
     {
     public:
         static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
         {
+            //u
             ModJsonRpc* mod=(ModJsonRpc*)i_param;
-            NyLPC_TUInt32 pin;
-            if(!NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,0,&pin)){
-                mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
-            }else{
-                addNewObjectBatch(*mod,i_rpc->method.id,new ModJsonRpc::RpcObject<DigitalOut>(new DigitalOut(MbedJsApi::pinId2PinName(pin))));
+            PinName pin;
+            if(getParamsAsPin(mod,i_rpc,&pin,1)){
+                addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<DigitalOut>(new DigitalOut(pin)));
             }
             return NyLPC_TBool_TRUE;
         }
         static NyLPC_TBool new2(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
         {
+            //ud return iid
             ModJsonRpc* mod=(ModJsonRpc*)i_param;
-            NyLPC_TUInt32 pin;
-            NyLPC_TInt32 value;
-            //pin number
-            if( (!NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,0,&pin)) ||
-                (!NyLPC_TJsonRpcParserResult_getInt32(i_rpc,1,&value)))
-            {
-                mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
-            }else{
-                addNewObjectBatch(*mod,i_rpc->method.id,new ModJsonRpc::RpcObject<DigitalOut>(new DigitalOut(MbedJsApi::pinId2PinName(pin),value)));
+            PinName pin;
+            if(getParamsAsPin(mod,i_rpc,&pin,1)){
+                int v;
+                if(getParamInt(mod,i_rpc,v,1)){
+                    addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<DigitalOut>(new DigitalOut(pin,v)));
+                }
             }
-            return NyLPC_TBool_TRUE;            
+            return NyLPC_TBool_TRUE;
         }
         static NyLPC_TBool write(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
         {
+            //dd return void
             ModJsonRpc* mod=(ModJsonRpc*)i_param;
-            NyLPC_TInt32 iid,value;            
-            if( (!NyLPC_TJsonRpcParserResult_getInt32(i_rpc,0,&iid)) ||
-                (!NyLPC_TJsonRpcParserResult_getInt32(i_rpc,1,&value)))
-            {
-                mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
-            }else{
-                DigitalOut* inst=(DigitalOut*)getObjectBatch(*mod,i_rpc->method.id,iid);
-                if(inst!=NULL){
-                    inst->write(value);
+            DigitalOut* inst=(DigitalOut*)getObjectBatch(mod,i_rpc);
+            if(inst!=NULL){
+                int v;
+                if(getParamInt(mod,i_rpc,v,1)){
+                    inst->write(v);
                     mod->putResult(i_rpc->method.id,"");
                 }
             }
@@ -77,19 +44,13 @@
         }
         static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
         {
+            //d return d
             ModJsonRpc* mod=(ModJsonRpc*)i_param;
-            NyLPC_TInt32 iid;            
-            if( (!NyLPC_TJsonRpcParserResult_getInt32(i_rpc,0,&iid)))
-            {
-                mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
-            }else{
-                DigitalOut* inst=(DigitalOut*)getObjectBatch(*mod,i_rpc->method.id,iid);
-                if(inst!=NULL){
-                    int v=inst->read();
-                    mod->putResult(i_rpc->method.id,"%d",v);
-                }
+            DigitalOut* inst=(DigitalOut*)getObjectBatch(mod,i_rpc);
+            if(inst!=NULL){
+                mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
             }
-            return NyLPC_TBool_TRUE; 
+            return NyLPC_TBool_TRUE;
         }
     };
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcHandlerBase.h	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,107 @@
+#include "mod/ModJsonRpc.h"
+#include "MbedJsApi.h"
+#include "mbed.h"
+namespace MiMic
+{
+
+	/**
+	 * JSONRPCハンドラのベースクラス。
+	 * よく使う関数群を定義します。
+	 */
+    class RpcHandlerBase
+    {
+    public:
+    	/**
+    	 * MiMicRPCの定義するピンIDをmbedピンIDへ変換します。
+    	 * ターゲットごとに実装します。
+    	 */
+    	static PinName pinId2PinName(unsigned int i_id);
+    	static PinMode pinmodeId2PinMode(unsigned int i_id);
+    	static PortName portId2PortName(unsigned int i_id);
+
+    	/**
+    	 * Websocketコネクションに同期したオブジェクトリストにnewオブジェクトを登録します。
+    	 * 登録するオブジェクトは、{@link BasicRpcObject}でラップする必要があります。
+    	 */
+        static void addNewObjectBatch(ModJsonRpc* i_mod,unsigned int i_id,ModJsonRpc::BasicRpcObject* i_new_object)
+        {
+            int i=i_mod->addObject(i_new_object);
+            if(i<0){
+                delete i_new_object;
+                i_mod->putError(i_id,ModJsonRpc::INVALID_PARAMS);
+                return;
+            }
+            i_mod->putResult(i_id,"%d",i);
+            return;
+        }
+        /** i_idx番目のRPCパラメータをiidとしてインスタンスを取得します。*/
+        static void* getObjectBatch(ModJsonRpc* i_mod,const union NyLPC_TJsonRpcParserResult* i_rpc,int i_idx=0)
+        {
+        	NyLPC_TInt32 v;
+            if(!NyLPC_TJsonRpcParserResult_getInt32(i_rpc,i_idx,&v)){
+            	i_mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
+                return NULL;
+            }
+            void* ret=i_mod->getObject(v);
+        	if(ret==NULL){
+                i_mod->putError(i_rpc->method.id,ModJsonRpc::INTERNAL_ERROR);
+                return NULL;
+        	}
+        	return ret;
+        }
+
+    	/** u...パラメータをN個のPinIDと解釈して返す。失敗した場合は終了処理も行う。
+    	 */
+    	static bool getParamsAsPin(ModJsonRpc* i_mod,const union NyLPC_TJsonRpcParserResult* i_rpc,PinName* o_pins,int i_num_of_pins)
+    	{
+            for(int i=0;i<i_num_of_pins;i++){
+            	NyLPC_TUInt32 p;
+                if(!NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,i,&p)){
+                	i_mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
+                    return false;
+                }
+                o_pins[i]=pinId2PinName(p);
+            }
+    		return true;
+    	}
+    	static bool getParamInt(ModJsonRpc* i_mod,const union NyLPC_TJsonRpcParserResult* i_rpc,int& o_val,int i_idx)
+    	{
+			if(!NyLPC_TJsonRpcParserResult_getInt32(i_rpc,i_idx,((NyLPC_TInt32*)&o_val))){
+				i_mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
+				return false;
+			}
+    		return true;
+    	}
+    	static bool getParamUInt(ModJsonRpc* i_mod,const union NyLPC_TJsonRpcParserResult* i_rpc,unsigned int& o_val,int i_idx)
+    	{
+			if(!NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,i_idx,((NyLPC_TUInt32*)&o_val))){
+				i_mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
+				return false;
+			}
+    		return true;
+    	}
+    	static bool getParamsInt(ModJsonRpc* i_mod,const union NyLPC_TJsonRpcParserResult* i_rpc,int* o_val,int i_num_ofparams,int i_start=0)
+    	{
+            for(int i=0;i<i_num_ofparams;i++){
+                if(!NyLPC_TJsonRpcParserResult_getInt32(i_rpc,i_start+i,(NyLPC_TInt32*)(o_val+i))){
+                	i_mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
+                    return false;
+                }
+            }
+    		return true;
+    	}
+    	static bool getParamsUInt(ModJsonRpc* i_mod,const union NyLPC_TJsonRpcParserResult* i_rpc,unsigned int* o_val,int i_num_ofparams,int i_start=0)
+    	{
+            for(int i=0;i<i_num_ofparams;i++){
+                if(!NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,i_start+i,(NyLPC_TUInt32*)(o_val+i))){
+                	i_mod->putError(i_rpc->method.id,ModJsonRpc::INVALID_PARAMS);
+                    return false;
+                }
+            }
+    		return true;
+    	}
+
+    };
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/SPI.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,76 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class SPIHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//uuuu
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin[4];
+            if(getParamsAsPin(mod,i_rpc,pin,4)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<SPI>(new SPI(pin[0],pin[1],pin[2],pin[3])));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool format(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//ddd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            SPI* inst=(SPI*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int p[2];
+	        	if(getParamsInt(mod,i_rpc,p,2,1)){
+	        		inst->format(p[0],p[1]);
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool frequency(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            SPI* inst=(SPI*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->frequency(v);
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool write(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            SPI* inst=(SPI*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					mod->putResult(i_rpc->method.id,"%d",(int)(inst->write(v)));
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"		,"uuuu"	,SPIHandler::new1},
+    { "format"		,"ddd"	,SPIHandler::format},
+    { "frequency"	,"dd"	,SPIHandler::frequency},
+    { "write"		,"dd"	,SPIHandler::write},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_SPI={
+    "mbedJS","SPI",func_table
+};
+
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/SPISlave.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,99 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class SPISlaveHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//uuuu
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PinName pin[4];
+            if(getParamsAsPin(mod,i_rpc,pin,4)){
+    			addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<SPISlave>(new SPISlave(pin[0],pin[1],pin[2],pin[3])));
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool format(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//ddd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            SPISlave* inst=(SPISlave*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int p[2];
+	        	if(getParamsInt(mod,i_rpc,p,2,1)){
+	        		inst->format(p[0],p[1]);
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool frequency(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return void
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            SPISlave* inst=(SPISlave*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+	        	if(getParamInt(mod,i_rpc,v,1)){
+					inst->frequency(v);
+	        	}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            SPISlave* inst=(SPISlave*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool receive(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            SPISlave* inst=(SPISlave*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->receive()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool reply(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//dd return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            SPISlave* inst=(SPISlave*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				int v;
+				if(getParamInt(mod,i_rpc,v,1)){
+					inst->reply(v);
+					mod->putResult(i_rpc->method.id,"");
+				}
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"		,"uuuu"	,SPISlaveHandler::new1},
+    { "format"		,"ddd"	,SPISlaveHandler::format},
+    { "frequency"	,"dd"	,SPISlaveHandler::frequency},
+    { "read"		,"d"	,SPISlaveHandler::read},
+    { "receive"		,"d"	,SPISlaveHandler::receive},
+    { "reply"		,"dd"	,SPISlaveHandler::reply},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_SPI_SLAVE={
+    "mbedJS","SPISlave",func_table
+};
+
+
+
+}
+
--- a/mbed/jsonrpc/TargetTypes.h	Sat Jun 14 17:42:11 2014 +0000
+++ b/mbed/jsonrpc/TargetTypes.h	Fri Jun 20 15:38:30 2014 +0000
@@ -27,10 +27,20 @@
 #define PINID_USER				0x40000000
 #define PINID_NC				0x7fffffff
 
+#define PINMODEID				0x00010000
+#define PORTID					0x00010000
 
 struct TPinNameMapItem{
 	PinName name;
 	unsigned int id;
 };
+struct TPinModeMapItem{
+	PinMode mode;
+	unsigned int id;
+};
+struct TPortNameMapItem{
+	PortName port;
+	unsigned int id;
+};
+
 }
-
--- a/mbed/jsonrpc/Target_LPC176x.cpp	Sat Jun 14 17:42:11 2014 +0000
+++ b/mbed/jsonrpc/Target_LPC176x.cpp	Fri Jun 20 15:38:30 2014 +0000
@@ -3,7 +3,7 @@
  * LPC176xのターゲットテーブルです。
  */
 #include "TargetTypes.h"
-#include "MbedJsApi.h"
+#include "RpcHandlerBase.h"
 #ifdef TARGET_LPC1768
 namespace MiMic
 {
@@ -15,7 +15,7 @@
 #define NS_LPC_PIN_4	(NS_LPC_PIN_2+32)
 #define NS_LPC_PIN_5	(NS_LPC_PIN_2+32)
 
-const static struct TPinNameMapItem table[]={
+const static struct TPinNameMapItem pin_table[]={
 	{P0_0	,NS_LPC_PIN_0+0},	{P0_1	,NS_LPC_PIN_0+1},	{P0_2	,NS_LPC_PIN_0+2},	{P0_3	,NS_LPC_PIN_0+3},
 	{P0_4	,NS_LPC_PIN_0+4},	{P0_5	,NS_LPC_PIN_0+5},	{P0_6	,NS_LPC_PIN_0+6},	{P0_7	,NS_LPC_PIN_0+7},
 	{P0_8	,NS_LPC_PIN_0+8},	{P0_9	,NS_LPC_PIN_0+9},	{P0_10	,NS_LPC_PIN_0+10},	{P0_11	,NS_LPC_PIN_0+11},
@@ -94,15 +94,51 @@
 	{NC,PINID_NC}
 };
 
-PinName MbedJsApi::pinId2PinName(unsigned int i_id)
+const static struct TPinModeMapItem pinmode_table[]=
+{
+	{PullUp		,PINMODEID+0},
+	{PullDown	,PINMODEID+1},
+	{PullNone	,PINMODEID+2},
+	{OpenDrain	,PINMODEID+3},
+	{PullDefault,PINMODEID+4}
+};
+const static struct TPortNameMapItem portname_table[]=
 {
-	for(int i=0;table[i].name!=NC;i++){
-		if(i_id==table[i].id){
-			return table[i].name;
+	{Port0	,PORTID+0},
+	{Port1	,PORTID+1},
+	{Port2	,PORTID+2},
+	{Port3	,PORTID+3},
+	{Port4	,PORTID+4}
+};
+
+PinName RpcHandlerBase::pinId2PinName(unsigned int i_id)
+{
+	for(int i=0;pin_table[i].name!=NC;i++){
+		if(i_id==pin_table[i].id){
+			return pin_table[i].name;
 		}
 	}
 	return NC;
 }
+
+PinMode RpcHandlerBase::pinmodeId2PinMode(unsigned int i_id)
+{
+	for(int i=0;pinmode_table[i].mode!=PullDefault;i++){
+		if(i_id==pinmode_table[i].id){
+			return pinmode_table[i].mode;
+		}
+	}
+	return PullDefault;
+}
+PortName RpcHandlerBase::portId2PortName(unsigned int i_id)
+{
+	for(int i=0;portname_table[i].port!=Port4;i++){
+		if(i_id==portname_table[i].id){
+			return portname_table[i].port;
+		}
+	}
+	return Port0;
+}
+
 }
 #endif
-