DHCP problem

Hello! I have this problem: in my project i use DHCP-server+ Rabbit MiniCore 6710. Often need switch-off server and Rabbit. If switch-on server and minicore, then server coming up a longer than rabbit and minicore don’t receive ip-address.
Use this code:

#define USE_IF_CALLBACK
#define DTIMEOUT 8 // Define dhcp timeout

static void dhcp_callback(void)
{
auto word dhcp_ok;
ifconfig(IF_DEFAULT,
IFG_DHCP_OK, &dhcp_ok,
IFS_END);
if (dhcp_ok)
{
/*****
init tcp and udp
******/
}
else
{
ifdown(IF_DEFAULT);
return;
}
}

void init()
{
ifconfig(IF_DEFAULT, IFS_ICMP_CONFIG, 1,
IFS_IF_CALLBACK, dhcp_callback,
IFS_DHCP, 1,
IFS_DHCP_FALLBACK, 1,
IFS_IPADDR, inet_addr(“192.168.2.13”),
IFS_NETMASK, inet_addr(“255.255.255.0”),
IFS_END);
sock_init();
while (ifpending(IF_DEFAULT) == IF_COMING_UP)
{
WDT_Reset();
tcp_tick(NULL);
}
}

After this code checking connection - and if minicore don’t receive any message, then init() called again. And problem in this - DHCP-server already work fine, but rabbit don’t receive address.

You shouldn’t have to call sock_init() more than once.

Try the sample program, dhcp.c, and see if you have the same results.

I recommend using DC9.62 and the latest patches, both are available at http://www.digi.com/support/productdetail?pid=5053&type=documentation.

before you ask i see this example and his don’t help me. But i see him once more and find what i need - if dhcp_callback() in case else must be another ifconfg():

static void dhcp_callback(void)
{
auto word dhcp_ok;
ifconfig(IF_DEFAULT,
IFG_DHCP_OK, &dhcp_ok,
IFS_END);
if (dhcp_ok)
{
/*****
init tcp and udp
******/
}
else
{
ifconfig( IF_DEFAULT,
IFS_IPADDR, inet_addr(“192.168.2.13”),
IFS_NETMASK, inet_addr(“255.255.255.0”),
IFS_DHCP, 1,
IFS_UP,
IFS_END)
return;
}

thanks for help!