---
title: "W5500-hl-rs"
url: "https://maker.wiznet.io/josephsr/projects/W5500hlrs/"
markdown_url: "https://maker.wiznet.io/josephsr/projects/W5500hlrs/md"
type: "UCC: User Created Content"
author: "josephsr"
author_url: "https://maker.wiznet.io/josephsr/"
original_author: "josephsr"
original_url: "https://github.com/newAM"
published: "2021-03-02"
language: "en"
hardware: ["WIZnet W5500"]
likes: 0
views: 395
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# W5500-hl-rs

> W5500-hl-rs

Original author: josephsr (source: https://github.com/newAM)

## Components

- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Article

https://github.com/newAM/w5500-hl-rs for high level socket with platform agnostic feature low level registers drivers are contained in https://github.com/newAM/w5500-ll-rs

## Examples

UDP sockets

```
use w5500_hl::ll::{
    net::{Ipv4Addr, SocketAddrV4},
    Registers,
    Socket::Socket0,
};
use w5500_hl::Udp;

// open Socket0 as a UDP socket on port 1234
w5500.udp_bind(Socket0, 1234)?;

// send 4 bytes to 192.168.2.4:8080, and get the number of bytes transmitted
let data: [u8; 4] = [0, 1, 2, 3];
let destination = SocketAddrV4::new(Ipv4Addr::new(192, 168, 2, 4), 8080);
let tx_bytes = w5500.udp_send_to(Socket0, &data, &destination);
```

TCP streams (client)

```
use w5500_hl::ll::{
    net::{Ipv4Addr, SocketAddrV4},
    Registers, Socket,
};
use w5500_hl::Tcp;

const MQTT_SOCKET: Socket = Socket::Socket0;
const MQTT_SOURCE_PORT: u16 = 33650;
const MQTT_SERVER: SocketAddrV4 = SocketAddrV4::new(Ipv4Addr::new(192, 168, 2, 10), 1883);

// initiate a TCP connection to a MQTT server
w5500.tcp_connect(MQTT_SOCKET, MQTT_SOURCE_PORT, &MQTT_SERVER)?;
```

TCP listeners (server)

```
use w5500_hl::ll::{
    net::{Ipv4Addr, SocketAddrV4},
    Registers, Socket,
};
use w5500_hl::Tcp;

const HTTP_SOCKET: Socket = Socket::Socket1;
const HTTP_PORT: u16 = 80;

// serve HTTP
w5500.tcp_listen(HTTP_SOCKET, HTTP_PORT)?;
```

---

Source: https://maker.wiznet.io/josephsr/projects/W5500hlrs/
