Main Site Documentation

Snippet - Simple HTTP server using GHI's Premium Net library


#1

Simple HTTP server using GHI’s Premium Net library

GHI’s exclusive new networking library adds a highly configured way to take handle the networking interfaces on a device. Developers are able to control and to receive events from each individual interface, like a Ethernet cable was removed or WiFi connection is Lost. Then one of the interfaces can be assigned to the TCP/IP stack. This means no interface (Ethernet, WiFI…) is active by default.

This Application sets a static or dynamic IP address to “Built-in Ethernet” interface and runs a simple HttpServer. Of course this example requires a device with built in Ethernet PHY, not ENC28 Ethernet. The code can be be simply changed to use ENC28


#2

Nice! I think I like this approach, I will definitely give it at try soon.


#3

thanks Gus. I will try later today. Grandkids are coming to visit.

I assume that the Gadgeteer way will be similar.


#4

@ Mike - gadgeteer driver exposes the object, not much more. Enjoy and grand kids then let’s us know if it worked for you.


#5

I tried it… and it appears to work great. I was able to get an IP address using DHCP. I have not tried
to do anything else yet.

Later, when I have time, I want to check error recovery, and then do some performance tests with the new stack.


#6

Yeah it would be great to see the closed source stack vs LwIP stack :slight_smile:


#7

Got a some projects moved over to the new 4.2, but what does a Cerberus with a ENC28 modules look like configuration wise for the new networking? its 5:30am here and sorry but my brain is done heavy lifting.

Thanks


#8

I have a EMX Development System with a UEXT cable to a WiFi_RS21. Can I use:
static WiFiRS9110 wifi = new WiFiRS9110(SPI.SPI_module.SPI1, chipSelect, externalInterrupt, resetPin);
If I can what would be the values:
e.g. chipSelect = EMX.pin.IO12 externalInterrupt = EMX.pin.IO3 resetPin = EMX.pin.IO4 ??? just guessing.
Can anyone help with this? KG1


#9

Does the schematic help you in figuring out the pins? http://www.ghielectronics.com/downloads/EMX/EMX_DevSys_sch.pdf


#10

Thanks for the reply. It does not help especially in comparing with http://www.ghielectronics.com/downloads/Gadgeteer/Module/WiFi%20RS21%20V1.2%20schematic.pdf


#11

Sorry, exactly why doesn’t it help ?

Interrupt is on IO3 on EMX
Reset is on IO2
CS is on IO12


#12

Thank you for the help.


#13

I have tried to use the ENC28 with the G120HDR board.
But when assigning the Network stack (2nd line here)


Eth1 = new EthernetENC28J60(SPI.SPI_module.SPI2, G120.Pin.P1_11, G120.Pin.P0_6, G120.Pin.P0_1);
NetworkInterfaceExtension.AssignNetworkingStackTo(Eth1);

I get an exception


The thread '<No Name>' (0x2) has exited with code 0 (0x0).
    #### Exception GHI.Premium.Net.NetworkInterfaceExtensionException - 0x00000000 (1) ####
    #### Message: 
    #### GHI.Premium.Net.NetworkInterfaceExtension::SetDefaultInterface [IP: 001b] ####
    #### GHI.Premium.Net.NetworkInterfaceExtension::AssignNetworkingStackTo [IP: 0026] ####
    #### EmulatorApp.Program::InitEthernet [IP: 0011] ####
    #### EmulatorApp.Program::Main [IP: 0003] ####
A first chance exception of type 'GHI.Premium.Net.NetworkInterfaceExtensionException' occurred in GHI.Premium.Net.dll
An unhandled exception of type 'GHI.Premium.Net.NetworkInterfaceExtensionException' occurred in GHI.Premium.Net.dll

The program '[6] Micro Framework application: Managed' has exited with code 0 (0x0).

Is it possible that I have used some wrong pins? I have connected them to one of the user ports.
Any idea?


#14

@ Reinhard Ostermeier - Are you trying to use the emulator? External hardware does not work in emjlafor


#15

@ Mike: I’m not trying to use the Emulator. I have an actual G120HDR (V1.1) board. I have only USB Client DP Module and ENC28 Module connected.
The ENC28 is connected to User-Port 1, and I have wired the Pins as seen in code to it (MOSI2, MISO2, SCLK2, CS, Interrupt and reset). I did not connect the ‘WOL’ PIn. I’m not sure what it is used for. When I’m back at work (on Moday) I will post my exact wireing.
I’m using SDK 0.0.6. NETMF 4.2, Firmware is updated.
Some other small program which controls an AEDog LCD Display via SPI1 is working well on this board.


#16

I believe you have to do an open on Eth1 before making it the active device/stack.

Eth1.Open();


#17

I thought I made a 1:1 copy of the sample, but somehow I’ve missed that line.
Thank you Mike.


#18

Can somebody tell me why is this better comparing to classic sockets (http://wiki.tinyclr.com/index.php?title=TCP_/_Web_Server_Tutorial).
I am using Spider, and i will be using Cobra II.


#19

with MF 4.2 the IP stack was changed, and GHI built a new API for initialization.


#20

Which one should i pick? What things are important for my decision?