Network Settings
#1
Posted 02 December 2012 - 07:01 PM
#2
Posted 02 December 2012 - 07:08 PM
#3
Posted 02 December 2012 - 07:29 PM
It's a ND+. Could not get a ND+2 here.Which version of the Netduino board are you using? Is this a ND+ or ND+2?
#4
Posted 02 December 2012 - 07:44 PM
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp(); WebServer webServer = new WebServer();
I believe I was having a similar issue and had to change the code to something like this below to enable Dynamic DNS also. You can also un-comment the System.Diagnostics.Debug...... line to show if you have an IP and if DHCP is enabled.
var interf = NetworkInterface.GetAllNetworkInterfaces()[0]; interf.EnableDynamicDns(); interf.EnableDhcp(); //System.Diagnostics.Debug.WriteLine("Webserver is running on " + interf.IPAddress + " /// DHCP: " + interf.IsDhcpEnabled); WebServer webServer = new WebServer();
#5
Posted 02 December 2012 - 08:27 PM
Not solved my issue though, but might be my own fault getting this error when hitting the line " interf.EnableDynamicDns();":
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
An unhandled exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.Net.dll
The program '[4] Micro Framework application: Managed' has exited with code 0 (0x0).
Back to what I originally *thought* is the problem.
If I run ipconfig on my laptop, I get:
IPv4 address: 10.0.0.5
Subnet Mask: 255.255.255.0
Default Gateway: 10.0.0.2
I tried setting my board via MFDeploy to rather use that default gateway and give it a static IP of 10.0.0.11.
However after getting the above error and looking in MVDeploy again, I saw it was set back to the "default" settings.
So I changed it again, but alas, still gives the same error.
Oh, wait..above settings must be wrong since I cannot ping the board in WFDeploy now. On tinkering...
UPDATE..could not ping because had another demo running (also not working) and stopped at a breakpoint.
#6
Posted 02 December 2012 - 10:04 PM
#7
Posted 03 December 2012 - 01:56 AM
#8
#9
Posted 03 December 2012 - 08:13 AM
- JerseyTechGuy likes this
#10
Posted 09 April 2013 - 07:04 AM
#11
Posted 09 April 2013 - 11:28 AM
Dave VanderWekke
var interf = NetworkInterface.GetAllNetworkInterfaces()[0];interf.EnableDynamicDns();interf.EnableDhcp();//System.Diagnostics.Debug.WriteLine("Webserver is runningon " + interf.IPAddress + " DHCP: " + interf.IsDhcpEnabled);WebServer webServer = new WebServer();hello Dave wer shud i include dis code in the program..
If you have a simple program with a "Main()" method, you will place this in the main method so it will run when the code begins to execute.
#12
Posted 11 April 2013 - 07:13 AM
thnx for reply dave . now i have problem with this coding i don know what wud be the reason, the program is for netduino v4.1 but m having netduino plus 2 v4.2, i upgraded the project version 4.1 to 4.2 if i run this program i get an ip called 192.168.1.4 but if i give this ip in the web browser no data is received from the device
i set the network cofiguration using MFDeploy with 192.168.1.4
subnet mask is 255.255.255.0
default gateway is 192.168.1.1
but dns primary i gave the default 8.8.8.8
dns secoundary 8.8.4.4
in my pc i use one lan for that it shows ip 192.168.1.7
for device in the output window it shows 192.168.1.4
but if i put in the web browser the page is not opening
this is the source code
weserver.cs
using System; using System.Net.Sockets; using System.Net; using System.Threading; using System.Text; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino;
namespace NetduinoGarageDoorOpener { public class WebServer : IDisposable { private Socket socket = null; //open connection to onbaord led so we can blink it with every request private OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); private OutputPort Garage2CarOpener = new OutputPort(Pins.GPIO_PIN_D13, false);
public WebServer() { //Initialize Socket class socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //Request and bind to an IP from DHCP server socket.Bind(new IPEndPoint(IPAddress.Any, 80)); //Debug print our IP address Debug.Print(Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress); //Start listen for web requests socket.Listen(10); ListenForRequest(); }
public void ListenForRequest() { while (true) { using (Socket clientSocket = socket.Accept()) { //Get clients IP IPEndPoint clientIP = clientSocket.RemoteEndPoint as IPEndPoint; EndPoint clientEndPoint = clientSocket.RemoteEndPoint; //int byteCount = cSocket.Available; int bytesReceived = clientSocket.Available; if (bytesReceived > 0) { //Get request byte[] buffer = new byte[bytesReceived]; int byteCount = clientSocket.Receive(buffer, bytesReceived, SocketFlags.None); string request = new string(Encoding.UTF8.GetChars(buffer)); string firstLine = request.Substring(0, request.IndexOf('n')); //Example "GET /activatedoor HTTP/1.1" string[] words = firstLine.Split(' '); //Split line into words string command = string.Empty; if (words.Length > 2) { string method = words[0]; //First word should be GET command = words[1].TrimStart('/'); //Second word is our command - remove the forward slash } switch (command.ToLower()) { case "activatedoor": ActivateGarageDoor(); //Compose a response string response = "I just opened or closed the garage!"; string header = "HTTP/1.0 200 OKrnContent-Type: text; charset=utf-8rnContent-Length: " + response.Length.ToString() + "rnConnection: closernrn"; clientSocket.Send(Encoding.UTF8.GetBytes(header), header.Length, SocketFlags.None); clientSocket.Send(Encoding.UTF8.GetBytes(response), response.Length, SocketFlags.None); break; // default: // //Did not recognize command // response = "Bad command"; // header = "HTTP/1.0 200 OKrnContent-Type: text; charset=utf-8rnContent-Length: " + response.Length.ToString() + "rnConnection: closernrn"; // clientSocket.Send(Encoding.UTF8.GetBytes(header), header.Length, SocketFlags.None); // clientSocket.Send(Encoding.UTF8.GetBytes(response), response.Length, SocketFlags.None); // break; } } } } } private void ActivateGarageDoor() { led.Write(true); //Light on-board LED for visual cue Garage2CarOpener.Write(true); //"Push" garage door button Thread.Sleep(1000); //For 1 second led.Write(false); //Turn off on-board LED Garage2CarOpener.Write(false); //Turn off garage door button }
#region IDisposable Members ~WebServer() { Dispose(); } public void Dispose() { if (socket != null) socket.Close(); } #endregion
} }
program.cs
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino;
namespace NetduinoGarageDoorOpener { public class Program { public static void Main() { Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp(); WebServer webServer = new WebServer(); webServer.ListenForRequest();
}
} }
#13
Posted 11 April 2013 - 07:19 AM
hello dave,
http://netduinohacki...-with-your.html visit dis link this code is not giving me the output..
i want interface android app with this board to controll the garage door open/close
#14
Posted 12 April 2013 - 06:05 AM
#15
Posted 15 April 2013 - 08:20 AM
HI CHRIS,
when i ping my netduino plus 2 from pc itz not responding itz telling destination host is unreachable
mean while how to find out my netduino plus 2 ip can u jus tell me the solution to use the netduino plus 2 for internet(webserver transmit/receive) pls look into my above webservice.cs and program.cs coding whether itz working with ur netduino plus 2 or can u pls modify the codings and put in the post .zip file..
Thnx in advance chris..
#16
Posted 15 April 2013 - 09:16 AM
HI CHRIS,
I am not able to connect my netduino plus 2 to erase and when i deploy the ERROR-CONFIG , FLASH file not able deploy itz telling unable to deploy,
hope i don know the proper procedure
first i hold the button n plugged into the micro usb to pc when i ping in mf deploy the device doesnt appears m not able to erase and not able to deploy the browsed EROR_CONFIG EROR_FLASH files, if i remove it n connect then the device is showing but could'nt deploy the hex files what is reason pls tel me the solution..
can u pls tel me the proper procedure for netduino plus 2 to do the above settings..
#17
Posted 15 April 2013 - 09:30 PM
I used the following tutorial to get my IP from my Netduino +2 http://wiki.netduino...duino-Plus.ashx Maybe you could try a different webserver application? I downloaded many examples and played a lot before I got it working (14 hours of reading, copy, pasting and testing). The webserver application that I have works for me but I don't know if it will work for you, it never hurts to try. It might feel like a slope learning curve but its like a puzzle. You have to find the right piece to make your project work.
My wife studies and lives in a different city and will be there for 2 years. I figured I could play Skyrim for 2 years (I love that game) or start learning programming, I chose programming
Netduino Plus 2 (v4.2.2.2)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users