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 Oct 01 13:58:53 2014 +0000
Revision:
92:4f77028cce64
Parent:
core/driver/flash/LPC17xx_IAP.c@12:efe841863fc8
?????????????????; K64F??????????????; LPC?????????????????

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