Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

NeonMika.Webserver

webserver web server neonmika internet web server http sd xml json

  • Please log in to reply
213 replies to this topic

#141 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 25 January 2013 - 01:09 AM

Not sure what the second DLL is but I am using the NeonMika.Webserver.dll in my project.  Actually I have all the projects within my solution so I can tweak them all as I develop so I am referencing the project instead of the DLL.



#142 skobyjay

skobyjay

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 25 January 2013 - 01:14 AM

Hmm, i guess i can try to do that. The only issue is that when I do that I get errors when trying to add methods like below.

 

 

 

Server WebServer = new Server(80);

 

WebServer.AddResponse(

 

new JSONResponse("getsettings", new JSONResponseCheck(WebServerMethods.GetSettings)));



#143 skobyjay

skobyjay

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 25 January 2013 - 01:27 AM

I went ahead and added the WebServer NET MF project to my solution, first time I got the project to launch, I'm not sure how thats different but this MF stuff is very humbling... :mellow:



#144 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 25 January 2013 - 05:56 PM

Hey skobyjay,
I just updated my project structure to get the .dll names right.

But I would recommend you this way:
Create a project (Let's call it Foo)
Now you have a "Solution" with one project in it.
Now click on your Solution, "Add existing project"
Go to NeonMika.Webserver -> Framework -> NeonMika.Webserver -> NeonMika.Webserver -> NeonMika.Webserver.csproj
Now you can go to the Foo project, rightclick on references and say "Add reference"
Open the Tab "Projects", there you go.

If you really want to use the .dll, you can add a reference to Go to NeonMika.Webserver -> Framework -> NeonMika.Webserver -> NeonMika.Webserver -> bin -> Debug -> NeonMIka.Webserver.dll

If you use the version for Netduino+ 2 i also think you should use the NeonMika.Webserver.dll

Here you can find the latest version: http://neonmikawebse...ew/f916b3510096

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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#145 skobyjay

skobyjay

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 26 January 2013 - 01:48 AM

Cool, thanks Marcus. I appreciate the help

#146 skarphedinnos

skarphedinnos

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationIceland

Posted 20 February 2013 - 11:27 PM

First of all, thanks a bunch for the webserver code Markus!! I think this code should be on every Netduino sold :)

 

I have a request, that is if it is not difficult for you to implement. 

 

Can you add a request to the server that returns all digital states. Like http://192.168.156.1...inState?pin=ALL ?

 

I'm creating an Android app that uses your webserver and it would be awesome to be able to get all the states in one request.

 

-Skarpi



#147 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 21 February 2013 - 02:26 AM

First of all, thanks a bunch for the webserver code Markus!! I think this code should be on every Netduino sold :)

 

I have a request, that is if it is not difficult for you to implement. 

 

Can you add a request to the server that returns all digital states. Like http://192.168.156.1...inState?pin=ALL ?

 

I'm creating an Android app that uses your webserver and it would be awesome to be able to get all the states in one request.

 

-Skarpi

 

That is the beauty of this server.  It is extensible and you can add that feature yourself by adding a new request response.



#148 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 21 February 2013 - 10:40 AM

First of all, thanks a bunch for the webserver code Markus!! I think this code should be on every Netduino sold :)

 

I have a request, that is if it is not difficult for you to implement. 

 

Can you add a request to the server that returns all digital states. Like http://192.168.156.1...inState?pin=ALL ?

 

I'm creating an Android app that uses your webserver and it would be awesome to be able to get all the states in one request.

 

-Skarpi

 

Thanks for using my code... Here are some hints how you can implement it yourself in less than 5 minutes:

 

With having a look at the first post, you can find code how to write your own method:

 

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


This is how you write a XMLResponse.

By using results.Add(name,value) you add an object to the response.

After you have written the method, you just have to add it to your webserver instance.

 

 

WebServer.AddResponse(newXMLResponse("echo", new XMLResponseMethod(Echo))); 

 

Now all you have to do is to change "echo" in the line above to "returnAllDigitalStates" or something like that... This will be the URL which you have to enter...

And instead of writing the Echo-Method you can write a ReturnAllDigitalStates method and add this one.

You don't need any "argument-checks" because you just have to call the URL without parameters :)

 

If you have further problems, just write here :)

 

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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#149 skarphedinnos

skarphedinnos

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationIceland

Posted 26 February 2013 - 12:38 AM

Thanks a whole lot!!

 

Regards,

Skarpi



#150 skarphedinnos

skarphedinnos

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationIceland

Posted 27 February 2013 - 03:43 PM

Thanks for using my code... Here are some hints how you can implement it yourself in less than 5 minutes:

 

With having a look at the first post, you can find code how to write your own method:

 

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

This is how you write a XMLResponse.

By using results.Add(name,value) you add an object to the response.

After you have written the method, you just have to add it to your webserver instance.

 

 

WebServer.AddResponse(newXMLResponse("echo", new XMLResponseMethod(Echo)));  

 

Now all you have to do is to change "echo" in the line above to "returnAllDigitalStates" or something like that... This will be the URL which you have to enter...

And instead of writing the Echo-Method you can write a ReturnAllDigitalStates method and add this one.

You don't need any "argument-checks" because you just have to call the URL without parameters  :)

 

If you have further problems, just write here  :)

 

Greets, Markus

I managed to create a method that prints out all of the digital stages. It didn't quite take 5 minutes, it should have though... Well, I'm learning :) There is one thing that "bothers" me a little, I simply created a for loop like so: 

 

for (Int32 pin = 0; pin < 14; pin++) { h.Add("pin" + pin, PinManagement.GetDigitalPinState(pin) ? "1" : "0"); }

 

but the xml output is in strange order. It does not print out the portnumbers from 0 - 13 rather in no particular order. Well, for my purpose of this it doesn't really matter, it would just look better :)



#151 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 02 March 2013 - 06:09 PM

Yeah, that's because I just run through the Hashtable's keys (which can be unsorted). It would slow down the Response and I didn't want that... 

 

If you want them sorted, open XMLResponse.cs and have a look at the following method:

 

 

 

/// <summary> /// Sends XML to client /// </summary> /// <param name="e">The request which should be handled</param> /// <returns>True if 200_OK was sent, otherwise false</returns> public override bool SendResponse(Request e) { String xml = ""; xml += "<!--XML created by NeonMika Webserver-->"; xml += "<Response>"; foreach ( object h in _Pairs.Keys ) xml += "<" + h + ">" + _Pairs[h].ToString() + "</" + h + ">"; xml += "</Response>"; byte[] bytes = Encoding.UTF8.GetBytes(xml); int byteCount = bytes.Length; try { Send200_OK("text/xml", byteCount, e.Client); SendData(e.Client, bytes); } catch (Exception ex) { Debug.Print(ex.ToString()); return false; } return true; } 

 

 

Here you can Change the foreach Loop to something else (for example sorting the keys and the create the Response. :)

 

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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#152 skarphedinnos

skarphedinnos

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationIceland

Posted 02 March 2013 - 07:04 PM

Thanks a lot Markus :)

 

-Skarpi.



#153 skarphedinnos

skarphedinnos

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationIceland

Posted 12 March 2013 - 01:12 AM

Hi all.

 

Just wanted to thank you for the help, and specially Markus for the server code and additional help.

 

I managed to create an Android app that can control the digital ports and the PWM. It is a closed loop system as the app checks every 5 seconds the status of the ports.

 

You can see it up and running in this video:

 

If I can help anyone out just send me a line.

 

Regards,

Skarpi.



#154 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 13 March 2013 - 11:29 AM

Hi all.

 

Just wanted to thank you for the help, and specially Markus for the server code and additional help.

 

I managed to create an Android app that can control the digital ports and the PWM. It is a closed loop system as the app checks every 5 seconds the status of the ports.

 

You can see it up and running in this video:

 

If I can help anyone out just send me a line.

 

Regards,

Skarpi.

 

Hey Skarpi, that is great!

If I had more time, I would like to update my WPF NeonMika.Webserver control to control it via the PC... Probably you just motivated me to go on with it :P

It's great that you mention the NeonMika.Webserver in you video title, thanks a lot.

 

ALSO: You are the first one who posted a YouTube video of controlling the N+'s Pins with NeonMika.Webserver. I love it! :) I hope I may link your video in the Topic description? =)

 

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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#155 skarphedinnos

skarphedinnos

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationIceland

Posted 15 March 2013 - 09:35 AM

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]hope I may link your video in the Topic description? =)[/color]

Of course :)



#156 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 28 March 2013 - 07:46 PM

Hey guys,
today is a great day for NeonMika.Webserver.

I am releasing Version 1.1! Wuhu! :D

I will give you a list of the new features that come with the new version:
-> Nameservice
  You now can give you Netduino a network name and can reach it using this one in your browsers URL field.
  You don't have to remember it's ip anymore :)
-> Server code refactor and restructure
  For anyone who want to dig a little bit into the server code to adjust it more to one's needs, I refactored to code.
  Some splitting up in more methods, name changings, etc. make the code now more readable.
  It also should help to give the server a little more stability.
-> Index page
  This was a feature even before Version 1.1, but I'm not quite sure if everybody knows about.
  If you enter just your Netduinos IP (or name), a index page with all available webmethods will be displayed.
  But you can adjust this index page easily, by going into Visual Studio -> NeonMika.Webserver -> Rightclick -> Properties -> Ressources
  There you find it. Here you could insert for example a little web interface or something similar
-> PostFileReader
  Also not that new, but never mentioned: The PostFileReader.
  You can use this class if you have "POST"ed some data to the netduino.
  NeonMika.Webserver stores POSTed data on the SD card, and this is a little helper class to access this temporary data.
-> New webserver methods
---> 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)

Aaaaand the biggest thing:
-> NeonMika.Webserver.ClientLibrary Version 0.1
  This library now supports to write client apps for the desktop for Netduino projects that use NeonMika.Webserver.
  It was coded pretty straight forwarded because I didn't have that much time, but it works pretty well and should be easy to use.
  In addition to the ClientLibrary, I also wrote an application which allows to use all in-built webmethods on the Netduino to control it.
  You can find the code here: https://netduinocontrol.codeplex.com/
  And the forum thread http://forums.netdui...rclientlibrary/

I hope you enjoy the new version and I also hope to get feedback on how to further improve this project.

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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#157 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 03 April 2013 - 08:30 PM

Hello.

I removed some parts of the text in the first post and moved it to the Codeplex' documentation page:

http://neonmikawebse...m/documentation

 

I think it is more important to know what this webserver is all about than to know exactly how the code has to look.

If anybody has some tips on how to improve this thread I'm always happy to hear your ideas.

 

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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#158 JoopC

JoopC

    Advanced Member

  • Members
  • PipPipPip
  • 148 posts

Posted 21 April 2013 - 04:46 PM

Does anyone have a working example with $ajax jsonP in HTML, how I can send a lager amount of data to the webserver?

Now it is possible to send around 400bytes of data with ajax, but I must send tekst data of 10KB. I did a lot of research without any result. 

 

Else I have to split the data in smaller parts but than i got other problems.

thanks in advance.



#159 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 25 April 2013 - 08:32 AM

I don't know about ajax, but is it possible to send the data via POST? Then there should be no problem because the POST receiving on NeonMika.Webserver can handle as much amount of data you have free on your SD card (but it could get a bit slow because the data is handeld on the SD card and not in RAM)

 

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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#160 skarphedinnos

skarphedinnos

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationIceland

Posted 18 May 2013 - 04:23 PM

Hi.

 

I got a message requesting the code from my android app.

 

I posted my project to github:

https://github.com/s...onMika_Netduino

 

Please be aware though that all commenting are in icelandic as this was a school project. I simply do not have the time to go over the code and re comment in english. However, if someone is stuck in not understanding something in the code, please send me a line and I will do my best to answer questions.

 

Regards,

Skarphedinn.







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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.