레이블이 WIZnetInterface인 게시물을 표시합니다. 모든 게시물 표시
레이블이 WIZnetInterface인 게시물을 표시합니다. 모든 게시물 표시

2015년 10월 29일 목요일

[WIZwiki_W7500ECO] HTTPClient with JSON parser

[WIZwiki_W7500ECO] HTTPClient with JSON parser

JSON is easy for machines to parse and generate which is based on a subset of the JavaScript Programming Language. Currently many Web Services allow to access data in JSON format. However, JSON parser is too big for low-end device as like a ARMmbed platform which has limited-resource. This post shows how to use HTTPClient parse Json data in ARMmbed platform.
IMG_20151029_165139

Preparation materials

  1. Software
  2. Hardware

Simplest python JSON server on PC

  • Reference : fraka6.blogsopot.kr: The simplest python server example

  • Modify Server IP address & port on ron_handler

    def run(port=8000): #set port
    
      print('http server is starting...')
      #ip and port of server
      #server_address = ('127.0.0.1', port)
      server_address = ('192.168.0.223', port)#set port
      httpd = HTTPServer(server_address, Handler)
      print('http server is running...listening on port %s' %port)
      httpd.serve_forever()
    
  • Modify JSON form in do_GET handler

    #handle GET command
    def do_GET(self):
      if format == 'html':
          self.send_response(200)
          self.send_header("Content-type", "text/plain")
          self.send_header('Content-type','text-html')
          self.end_headers()
          self.wfile.write("body")
      elif format == 'json':
          #self.request.sendall(json.dumps({'path':self.path}))
          #self.request.sendall(json.dumps({'pi':3.14}))
          self.request.sendall(json.dumps({'name':'John snow', 'age': 30, 'gender':'male'}))
      else:
          self.request.sendall("%s\t%s" %('path', self.path))
      return
    
  • Excute json_server
    2015-10-29_16-26-33

  • Test by using curl

      $>curl ip_address:port_number
    

    2015-10-29_16-26-00

Make main.cc

  1. Network Configration for WIZwiki-W7500ECO

     // Enter a MAC address for your controller below.
     uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
    
     printf("initializing Ethernet\r\n");
     // initializing MAC address
     eth.init(mac_addr, "192.168.0.34", "255.255.255.0", "192.168.0.1");
    
     // Check Ethenret Link
     if(eth.link() == true)   printf("- Ethernet PHY Link-Done \r\n");
     else printf("- Ethernet PHY Link- Fail\r\n");
    
     // Start Ethernet connecting: Trying to get an IP address using DHCP
     if (eth.connect()<0)    printf("Fail - Ethernet Connecing");
    
  2. TCP connect to simple python JSON server

     sock.connect("192.168.0.223", 8000); // "destination IP address", destination port number
    
  3. Make Get form in HTTP format

     snprintf(http_tx_msg, http_tx_msg_sz,  "GET / HTTP/1.1\r\nHost: 192.168.0.223:8000\r\nUser-Agent: WIZwiki-W7500ECO\r\nConection: close\r\n\r\n");
    
  4. TCP Send Get form

     sock.send_all(http_tx_msg, http_tx_msg_sz-1); // tx_buf, tx_buf_size
    
  5. TCP Recv data in JSON format

     while ( (returnCode = sock.receive(http_rx_msg, http_rx_msg_sz-1)) > 0) {
             http_rx_msg[returnCode] = '\0';
             printf("Received %d chars from server:\n\r%s\n", returnCode, http_rx_msg);
         }
    
  6. Do JSON parse
     parse(parser, http_rx_msg);
    
  7. Output the parsed data
     // parsing "string" in string type
     printf("name =%s\r\n" , parser["name"].get<string>().c_str());
     // parsing "age" in integer type
     printf("age =%d\r\n" , parser["age"].get<int>());
     // parsing "gender" in string type
     printf("gender =%s\r\n" , parser["gender"].get<string>().c_str());
    

Demo. HTTPClient with JSON parser

  1. Network config.
  2. Confirm Received JSON data
  3. Print-out the pasing data
    2015-10-29_16-42-55

Packet Capture

  1. TCP-Connection
  2. Target board sends GET Form to simple python JSON server
  3. simple python JSON server sends JSON data to Target board
    2015-10-29_16-22-56

2015년 7월 1일 수요일

ARMmbed WIZnetInterface

WIZnetInterface

WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.
Users » embeddist » Code » WIZnetInterface

WIZnetInterface ?

  • EthernetInterface in ARM mbed
    mbed.org는 Handbook>>Ethernet에 ARM mbed platform들이 Internet에 Connecting하기 위한 Network Library인 EthernetInterface를 제공하고 있다. EthernetInterface는 TCP/IP Software stack으로 lwIP을 채택하고 있다.
  • WIZnet TCP/IP Offload Engine
    아래의 그림과 같이 TOE는 TCP이하의 Network Layer가 Hardware적으로 설계되어 있어 Operating System과 Microcontroller의 Networking을 위한 리소스와 메모리를 최소화 해준다. 따라서, 리소스가 제한되는 Low-end IoT Device에서 TOE의 기능이 탑재한 MCU혹은 TOE를 채택한 System은 보다 Networking 이외의 기능들에 최적화 시킬 수 있다.
    TCP/IP Offload Engine
  • 과연, ARM mbed에서 이러한 TOE를 적용한 Platform혹은 Components 있나?
    있습니다. 있고요.
    Platform으로는 W7500이 적용된 WIZwiki_W7500이 있습니다.
    Component로는 W5500이 적용된 W5500 Ethernet Shield가 있습니다. 둘다 made in 대한민국!
  • 그럼, 이렇게 TOE가 적용된 Platform과 Component들도 EthernetInterface를 사용하나?
    아니요. TOE가 적용된 Platform과 Component는 WIZnetInterface를 사용해야 합니다.
    WIZnetInterface
    WIZnetInterface는 위의 그림처러 TOE Driver를 mbed Ethernet Interface기반으로 포팅하였습니다. 따라서, ARM mbed에서 EthernetInterface를 적용한 program을 WIZnetInterface로 replace하는 것이 가능합니다.

What is new?

  • W7500과 W5500을 어떻게 선택하나
    eth_arch.h을 추가하여 Web-IDE에서 platform을 선택하면 Target Platform에 따라 자동적으로 W7500혹은 W5500을 적용할 수 있다. W5500과 W7500이 통합된 Library이지만 둘 중 하나를 선택하기 위해 여분의 Configuration이 필요없다.
    #if defined(TARGET_WIZwiki_W7500)
    #include "W7500x_toe.h"
    #define __DEF_USED_IC101AG__  //For using IC+101AG@WIZwiki-W7500
    #else
    #include "W5500.h"            // W5500 Ethernet Shield 
    //#define USE_WIZ550IO_MAC    // WIZ550io; using the MAC address
    #endif
    
  • PHY링크를 어떻게 설정하고 확인하나
    Ethernet PHY는 아래의 그림과 같이 RJ45의 Link LED와 Active LED를 이용하여 육안으로 확인이 가능하다. Embedded system에서는 MCU의 GPIO에 Link와 Active Signal을 연결하거나 MDIO Interface를 확인 할 수 있다.
    PHY link
    (http://www.avtech.com/Support/modules/KB/Image/Image/166_RA_LEDs/Ethernet_LEDs_NormalOperation_BothTypes.gif)
    EthernetInterface에서 이러한 기능을 위해 link()와 set_link()를 제공하고 WIZnetInterface에서도 이 API를 제공하고 있다.
    • link()
      PHY링크를 확인할 수 있는 함수 return값이 True이면 Link이고, Fail이면 Link-Fail이다
        * Check if an ethernet link is pressent or not.
        *
        * @returns true if successful
        */
        bool link(int wait_time_ms= 3*1000);
      
    • set_link()
      PHY의 Duplex/SPEED를 설정할 수 있는 함수이다.
       /*
        * Sets the speed and duplex parameters of an ethernet link.
        *
        * @returns true if successful
        */
        void set_link(PHYMode phymode);
      
  • Networking에 필수적으로 필요한 DHCP와 DNS lib를 포함
    dhcpdns

How to import

  • import and update
    • WIZnetInterface Library의 import를 위해 import하고자 하는 program에서 오른쪽 클릭 후 ‘From Import Wizard’를 클릭 한다.
      import_WIZnetInterface
    • import wizard의 검색 창에서 ‘WIZnetInterfae”를 적고 ‘Search’ button을 클릭한다. 검색 결과 창에서 ‘WIZnetInterface’을 선택한 후 거침없이 ‘Import’ button을 클릭!
      search_WIZnetInterface
    • Import Library창이 뜨면 당황하지 않고 각항목을 알맞게 ‘Import name’ 과 ‘Target path’설정 한다. 또한 최신의 Library를 import하기 위해 ‘update’ check box를 반드시 체크한다. 그리고 ‘Import’ Button을 클릭하여 WIZnetInteface의 Import를 완료한다.
      importandupdate_WIZnetInteface

Where is Clone repository

파일 버젼관린 시스템 Git과 같은 Mecurial를 ARM mbed에서 적용하고 있다.
아래의 명령어를 이용하여 WIZnetInterface를 Clone할 수 있으며 hg명령어를 이용하여 버젼관리를 할 수 있다.
hg clone https://embeddist@developer.mbed.org/users/embeddist/code/WIZnetInterface/
또한, WIZnetInterface는 ARM mbed의 Team WIZnet에서 관리하고 있으므로 https://developer.mbed.org/teams/WIZnet/를 방문하여 다운 및 다수의 예제를 활용할 수 있다.

How to use

  • make main.cpp
    • WIZwiki_W7500
      #define _DHCP_
      EthernetInterface eth;  /*1. Creat eth object from EthernetInteface class*/
      
      main()
      {
        /*2. MAC address as arr in HEX-Type*/
        uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};  
      
        /*3. Select DHCP or Fixed IP address*/
      #ifdef _DHCP_
        /*3.1 Set  MAC address, Initialize the interface with DHCP*/
        eth.init(mac_addr); 
      #else   
        /*3.2 Set  MAC address and Set MAC, IP, Gatway address and Subnet Mask as String-Type*/
        eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); 
      #endif
      
        /*4. Check Ethernet Link-Done */
        printf("Check Ethernet Link\r\n");
        if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
        else {printf("- Ethernet PHY Link- Fail\r\n");}
      
        /*5. Set IP addresses ,start DHCP if needed  */
        if( eth.connect() == ture )
        {
            printf("Connected, IP: %s\n\r", eth.getIPAddress());
            printf("MASK: %s\n\r", eth.getNetworkMask());
            printf("GW: %s\n\r",eth.getGateway());
        }
        else
        {
            printf("eth.connect fail\n\r");
        }
        ...
      
        /* Your application 
           Visit for examples - https://developer.mbed.org/teams/WIZnet/
        */
      
      }
      
    • W5500 Ethernet Shield
      #define _DHCP_
      /* 0. Set SPI Interface with SPI API*/
      SPI spi(D11, D12, D13);                  // mosi, miso, sclk
      /*1. Creat eth object from EthernetInteface class*/
      EthernetInterface eth(&amp;spi, D10, D9);    // spi, cs, reset
      
      main()
      {
        /*2. MAC address as arr in HEX-Type*/
        uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};  
      
         /*3. Select DHCP or Fixed IP address*/
      #ifdef _DHCP_
        /*3.1 Set  MAC address, Initialize the interface with DHCP*/
        eth.init(mac_addr); 
      #else
        /*3.2 Set  MAC address and Set MAC, IP, Gatway address and Subnet Mask as String-Type */
        eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); 
      #endif
      
        /*3. Check Ethernet Link-Done */
        printf("Check Ethernet Link\r\n");
        if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
        else {printf("- Ethernet PHY Link- Fail\r\n");}
      
        /*4. Set IP addresses ,start DHCP if needed  */
        if( eth.connect() == ture )
        {
            printf("Connected, IP: %s\n\r", eth.getIPAddress());
            printf("MASK: %s\n\r", eth.getNetworkMask());
            printf("GW: %s\n\r",eth.getGateway());
        }
        else
        {
            printf("eth.connect fail\n\r");
        }
        ...
      
        /* Your application 
           Visit for examples - https://developer.mbed.org/teams/WIZnet/
        */
      
      }
      

WIZnetInterface APIs for mbed Ethenret Interface

Ethernet 기반의 Networking을 위해 *Ethenret Interface Library를 ARM mbed에서 제공하고 있으며, 이 Library는 크게 4가지 TCP/IP Protocol layer, Ethernet, EthernetInterface and Socket로 구성되있다.
Internet에 연결하기 위해 EthernetInterface의 각각의 Layer는 APIs들로 구성되어 있다. 각각의 API는 아래의 경로에서 확인할 수 있다.

WIZnetInterface Implementation base on mbed Ethernet Interface

  • EthernetInterface- EthernetInterface Class
    Type Func. Descriptions WIZnetInterface
    static int init () Initialize the interface with DHCP. O
    static int init (const char ip, const char mask, const char *gateway) Initialize the interface with a static IP address. O
    static int connect (unsigned int timeout_ms=15000) Connect Bring the interface up, start DHCP if needed. O
    static int disconnect () Disconnect Bring the interface down. no use
    static char* getMACAddress () Get the MAC address of your Ethernet interface. O
    static char* getIPAddress () Get the IP address of your Ethernet interface. O
    static char* getGateway () Get the Gateway address of your Ethernet interface. O
    static char* getNetworkMask () Get the Network mask of your Ethernet interface. O
    void EthernetInterface (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset) Initialize SPI SPI pins to user for SPI interface and Reset pin for W5500 0 (for W5500)
    void EthernetInterface (SPI* spi, PinName cs, PinName reset) Initialize SPI SPI pins to user for SPI interface and Reset pin for W5500 O (for W5500)
  • Socket - TCPSocketServer Class
    Type Func. Descriptions WIZnetInterface
    TCPSocketServer () Instantiate a TCP Server. O
    int bind (int port) Bind a socket to a specific port. O
    int listen (int backlog=1) Start listening for incoming connections. O
    int accept ( TCPSocketConnection &connection) Accept a new connection. O
    void set_blocking (bool blocking, unsigned int timeout=1500) Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations. O
    int set_option (int level, int optname, const void *optval, socklen_t optlen) Set socket options. no use
    int get_option (int level, int optname, void optval, socklen_t optlen) Get socket options. no use
    int close (bool shutdown=true) Get socket options. O
  • Socket - TCPSocketConnection Class
    Type Func. Descriptions WIZnetInterface
    TCPSocketConnection () TCP socket connection. O
    int connect (const char *host, const int port) Connects this TCP socket to the server. O
    bool is_connected (void) Check if the socket is connected. O
    int send (char *data, int length) Send data to the remote host. O
    int send_all (char *data, int length) Send all the data to the remote host. O
    int receive (char *data, int length) Receive data from the remote host. O
    int receive_all (char *data, int length) Receive all the data from the remote host. O
    void set_blocking (bool blocking, unsigned int timeout=1500) Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations. O
    int set_option (int level, int optname, const void *optval, socklen_t optlen) Set socket options. no use
    int get_option (int level, int optname, void optval, socklen_t optlen) Get socket options. no use
    int close (bool shutdown=true) Close the socket. O
    void reset_address (void) Reset the address of this endpoint. O
    int set_address (const char *host, const int port) Set the address of this endpoint. O
    char* get_address (void) Get the IP address of this endpoint. O
    int get_port (void) Get the port of this endpoint. O
  • etnerhet_api - ethernet_api Class
    Type Func. Descriptions WIZnetInterface
    Ethernet () Initialise the ethernet interface. no use
    virtual ~Ethernet () Powers the hardware down. no use
    int write (const char *data, int size) Writes into an outgoing ethernet packet. no use
    int send () Send an outgoing ethernet packet. no use
    int receive () Recevies an arrived ethernet packet. no use
    int read (const char *data, int size) Read from an recevied ethernet packet. no use
    void address (char *mac) Gives the ethernet address of the mbed. no use
    int link() Returns if an ethernet link is pressent or not. O
    void set_link(Mode mode) Sets the speed and duplex parameters of an ethernet link. O

2015년 6월 18일 목요일

WIZnetInterface for ARMmbed

WIZnetInterface for ARMmbed

This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.
Users » embeddist » Code » WIZnetInterface
-> WIZnetInterface Lib will be released on Team WIZnet

What is this?

This is an Ethernet Interface library port-based on EthernetInterface. This is where the driver using TCP/IP offload(W5500/W7500), which is a market-proven hardwired TCP/IP stack, is implemented. Therefore, this library does not need lwip-eth.library.

  • The Socket folder contains files that implement the SocketAPI and Protocols as like DHCP and DNS.
  • The arch folder contains files that implement the driver for W5500 and W7500x_TOE.
  • The EthernetInterface.c/.h implement the functions from SocketAPI/EthernetInterface.h
  • The eth_arch.h implement to select TCP/IP TOE depending on platform.

What is new?

  • eth_arch.h
    The eth_arch.h file is added to select arch depending to Target platform, we used define of TARGET_platform.

    #if defined(TARGET_WIZwiki_W7500)
    #include "W7500x_toe.h"
    #define __DEF_USED_IC101AG__  //For using IC+101AG@WIZwiki-W7500
    #else
    #include "W5500.h"            // W5500 Ethernet Shield 
    //#define USE_WIZ550IO_MAC    // WIZ550io; using the MAC address
    #endif
    
  • link()
    The link function is added to check Ethernet link (PHY) up or not.

      * Check if an ethernet link is pressent or not.
      *
      * @returns true if successful
      */
      bool link(int wait_time_ms= 3*1000);
    
  • link_set()
    The set_link function is added to check Ethernet link (PHY) up or not.

     /*
      * Sets the speed and duplex parameters of an ethernet link.
      *
      * @returns true if successful
      */
      void set_link(PHYMode phymode);
    
  • Included DHCP and DNS lib
    DHCP and DNS lib moved in Socket folder.
    Included DHCP&DNS

How to import

  • import and update
    • Right Click and click ‘From Import Wizard’ to import WIZnetInterface Library
      import library
    • In import Wizard, input ‘WIZnetInterfae” in search box and click ‘Search’ button. Click ‘WIZnetInterface’ in search result window and click ‘Import’ button.
      Search WIZnetInterface
    • Set ‘Import name’ and ‘Target path’, check ‘update’
      import and update WIZnetInterface

Where is Clone repository

hg clone https://embeddist@developer.mbed.org/users/embeddist/code/WIZnetInterface/

How to use

  • make main.cpp

    • WIZwiki_W7500

      #define _DHCP_
      EthernetInterface eth;  /*1. Creat eth object from EthernetInteface class*/
      
      main()
      {
        uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};  
      
        /*2. Set MAC, IP, Gatway address and Subnet Mask*/
      #ifdef _DHCP_
        /*2.1 Set  MAC address, Initialize the interface with DHCP*/
        eth.init(mac_addr); 
      #else   
        /*2.2 Set  MAC address and Set MAC, IP, Gatway address and Subnet Mask with string type */
        eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); //Use fixed IP address 
      #endif
      
        /*3. Check Ethernet Link-Done */
        printf("Check Ethernet Link\r\n");
        if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
        else {printf("- Ethernet PHY Link- Fail\r\n");}
      
        /*4. Set IP addresses ,start DHCP if needed  */
        eth.connect();
        printf("Connected, IP: %s\n\r", eth.getIPAddress());
        printf("MASK: %s\n\r", eth.getNetworkMask());
        printf("GW: %s\n\r",eth.getGateway());
        ...
      
        /* Your application 
           Visit for examples - https://developer.mbed.org/teams/WIZnet/
        */
      
      }
      
    • W5500 Ethernet Shield

      #define _DHCP_
      /* 0. Set SPI Interface with SPI API*/
      SPI spi(D11, D12, D13);                  // mosi, miso, sclk
      /*1. Creat eth object from EthernetInteface class*/
      EthernetInterface eth(&spi, D10, D9);    // spi, cs, reset
      
      main()
      {
        uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x1D, 0x62, 0x11}; 
        /*2. Set MAC, IP, Gatway address and Subnet Mask*/
      #ifdef _DHCP_
        /*2.1 Set  MAC address, Initialize the interface with DHCP*/
        eth.init(mac_addr); 
      #else
        /*2.2 Set  MAC address and Set MAC, IP, Gatway address and Subnet Mask with string type */
        eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); //Use fixed IP address 
      #endif
      
        /*3. Check Ethernet Link-Done */
        printf("Check Ethernet Link\r\n");
        if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
        else {printf("- Ethernet PHY Link- Fail\r\n");}
      
        /*4. Set IP addresses ,start DHCP if needed  */
        eth.connect();
        printf("Connected, IP: %s\n\r", eth.getIPAddress());
        printf("MASK: %s\n\r", eth.getNetworkMask());
        printf("GW: %s\n\r",eth.getGateway());
        ...
      
        /* Your application 
           Visit for examples - https://developer.mbed.org/teams/WIZnet/
        */
      
      }
      

WIZnetInterface Implementations for mbed Ethenret Interface

For networking based on Ethernet network, Ethenret Interface library is provided and is composed TCP/IP Protocol layer, Ethernet, EthernetInterface and Socket. In other words, the EthernetInterface library includes the networking stack necessary for connect betwwen mbed platform and Internet.

Each layer in EthernetInterface provides APIs to connect to the internet.

WIZnetInterface Implementation base on mbed Ethernet Interface

  • EthernetInterface- EthernetInterface Class

    Type Func. Descriptions WIZnetInterface Support
    static int init () Initialize the interface with DHCP. O
    static int init (const char ip, const char mask, const char *gateway) Initialize the interface with a static IP address. O
    static int connect (unsigned int timeout_ms=15000) Connect Bring the interface up, start DHCP if needed. O
    static int disconnect () Disconnect Bring the interface down. X
    static char* getMACAddress () Get the MAC address of your Ethernet interface. O
    static char* getIPAddress () Get the IP address of your Ethernet interface. O
    static char* getGateway () Get the Gateway address of your Ethernet interface. O
    static char* getNetworkMask () Get the Network mask of your Ethernet interface. O
    void EthernetInterface (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset) Initialize SPI SPI pins to user for SPI interface and Reset pin for W5500 0 (for W5500)
    void EthernetInterface (SPI* spi, PinName cs, PinName reset) Initialize SPI SPI pins to user for SPI interface and Reset pin for W5500 O (for W5500)
  • Socket - TCPSocketServer Class

    Type Func. Descriptions WIZnetInterface Support
    TCPSocketServer () Instantiate a TCP Server. O
    int bind (int port) Bind a socket to a specific port. O
    int listen (int backlog=1) Start listening for incoming connections. O
    int accept ( TCPSocketConnection &connection) Accept a new connection. O
    void set_blocking (bool blocking, unsigned int timeout=1500) Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations. O
    int set_option (int level, int optname, const void *optval, socklen_t optlen) Set socket options. X
    int get_option (int level, int optname, void optval, socklen_t optlen) Get socket options. X
    int close (bool shutdown=true) Get socket options. O
  • Socket - TCPSocketConnection Class

    Type Func. Descriptions WIZnetInterface Support
    TCPSocketConnection () TCP socket connection. O
    int connect (const char *host, const int port) Connects this TCP socket to the server. O
    bool is_connected (void) Check if the socket is connected. O
    int send (char *data, int length) Send data to the remote host. O
    int send_all (char *data, int length) Send all the data to the remote host. O
    int receive (char *data, int length) Receive data from the remote host. O
    int receive_all (char *data, int length) Receive all the data from the remote host. O
    void set_blocking (bool blocking, unsigned int timeout=1500) Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations. O
    int set_option (int level, int optname, const void *optval, socklen_t optlen) Set socket options. X
    int get_option (int level, int optname, void optval, socklen_t optlen) Get socket options. X
    int close (bool shutdown=true) Close the socket. O
    void reset_address (void) Reset the address of this endpoint. O
    int set_address (const char *host, const int port) Set the address of this endpoint. O
    char* get_address (void) Get the IP address of this endpoint. O
    int get_port (void) Get the port of this endpoint. O
  • etnerhet_api - ethernet_api Class

    Type Func. Descriptions WIZnetInterface Support
    Ethernet () Initialise the ethernet interface. X
    virtual ~Ethernet () Powers the hardware down. X
    int write (const char *data, int size) Writes into an outgoing ethernet packet. X
    int send () Send an outgoing ethernet packet. X
    int receive () Recevies an arrived ethernet packet. X
    int read (const char *data, int size) Read from an recevied ethernet packet. X
    void address (char *mac) Gives the ethernet address of the mbed. X
    int link() Returns if an ethernet link is pressent or not. O
    void set_link(Mode mode) Sets the speed and duplex parameters of an ethernet link. O

Revision History

  • Initial Release : 19 June. 2015