Ethernet interface

14 Nov 2009 . Edited: 15 Nov 2009

This question raised to support. I have posted here so that there is a searchable record that will help mbed users inthe future.

This seems like a great project, though its seriously lacking documentation.
I am most interested in the Ethernet portion of it.
Though i dont know whats i capable of as i can find no good documentation on it.
can it do DHCP & static and if so how ?
Can i have multiple TCP listeners ?

Glad you like the project!

NXP have documented the microcontroller itself in detail, but the thing that is hard to do is document projects and examples that are useful. There are so many possible designs and it is still early days - it will improve over time!

Some good work and example projects have started using Ethernet, they are documented is

The IP stack used does use DHCP :

It is possible to use static IP with a few tricks, though I'm not sure about the multiple TCP listeners. Rolf (who did these projects) will probably post with some definitie answers when he sees the thread.

Cheers,
Chris

23 Nov 2009

Hi,

Can someone please enlighten me on the 'few tricks' required to implement static IP?  I am getting a bit lost in the inheritance hierarchies as to where to implement it...

23 Nov 2009

Note: So I found an easier solution, I just installed a DHCP server myself and then could use the pre-existing code.

( I am connecting an mbed to a WindowsPC directly, no router).

This is okay for now but not long term.... I would still appreciate some tips on how to properly implement static IP into my code using the pre-existing libraries!!

Thanks

23 Nov 2009

Hi Angus,

Do you mean static IP just with the Ethernet class?

I'm afraid, thats not easy, the mbed Ethernet class speaks just plain Ethernet. So you can place a packet on the wire and receive a packet from the wire. This is enough for things like ARP requests. Wakeup over LAN or some simple UDP hacks.

For anything more like what requires a full IP stack its better to use an IP stack like lwip. We have a Cookbook project which deals with lwip.

If you want to have a look at it and using the HTTPClient/Server implementations priovided by it it looks like it's fairly simple to use just have a look here:

http://mbed.org/projects/cookbook/api/EMAC/lwip/trunk/HTTPClient/HTTPClient#HTTPClient.HTTPClient

something like

 

HTTPClient http("wolf",              // Brings up the device with static IP address and domain name.
                IPv4(192,168,0,44),  // IPv4 is a helper function which allows to rtype ipaddresses direct
                IPv4(255,255,255,0), // as numbers in C++.
                IPv4(192,168,0,1),   // the device address is set to 192.168.0.44, netmask 255.255.255.0
                IPv4(192,168,0,1));  // default gateway is 192.168.0.1 and dns to 192.168.0.1 as well.

might work for you

 

Cheers

Rolf