NeonMika.Webserver
#62
Posted 03 May 2012 - 03:10 PM
A screenshot of step-through with F11 one step BEFORE jumping to Dispose() would be great...
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 down - 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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#63
Posted 03 May 2012 - 08:20 PM
Attached Files
#64
Posted 10 May 2012 - 08:55 AM
#65
Posted 12 May 2012 - 11:45 AM
I'm working on some more points like file uploading via POST and stuff, but I'm @ home very few.
I have no exact idea why it is working on my 4.1, but you could try the following XMLPair code:
public class XMLPair { private string _key; private object _value; private Hashtable _attributes; public string Key { get { return _key; } set { _key = value; } } public object Value { get { return _value; } set { _value = value; } } public Hashtable Attributes { get { return _attributes; } set { _attributes = value; } } public XMLPair(string Key, object Value) { this.Key = Key; this.Value = Value; this.Attributes = new Hashtable(); } public XMLPair(string Key) { this.Key = Key; this.Value = null; this.Attributes = new Hashtable(); } public override string ToString() { return XMLConverter.ConvertXMLPairToXMLString(this); } }
I removed the "inline property" (or however it is called) and changed it to the "old fashioned way of declaring properties"... Probably it works now
As soon as i have tested through my new version, i will upload 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 down - 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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#66
Posted 11 July 2012 - 11:14 PM
#67
Posted 05 August 2012 - 01:57 AM
I have many questions about NeonMika.Weserver. A few weeks ago I get started to make a webserver, and find a lot of information but everything are so superficial and isolated ... but , then, I find NeonMika e every thing start to work! Let me congratulate you on your nice job!!!
According I stared, I have questions about. First time I try to put a fix IP but I don't find someway to do and a made a little modification in Server() to force to set the network configuration. I would like to know if it's a correct way or has an other solution without modifications?
/// <summary> /// Creates an instance running in a seperate thread /// </summary> /// <param name="ledPort">OutputPort to indentify</param> /// <param name="portNumber">The port to listen</param> /// <param name="DhcpEnable"></param> /// <param name="ipAddress">IP</param> /// <param name="subnetMask">Mask</param> /// <param name="gatewayAddress">GateWay</param> public Server(OutputPort ledPort, int portNumber = 80, bool DhcpEnable = false, string ipAddress = "", string subnetMask = "", string gatewayAddress = "") { var interf = NetworkInterface.GetAllNetworkInterfaces()[0]; if (DhcpEnable) { interf.EnableDhcp(); interf.RenewDhcpLease(); } else { //New to fix interf.EnableStaticIP(ipAddress, subnetMask , gatewayAddress ); }
PS: Sorry my bad English!
#68
Posted 08 August 2012 - 04:20 PM
Playig with the server, like it so far!
Ran into an issue, not sure if it's my network or something in code, but when trying to request an analogue pin, I get a null reference:
/// <summary> /// Sets up the request /// </summary> /// <param name="data">Input from network</param> private void ProcessRequest(char[] data) { string content = new string(data); string htmlHeader1stLine = content.Substring(0, content.IndexOf('\n'));In my case, char[] data is coming in as char[0], so content is null. When this happens, I get an error page on browser. After one or more retries on the browser, I'll get a data[] with actual data.
It's getting out of the do..while loop:
do { newAvBytes = clientSocket.Available - availableBytes; if (newAvBytes == 0) break; availableBytes += newAvBytes; newAvBytes = 0; Thread.Sleep(1); } while (true);With 'availableBytes' being 0, so nothing loads from the server in these two lines:
byte[] buffer = new byte[availableBytes]; int readByteCount = clientSocket.Receive(buffer, availableBytes, SocketFlags.None);..because clientSocket.Available == 0 the first time around, so 'newAvBytes' is 0 as well as availableBytes being 0.
#69
Posted 08 August 2012 - 04:24 PM
private void ResponseListXML(RequestReceivedEventArgs e, Hashtable h)function.. in it, you're trying to add multiple values with 'methodURL' as the key. Hashtables cannot have identical keys, so it's throwing an 'System.ArgumentException' (of "Key Exists") on the second loop of .Keys.
#70
Posted 11 August 2012 - 02:29 PM
Attached Files
#71
Posted 12 August 2012 - 02:12 PM
I make in this week a few modification in NeonMika.Webserver to make a login page request first and I would like to share my modifications. Now, when you create a server in Program.cs you can put a Username and Password to protect the page access.
I try to implement the POST method to send the login request without cryptography password . But it's work...
EDITED LAST ON 15.3.2012
NeonMika.Webserver
__________________________________________________________________________
Download & Documentation:
http://neonmikawebserver.codeplex.com/
__________________________________________________________________________
Inroducing:
Hey guys,
NeonMika.Webserver is easy to set up and easy to extend. With minimal (to no) code you can achieve great results controlling and accessing your Netduino+.
__________________________________________________________________________
Possibities:
Controll your Netduino or Query your Netduinos status:
You can use this completely without SD card
Typical web server for html-files:
Leave your NeonMika.Webserver completly untouched and just store html-files on your SD card.
Access files over the network:
Just store every kind of other files on your SD card. You can download files from your Netduino the same way as you download files from the web.
Or everything together!
EVERTHING IS POSSIBLE! --> I should study marketing
__________________________________________________________________________
Structure:
The basic steps the server runs through are not that complicated at all:
Request receiving -> Request wrapping -> Response action -> Response generation -> Response sending
Responses:
XML Responses
JSON Responses
File Response
Complex Response
The server methods handles everything for you, except the Action.
Why? Not every project is the same. Everyone has other needs.
So thats why there are different types of responses you can use to expand your server.
But don't worry about much work.
In the latest version of NeonMika.Webserver I've alread included the following
Standard response actions:
XML:
echo
> [ipnetduino]/echo?value=[a-Z]
switchDigitalPin
> [ipnetduino]/switchDigitalPin?pin=[0-13]
setDigitalPin
> [ipnetduino]/setDigitalPin?pin=[0-13]&state=[true|false]
pwm
> [ipnetduino]/pwm?pin=[5|6|9|10]&period=[int]&duration=[int]
xmlResponselist
> [ipnetduino]/xmlResponselist
getAnalogPinValue
> [ipnetduino]/getAnalogPinValue?pin=[0-5]
getDigitalPinState
> [ipnetduino]/getDigitalPinState?pin=[0-13]
multipleXML
>[ipnetduino]/multixml
JSON:
jsonResponselist
> [ipnetduino]/jsonResponselist
Complex:
IndexPage
> [ipnetduino]/
FileResponse:
> [ipnetduino]/\SD\[filepath]
__________________________________________________________________________
Documentation:
I try to keep this project easy to understand (I hope so) and very extendable.
I'm trying to comment most of the methods and to keep the wiki (http://neonmikawebse...m/documentation) up to date. Please go there to have a little "Getting started"
__________________________________________________________________________
Useage:
There are two directories of interest for you:
Framework and Executeable.
Framework contains the basic code for a new project based on NeonMika.Webserver. Check out this folder if you want an untouched version of NeonMika.Webserver).
Executeable will contain little projects created by me that base on NeonMika.Webserver. Check out this folder if you want to see some examples of how to use NeonMika.Webserver
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.
2.1 This sample project using NeonMika.Webserver has the following xml method added to the webserver at runtime: [ipnetduino]/wave ... Connect LEDs to Pin 0,1,4,5,8,9 and you will see your LED lighting up one after the other
__________________________________________________________________________
To do:
- Return file list from directory
- Authentification for different areas on the SD (which user is allowed to go where)
- Screenshots
- Videos
- Index page refactor / Control center (29.11.11)
- Suggestions!?
__________________________________________________________________________
Added:
- Index page (8.11.2011)
- Screenshot of echo, 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)
- FileResponse improved (15.3.2012)
- Changed index page (15.3.2012)
- Nested XML support (28.4.2012)
- Example method for nested XML -> see MultipeXML(28.4.2012)
- Code cleanup (28.4.2012)
__________________________________________________________________________
Other things to mention:
- I will keep this post up to date and will mention it if there were some code or documentation changes you could profit from
- 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
- http://neonmikawebserver.codeplex.com/
__________________________________________________________________________
Examples
XML response:
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 to server"); }
JSON response:
private void ResponseListJSON(RequestReceivedEventArgs e, JsonArray j) { JsonObject o; foreach (Object k in _Responses.Keys) { o = new JsonObject(); o.Add("methodURL", k); o.Add("methodName", ((Response)_Responses[k]).Name); j.Add(o); } }
Server setup:
Server WebServer = new Server(PinManagement.OnboardLED, 50000); WebServer.AddResponse(new XMLResponse("echo", new XMLResponseMethod(Echo))); WebServer.AddResponse(new JSONResponse("jsonResponselist", new JSONResponseMethod(ResponseListJSON)));
Example access:
http://192.168.0.2/echo?value=markushttp://192.168.0.2/jsonResponslisthttp://192.168.0.2/\SD\folder\file.txt
__________________________________________________________________________
Greets, Markus
__________________________________________________________________________
Attached Files
#72
Posted 18 November 2012 - 06:55 AM
See the changes below, where "SecretLabs.NETMF.Hardware." has been added in front of PWM and AnalogInput references. Also add those two SecretLabs references. (Hardware.PWM and Hardware.AnalogInput) This is needed because SPOT now has their own built in ones, and the OP's code does not use them, as they did not exist in 4.1.
Cheers
//Output ports with PWM functionallity static private SecretLabs.NETMF.Hardware.PWM PWM5 = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5); static private SecretLabs.NETMF.Hardware.PWM PWM6 = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D6); static private SecretLabs.NETMF.Hardware.PWM PWM9 = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D9); static private SecretLabs.NETMF.Hardware.PWM PWM10 = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D10); //Analog inputs static private SecretLabs.NETMF.Hardware.AnalogInput Analog0 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0); static private SecretLabs.NETMF.Hardware.AnalogInput Analog1 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A1); static private SecretLabs.NETMF.Hardware.AnalogInput Analog2 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A2); static private SecretLabs.NETMF.Hardware.AnalogInput Analog3 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A3); static private SecretLabs.NETMF.Hardware.AnalogInput Analog4 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A4); static private SecretLabs.NETMF.Hardware.AnalogInput Analog5 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A5); static private OutputPort[] Digitals = new OutputPort[] { Digital0, Digital1, Digital2, Digital3, Digital4, null, null, Digital7, Digital8, null, null, Digital11, Digital12, Digital13 }; static private SecretLabs.NETMF.Hardware.AnalogInput[] Analogs = new SecretLabs.NETMF.Hardware.AnalogInput[] { Analog0, Analog1, Analog2, Analog3, Analog4, Analog5 }; static private PWM[] PWMs = new PWM[] { PWM5, PWM6, PWM9, PWM10 }; static private bool[] PWM_On = new bool[] { false, false, false, false };
#73
Posted 20 November 2012 - 03:41 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 down - 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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#74
Posted 22 November 2012 - 04:21 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 down - 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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#75
Posted 22 November 2012 - 05:11 PM
#76
Posted 22 November 2012 - 05:21 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 down - 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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#77
Posted 23 November 2012 - 03:01 AM
#78
Posted 23 November 2012 - 08:02 AM
I'll download it and update my ND+2 tomorrow. Thank for your contribution Markus. The server is working great on ND+2. Can't wait to try the file list.
Glad to here that
If you also want to use the other Features, not only the file list, be sure to follow this post:
Hint for those converting this 4.1 project to 4.2:
See the changes below, where "SecretLabs.NETMF.Hardware." has been added in front of PWM and AnalogInput references. Also add those two SecretLabs references. (Hardware.PWM and Hardware.AnalogInput) This is needed because SPOT now has their own built in ones, and the OP's code does not use them, as they did not exist in 4.1.
Cheers
//Output ports with PWM functionallity static private SecretLabs.NETMF.Hardware.PWM PWM5 = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5); static private SecretLabs.NETMF.Hardware.PWM PWM6 = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D6); static private SecretLabs.NETMF.Hardware.PWM PWM9 = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D9); static private SecretLabs.NETMF.Hardware.PWM PWM10 = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D10); //Analog inputs static private SecretLabs.NETMF.Hardware.AnalogInput Analog0 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0); static private SecretLabs.NETMF.Hardware.AnalogInput Analog1 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A1); static private SecretLabs.NETMF.Hardware.AnalogInput Analog2 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A2); static private SecretLabs.NETMF.Hardware.AnalogInput Analog3 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A3); static private SecretLabs.NETMF.Hardware.AnalogInput Analog4 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A4); static private SecretLabs.NETMF.Hardware.AnalogInput Analog5 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A5); static private OutputPort[] Digitals = new OutputPort[] { Digital0, Digital1, Digital2, Digital3, Digital4, null, null, Digital7, Digital8, null, null, Digital11, Digital12, Digital13 }; static private SecretLabs.NETMF.Hardware.AnalogInput[] Analogs = new SecretLabs.NETMF.Hardware.AnalogInput[] { Analog0, Analog1, Analog2, Analog3, Analog4, Analog5 }; static private PWM[] PWMs = new PWM[] { PWM5, PWM6, PWM9, PWM10 }; static private bool[] PWM_On = new bool[] { false, false, false, false };
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 down - 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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#79
Posted 23 November 2012 - 10:55 AM
Glad to here that
If you also want to use the other Features, not only the file list, be sure to follow this post:
Greets, Markus
Yes, I made those changes when I tried it last Saturday. Very easy changes and it worked great.
#80
Posted 08 December 2012 - 05:36 PM
namespace NeonMika.Webserver { /// <summary> /// Interface between NeonMika.Webserver and the executing programm /// Use this class to work with your pins /// </summary> static public class PinManagement { //Standard output ports static private OutputPort Digital0 = new OutputPort(SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D0, false);
When I run the code, I get the following error when defining the standard output ports. The last line shown above.
A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
Uncaught exception
Any idea what I am doing wrong? Thanks.
Also tagged with one or more of these keywords: webserver, web server, neonmika, internet, web, server, http, sd, xml, json
Hardware →
Netduino 3 →
Web server, socket, reading buffer data?Started by TheBrian, 10 Feb 2016 web server, socket, buffer |
|
|||
Hardware →
Netduino 3 →
ND3 SD Filestream.Read() seems to become brokenStarted by ukkiwisurfer, 08 Nov 2015 SD |
|
|||
Hardware →
Netduino 3 →
ND3 hangs calling File.Delete()Started by ukkiwisurfer, 06 Nov 2015 SD, Wifi, Netduino |
|
|||
General →
General Discussion →
Support for Micro SD Card > 2 GBStarted by TechnoGuy, 10 Sep 2015 MicroSD, SD, SDHC, SDXC, FAT12 and 3 more... |
|
|||
Hardware →
Netduino Plus 2 (and Netduino Plus 1) →
Why do I have to reboot my device to change the IP address?Started by cSharper, 31 Jul 2015 webserver, ip, netduino, change and 1 more... |
|
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users