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

Dependencies:   NyFileSystems libMiMic mbed-rtos mbed

Fork of MiMicRemoteMCU-for-Mbed by Ryo Iizuka

English

MiMicProject http://nyatla.jp/mimic/wp/

This application allow to control the remote mbed through the network. It allows to control the mbed without a firmware update. It has some Interface. There are Javascript(WebBrowser), Procesing, Java. API waits for a function very similar to mbedSDK.

/media/uploads/nyatla/--_2.png

Feature

  • Low delay RPC by Websocket+JSON-RPC.
  • OnChip programing environment (Javascript).
  • Zero configuration support (UPnP/mDNS/AutoIP/DHCP)
  • mbedAPI like APIs.
  • Supports mbed LPC1768/LPCXpresso1769/LPC4088/FRDM-K64F

GettingStarted

mbed(LPC1768)

  • Compile and write mbedJS to your mbed.
  • Create mimic.cfg file to the mbed drive. This is network configuration.
  • Connect to Ethernet cable to the mbed.
  • Reset mbed.
  • Open http://[mbed IP address]/ by web browser.
  • Click JavascriptEditor.
  • Click StartButton. LED will be blinking.

LPCXpresso1769 and LPC4088 QuickStartBoard and FRDM-K64F

Those do not have LocalFileSystem. mbedJS initial IP address is "192.168.0.39". Open this address and click Setup page. You can change ipaddress at here.

Other APIs

Reference

日本語

MiMicProject http://nyatla.jp/mimic/wp/

mbedJSはmbedをWebネットワークにつなぐためのアプリケーションです。 Javascript(ウェブブラウザ)、Processing、Javaから、mbedを操作することができます。 これらはmbedSDKのクラスライブラリとよく似たAPIなので、mbedを知っている方なら簡単に使うことができます。

/media/uploads/nyatla/--_2.png

特徴

  • Websocket+JSONRPCによる低遅延なRPC
  • ワンチップでブラウザ向けの開発環境を提供
  • UPnP/Bonjurによるディスカバりに対応
  • mbedSDKのAPIと同じ構成のAPI
  • mbed LPC1768/LPCXpresso1769/LPC4088/FRDM-K64Fに対応

このアプリケーションはMiMicRemoteMCUとよく似ていますが、JavascriptAPIがより使いやすくなりました。

はじめかた

  • ファームウェアをmbedに書き込みます。
  • 設定ファイルにネットワークに合わせたIPアドレスを指定します。
  • mbedをリセットして、設定したIPアドレスをブラウザで開きます。
  • JavascriptEditorを開きます。
  • Startボタンを押してLEDがチカチカすれば成功です。

mbedJS APIs

ドキュメント

関連記事

main.cpp

Committer:
nyatla
Date:
2014-06-24
Revision:
33:8e869201db67
Parent:
28:3d7bac2a6278
Child:
37:ba7de395f009

File content as of revision 33:8e869201db67:

#include "mbed.h"
#include "rtos.h"
#include "SDFileSystem.h"
#include "mimic.h"
#include "fsdata.h"
#include "rpctbl.h"
/**
 * local filesystem support.
 * MiMic::LocalFileSystem2 do not freeze on LPCXpresso.
 */
LocalFileSystem2 lf("local");
SDFileSystem sd(p5, p6, p7, p8,"sd");

Net* net;


/**
 * MiMic RemoteMCU httpd.<br/>
 * <p>Service list</p>
 * <pre>
 * /rom/ - romfs
 * /setup/ - MiMic configulation REST API.
 * /local/ - mbed LocalFileSystem
 * /mvm/   - MiMicVM REST API
 * </pre>
 */
class MiMicRemoteMcu:public MiMic::Httpd
{
private:
    ModRomFiles modromfs; //ROM file module
    ModMiMicSetting mimicsetting; //mimic setting API
    ModRemoteMcu remotemcu; // remotemcu API
    ModLocalFileSystem modlocal; //FileSystem mounter
    ModLocalFileSystem modsd; //FileSystem mounter
    ModFileIo modfio;   //fileupload API
    ModUPnPDevice modupnp;
    ModJsonRpc modrpc;
public:
    MiMicRemoteMcu(NetConfig& i_cfg):Httpd(i_cfg.getHttpPort())
    {
        this->modromfs.setParam("rom",RMCU_FSDATA,18);
        this->mimicsetting.setParam("setup");
        this->remotemcu.setParam("mvm");
        this->modlocal.setParam("local");
        this->modsd.setParam("sd",ModLocalFileSystem::FST_SDFATFS);
        this->modfio.setParam("fio");
        this->modupnp.setParam(*net);
        this->modrpc.setParam("rpc",RPCTBL);
    }
    /**
     * Http handler
     */
    virtual void onRequest(HttpdConnection& i_connection)
    {
        //pause persistent mode if websocket ready.
        if(this->modrpc.isStarted()){
            i_connection.breakPersistentConnection();
        }
        //try to ModRomFS module.
        if(this->modromfs.execute(i_connection)){
            return;
        }
        //try to ModMiMicSetting module.
        if(this->mimicsetting.execute(i_connection)){
            return;
        }
        //try to ModRemoteMcu module.
        if(this->remotemcu.execute(i_connection)){
            return;
        }
        //try to ModLocalFileSystem
        if(this->modlocal.execute(i_connection)){
            return;
        }
        //try to ModLocalFileSystem(SD)
        if(this->modsd.execute(i_connection)){
            return;
        }
        //try to FileUpload
        if(this->modfio.execute(i_connection)){
            return;
        }
        //try to UPnP
        if(this->modupnp.execute(i_connection)){
            return;
        }
        if(this->modrpc.execute(i_connection)){
            this->modrpc.dispatchRpc();
            return;
        }
        
        //Otherwise, Send the redirect response to /rom/index.html
        i_connection.sendHeader(302,
            "text/html",
            "Status: 302:Moved Temporarily\r\n"
            "Location: /rom/index.html\r\n");        
        return;
    }
};


NetConfig cfg; //create network configulation  with onchip-setting.
int main()
{
    net=new Net();//Net constructor must be created after started RTOS
    //Prepare configulation.
    cfg.setUPnPIcon(64,64,8,"image/png","/rom/icon.png");
    cfg.setUPnPUdn(0xe29f7101,0x4ba2,0x01e0,0);
    cfg.setFriendlyName("MiMicRemoteMCU");
    cfg.setUPnPPresentationURL("/rom/index.html");

    //try to override setting by local file.
    if(!cfg.loadFromFile("/local/mimic.cfg")){
        Thread::wait(2000);//wait for SD card initialization.
        cfg.loadFromFile("/sd/mimic.cfg");
    }
    
    MiMicRemoteMcu httpd(cfg); //create a httpd instance.
    net->start(cfg);
    httpd.loop();  //start httpd loop.
    return 0;
}