Mbed library for ENC28J60 Ethernet modules. Full support for TCP/IP and UDP Server, Client and HTTP server (webserver). DHCP and DNS is included.
Dependents: mBuino_ENC28_MQTT Nucleo_Web_ENC28J60 Nucleo_Web_ENC28J60_ADC Serial_over_Ethernet ... more
Library for ENC28J60 Ethernet modules.
Ported to mbed from Norbert Truchsess's UIPEthernet library for Arduino. Thank you Norbert!
- Full support for persistent (streaming) TCP/IP and UDP connections Client and Server each, ARP, ICMP, DHCP and DNS.
- Works with both Mbed OS 2 and Mbed OS 5.
Usage:
- Import the library into your project.
- Add
#include "UipEthernet.h"
tomain.cpp
- Create one instance of the UipEthernet class initialized with the MAC address you'd like to use and SPI pins of the connected Mbed board.
Example programs:
Import programWebSwitch_ENC28J60
HTTP Server serving a simple webpage which enables to remotely turn a digital output on/off. Compile, download, run and type 'IP_address/secret/' (don't forget the last '/') into your web browser and hit ENTER.
Import programHTTPServer_Echo_ENC28J60
A simple HTTP server echoing received requests. Ethernet connection is over an ENC28J60 board. Usage: Type the server's IP address into you web browser and hit <ENTER>.
Import programTcpServer_ENC28J60
Simple TCP/IP Server using the UIPEthernet library for ENC28J60 Ethernet boards.
Import programTcpClient_ENC28J60
Simple TCP/IP Client using the UIPEthernet library for ENC28J60 Ethernet boards.
Import programUdpServer_ENC28J60
Simple UDP Server using the UIPEthernet library for ENC28J60 Ethernet boards.
Import programUdpClient_ENC28J60
Simple UDP Client using the UIPEthernet library for ENC28J60 Ethernet boards.
Import programMQTT_Hello_ENC28J60
MQTT Client example program. Ethernet connection is via an ENC28J60 module.
utility/ip4string.h@14:7648334eb41b, 2019-09-03 (annotated)
- Committer:
- hudakz
- Date:
- Tue Sep 03 09:16:55 2019 +0000
- Revision:
- 14:7648334eb41b
UDP socket improved.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 14:7648334eb41b | 1 | /* |
hudakz | 14:7648334eb41b | 2 | * Copyright (c) 2014-2018 ARM Limited. All rights reserved. |
hudakz | 14:7648334eb41b | 3 | * SPDX-License-Identifier: Apache-2.0 |
hudakz | 14:7648334eb41b | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
hudakz | 14:7648334eb41b | 5 | * not use this file except in compliance with the License. |
hudakz | 14:7648334eb41b | 6 | * You may obtain a copy of the License at |
hudakz | 14:7648334eb41b | 7 | * |
hudakz | 14:7648334eb41b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
hudakz | 14:7648334eb41b | 9 | * |
hudakz | 14:7648334eb41b | 10 | * Unless required by applicable law or agreed to in writing, software |
hudakz | 14:7648334eb41b | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
hudakz | 14:7648334eb41b | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
hudakz | 14:7648334eb41b | 13 | * See the License for the specific language governing permissions and |
hudakz | 14:7648334eb41b | 14 | * limitations under the License. |
hudakz | 14:7648334eb41b | 15 | */ |
hudakz | 14:7648334eb41b | 16 | #ifndef IP4STRING_H |
hudakz | 14:7648334eb41b | 17 | #define IP4STRING_H |
hudakz | 14:7648334eb41b | 18 | #ifdef __cplusplus |
hudakz | 14:7648334eb41b | 19 | extern "C" { |
hudakz | 14:7648334eb41b | 20 | #endif |
hudakz | 14:7648334eb41b | 21 | |
hudakz | 14:7648334eb41b | 22 | #include "ns_types.h" |
hudakz | 14:7648334eb41b | 23 | |
hudakz | 14:7648334eb41b | 24 | /** |
hudakz | 14:7648334eb41b | 25 | * Print binary IPv4 address to a string. |
hudakz | 14:7648334eb41b | 26 | * |
hudakz | 14:7648334eb41b | 27 | * String must contain enough room for full address, 16 bytes exact. |
hudakz | 14:7648334eb41b | 28 | * |
hudakz | 14:7648334eb41b | 29 | * \param ip4addr IPv4 address. |
hudakz | 14:7648334eb41b | 30 | * \param p buffer to write string to. |
hudakz | 14:7648334eb41b | 31 | * \return length of generated string excluding the terminating null character |
hudakz | 14:7648334eb41b | 32 | */ |
hudakz | 14:7648334eb41b | 33 | uint_fast8_t ip4tos(const void *ip4addr, char *p); |
hudakz | 14:7648334eb41b | 34 | |
hudakz | 14:7648334eb41b | 35 | /** |
hudakz | 14:7648334eb41b | 36 | * Convert numeric IPv4 address string to a binary. |
hudakz | 14:7648334eb41b | 37 | * |
hudakz | 14:7648334eb41b | 38 | * \param ip4addr IPv4 address in string format. |
hudakz | 14:7648334eb41b | 39 | * \param len Length of IPv4 string, maximum of 16.. |
hudakz | 14:7648334eb41b | 40 | * \param dest buffer for address. MUST be 4 bytes. |
hudakz | 14:7648334eb41b | 41 | * \return boolean set to true if conversion succeed, false if it didn't |
hudakz | 14:7648334eb41b | 42 | */ |
hudakz | 14:7648334eb41b | 43 | bool stoip4(const char *ip4addr, size_t len, void *dest); |
hudakz | 14:7648334eb41b | 44 | |
hudakz | 14:7648334eb41b | 45 | #ifdef __cplusplus |
hudakz | 14:7648334eb41b | 46 | } |
hudakz | 14:7648334eb41b | 47 | #endif |
hudakz | 14:7648334eb41b | 48 | #endif |