Open DtNeo opened 2 months ago
Did no one test it?
Sorry, just too much stuff on my plate. It is still in my queue to check when I'll have time. Nobody pays for this, and you know, I have tons of projects like this, unfortunately.
I do appreciate you sharing the PR! The project does require a lot of refactoring (and redesigning even).
Hello!
I’m sharing the v3 update tonight and wanted to provide some explanations.
I’ve renamed the folders: ./inc to ./Inc and ./src to ./Src.
I’ve reviewed the headers of all files (both header and source files). There's nothing particularly special to note about this. A good way to be good for a right license.
The Timers file is used for Timer4, which I’ve set up to renew the connection every 6 hours. I'm not entirely sure if it’s necessary, but I thought it might be useful.
The RTC and ntp files are responsible for obtaining the time from an NTP server and updating the STM32. It works well, although I still haven’t figured out why the STM32 drifts by a few minutes after an hour compared to the actual time.
The LogManager file is an "update" of ETHERSHIELD_DEBUG. My testing approach might be considered the hard way, as I’m using UDP for logging on syslog to track what’s happening—which means I don't see much directly. I think adding UART or another method for logging would be beneficial.
As for websrv or tcp, that’s a bit beyond my expertise.
The most important and significant update is the packet file. This file is crucial and should be optimized as much as possible. It handles the processing of all packets, serving as the bridge between the technical operations of the ENC28J60 and the processing of incoming packets from the internet. This part needs to be both fast and accurate.
I reorganize files :
defines: Contains macro definitions and constants, and is intended for users to specify their configuration variables, such as the desired IP address, the IP addresses of local servers for communication, and other customizable settings.
EtherShield: Serves as a summary of specific commands, consolidating key functions for managing the Ethernet shield.
packet: Handles packet processing and sending operations. (NEW !!!)
dnslkup: Implements DNS lookup functionality to resolve domain names to IP addresses.
_ip_arp_udptcp: Implements core network protocols, including IP, ARP, and UDP. The file shouldn't be TCP, there is a file dedicated.
tcp: Manages TCP connections and related operations.
net: Provides low-level network utilities and data structures. (not working)
_websrv_helpfunctions: Offers helper functions for web server operations. (not working)
dhcp: Implements DHCP client functionality for dynamic IP address configuration.
enc28j60: Manages the ENC28J60 Ethernet controller communication.
LogManager: Aims to provide various logging methods for the ENC28J60 module, and is designed to improve overall communication. Currently, the udplog2 function is widely used throughout the code.
ntp: Handles NTP client operations to synchronize time.
RTC: Manages the Real-Time Clock (RTC) on the STM32.
timers: Implements timing and delay functionalities using hardware timers.
_errorhandler: Handles error reporting and recovery mechanisms.
It’s still a draft in many ways, but I hope it provides some useful functionality, like a fast boot (ES_FullConnection) and an efficient way to send a UDP command to the STM32. For example, you can send this UDP packet from your network to log the time on your STM32: echo -n "sendRTCDateTime" | socat - UDP4-DATAGRAM:192.168.0.100:10001
At startup, in my log, for every start of my STM32, I receive the following UDP log:
This indicates that the internet connection is working, the RTC datetime is being requested (showing a delay of 1 minute as the NTP update happens shortly after and updates the RTC within the same second), the initialization of Timer 4 on line 3, and finally the NTP update.