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

DHCP doesn't work


  • Please log in to reply
22 replies to this topic

#21 thenecroscope

thenecroscope

    Member

  • Members
  • PipPip
  • 13 posts

Posted 25 November 2011 - 12:35 AM

just to add to my previous post. what is odd, if i look in mfdeply, i can see that its get an ip number but i still cant ping it. whats even stranger is that the router picks up and assigns the DHCP to the netduino for about 3 seconds and then it just disappears again. a constant ping comes back with no responses during this time. very odd.

#22 ritchie

ritchie

    New Member

  • Members
  • Pip
  • 7 posts

Posted 01 December 2011 - 08:37 PM

I have the exact same issue :( using v4.2 firmware.

This is the code i tried to use, taken from another site / forum (im very much still learning)

...
// DHCP
NI.EnableDhcp();
//NI.ReleaseDhcpLease();
NI.RenewDhcpLease();
...


I've found that for whatever reason calling ReleaseDhcpLease()/RenewDhcpLease() doesn't actually seem to do so - the lease never gets renewed. If I just enable DHCP it usually sorts itself out after that. It would be nice if there was a callback on DHCP events instead of having to poll for a valid address, but this is a start.

DeviceInfo:
HAL build info: 4.2.0.0, Netduino Plus (v4.2.0.0 RC3) by Secret Labs LLC

#23 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 01 December 2011 - 11:51 PM

Whats the code for this in VB out of interest?


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.NetduinoPlus
Imports Microsoft.SPOT.Net.NetworkInformation

Namespace IP_Discovery
	Public Class Program
		Public Shared Sub Main()
			' Fetches the first network interface
			Dim NI__1 As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces()(0)

			' DHCP
			NI__1.EnableDhcp()
			'NI.ReleaseDhcpLease();
			NI__1.RenewDhcpLease()

			Dim ni__2 As NetworkInterface

			' Wait for DHCP (on LWIP devices)
			While True
				ni__2 = NetworkInterface.GetAllNetworkInterfaces()(0)

				If ni__2.IPAddress <> "0.0.0.0" Then
					Exit While
				End If
				Debug.Print("Waiting for an IP Address...")
				Thread.Sleep(5000)
			End While
			Debug.Print(NI__1.IPAddress.ToString())
			' Static 
			NI__1.EnableStaticIP("192.168.0.75", "255.255.255.0", "192.168.0.1")
			Debug.Print(NI__1.IPAddress.ToString())
			
		End Sub

	End Class
End Namespace
From this link,
http://www.developer...t/csharp-to-vb/

Baxter




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.