chipKIT® Development Platform

Inspired by Arduino™

IP address in DHCP on wifi shield

Created Mon, 04 Mar 2013 09:38:00 +0000 by aredman


aredman

Mon, 04 Mar 2013 09:38:00 +0000

Hey All, New to the forum, so this is my first post.

I am using the Max32 with the WiFi module to connect to a network with DHCP. Could anyone be able to help me on how to get the IP Address asigned to it so I can display it in the terminal.

Thanks in advanced. :D


aredman

Thu, 07 Mar 2013 10:20:21 +0000

I did get it in the end.

Using IPv4 pIP;

          if (DNETcK::getMyIP(&pIP)){
          for(int i=0 ; i <4; i++){
          Serial.print((int)pIP.rgbIP[i]);
          Serial.print(".");
          }

Will print it on the screen (yes I know there will be an extra".") Need to cast it as an int as println can not use the IPv4 structure for printing.

;)


jmjulien

Wed, 10 Apr 2013 20:29:00 +0000

I use the streaming library so it looks cleaner :

IPv4 myIp;
if (DNETcK::getMyIP(&myIp))
{
  Serial << "IP Adress : " << _DEC(myIp.rgbIP[0]) << "." << _DEC(myIp.rgbIP[1]) << "." << _DEC(myIp.rgbIP[2]) << "." << _DEC(myIp.rgbIP[3]) << endl;
}

The Streaming library is available there: [url]http://arduiniana.org/libraries/streaming/[/url]

JMJ