- Mon Feb 13, 2017 3:15 pm
#62518
Hello, Cicero,
Sorry for the late answer. Looks like my providers spam filter is eating the forum notifications
I have no problem helping you out, I've done quite a bit more to this project that I just haven't had the time to release.
That sounds great - thank you!
Unfortunately I've never used lua though!
I think this is not a big problem. 5 weeks ago, I haven't either.
Usually you don't do big things in lua. You just write small codelets to connect the C-functions, which are surfaced to "lua land" by tiny wrapper functions.
As you may see from my github, I'm right now trying to get a PR pulled with a interface to the espconn ping service. This is a good trainig for this kind of lua-C interfacing. I feel I had some breakthrough yesterday and am on a good way now.
Unfortunately, my time is not that ample, so sometimes things may take a bit.
I see that there are two ways to electrically connect the ENC28J60 - your resistor scheme
https://github.com/Cicero-MF/esp_enc28j ... wiring.pngand UPIP using Mosfets.
https://github.com/UIPEthernet/UIPEther ... wiring.PNGI've ordered some of those BS170. Am I correct that both schematics are logically equivalent ? Which one is the more stable / reliable one?
I think I'll try to get your git firmware running first, so I can be sure that the hardware part is working.
Next step would be to surface your enc28j60.c to lua land and try to load / configure / blink / regdump and maybe even send/recieve raw packets.
Then I'd try to surface the netif driver interface to lua land and then connect both sides by a simple main loop followong the the lwip netif doku.
If you could see where lwip does that processing then that may remove the reliance on stack.c.
Maybe I underestimate the task. But when I glance into the lwip doku
- http://lwip.wikia.com/wiki/LwIP_with_or_without_an_operating_system
- http://lwip.wikia.com/wiki/Writing_a_device_driver
- http://lwip.wikia.com/wiki/Network_interfaces_management
this does not look that difficult.
I even could imagine to implement the main callbacks lwip <-> driver in lua, at least for testing, debugging and maybe API for special tasks (just think of packet filtering...).
But most of the use cases will rely on a reliable tested connection implemented in C.
Lua land can be used to configure SPI, driver, IP and stuff like that.
my initial guess is you'll have to tap into the tcpip_thread() -> sys_timeouts_mbox_fetch() and have a good look down that rabbit hole!
This is somewhat contrary to above mentioned docu.
Well, it may be some flats up or down the rabbit hole, of course.
You need to also have a method of distinguishing between interfaces for each packet received, wifi/wired at the low level as well.
I despereately expect lwip to take care of that.
At least I could alread get diffent interfaces listed for wifi and loopback (similiar to *nix ifconfig)
at the time when I looked into it, it wasn't open enough and still required some closed binary blobs which restricted full lwip implementation.
That would be really bad.
You think they don't have a full lwip on board?
And / or tweaked it in some inseperable way with their espconn stuff?
This might be a game killer, actually.