I just released 0.20.0. The changes:
...Code:* Added a `BroadcastChat` example that implements a simple chat over UDP.
Highlights:
* Two new examples: AltcpTemplate and BroadcastChat
...
Link: https://github.com/ssilverman/QNEthernet/releases/tag/v0.20.0
### Added
* Added `EthernetClass::linkIsCrossover()` for checking if a crossover cable
is detected.
* Added entropy-based random number functions, `entropy_random()` and
`entropy_random_range(range)`. The second uses an unbiased algorithm.
### Changed
* Renamed TRNG tests to test_entropy.
* Added calling file, line, and function information to
`LWIP_ASSERT_CORE_LOCKED()`.
* Un-deprecated `EthernetClass::MACAddress(mac)` and `setDnsServerIP(ip)`.
* Optimized byte-swapping by using GCC built-ins.
### Fixed
* Reset the PHY in a much more conservative way. Hopefully this helps with
restarting Ethernet causing packets to not be received.
* Fixed dhcp struct assignment to be done each time the netif is added. This
addresses `netif_add()` clearing all the client data.
* Fixed `LWIP_PLATFORM_ASSERT()` to flush stdout's underlying `Print` object.
This ensures all output for an assertion failure gets sent out before the call
to `abort()`.
* Fixed the link status values changing after setting the link up.
### Added
* `EthernetClass::setDHCPEnabled(flag)` enables or disables the DHCP client. May
be called either before or after Ethernet has started.
* `EthernetClass::isDHCPEnabled()` returns whether the DHCP client is enabled.
Valid whether Ethernet has been started or not.
* New `LinkWatcher` example.
* Added support for building for unsupported boards via a new bare lwIP driver.
### Changed
* Limit the number of times `enet_proc_input()` can loop to twice the ring size.
* Limit UDP output size to the maximum possible (65535 - 28(total header)).
* It's now possible to know when adding or removing a MAC address filter failed.
* Make it possible to disable and exclude DHCP, DNS, IGMP, TCP, and UDP.
* Changed `EthernetClass::setMACAddress(mac)` to use the built-in MAC address if
the given array is NULL.
* Changed `EthernetClass::begin(mac)` to wait for an IP address. The default is
a 60-second timeout. There's also a new, optional, `timeout` parameter for
specifying that timeout. This change makes the API match the Arduino
Ethernet API.
* Renamed `enet_getmac(mac)` to `enet_get_mac(mac)`.
* Better NULL argument checking.
* Simplified `ServerWithListeners` example.
* Changed `enet_init(...)` to return a `bool` for detecting init. failure.
### Fixed
* Fixed how `EthernetClient` functions work when there's a pending connect
triggered by `connectNoWait()`.
* Fixed how raw frame size limits are checked. Padding is already handled by
the MAC.
* Fixed compilation if `LWIP_IGMP` is disabled, including making
`LWIP_MDNS_RESPONDER` dependent on `LWIP_IGMP` (in addition to `LWIP_UDP`).
* Improved `trng_is_started()` by adding an additional check for the "OK to
stop" bit. It now works at system startup if the clock is already running.
The lwIP project just released v2.2.0-rc1, so I made a QNEthernet branch that uses it. ...
The lwIP project just released v2.2.0-rc1, so I made a QNEthernet branch that uses it…
#define LWIP_DNS 0
#define LWIP_IGMP 0
#define LWIP_TCP 0
## [0.23.0]
### Added
* Added `qindesign::security::RandomDevice`, a class that conforms to the
_UniformRandomBitGenerator_ C++ named requirement. This makes it a little
easier to generate platform-independent entropy.
* `EthernetUDP::receivedTimestamp()` for retrieving a packet's approximate
arrival time.
* Added a "`writeFully()` with more break conditions" subsection to the README.
* `EthernetFrame::receivedTimestamp()` for retrieving a frame's approximate
arrival time.
* `EthernetClient::connectionTimeout()` for getting the current timeout value.
### Changed
* Changed `EthernetUDP::localPort()` to be `const`.
* Changed `entropy_random_range()` to return zero if `EAGAIN`.
* Changed `entropy_random_range()` to use Daniel Lemire's nearly-
divisionless algorithm.
* Updated lwIP to v2.2.0-rc1.
* Made `StdioPrint` single-argument constructor `explicit`.
* Updated `EthernetClass::linkStatus()` to return `EthernetLinkStatus::Unknown`
if the hardware hasn't yet been probed.
* Updated `AltcpTemplate` example to print proxy information.
* Updated `EthernetUDP::availableForWrite()` to return the amount remaining
before hitting the maximum possible payload size.
* Add 5 to `MEMP_NUM_SYS_TIMEOUT` option for mDNS instead of 1.
### Removed
* Removed TTL concept from `MDNSClass`. This enables it to compile with the
latest lwIP.
### Fixed
* Fixed `SNTP_SET_SYSTEM_TIME_US(sec, us)` definition to set the RTC directly
because `settimeofday()` doesn't exist here.
* Fixed `AltcpTemplate` example so that it compiles when `LWIP_ALTCP` isn't set.
## [0.24.0]
### Added
* The new `QNETHERNET_MEMORY_IN_RAM1` configuration macro indicates that
lwIP-declared memory should go into RAM1.
* New `EthernetFrameClass::receiveQueueSize()` function.
* New `EthernetUDP::receiveQueueSize()` and `setReceiveQueueSize(size)`
functions.
* Enabled external definition of macros `LWIP_NETIF_LOOPBACK` and
`LWIP_LOOPBACK_MAX_PBUFS`.
* Sprinkled some more `Ethernet.loop()` calls where pcb and pbuf
allocations fail.
* Added `EthernetClass::setLinkState(flag)` for manually setting the link state
when a link is needed, such as when using the loopback feature. Network
operations will usually fail unless there's a link.
* Added more unit tests:
* test_ethernet:
* test_setLinkState
* test_udp_receive_queueing
* test_udp_receive_timestamp
* test_udp_state
* test_client_connectNoWait
* test_client_timeout
* test_client_state
* test_server_state
* test_other_state
* test_entropy:
* test_randomDevice
* Added commented-out `LWIP_STATS_LARGE` option to _lwipopts.h_.
### Changed
* Changed memory declaration macro, `LWIP_DECLARE_MEMORY_ALIGNED()`, to use the
`MEM_ALIGNMENT` value.
* Now calling `shrink_to_fit()` on the UDP and Ethernet frame queues when
changing their size.
* Add 6 to `MEMP_NUM_SYS_TIMEOUT` option for mDNS instead of 5. Timeout
exhaustion was still observed with 5.
* There's now a single _lwip_driver.h_ header for interfacing with the stack.
* Changed all `EthernetClass::begin(mac, ...)` functions to be consistent. If
the MAC address is NULL then the MAC will be set to the internal one. Also,
if starting Ethernet fails, the MAC address will not be changed.
* Improved Ethernet tests to do proper object destruction when tests fail. The
Unity test framework makes use of _longjmp_ for failing tests, and that
doesn't work well with object destructors.
* Unit test updates.
* Made single-argument `EthernetClass` and `EthernetClient` constructors
explicit.
### Fixed
* Now using the correct name when adding an mDNS service.
* Pre-reserving memory for raw frames and UDP packets prematurely exhausts the
heap when a larger number of them are reserved in the queue. These buffers are
no longer reserved; they only grow appropriately when data comes in.
* Fixed closing `EthernetClient`s to remove the connection state if not already
connected. Restarting an `EthernetClient` via one of the `connectXXX()`
functions calls `close()` first. If there was no connection, then closing
never removed the internal connection object, causing a leak.
* Fixed `Ethernet.loop()` to also poll the netif if loopback is enabled. This
allows loopback to work.
* `EthernetServer::end()` now sets the port to -1.
## [0.25.0]
### Added
* New "Heap memory use" section in the README that discusses memory
allocation functions.
* New _RandomNumbers_ example.
* Added a README subsection that talks about the `RandomDevice` class.
* Added `RandomDevice::instance()`.
* Added `EthernetClient::status()` for getting the TCP connection state.
### Changed
* Enabled the `MEM_LIBC_MALLOC` option by default to make use of the system-
defined malloc functions instead of the lwIP-defined ones.
* Moved around where the netif gets its address set.
* Changed the license to "AGPL-3.0-or-later".
* Made `RandomDevice` constructor and destructor private.
* Improved unit tests.
* Updated lwIP to v2.2.0.
### Removed
* Removed the `extern qindesign::security::RandomDevice randomDevice` instance
from _QNEthernet.h_ because the way to access the device now is via its
`instance()` function (the constructor is also private now). (It had been
added in v0.23.0.)
### Fixed
* Fixed `enet_init()` to always initialize the internal MAC address on
first init.
* Fixed execution error when running _main.cpp_ (`MAIN_TEST_PROGRAM` macro
defined) by removing `build_type = debug` from _platformio.ini_.
* Fixed static initialization order for `Ethernet`, `EthernetFrame`, and `MDNS`
singletons by using the Nifty Counter idiom.
I'm using IDE2.2.1 on macOS with the latest QNEthernet it installs. I'm not great at GitHub Desktop but do use it (probably incorrectly).Anyone up for helping and trying it out? I'd love some feedback before I roll another release.
Yes, you could do that.I'm using IDE2.2.1 on macOS with the latest QNEthernet it installs. I'm not great at GitHub Desktop but do use it (probably incorrectly).
Should I clone the master into ~/Documents/Arduino/libraries replacing the existing QNEthernet folder ?
~/Documents/Arduino/libraries/QNEthernet/src/QNEthernet.cpp: In member function 'bool qindesign::network::EthernetClass::begin(const IPAddress&, const IPAddress&, const IPAddress&, const IPAddress&)':
~/Documents/Arduino/libraries/QNEthernet/src/QNEthernet.cpp:186:11: error: ambiguous overload for 'operator!=' (operand types are 'const IPAddress' and 'const IPAddress')
186 | if (dns != INADDR_NONE) {
| ~~~ ^~ ~~~~~~~~~~~
| | |
| | const IPAddress
| const IPAddress
~/Documents/Arduino/libraries/QNEthernet/src/QNEthernet.cpp:186:11: note: candidate: 'operator!=(uint32_t {aka long unsigned int}, uint32_t {aka long unsigned int})' (built-in)
186 | if (dns != INADDR_NONE) {
| ~~~~^~~~~~~~~~~~~~
In file included from ~/Documents/Arduino/libraries/QNEthernet/src/QNEthernet.h:15,
from ~/Documents/Arduino/libraries/QNEthernet/src/QNEthernet.cpp:7:
~/Library/Arduino15/packages/teensy/hardware/avr/0.59.4/cores/teensy4/IPAddress.h:82:14: note: candidate: 'bool IPAddress::operator!=(const IPAddress&) const'
82 | bool operator!=(const IPAddress& addr) const {
| ^~~~~~~~
In file included from ~/Documents/Arduino/libraries/QNEthernet/src/QNEthernet.h:33,
from ~/Documents/Arduino/libraries/QNEthernet/src/QNEthernet.cpp:7:
~/Documents/Arduino/libraries/QNEthernet/src/util/ip_tools.h:27:6: note: candidate: 'bool qindesign::network::operator!=(const IPAddress&, const IPAddress&)'
27 | bool operator!=(const IPAddress &a, const IPAddress &b);
| ^~~~~~~~
const IPAddress
operators for comparison operations because previous Teensyduinos didn't have the const
version. The latest code only adds those if the Teensyduino version is <= 1.58.## [0.26.0]
### Added
* Added `EthernetClient::localIP()`.
* Added `EthernetClass::hostByName(hostname, ip)` convenience function.
* Added `EthernetClass::setDNSServerIP(index, ip)` and `dnsServerIP(index)`.
* Added some support for Mbed TLS v2.x.x. There's four new adapter functions
for assisting integration (see _src/altcp_tls_adapter.cpp_), included if the
`QNETHERNET_ALTCP_TLS_ADAPTER` option is set:
1. `qnethernet_altcp_is_tls`
2. `qnethernet_altcp_tls_client_cert`
3. `qnethernet_altcp_tls_server_cert_count`
4. `qnethernet_altcp_tls_server_cert`
* Added _MbedTLSDemo_ example.
* Added printing the message size in _LengthWidthServer_ example.
* Added `QNETHERNET_ENABLE_ALTCP_DEFAULT_FUNCTIONS`-gated default
implementations of the altcp interface functions.
* Added `EthernetClass::macAddress()` for returning a pointer to the current
MAC address.
### Changed
* Updated lwIP to the latest master (5e3268cf).
* Made the driver non-blocking:
1. TX: if there's no available buffer descriptors (returns ERR_WOULDBLOCK)
2. Link checks via MDIO
* Updated the tests:
* Added a 10s connection timeout to `test_client_addr_info()`
* Added SNTP retries to `test_udp()`
* Updated and added some messages
* Made `MDNSClass::Service::operator==()` `const`.
* Completely revamped PHY and pin initialization.
* Gated PHY and Ethernet shutdown in `EthernetClass::end()` with a macro; the
default behaviour is to not execute these blocks. This and the previous are
part of the quest to figure out why performance drops off a cliff when
Ethernet is restarted via first calling `end()`.
* Changed return type of `qnethernet_get_allocator` to `bool`.
* Renamed `qnethernet_get_allocator` and `qnethernet_free_allocator` to
`qnetheret_altcp_get_allocator` and `qnethernet_altcp_free_allocator`,
respectively.
* Changed `qnethernet_get_allocator` and `qnethernet_free_allocator` `allocator`
parameter to be a reference.
* Renamed `QNETHERNET_MEMORY_IN_RAM1` to `QNETHERNET_LWIP_MEMORY_IN_RAM1`.
* Updated the _AltcpTemplate_ example.
* Fixed `IPAddress`-related build problems with the new Teensyduino 1.54-beta4.
* Updated the _RawFrameMonitor_ example with information about how to
disable DHCP.
* Disabled waiting in `EthernetClient::close()` for altcp clients because it's
not defined.
* Changed configuration macro checks to use value instead of definedness.
### Fixed
* Fixed a `printf` conversion specifier in the _RandomNumbers_ example. This was
causing a compile warning.
* Fixed location of STATIC_INIT_DECL() for `RandomDevice` by putting it into
the header. It needs to be in a place where users of the class see it.
* Fixed `EthernetClass::setMACAddress()` for when the interface is up.
## [0.27.0]
### Added
* New `QNETHERNET_FLUSH_AFTER_WRITE` configuration macro for flushing after
every call to `EthernetClient::write()`. This may reduce TCP efficiency.
* Added a W5500 driver.
* Added a new `EthernetHardwareStatus::EthernetTeensy41` enum value.
* New `QNETHERNET_DEFAULT_HOSTNAME` option.
### Changed
* Made it easier to add other low-level drivers.
* Redesigned the driver interface.
* Un-deprecated `EthernetClass::begin(mac, timeout)` and
`begin(mac, ip, dns, gateway, subnet)`.
* Un-deprecated `EthernetClass::init(sspin)` and added a driver function for
setting the chip select pin. The type of `sspin` was also changed to `int`.
* Removed dependency on `elapsedMillis`. This might help with compiling for
other platforms.
* Made the library easier to compile for other platforms.
* Replaced all `#define` guards with `#pragma once`.
* All `QNETHERNET_*` configuration macros can now be defined in a new
`qnethernet_opts.h` file in addition to the project build.
* Removed test dependencies on Teensy-specific things.
* Renamed _t41_ driver source files to use _teensy41_ in the name instead.
* Changed return type of `EthernetUDP::beginWithReuse()` and
`beginMulticastWithReuse()` to `bool`.
* Using better randomness for `LWIP_RAND()`.
* Changed attributes to use the C++ style.
* Changed the default hostname to "qnethernet-lwip".
* Renamed `enet_get_mac(mac)` to `enet_get_system_mac(mac)`.
### Fixed
* Added missing `hostByName` to keywords.txt.
* Fixed `enet_output_frame()` to return false if there's no output buffer.
* Fixed `EthernetClient::write(buf, size)` to re-check the state after a call
to `loop()`.
* Fixed `util::writeMagic()` `mac` parameter to be `const`.
* Fixed `test_ethernet`'s `tearDown()` to remove listeners before calling
`Ethernet.end()`. This ensures no out-of-scope variables are accessed.
* Updated `StdioPrint` to not use `errno` because stdio doesn't set this.