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.

Bejay

Member Since 13 Dec 2011
Offline Last Active Mar 16 2013 10:44 PM
-----

Topics I've Started

Networking Trouble with VB

23 January 2012 - 10:46 AM

I have tried to get a 'simple' networking server running with VB on the netduino plus and now I am feeling really dumb because no matter what I do it just will not work.
The first step is to go get an IP through the Dhcp and then tell me what it is so I can move onto the next bit, but all it does is repeat the waiting for IP
I connected and disconnected the cable several times but it just will not progress, it there something else I need to do?

Here is the code:

Private wSocket As System.Net.Sockets.Socket
Private wPortNumber as Int32 = 4000

Sub Main()
   Microsoft.SPOT.Debug.Print("Starting System...")
   Dim Led As New Microsoft.SPOT.Hardware.OutputPort(SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.ONBOARD_LED, False)
   Led.Write(False)

   Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0).EnableDhcp()
   Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0).ReleaseDhcpLease()
   Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0).RenewDhcpLease()

   'this is a test to determine the IP address of the device
   Dim LocalIp As String = "0.0.0.0"                                                                           'Set the address to an invalid value
   LocalIp = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0).IPAddress       'attempt to get the ip address
   Do While LocalIp = "0.0.0.0"                                                                                'while it stays invalid keep looping
      Microsoft.SPOT.Debug.Print("Waiting for IP address...")                                                  'write in the debug display that we are still waiting
      System.Threading.Thread.Sleep(1000)                                                                      'wait a second before trying again

      LocalIp = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0).IPAddress    'attempt to get the ip address
   Loop
   Microsoft.SPOT.Debug.Print("The local IP address of your device is " & LocalIp)                             'report the ip address to the debug log
   Led.Write(True)                                                                                             'turn on the status led to indicate that the self setup is complete

   wSocket = New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)
   wSocket.Bind(New System.Net.IPEndPoint(System.Net.IPAddress.Any, wPortNumber))
   wSocket.Listen(Int32.MaxValue)
   
   'call code to wait for connection

End Sub



Here is what the debug produces:

A first chance exception of type 'System.NotImplementedException' occurred in Microsoft.SPOT.Native.dll
Starting System...
Waiting for IP address...
Waiting for IP address...
Waiting for IP address...
Waiting for IP address...
Waiting for IP address...
Waiting for IP address...
Waiting for IP address...
Waiting for IP address... <== This repeats endlessly even after I connect the network cable


I would be greatful for any help

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.