I’m writing a Gadgeteer module that has code for either using a wifi module or an ethernet one. I’m switching between the two modes by commenting and uncommenting different bits of code. It would be more elegant if I could probe the socket (9 on a FEZ Spider) to see which of the two flavours of networking is present. Is that possible in code?
Since both are SPI you could open the SPI port at first and send one specific SPI command to each module.
If you get the answer, the module is present.
Then close SPI and initialize the network interface.
The hard part would be to find a unique SPI command for each module where you get an answer for sure.
For my part, I store this information (along with the GPIO’s and Baudrate of SPI, IP address, Gateway, …) on SD card and load it from there on startup.
You could also store some information on a one time init in EWR.