mbed RPC with W5500 Ethernet Shield

This post shows how to use mbed RPC with W5500 Ethernet Shield and how to port an Ethernet application used lwIP to W5500Interface.

Remote Procedure Call

In computer science, a remote procedure call (RPC) is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction.
http://en.wikipedia.org/wiki/Remote_procedure_call

RPC
*source – http://uw714doc.sco.com/en/SDK_netapi/rpcpD.how_RPC_works.html

HW – FRDM-KL25Z + W5500 Ethernet Shield

FRDM-KL25Z + W5500 Ethernet Shield
http://developer.mbed.org/platforms/KL25Z/
http://developer.mbed.org/components/W5500-Ethernet-Kit-for-IoT/
HW connection : D10 – SCS / D11 – MOSI / D12 – MISO / D13 – SCLK

SW – mbed RPC

Server that executes remote procedure call (RPC) commands through HTTP.
mbed RPC @developer.mbed.org/handbook
In RPC libaray, a simple HTTP Server can execute RPC commands sent from HTTP Client.
This library uses EthernetInterface (lwIP) and mbedOS.

RPC command

The RPC command is encoded in this way :

  • container that wraps a skeleton’s ID
  • method that will be invoked
  • parameters that will be inputted (optional)
    • Command examples
      PUT command : “/DigitalOut/new?arg=LED2&name=led2”
      GET command : “/led2/write?arg=1”

Request handlers

To process requests, the server relies on RequestHandler. Each RequestHandler is assigned to a request type. Each type of request is assigned to a certain role :

  • PUT requests to create new objects
  • DELETE requests to delete objects
  • GET requests to call a function of an object

Porting EthernetInterface to W5500Interface

Here is a guide how to modify :

  • Folk HTTP-Server in you program workspace
  • Delete 2 Folders; EthernetInterface(lwIP) & mbed-rtos in HTTP-Server
  • Added array for MAC Address which was written at Source Hardware Address Register in W5500.
    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};`
    
  • Change EthernetInterface() and set SPI Interface for W5500
        /*  Use EthernetInterface
         *EthernetInterface eth;
         *if(eth.init())
         *int ret = eth.init("192.168.77.34", "255.255.255.0", "192.168.77.1");    
         */
        /* ----- Use W5500 Ethernet Shied -----*/
        SPI spi(D11, D12, D13);      /* mosi, miso, sclk */
        //spi.frequency(12500000); /* Optional : set proper SPI clock */
        EthernetInterface eth(&spi, D10, D9); /* spi, cs, reset(dummy) */
        ...
        /* ----- Use W5500 Ethernet Shied -----*/
    
  • Set Network configuration: I will use fixed Address.
        /*  in case of using W5500 Ethenret Shield */
        int ret = eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1");    
        /* in case of using W550io (has a unique real MAC address) */
        //int ret = eth.init("192.168.77.34", "255.255.255.0", "192.168.77.1");   
    

Repository : Users » embeddist » Code » HTTP-Server_W5500Interface

http://developer.mbed.org/users/embeddist/code/HTTP-Server_W5500Interface/

Demo – Using a browser for HTTP Client

Here is a quick guide how to run this program :

  • Compiles this program and copies it to the mbed
  • Open TeraTerm (install it if you don’t have it), select serial and choose the port named “mbed Serial Port”
  • Reset your mbed
  • The IP address should appear in teraterm. In this example, I will use 192.168.77.34
    Terminal
  • Open your browser and go to http://192.168.77.34
    connecttingl
  • If everything is ok, you should see a webpage.

  • Create Red LED as arg=LED1 and name=RLED
    RGB LED
    Create Red LED

  • To procedure, send command: RLED/write 0
    Reset Red LED

  • To procedure, send command: RLED/write 1
    Reset Red LED

Advertisements

Internet Radio (WIZ550io)

 

Go to post (in Japanese)

We will introduce the “Internet radio” produced by using the WIZ550io (built-in MAC address) and ATMEGA1284P (Flash128K, EEPROM4K). User can register maximum 80 radio broadcastings. The radio broadcasting registration can be done by the built-in Web page.

The Hardware configuration of “Internet Radio” is as follows,

  • MP3 codec : VS1053b module (3.3V, 74HC4050AP level shift)
  • Ethernet : WIZ550io module
  • Display : 16X2 LCD module

The following Ethernet protocol has been applied in Sketch (arduino-IDE 1.0.5) .

  • DHCP Client
  • HTTP Server ( Web-based broadcast registration )