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.

Dependencies:   libMiMic mbed-rtos mbed NySDFileSystem

English

This is MiMic project product.

Recently modern browser is very useful. If we write small HTML code, we can draw graphics, play music. And more, we can use a lot of libraries. For example, physics engine and WebGL and .

However, the browser is clumsy for things of outside computer. For example, it can not control switching of LED and read sensor value easily.

If you can control the device outside of the computer like writing a Web page HTML, it is very convenient.

MiMicRemoteMCU enables to control directly mbed(LPC1768/LPC4088/LPCXpresso1769) by browser application .

Feature 

This is the features of MiMicRemoteMCU to experience for the user.

MiMicRemoteMCU has builtin web content in on-chip memory and some WebAPI. Browser can access contents through internal web server. The web server can handle 4 connections in parallel. Average transport speed is 1.6Mbps.

/media/uploads/nyatla/function_block.png

Browser(User interface) centralized system

From the perspective of the web browser, MiMicRemoteMCU is a standard web server. There is a Web browser is the center of the system.

By designing the browser center system, you can easily implement cooperation with multi-media system or external Web services. And, You can take advantage of all online resources that you can access from the browser. It was difficult in the standalone microcomputer legacy applications design.

/media/uploads/nyatla/fig3.png

Getting started

See more information here(Japanese).

This is old documentation(English).

日本語

新しいAPIを搭載したmbedJSをリリースしました。mbedJSのご利用をご検討ください。

Import programmbedJS

This is a Json-RPC/2.0 server with websocket and httpd. You can control mbed(s) by Javascript, processing, Java. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

このアプリケーションはMiMic project を使った製品です。

最近のブラウザって便利ですよね。HTMLをちょこっと書けば、絵を描いたり音楽を再生したり、OpenGLやら物理演算やらなんでも出来てしまいます。

でもコンピュータの外の事、例えばその辺にあるLEDを点滅させたいとかちょっとセンサの値を読み出したいとか。そういったものには途端に不器用になります。

Webページを書くような感覚でコンピュータの外にあるデバイスを操作できれば便利だと思いませんか?

MiMicRemoteMCUをインストールしたmbed(LPCXpresso1769)を使えば、コンピュータの外にあるデバイスを、ブラウザから直接扱うことができます。

/media/uploads/nyatla/mimicrmcu1.4.png

機能

MiMicRemoteMCUの機能を紹介します。対外的な機能はMiMicRemoteMCUのROMContentsに収録されており、内蔵Webサーバを通じてWebブラウザから提供します。このWebサーバは最大4接続までのコネクションを、平均1.6Mbpsで提供することができます。

/media/uploads/nyatla/function_block.png

MiMicのアプリケーション開発

MiMicRemoteMCUはブラウザ中心のフィジカルコンピューティングを実装することに適しています。ブラウザ中心のシステムを設計することで、従来のマイコン単体アプリケーションでは難しかった外部Webサービスやマルチメディアシステムとの連携を容易に実装できます。さらにブラウザからアクセスできる全ての場所にあるオンラインリソースを活用することが出来ます。

/media/uploads/nyatla/fig3.png

導入方法

こちらの記事をご覧ください。

Committer:
nyatla
Date:
Fri May 30 00:43:03 2014 +0000
Revision:
32:4908a17d9587
Parent:
28:3d7bac2a6278
update libMiMic; LPC4088 patch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nyatla 4:00b4e7596014 1 #include "mbed.h"
nyatla 27:a3b49b4a814d 2 #include "rtos.h"
nyatla 5:227d20070da4 3 #include "SDFileSystem.h"
nyatla 1:82b8312c78a1 4 #include "mimic.h"
nyatla 1:82b8312c78a1 5 #include "fsdata.h"
nyatla 1:82b8312c78a1 6
nyatla 1:82b8312c78a1 7 /**
nyatla 3:335512e81ba9 8 * local filesystem support.
nyatla 16:06dee6eef0bc 9 * MiMic::LocalFileSystem2 do not freeze on LPCXpresso.
nyatla 3:335512e81ba9 10 */
nyatla 16:06dee6eef0bc 11 LocalFileSystem2 lf("local");
nyatla 7:8cbfa0625c51 12 SDFileSystem sd(p5, p6, p7, p8,"sd");
nyatla 5:227d20070da4 13
nyatla 28:3d7bac2a6278 14 Net* net;
nyatla 28:3d7bac2a6278 15
nyatla 3:335512e81ba9 16
nyatla 3:335512e81ba9 17 /**
nyatla 1:82b8312c78a1 18 * MiMic RemoteMCU httpd.<br/>
nyatla 1:82b8312c78a1 19 * <p>Service list</p>
nyatla 1:82b8312c78a1 20 * <pre>
nyatla 1:82b8312c78a1 21 * /rom/ - romfs
nyatla 1:82b8312c78a1 22 * /setup/ - MiMic configulation REST API.
nyatla 1:82b8312c78a1 23 * /local/ - mbed LocalFileSystem
nyatla 1:82b8312c78a1 24 * /mvm/ - MiMicVM REST API
nyatla 1:82b8312c78a1 25 * </pre>
nyatla 1:82b8312c78a1 26 */
nyatla 1:82b8312c78a1 27 class MiMicRemoteMcu:public MiMic::Httpd
nyatla 1:82b8312c78a1 28 {
nyatla 1:82b8312c78a1 29 private:
nyatla 1:82b8312c78a1 30 ModRomFiles modromfs; //ROM file module
nyatla 1:82b8312c78a1 31 ModMiMicSetting mimicsetting; //mimic setting API
nyatla 1:82b8312c78a1 32 ModRemoteMcu remotemcu; // remotemcu API
nyatla 23:1861be744ad1 33 ModLocalFileSystem modlocal; //FileSystem mounter
nyatla 23:1861be744ad1 34 ModLocalFileSystem modsd; //FileSystem mounter
nyatla 28:3d7bac2a6278 35 ModFileIo modfio; //fileupload API
nyatla 28:3d7bac2a6278 36 ModUPnPDevice modupnp;
nyatla 1:82b8312c78a1 37 public:
nyatla 28:3d7bac2a6278 38 MiMicRemoteMcu(NetConfig& i_cfg):Httpd(i_cfg.getHttpPort())
nyatla 1:82b8312c78a1 39 {
nyatla 28:3d7bac2a6278 40 this->modromfs.setParam("rom",RMCU_FSDATA,18);
nyatla 3:335512e81ba9 41 this->mimicsetting.setParam("setup");
nyatla 3:335512e81ba9 42 this->remotemcu.setParam("mvm");
nyatla 3:335512e81ba9 43 this->modlocal.setParam("local");
nyatla 28:3d7bac2a6278 44 this->modsd.setParam("sd",ModLocalFileSystem::FST_SDFATFS);
nyatla 23:1861be744ad1 45 this->modfio.setParam("fio");
nyatla 28:3d7bac2a6278 46 this->modupnp.setParam(*net);
nyatla 1:82b8312c78a1 47 }
nyatla 28:3d7bac2a6278 48 /**
nyatla 28:3d7bac2a6278 49 * Http handler
nyatla 28:3d7bac2a6278 50 */
nyatla 1:82b8312c78a1 51 virtual void onRequest(HttpdConnection& i_connection)
nyatla 1:82b8312c78a1 52 {
nyatla 1:82b8312c78a1 53 //try to ModRomFS module.
nyatla 1:82b8312c78a1 54 if(this->modromfs.execute(i_connection)){
nyatla 1:82b8312c78a1 55 return;
nyatla 1:82b8312c78a1 56 }
nyatla 1:82b8312c78a1 57 //try to ModMiMicSetting module.
nyatla 1:82b8312c78a1 58 if(this->mimicsetting.execute(i_connection)){
nyatla 1:82b8312c78a1 59 return;
nyatla 1:82b8312c78a1 60 }
nyatla 1:82b8312c78a1 61 //try to ModRemoteMcu module.
nyatla 1:82b8312c78a1 62 if(this->remotemcu.execute(i_connection)){
nyatla 1:82b8312c78a1 63 return;
nyatla 1:82b8312c78a1 64 }
nyatla 3:335512e81ba9 65 //try to ModLocalFileSystem
nyatla 3:335512e81ba9 66 if(this->modlocal.execute(i_connection)){
nyatla 3:335512e81ba9 67 return;
nyatla 3:335512e81ba9 68 }
nyatla 5:227d20070da4 69 //try to ModLocalFileSystem(SD)
nyatla 5:227d20070da4 70 if(this->modsd.execute(i_connection)){
nyatla 5:227d20070da4 71 return;
nyatla 5:227d20070da4 72 }
nyatla 23:1861be744ad1 73 //try to FileUpload
nyatla 23:1861be744ad1 74 if(this->modfio.execute(i_connection)){
nyatla 23:1861be744ad1 75 return;
nyatla 23:1861be744ad1 76 }
nyatla 28:3d7bac2a6278 77 //try to UPnP
nyatla 28:3d7bac2a6278 78 if(this->modupnp.execute(i_connection)){
nyatla 28:3d7bac2a6278 79 return;
nyatla 28:3d7bac2a6278 80 }
nyatla 3:335512e81ba9 81
nyatla 1:82b8312c78a1 82 //Otherwise, Send the redirect response to /rom/index.html
nyatla 18:0b1759b8d55f 83 i_connection.sendHeader(302,
nyatla 1:82b8312c78a1 84 "text/html",
nyatla 5:227d20070da4 85 "Status: 302:Moved Temporarily\r\n"
nyatla 4:00b4e7596014 86 "Location: /rom/index.html\r\n");
nyatla 1:82b8312c78a1 87 return;
nyatla 1:82b8312c78a1 88 }
nyatla 1:82b8312c78a1 89 };
nyatla 5:227d20070da4 90
nyatla 28:3d7bac2a6278 91
nyatla 28:3d7bac2a6278 92 NetConfig cfg; //create network configulation with onchip-setting.
nyatla 1:82b8312c78a1 93 int main()
nyatla 1:82b8312c78a1 94 {
nyatla 28:3d7bac2a6278 95 net=new Net();//Net constructor must be created after started RTOS
nyatla 28:3d7bac2a6278 96 //Prepare configulation.
nyatla 28:3d7bac2a6278 97 cfg.setUPnPIcon(64,64,8,"image/png","/rom/icon.png");
nyatla 28:3d7bac2a6278 98 cfg.setUPnPUdn(0xe29f7101,0x4ba2,0x01e0,0);
nyatla 28:3d7bac2a6278 99 cfg.setFriendlyName("MiMicRemoteMCU");
nyatla 28:3d7bac2a6278 100 cfg.setUPnPPresentationURL("/rom/index.html");
nyatla 28:3d7bac2a6278 101
nyatla 9:18e9bf764cc1 102 //try to override setting by local file.
nyatla 16:06dee6eef0bc 103 if(!cfg.loadFromFile("/local/mimic.cfg")){
nyatla 27:a3b49b4a814d 104 Thread::wait(2000);//wait for SD card initialization.
nyatla 16:06dee6eef0bc 105 cfg.loadFromFile("/sd/mimic.cfg");
nyatla 16:06dee6eef0bc 106 }
nyatla 28:3d7bac2a6278 107
nyatla 21:6555a25e67e7 108 MiMicRemoteMcu httpd(cfg); //create a httpd instance.
nyatla 28:3d7bac2a6278 109 net->start(cfg);
nyatla 1:82b8312c78a1 110 httpd.loop(); //start httpd loop.
nyatla 1:82b8312c78a1 111 return 0;
nyatla 1:82b8312c78a1 112 }