• AVR Freaks

DHCP problem with explorer 16

Author
francoisssaade
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2015/03/17 04:45:25
  • Location: 0
  • Status: offline
2015/03/17 05:23:12 (permalink)
0

DHCP problem with explorer 16


hello  i am working on a  project using the TCP/IP of microchip v5.42.
the purpose of my project is to perform a fault detection basically for the DHCP server and the DNS and more if it can be done , in other word, to detect if they are working or not. i wrote these functions and  i added them to the Maindemo.c the result will be printed on the screen of the explorer 16 board, the problem that i am having is that the DHCP server of the router that the board is connected to it through an Ethernet controller (ENC28J60)  isn't given an IP to the board despite that i uncomment the the specific macros in the TCPIP ENC28.h file. the router IP is 192.168.1.1 but the board is still saving the IP 169.254.1.31 which i also changed with the default gateway to 192.168.1.4. my question is if you can tell me how to make the board to auto-negotiate with the DHCP server to obtain an IP in case of the presence of it. 
PS: im working with PIC24FJ128GA010

 
 
this is where i call the test to  begin and the dhcp to start working
 
while(1)
    { DHCPInit(vInterface);
DHCPServerTask();
DHCPtesting();DelayMs(1000);LCDErase();
LCDInit();
DelayMs(1000);
 
strcpypgm2ram((char*)LCDText, "testing the Gateway and the DNS" ); 
LCDUpdate();DelayMs(1000);LCDErase();
GateTest();DelayMs(1000);LCDErase();
DNStest();
        // Blink LED0 (right most one) every second.
        if(TickGet() - t >= TICK_SECOND/2ul)

 
 
 
 
 
 
these are the fucnction that i wrote and added to Maindemo.c
 
void DHCPtesting(void)
{
char str[80];
 
extern APP_CONFIG AppConfig;
 
 
if ( DHCPIsBound(vInterface)==true )
{
 
{
DisplayIPValue(AppConfig.MyIPAddr); 
 
//LCD_PutString (DisplayIPAddress() ,sizeof(DisplayIPAddress()));
//DelayMs(2000);
//LCD_ClearScreen ();
}
}
 
else
   {
 
if(DHCPIsServerDetected(vInterface)==false)
{
strcpypgm2ram((char*)LCDText, "DHCP server is not detected" ); LCDUpdate();
}
 
if (DHCPIsEnabled(vInterface)==false)
{
strcpypgm2ram((char*)LCDText, "DHCP server is disabled" ); LCDUpdate();
 
}
 
  }
 
}
 
 
 
 
void GateTest(void)
{
extern APP_CONFIG AppConfig;
/**************************testing default gateway****************************************/
/*****************************************************************************************/
 
while(ICMPBeginUsage() )
{
ICMPSendPing(AppConfig.MyGateway.Val);
if(ICMPGetReply()>=0){
strcpypgm2ram((char*)LCDText, "GateWay matching" );
}
else{
strcpypgm2ram((char*)LCDText, "GateWay errornous" );
}
 
LCDUpdate();
ICMPEndUsage();
}
}
 
void DNStest(void)
{
char str[80];
extern APP_CONFIG AppConfig;
/************************** testing DNS**************************************************/
/****************************************************************************************/
while(ICMPBeginUsage())
{
 
             ICMPSendPingToHost(HOST_TO_PING);
 v=ICMPGetReply();
switch(v)
{
case '-3':
strcpypgm2ram((char*)LCDText, "Could not resolve hostname" );
 
case '-2':
strcpypgm2ram((char*)LCDText, "No response received yet" );
 
case '-1':
strcpypgm2ram((char*)LCDText, "Operation timed out" );
 
default:
strcpypgm2ram((char*)LCDText, "successful operation" );
 
 
}
 
LCDText[32]=str;LCDUpdate();
//DelayMs(2000);
//LCD_ClearScreen ();
ICMPEndUsage();
}
}

 
the macros :
#define STACK_USE_AUTO_IP                           // Dynamic link-layer IP address automatic configuration protocol
#define STACK_USE_DHCP_CLIENT // Dynamic Host Configuration Protocol client for obtaining IP address and other                                                                                                parameters
 

 
 
 
 
 










 










        
#1

0 Replies Related Threads

    Jump to:
    © 2020 APG vNext Commercial Version 4.5