Netduino home hardware projects downloads community

Jump to content


Photo

NeonMika.Webserver

webserver web server neonmika internet web server http sd xml json

  • Please log in to reply
213 replies to this topic

#1 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 07 November 2011 - 04:42 PM

NeonMika.Webserver @ http://neonmikawebserver.codeplex.com/


Introducing

Hey guys,

NeonMika.Webserver is an pre-setup and easy to extend webserver. With minimal (to no) code you can achieve great results controlling your Netduino+, accessing and uploading files and more!

 

It's supports:
- SD card access

- Controlling your Netduino using existing methods like setPWM or setDigitalPinState (see full list below)

- Adding your own webservice-like methods so you can expand NeonMika.Webserver to your own needs for every project.

How easy is it?

Server WebServer = new Server PinManagement.OnboardLED, 80, false, "192.168.0.200", "255.255.255.0", "192.168.0.1", "NETDUINOPLUS");

The parameter for setup are: The OnboardLED, Port, DHCPenable, ipAdress, subnetMask, gateway, name.
You don't need anything more to run it!

 

At http://neonmikawebse...m/documentation you can find a complete documentation on how to set up the server and how to expand it.

 

What methods are already implemented?

 

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]

AND FOR SURE:
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

 

Some examples:

 

Example commands (can be executed with browser):

Show file directory:

Access file:

Download & Documentation:

http://neonmikawebserver.codeplex.com/

http://neonmikawebse...m/documentation

 

Project & Videos
 

Controlling your Netduino+ with Android phone

Thanks to skarphedinnos for this great video about controlling Pins and PWM with NeonMika.Webserver & Android!

http://www.youtube.c...h?v=Q5T7TQsOf-w

 

Home brewery

Thanks to Coding Smackdown for using NeonMika.Webserver in his awesome beer brewing Project!

http://diybrewery.com/

 

N+2 aquarium controller

Thanks to H07R0D!

http://forums.netdui...roller/?p=34544

 

--------------------------------------------------------

I appreciate every kind of response. I want this to help the community, so I hope the communty will help me to get this project better and better

Thanks and greets,

Markus
 

 

-----------------------------------------------------------------

-----------------------------------------------------------------

Changelog:

- Index page(8.11.2011)
- Screenshot ofecho, switchPin and index page (8.11.2011)
- JSON support(30.11.11)
- PWM(30.11.11)
- getAnalogPinValue and getDigitalPinState (30.11.2011)
- Examples(30.11.2011)
- FileResponseimproved (15.3.2012)
- Changed indexpage (15.3.2012)
- Nested XMLsupport (28.4.2012)
- Example method for nested XML -> see MultipeXML(28.4.2012)
- Code cleanup(28.4.2012)
- POST working!(22.11.2012)
- File upload(22.11.2012)
- Better XML(22.11.2012)
- Choosing between DHCP and fixed IP (22.11.2012)
- Return filelist from directory (Directory view) (22.11.2012)

- Some changes to the code (Somewhere here between :P)

- Videos (13.3.2013)

- Nameservice (28.3.2013)
- Server code refactor and restructure (28.3.2013)
- Index page (28.3.2013)
- New webserver methods (28.3.2013)
--- GetAllPWM (Returns duration and period for all PWM pins)
--- GetAllDigitalPinStates (Returns the state for all digital pins)
--- GetAllAnalogPinValues (Returns the value for all analog pins)
- NeonMika.Webserver.ClientLibrary Version 0.1 (28.3.2013)

- NeonMika.Webserver V1.2

--- Fixed POST file upload

--- Fixed SD card view

Attached Files


Edited by NeonMika / Markus VV., 30 January 2014 - 05:47 PM.

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 07 November 2011 - 05:10 PM

Oh wow, Markus. That's pretty cool. Do you have a sample "site" for it already? Can you show off screenshots/photos so people can see what NeonMika.Webserver can do? Chris

#3 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 07 November 2011 - 05:55 PM

Oh wow, Markus. That's pretty cool.

Do you have a sample "site" for it already? Can you show off screenshots/photos so people can see what NeonMika.Webserver can do?

Chris


I will sit down tonight @ my girlfriends place to write a little index.html
But i don't have a SD card atm, so i will write a sample "Complex response" so people can see how this is done. :)
Tomorrow i will take some screenshots and a little video. So stay tuned for more visual info tomorrow ;)

Greets, Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#4 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 08 November 2011 - 05:23 PM

I added some screenshots, did'nt have time for the video, have to go to work #2 now... Probalby in the night, otherwise tomorrow =) But i hope that the screenshots help to understand how to use it :) Greets, Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#5 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 27 November 2011 - 03:51 AM

Markus, I've pulled down your code and have been trying to use it for an interface to a temperature logger that I'm building. The concept really fits into what I need, however I've noticed that after running for a couple of minutes it seems to be going off into nowhere and never answers. I'm running under the .NetMF 4.2 RC3 firmware, so I'm not sure if it is the newer firmware or maybe the code. Have you run into anything like this or does it run without issue for you? Just trying to figure out where I should be spending my time trouble shooting. Thanks
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#6 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 27 November 2011 - 08:51 AM

Markus,

I've pulled down your code and have been trying to use it for an interface to a temperature logger that I'm building. The concept really fits into what I need, however I've noticed that after running for a couple of minutes it seems to be going off into nowhere and never answers.

I'm running under the .NetMF 4.2 RC3 firmware, so I'm not sure if it is the newer firmware or maybe the code. Have you run into anything like this or does it run without issue for you?

Just trying to figure out where I should be spending my time trouble shooting.

Thanks


Are you running in debug mode?
There you can check if incoming requests get ignored...
Probably you get a outofmemory-exception?

I sometimes had the problem that it just worked fine for a time and then it stopped receiving requests, i will look into that as soon as i have time :)

It mustbe something in the Server-class' Listening loop...
Probably you can find an error there (about 20 lines of code)...

Greets

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#7 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 27 November 2011 - 03:36 PM

Are you running in debug mode?
There you can check if incoming requests get ignored...
Probably you get a outofmemory-exception?

I sometimes had the problem that it just worked fine for a time and then it stopped receiving requests, i will look into that as soon as i have time :)

It mustbe something in the Server-class' Listening loop...
Probably you can find an error there (about 20 lines of code)...

Greets


Markus,

It is not throwing an exception of any kind, but I think you are right with it running out of resources. I was playing with the server listening loop and did make some changes and now it runs without issue. Let me spend some time comparing my changes to the original code and I'll post an issue to the codeplex page.

I also made some changes to the Handle Request method and changed from an array list to a hashtable to speed up request processing. I'll also post those changes as well.

Thanks,

Jim Lavin
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#8 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 27 November 2011 - 04:52 PM

Markus, I've posted the differences out on codeplex for you. Hopefully they'll be of help. Cheers, Jim Lavin
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#9 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 27 November 2011 - 07:56 PM

Markus,

I've posted the differences out on codeplex for you. Hopefully they'll be of help.

Cheers,

Jim Lavin


Thank you Jim!
Doing some error handling, good idea. Next time I'll consider it more :)
So did you find out why exactly the code was stopping working? Or are you also not sure and just do some "workaround" with the errorhandling block?
And thank you for the tip with the using for the ClientSocket and the hashtable, i will include them in my next version and will upload the new code in the next few days :)

Thanks for you help.
Greets, Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#10 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 28 November 2011 - 01:04 AM

I think it had to do with the client socket not being closed after the request.
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#11 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 28 November 2011 - 08:50 AM

You are so right, I think that's the point! It's great to have people like you around that help to find this little problems you spend hours on and don't find them (even if it is just one line :P) Greets, Markus PS: I just updated the project main page and the thread start post. The next step will be to build a more "beautiful" index page you can use as a "control center". The last days I read through w3schools.com on HTML, HTML5, CSS and a bit Javascript. I am excited how my first "website" will look like :P

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#12 AJB2K3

AJB2K3

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 29 November 2011 - 07:36 AM

This looks like it could be a very noobe friendly server but I have a few questions. 1, Is there a plan to add PWM control to the server to dim the outputs? 2, Would it be possible to add a web page side method that alows you to control which input is tied to which output i.e:input 1, analogue, :output 1,PWM Sorry I'm a noob to programming and not getting much time to learn how to code things yet.

"Maybe it's because you're a crap programmer"


#13 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 29 November 2011 - 09:32 AM

Thanks for your idea sharing.
PWM gets on the to-do list. But it's not that difficult at all. This is why i wanted to build this server extendable. You can have a look at this: http://neonmikawebse...m/documentation
Just build a method in this way:
private void Methodname(RequestReceivedEventArgs e, Hashtable h)
{
//fill h with your response keys and values
}

I never worked with PWM, but I think it will look something like this:

private void PWM(RequestReceivedEventArgs e, Hashtable h)
{
  SecretLabs.NETMF.Hardware.PWM pwm  = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5); 
  if(e.Request.GetArguments.Contains("pulse")
  {
    int pulse = Convert.ToInt32(e.Request.GetArgumenst["pulse"];
    pwm.SetPulse(20000, pulse);
    h.Add("newPulse",pulse);
  }
  else
    h.Add("ERROR","No 'pulse'-value transmitted");
  }
}

Then you have to add this method to your webserver instance:
webserver.AddResponse(new XMLResponse("pwm",new XMLResponseCheck(PWM)));

Just did that out of mind without IDE, this is probably not going to work without changes.

Then you could set your PWM via this URL:
"http://netduinoip:port/pwm?pulse=4000"

Sorry, I'm no native speaker. Could you explane your second question in more detail?
I dont have my netduino at home to work with it today, but i will sit down today to expand the server code (probably i also include pwm)
Tomorrow you can test the new version :)

Greets, Markus

Edited by Markus VV., 29 November 2011 - 11:17 AM.

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#14 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 29 November 2011 - 10:03 AM

Sorry, didn't want to post :P

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#15 AJB2K3

AJB2K3

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 29 November 2011 - 12:58 PM

Sorry, times I forget not all clever people are english What I was thinking was eather 2 buttons up and down to alter the value or a slider to adjust the brightness level.

"Maybe it's because you're a crap programmer"


#16 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 29 November 2011 - 01:17 PM

Sorry, times I forget not all clever people are english

What I was thinking was eather 2 buttons up and down to alter the value or a slider to adjust the brightness level.


That shouldn't be that hard, I'm already in the Javascript learning phase :P
The slider (or buttons) only have to execute the "http://netduinoip:port/pwm?pulse=[INSERT VALUE HERE 0-20000]" command with the wanted value. E.g. 0 is completly off, 20000 is completly on...

Greets, Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#17 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 29 November 2011 - 01:22 PM

I'm doing something similar by using jQuery to post data back to the server. First I added additional pin types to the Pin Management class, then I added a couple of new request methods like Markus discussed. I then have web pages that can be returned from the server which contain my user interface which have jQuery methods that send the request back to the server to be processed and return the results. This way I can interact with the Netduino however I wish, I can even use this method to set the time and network settings on the device. You just have to be careful about how much functionality you try to shoehorn into the device since memory is pretty tight. To build my temperature controller complete with logging and history charts I end up with about 30K worth of code when all finished. That included a complete library to send back JSON formatted data. You can do quite a bit.
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#18 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 29 November 2011 - 01:29 PM

Markus, I had to add code to handle the HTM and HTML file types to the extension handler so it would return the proper MIME type. It seems if you request index.html from the server it was always coming back as application/octetstream instead of text/html. I also added a JSON request handler that uses a JSON library to return requests in JSON format. Let me know if you want me to post the code for you to include. Cheers,
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#19 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 29 November 2011 - 02:05 PM

Forgetting the most important mime type is a little embarrasing :P Yeah it would be great to receive your cs files :) Thanks! Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#20 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 30 November 2011 - 03:50 PM

Wow, now that was some long work:
But I am proud to announce Version 0.2. Now with:
- JSON support
Thanks to Jim aka Coding Smackdown for sending me his code to include JSON support into NeonMika.Webserver
- PWM
- getAnalogPinValue and getDigitalPinState
Now you can not only send commands to your Netduino like switchPin, now you can also query the actual state of your digital and analog pins.
- Examples
Have a look at the thread opening post. There are now examples how to write xml and json responses and how to set up a simple webserver.

I don't have my Netduino+ at my place today. I will test it tomorrow :)
But I hope everything works fine :P

And again a big thanks at Jim!

Have fun with the new version of NeonMika.Webserver.

Greets, Markus

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------






Also tagged with one or more of these keywords: webserver, web server, neonmika, internet, web, server, http, sd, xml, json

1 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


    Bing (1)
home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.