Hi,
I was enabling the DHCP functionality in our code. I observed that in file FreeRTOS_DHCP.c
the DHCP state from “vDHCPProcessEndPoint()” function is not changing.
-
When the DHCP event (“eDHCPEvent”) is generated from “prvIPTask( void *pvParameters )” function.
“vDHCPProcess()” function is called and then after that the xDHCPData.eDHCPState is checked and I have observed that it’s countinously on eWaitingOffer state. -
Following is the code snippet for eWaiting offer case from vDHCPProcessEndPoint function.
case eWaitingOffer :
xGivingUp = pdFALSE;
/* Look for offers coming in. */
if( ( xDoCheck != pdFALSE ) && ( prvProcessDHCPReplies( dhcpMESSAGE_TYPE_OFFER, pxEndPoint ) == pdPASS ) )
{
#if( ipconfigUSE_DHCP_HOOK != 0 )
/* Ask the user if a DHCP request is required. */
eAnswer = xApplicationDHCPHook( eDHCPPhasePreRequest, pxEndPoint->xDHCPData.ulOfferedIPAddress );
if( eAnswer == eDHCPContinue )
#endif /* ipconfigUSE_DHCP_HOOK */
{
/* An offer has been made, the user wants to continue,
generate the request. */
pxEndPoint->xDHCPData.xDHCPTxTime = xTaskGetTickCount();
pxEndPoint->xDHCPData.xDHCPTxPeriod = dhcpINITIAL_DHCP_TX_PERIOD;
prvSendDHCPRequest( pxEndPoint );
pxEndPoint->xDHCPData.eDHCPState = eWaitingAcknowledge;
break;
}
#if( ipconfigUSE_DHCP_HOOK != 0 )
if( eAnswer == eDHCPUseDefaults )
{
memcpy( &xNetworkAddressing, &xDefaultAddressing, sizeof( xNetworkAddressing ) );
pxEndPoint->ulIPAddress = pxEndPoint->ulDefaultIPAddress; /* Use this address in case DHCP has failed. */
}
/* The user indicates that the DHCP process does not continue. */
xGivingUp = pdTRUE;
#endif /* ipconfigUSE_DHCP_HOOK */
}
/* Is it time to send another Discover? */
else if( ( xTaskGetTickCount() - pxEndPoint->xDHCPData.xDHCPTxTime ) > pxEndPoint->xDHCPData.xDHCPTxPeriod )
{
/* Increase the time period, and if it has not got to the
point of giving up - send another discovery. */
pxEndPoint->xDHCPData.xDHCPTxPeriod <<= 1;
if( pxEndPoint->xDHCPData.xDHCPTxPeriod <= ipconfigMAXIMUM_DISCOVER_TX_PERIOD )
{
pxEndPoint->xDHCPData.ulTransactionId++;
pxEndPoint->xDHCPData.xDHCPTxTime = xTaskGetTickCount();
pxEndPoint->xDHCPData.xUseBroadcast = !pxEndPoint->xDHCPData.xUseBroadcast;
prvSendDHCPDiscover( pxEndPoint );
FreeRTOS_printf( ( "vDHCPProcess[%02x-%02x]: timeout %lu ticks\n",
pxEndPoint->xMACAddress.ucBytes[ 4 ],
pxEndPoint->xMACAddress.ucBytes[ 5 ],
pxEndPoint->xDHCPData.xDHCPTxPeriod ) );
}
else
{
FreeRTOS_printf( ( "vDHCPProcess[%02x-%02x]: giving up %lu > %lu ticks\n",
pxEndPoint->xMACAddress.ucBytes[ 4 ],
pxEndPoint->xMACAddress.ucBytes[ 5 ],
pxEndPoint->xDHCPData.xDHCPTxPeriod, ipconfigMAXIMUM_DISCOVER_TX_PERIOD ) );
#if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 )
{
/* Only use a fake Ack if the default IP address == 0x00
and the link local addressing is used. Start searching
a free LinkLayer IP-address. Next state will be
'eGetLinkLayerAddress'. */
prvPrepareLinkLayerIPLookUp();
/* Setting an IP address manually so set to not using
leased address mode. */
pxEndPoint->xDHCPData.eDHCPState = eGetLinkLayerAddress;
}
#else
{
xGivingUp = pdTRUE;
}
#endif /* ipconfigDHCP_FALL_BACK_AUTO_IP */
}
}
break;
- This should change its state form “eWaitingOffer” to “eWaintingAcknowledge” inorder to work. I have also debugged the code. But yet not able to solve it can you help?
Thanks and Regards
Prince