How to start?

There are two directories of interest for you:
Framework and Executeable.

Framework contains the library code for a new project using NeonMika.Webserver. Check out this folder if you want to add NeonMika.Webserver to an existing project.

Executeable contains a little project created using NeonMika.Webserver. Check out this if you want to get a first experience with the server. You can run it without writne any line of code!

To test NeonMika.Webserver and to have some sample code, just follow these steps:

  1. Just download the code and go to "Executeables".
  2. Deploy the project to your Netduino Plus. It should start running.
  3. This sample project using NeonMika.Webserver has the following xml method added to the webserver at runtime: netduinoplus/wave ... Connect LEDs to Pin 0,1,4,5,8,9 and you will see your LED lighting up one after the other.



Server WebServer = new Server(PinManagement.OnboardLED, 80, false, "", "", "", "NETDUINOPLUS");


As you can see, you just need to call the constructor to start NeonMika.Webserver.

The needed parameters a pretty self explaining:

  1. The led port
  2. DHCP on / off
  3. IP adress
  4. Subnetwork mask
  5. Gateway
  6. Network name

You don't need anything more to run it!

What methods are already included?

Here is a list with all pre-coded webmethods you can use within your browser or any other application to communicate with your Netduino:

echo (Returns the submitted value)
-> netduinoplus/echo?value=[a-Z]

switchDigitalPin (Switches the selected pin from true to false and vis-a-vis)
-> netduinoplus/switchDigitalPin?pin=[0-13]

setDigitalPin (Set the selected digital pin to the selected state)
-> netduinoplus/setDigitalPin?pin=[0-13]&state=[true|false]

pwm (Set the PWM of the pin to the submitted period & duration
-> netduinoplus/pwm?pin=[5|6|9|10]&period=[int]&duration=[int]

getAnalogPinValue (Return the value of the selected analog pin)
-> netduinoplus/getAnalogPinValue?pin=[0-5]

getDigitalPinState (Returns your selected pin's state (on / off))
-> netduinoplus/getDigitalPinState?pin=[0-13]

getAllAnalogPinValues (Return the value for each analog pin)
-> netduinoplus/getAllAnalogPinValues

getDigitalPinState (Returns the state for each digital pin)
-> netduinoplus/getAllDigitalPinStates

getAllPWMValues (Returns the values for all PWM ports)
-> netduinoplus/getAllPWMValues

fileUpload (Uploads a file to the path on the SD card via POST. You have to write the file-data (bytes) into the POST body)
-> netduinoplus/upload?path=[a-Z]

File and directory response
Just type in netduinoplus/[pathtomyfile] and you can view / download your file. If the given path is a directory, a directory view will be returned

More for testing purpose, but also part of NeonMika.Webserver:

xmlResponselist (Gives you a list of all XML methods)
-> netduinoplus/xmlResponselist

jsonResponselist (Gives you a list of all JSON methods)
-> netduinoplus/jsonResponselist

multipleXML (Example on how to use nested XML)
-> netduinoplus/multixml

And how to expand it?

WebServer.AddResponse(new XMLResponse("wave", new XMLResponseMethod(WebserverXMLMethods.Wave)));

Doesn't look that complicated? That because it isn't complicated.

This an an example on how to write a XMLResponse:

private void Echo(Request e,Hashtable results)
  if(e.Request.GetArguments.Contains("value") == true)
    results.Add("ERROR", "No 'value'-parameter transmitted toserver");


All XMLResponses must have this form:

Return value:

Request (with this you can access the parameter written in the URL)
Hashtable (Here you add the response)

If you need stacked XML have a look at the MultiXMLmethod in Server.cs

How to write a JSON response:

private void ResponseListJSON(Request e, JsonArray j)
   JsonObject o;
   foreach(Object k in _Responses.Keys)
     o = newJsonObject();
     o.Add("methodURL", k);
     o.Add("methodName", ((Response)_Responses[k]).Name);


Server setup:

Server WebServer = new Server(PinManagement.OnboardLED,80,false,"","","","NETDUINOPLUS"); 
WebServer.AddResponse(newXMLResponse("echo", new XMLResponseMethod(Echo)));
WebServer.AddResponse(newJSONResponse("jsonResponselist", new JSONResponseMethod(ResponseListJSON)));


How to access the latest POST-data:

PostFileReader post = new PostFileReader();

byte[] postData = post.Read(bufferSize);


Example commands (can be executed with browser):


Show file directory:


Access file:

Last edited Jun 26, 2014 at 10:07 AM by NeonMika, version 7


No comments yet.