New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wired Ethernet module, using ENC28J60 , W5100 or similiar Hardware #1725
Comments
For the loose end, I started a thread at the forum Preliminary conclusions after a first scrutiny of datasheet, NodeMCU and the mentioned libs:
I conclude, instead of dismanteling hands-on mixed-layered libraries, it may be better to use existing layer 2 implementations (aka drivers ) for the enc28j60 on lwIP, even if they were written for other platforms. From googled results, I selected two candidates for a closer look:
|
... still diving in manuals ... |
Things getting shape now.
=(1)= SPI calls |
regarding the upside interfaces, I hope that lwIP will do most of the job. |
regarding Interface =(1)= SPI lib I start with my favourate driver template:
For the other edge, let's dissect the
According to the Espressif IoT SDK Documentation, the SPI provided by the SDK only refer to flash memory interface. I found no documented SPI functions in the SDK for interfacing the outside world. We don't want to reinvent the wheel and double maintenance load. |
I agree with your findings, the SPI platform layer is the right choice. A recommendation regarding SPI setup: let the user configure the SPI module from Lua land with SS / CS pin should be controlled by the |
I'd expect that new functionality for managing the routing tables will be needed. So far we had a trivial setup with just one interface. Adding another phy will probably require to set up default routes etc. from Lua land. |
regarding Interface =(2)= system helpers A survey of
Let's compare them with the nodemcu coding guide: The 50 ms timeout is far above the sound 8ms limit of the NodeMCU Documentation.
hm.... while this looks simple in the LUA docu, how does it look like in C? Can we then even stay with the loops as they are? In good old hex coding times on 6502 bare metal, we wrote
I don't think I have to reinvent the wheel, have I ? |
@devsaurus write
I'd hope that lwIP might provide some of this functionality. Is there a LUA interface for lwIP But don't we overload the ESP platform with routing? From my own point of need, I would not require routing. Recently I bought a module for 25 bucks from Olimex wiht openWRT on it, including Wlan, 2 ethernet ports broken out (another 3 available at some pins). Available for 15 €/$ as a bare module. This is the stuff to make embedded routers of. I am looking for a single sensor/actor interface platform where I can connect the same type of sensor either by LAN or by WLAN, presumaply using MQTT. So I would simply switch of the WLAN when I am on Ethernet. But of course I see that others might have different Ideas. I even remeber having read of "enabling IP forwarding" in ESP context. I mean you can have more than one IP on the same interface anyway. Just think of elaborated WLAN relaying. And yes, there is the issue of level 7 relaying. Receiving a mqqt message on one foot, sending an email, for example, on the other. Binding differnt sockets to different interfaces. I'll keep an eye on it, not to break it, if it is possible without too much effort. |
Maybe I found an Answer to my question above
"Protothreads" is invented by Adam Dunkels, the creator of the lwIP library.
And the manual states
This is exactly what the driver does. However, grepping through the nodeMCU tree does not yield any use of protothreads yet. |
@devsaurus wrote
As I expected, lwIP should provide this functionality - start looking here: Unfortunately, only a small part of the lwIP API is wrapped in Lua callers yet.
I'd propose For the development stage, it would really be great to interacitvely inspect and call arbitrary C-code from Lua-Land. Is this possible? Would be great to have pointer to start... |
@wolfgangr I think your undertaking is just awesome. Please know that this would be a great addition to the ESP. About routing, you probably already realized this, but the ESP already has two interfaces: the station and the ap. Currently, they don't really talk to each other, unless you compile lwip with some special defines*, but I think a formal routing api would fix that. An ethernet interface would add a third interface. *I tried this. I used the ESP as a makeshift wifi range extender, where the ESP was between the wlan router and my laptop. It works, I was even able to stream netflix through the ESP without issues, but it required routing rules in the wlan router, which is troublesome and inflexible. |
This i a nice way to tell. Hope there is no (C) on it ;-)
I knew that people are out there with Ideas beyond mine :-O Started a tutorial last night of lua <-> lib surfacing Maybe the Albeit I haven't yet found a routine to list all available interfaces. This would have easily told everybody that AP and station are implmented as two interfaces on top of the same PHY. But first, live gets into the way ;-) |
Head bangs metal :-( |
After some training loopings in the nodemcu ecosystem, (somewhat successful in terms of learning, but not yet so much in usable outcome) I'm reconsidering my plans right now. As I can estimate at the moment, these problems (referring to interface layers =(1)= and =(2)= in above sketch outweight the complexity of interface =(5)= of connection to the lwIP machinery. These induces me to rate down the idea of adapting lwIP drivers to nodeMCU and rate up existing drivers for the ESP SDK and fix the lwIP interface instead. From the links in the top post, I see that UIPEthernet is written in C++ . This adds another layer of complexity, since I do not yet find such in nodeMCU firmware, and I'm by no way an experienced C / C++ specialist. For the moment, this leaves the Cicero-MF driver at the top of my ranking I just cross-check the lwIP requirements (Chapter 7 of 'THE Dunkles Paper',
plus some houskeeping addons (init, raw packets for ARP, state change callbacks, ...) I think I can find those hooks in the Cicero-MF driver. So, Cicero-MF-driver will be my first candidate to test. |
I don't mind helping out where I can if needed. I'm just not versed with Lua at all. |
@wolfgangr Not meaning to hi-jack the issue, but your how-to post was great - would love to see that linked from our docs. PR perhaps? What do you think @marcelstoer? |
<hi-jack> |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@wolfgangr Are you still working on this? I've been wondering today whether or not it would be possible to wire esp8266's together using ethernet. |
Missing feature
Wired ethernet connectivity.
Justification
IoT in harsh environments and/or demanding reliability and/or low power may be better of with wired ethernet. I'd like to put some modules on my heater, my farm, my tractors, my machinery...
Workarounds
May use CAN, serial communication, I2C, SPI on short distance or relay WIFI over openWRT AP or Raspi in AP mode.
Road to solution
The ENC28J60 is easily available as a breakout module from asian sources < 3 EUR for Arduinos etc.
There are already existing libraries for the ENC28J60 on ESP8266, e.g.
https://github.com/Cicero-MF/esp_enc28j60
https://github.com/UIPEthernet/UIPEthernet
They do not yet fit into the framwork of the nodeMCU LUA architecture, but I hope they may be adopted.
My possible contributions:
I have no clue where to look for the hooks. But I'm sure there are some in the existing WIFI IP stack. My C coding knowledge is limited, but with some assistance from the community, I could try my best.
The text was updated successfully, but these errors were encountered: