Okay, back on the test list for this week
It sounds like if it has a reservation...it works properly. But if it doesn't have a reservation on your network, it has an identity crisis
Chris,
I am having similiar problems with my NP2, I set the IP Address in MFDeploy to 192.168.0.122
I then load my program and it says that the IP Address is 192.168.0.134
The program works as it should only with the IP 192.168.0.134 not 122 which is setup in my router with port forwarding.
MFDeploy still show the IP as 192.168.0.122
Imports System
Imports Microsoft.VisualBasic.Constants
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.Netduino
Namespace Connect_to_Web_2
Public Class Program
Public Shared Sub Main()
' write your code here
' setup the LED and turn it off by default
Dim led As New OutputPort(Pins.ONBOARD_LED, False)
' configure the port # (the standard web server port is 80)
Dim port As Integer = 80
' wait a few seconds for the Netduino Plus to get a network address.
Thread.Sleep(5000)
' display the IP address
Dim networkInterface As Microsoft.SPOT.Net.NetworkInformation.NetworkInterface = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()(0)
Debug.Print("my ip address: " + networkInterface.IPAddress.ToString())
' create a socket to listen for incoming connections
Dim listenerSocket As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim listenerEndPoint As New IPEndPoint(IPAddress.Any, port)
' bind to the listening socket
listenerSocket.Bind(listenerEndPoint)
' and start listening for incoming connections
listenerSocket.Listen(1)
' listen for and process incoming requests
While True
' wait for a client to connect
Dim clientSocket As Socket = listenerSocket.Accept()
' wait for data to arrive
Dim dataReady As Boolean = clientSocket.Poll(5000000, SelectMode.SelectRead)
' if dataReady is true and there are bytes available to read,
' then you have a good connection.
If dataReady AndAlso clientSocket.Available > 0 Then
Dim buffer As Byte() = New Byte(clientSocket.Available - 1) {}
Dim bytesRead As Integer = clientSocket.Receive(buffer)
Dim request As New String(System.Text.Encoding.UTF8.GetChars(buffer))
Debug.Print("Command: " + request)
' request = up(request)
If request.IndexOf("ON") >= 0 Then
led.Write(True)
ElseIf request.IndexOf("OFF") >= 0 Then
led.Write(False)
End If
Dim statusText As String = "LED is " + (If(led.Read(), "ON", "OFF")) + "."
' return a message to the client letting it
' know if the LED is now on or off.
Dim response As String = "HTTP/1.1 200 OK" & vbCr & vbLf + "Content-Type: text/html; charset=utf-8" & vbCr & vbLf & vbCr & vbLf + "<html><head><title>Netduino Plus LED Sample</title></head>" + "<body>" + statusText + "</body></html>"
clientSocket.Send(System.Text.Encoding.UTF8.GetBytes(response))
End If
' important: close the client socket
clientSocket.Close()
End While
End Sub
End Class
End Namespace
Chuck