Using Ethernet port, Not getting DNS via DHCP

Hi Apologies if this is something stupid, I’ve been trying out the networking on the SCM20260D.
I’ve used the example code:

            //Reset external phy.
            var gpioController = GpioController.GetDefault();
            var resetPin = gpioController.OpenPin(SC20260.GpioPin.PG3);

            resetPin.SetDriveMode(GpioPinDriveMode.Output);

            resetPin.Write(GpioPinValue.Low);
            System.Threading.Thread.Sleep(100);

            resetPin.Write(GpioPinValue.High);
            System.Threading.Thread.Sleep(100);

            _controller = NetworkController.FromName(SC20260.NetworkController.EthernetEmac);

            var networkInterfaceSetting = new EthernetNetworkInterfaceSettings();

            var networkCommunicationInterfaceSettings = new BuiltInNetworkCommunicationInterfaceSettings();
            networkInterfaceSetting.MacAddress = new byte[] { 0x00, 0x4, 0x00, 0x00, 0x00, 0x00 };
            networkInterfaceSetting.DhcpEnable = true;

            _controller.SetInterfaceSettings(networkInterfaceSetting);
            _controller.SetCommunicationInterfaceSettings(networkCommunicationInterfaceSettings);

            _controller.SetAsDefaultController();

            _controller.NetworkAddressChanged += NetworkController_NetworkAddressChanged;
            _controller.NetworkLinkConnectedChanged += NetworkController_NetworkLinkConnectedChanged;

            _controller.Enable();

When the Network Address changes with DHCP, the address is set but the DNS entries are set to 0.0.0.0:

Address changed: 0.0.0.0 DNS = 0.0.0.0
Network Link Connected Changed
Address changed: 169.254.1.0 DNS = 0.0.0.0
    #### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####

I’ve tried setting networkInterfaceSetting.DynamicDnsEnable = true and that didn’t make any difference. Also, it looks like the IP address that is set, isn’t in the normal range of 172.24.1.* for my network.

Any ideas?

Thanks for any help,
Jas

The 169.254.x.x is the Auto IP address that was recently added to TinyCLR (APIPA (AutoIP))
If it can’t get an address from the DHCP server it will self-assign an address in the 169.254.x.x range.

So it seems it is not getting an address from the DHCP server for some reason. Can you use a fix IP address and see if you can ping the device from a PC?

1 Like

I’ve tried to set it to a set IP (And set the gateway/dns manually) and getting a timeout error. I have a Wifi 7 Click board (MIKROE-2046) on order and I’ll try again with that when it arrives.

Hi All,
Got the Wifi 7 Click board and used the code from the demo and it works perfectly (And no long cables strewn across the room :slight_smile: )

Getting back to the REST API code now.

5 Likes