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.

/media/uploads/hudakz/enc28j60_module01.jpg

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" to main.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.

Committer:
hudakz
Date:
Sat Sep 07 17:42:42 2019 +0000
Revision:
15:53715cc81c63
Parent:
8:4acb22344932
Timeout parameter added for the 'connect' function, SPI speed reduced from 20 to 10 Mb/s, debug messages fixed ...

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 3:5b17e4656dd0 1 /**
hudakz 3:5b17e4656dd0 2 * \defgroup timer Timer library
hudakz 3:5b17e4656dd0 3 *
hudakz 3:5b17e4656dd0 4 * The timer library provides functions for setting, resetting and
hudakz 3:5b17e4656dd0 5 * restarting timers, and for checking if a timer has expired. An
hudakz 3:5b17e4656dd0 6 * application must "manually" check if its timers have expired; this
hudakz 3:5b17e4656dd0 7 * is not done automatically.
hudakz 3:5b17e4656dd0 8 *
hudakz 3:5b17e4656dd0 9 * A timer is declared as a \c struct \c timer and all access to the
hudakz 3:5b17e4656dd0 10 * timer is made by a pointer to the declared timer.
hudakz 3:5b17e4656dd0 11 *
hudakz 3:5b17e4656dd0 12 * \note The timer library uses the \ref clock "Clock library" to
hudakz 3:5b17e4656dd0 13 * measure time. Intervals should be specified in the format used by
hudakz 3:5b17e4656dd0 14 * the clock library.
hudakz 3:5b17e4656dd0 15 *
hudakz 3:5b17e4656dd0 16 * @{
hudakz 3:5b17e4656dd0 17 */
hudakz 3:5b17e4656dd0 18 /**
hudakz 3:5b17e4656dd0 19 * \file
hudakz 3:5b17e4656dd0 20 * Timer library header file.
hudakz 3:5b17e4656dd0 21 * \author
hudakz 3:5b17e4656dd0 22 * Adam Dunkels <adam@sics.se>
hudakz 3:5b17e4656dd0 23 */
hudakz 3:5b17e4656dd0 24 /*
hudakz 3:5b17e4656dd0 25 * Copyright (c) 2004, Swedish Institute of Computer Science.
hudakz 3:5b17e4656dd0 26 * All rights reserved.
hudakz 3:5b17e4656dd0 27 *
hudakz 3:5b17e4656dd0 28 * Redistribution and use in source and binary forms, with or without
hudakz 3:5b17e4656dd0 29 * modification, are permitted provided that the following conditions
hudakz 3:5b17e4656dd0 30 * are met:
hudakz 3:5b17e4656dd0 31 * 1. Redistributions of source code must retain the above copyright
hudakz 3:5b17e4656dd0 32 * notice, this list of conditions and the following disclaimer.
hudakz 3:5b17e4656dd0 33 * 2. Redistributions in binary form must reproduce the above copyright
hudakz 3:5b17e4656dd0 34 * notice, this list of conditions and the following disclaimer in the
hudakz 3:5b17e4656dd0 35 * documentation and/or other materials provided with the distribution.
hudakz 3:5b17e4656dd0 36 * 3. Neither the name of the Institute nor the names of its contributors
hudakz 3:5b17e4656dd0 37 * may be used to endorse or promote products derived from this software
hudakz 3:5b17e4656dd0 38 * without specific prior written permission.
hudakz 3:5b17e4656dd0 39 *
hudakz 3:5b17e4656dd0 40 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
hudakz 3:5b17e4656dd0 41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
hudakz 3:5b17e4656dd0 42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
hudakz 3:5b17e4656dd0 43 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
hudakz 3:5b17e4656dd0 44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
hudakz 3:5b17e4656dd0 45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
hudakz 3:5b17e4656dd0 46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
hudakz 3:5b17e4656dd0 47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
hudakz 3:5b17e4656dd0 48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
hudakz 3:5b17e4656dd0 49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
hudakz 3:5b17e4656dd0 50 * SUCH DAMAGE.
hudakz 3:5b17e4656dd0 51 *
hudakz 8:4acb22344932 52 * This file is part of the UIP TCP/IP stack
hudakz 3:5b17e4656dd0 53 *
hudakz 3:5b17e4656dd0 54 * Author: Adam Dunkels <adam@sics.se>
hudakz 3:5b17e4656dd0 55 *
hudakz 3:5b17e4656dd0 56 * $Id: timer.h,v 1.3 2006/06/11 21:46:39 adam Exp $
hudakz 3:5b17e4656dd0 57 */
hudakz 3:5b17e4656dd0 58 #ifndef __UIP_TIMER_H__
hudakz 8:4acb22344932 59 #define __UIP_TIMER_H__
hudakz 3:5b17e4656dd0 60
hudakz 8:4acb22344932 61 #include "uip_clock.h"
hudakz 3:5b17e4656dd0 62
hudakz 3:5b17e4656dd0 63 /**
hudakz 3:5b17e4656dd0 64 * A timer.
hudakz 3:5b17e4656dd0 65 *
hudakz 3:5b17e4656dd0 66 * This structure is used for declaring a timer. The timer must be set
hudakz 3:5b17e4656dd0 67 * with timer_set() before it can be used.
hudakz 3:5b17e4656dd0 68 *
hudakz 3:5b17e4656dd0 69 * \hideinitializer
hudakz 3:5b17e4656dd0 70 */
hudakz 3:5b17e4656dd0 71 struct uip_timer
hudakz 3:5b17e4656dd0 72 {
hudakz 3:5b17e4656dd0 73 clock_time_t start;
hudakz 3:5b17e4656dd0 74 clock_time_t interval;
hudakz 3:5b17e4656dd0 75 };
hudakz 3:5b17e4656dd0 76
hudakz 3:5b17e4656dd0 77 void uip_timer_set(struct uip_timer* t, clock_time_t interval);
hudakz 3:5b17e4656dd0 78 void uip_timer_reset(struct uip_timer* t);
hudakz 3:5b17e4656dd0 79 void uip_timer_restart(struct uip_timer* t);
hudakz 3:5b17e4656dd0 80 int uip_timer_expired(struct uip_timer* t);
hudakz 3:5b17e4656dd0 81 #endif /* __UIP_TIMER_H__ */
hudakz 3:5b17e4656dd0 82
hudakz 3:5b17e4656dd0 83 /** @} */