This is the Interface library for WIZnet W5500 chip which forked of EthernetInterfaceW5500, WIZnetInterface and WIZ550ioInterface. This library has simple name as "W5500Interface". and can be used for Wiz550io users also.

Dependents:   EvrythngApi Websocket_Ethernet_HelloWorld_W5500 Websocket_Ethernet_W5500 CurrentWeatherData_W5500 ... more

Information

It has EthernetInterface class like official EthernetInterface , but uses Wiznet chip driver codes.

So this library can use only the WIZnet W5500 or WIZ550io users.

This library has referred to many project such as WIZ550ioInterface, WiflyInterface and WIZnet Library.

Thanks all.

Committer:
embeddist
Date:
Tue Apr 28 13:52:23 2015 +0000
Revision:
11:5499fa2d8898
Parent:
10:713b6d2aaefb
Remove the setting of tx/rx buffer in SWReset

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bongjun 0:e11e8793c3ce 1 /* Copyright (C) 2012 mbed.org, MIT License
Bongjun 0:e11e8793c3ce 2 *
Bongjun 0:e11e8793c3ce 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Bongjun 0:e11e8793c3ce 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Bongjun 0:e11e8793c3ce 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Bongjun 0:e11e8793c3ce 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Bongjun 0:e11e8793c3ce 7 * furnished to do so, subject to the following conditions:
Bongjun 0:e11e8793c3ce 8 *
Bongjun 0:e11e8793c3ce 9 * The above copyright notice and this permission notice shall be included in all copies or
Bongjun 0:e11e8793c3ce 10 * substantial portions of the Software.
Bongjun 0:e11e8793c3ce 11 *
Bongjun 0:e11e8793c3ce 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Bongjun 0:e11e8793c3ce 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Bongjun 0:e11e8793c3ce 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Bongjun 0:e11e8793c3ce 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Bongjun 0:e11e8793c3ce 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Bongjun 0:e11e8793c3ce 17 */
Bongjun 0:e11e8793c3ce 18
Bongjun 0:e11e8793c3ce 19 #include "Socket.h"
hjjeon 10:713b6d2aaefb 20
Bongjun 0:e11e8793c3ce 21 Socket::Socket() : _sock_fd(-1),_blocking(true), _timeout(1500)
Bongjun 0:e11e8793c3ce 22 {
Bongjun 0:e11e8793c3ce 23 eth = WIZnet_Chip::getInstance();
Bongjun 0:e11e8793c3ce 24 if (eth == NULL) {
Bongjun 0:e11e8793c3ce 25 error("Socket constructor error: no W5500 instance available!\r\n");
Bongjun 0:e11e8793c3ce 26 }
Bongjun 0:e11e8793c3ce 27 }
Bongjun 0:e11e8793c3ce 28
Bongjun 0:e11e8793c3ce 29 void Socket::set_blocking(bool blocking, unsigned int timeout)
Bongjun 0:e11e8793c3ce 30 {
Bongjun 0:e11e8793c3ce 31 _blocking = blocking;
Bongjun 0:e11e8793c3ce 32 _timeout = timeout;
Bongjun 0:e11e8793c3ce 33 }
Bongjun 0:e11e8793c3ce 34
Bongjun 0:e11e8793c3ce 35 int Socket::close()
Bongjun 0:e11e8793c3ce 36 {
Bongjun 0:e11e8793c3ce 37 // add this code refer from EthernetInterface.
Bongjun 4:af0ed4fbca02 38 // update by Patrick Pollet
Bongjun 4:af0ed4fbca02 39 int res;
Bongjun 4:af0ed4fbca02 40 res = eth->close(_sock_fd);
Bongjun 0:e11e8793c3ce 41 _sock_fd = -1;
Bongjun 4:af0ed4fbca02 42 return (res)? 0: -1;
Bongjun 0:e11e8793c3ce 43 }
Bongjun 0:e11e8793c3ce 44
Bongjun 0:e11e8793c3ce 45 Socket::~Socket()
Bongjun 0:e11e8793c3ce 46 {
Bongjun 0:e11e8793c3ce 47 close(); //Don't want to leak
Bongjun 0:e11e8793c3ce 48 }