cancel
Showing results for 
Search instead for 
Did you mean: 

Assign Static IP address in Threadx

PG.9
Associate III

Greetings !

I am working on STM32H743 EVK and I could successfully compiled and executed the sample TCP Echo Server application over Threadx .

But here DHCP IP is assigning . Please help me out to make IP as static IP.

Thanks in Advance

1 ACCEPTED SOLUTION

Accepted Solutions
STM32_ZA
ST Employee

Hi,

If you are using STM32CubeMX to generate project, you need just to disable the "Addons DHCP client" component and regenerate your project or you can disable DHCP manually and define your static address in app_netxduo.h:

#define NX_APP_DEFAULT_IP_ADDRESS          IP_ADDRESS(192, 168, 1, 1)

#define NX_APP_DEFAULT_NET_MASK           IP_ADDRESS(255, 255, 255, 0)

regards

View solution in original post

2 REPLIES 2
STM32_ZA
ST Employee

Hi,

If you are using STM32CubeMX to generate project, you need just to disable the "Addons DHCP client" component and regenerate your project or you can disable DHCP manually and define your static address in app_netxduo.h:

#define NX_APP_DEFAULT_IP_ADDRESS          IP_ADDRESS(192, 168, 1, 1)

#define NX_APP_DEFAULT_NET_MASK           IP_ADDRESS(255, 255, 255, 0)

regards

PG.9
Associate III

Hi ,

Thanks for the valid information . Now I could able to assign Static IP .

But here I am facing issues with it . Most of the times Ethernet is assigning the IP only when I remove and reinsert the network cable (proper Network cable is used).

Can you please help me out to overcome this issue . Below mentioned is my "App_Link_Thread_Entry" function .

Thanks in Advance

-----------------------------------------------------------------------------------------------------------

/* @brief Link thread entry

* @param thread_input: ULONG thread parameter

* @retval none

*/

static VOID App_Link_Thread_Entry(ULONG thread_input)

{

 ULONG actual_status;

 UINT linkdown = 0, status;

 while(1)

 {

  /* Get Physical Link stackavailtus. */

  status = nx_ip_interface_status_check(&IpInstance, 0, NX_IP_LINK_ENABLED, &actual_status, 10);

  if(status == NX_SUCCESS)

  {

   if(linkdown == 1)

   {

    linkdown = 0;

    status = nx_ip_interface_status_check(&IpInstance, 0, NX_IP_ADDRESS_RESOLVED,

                   &actual_status, 10);

    if(status == NX_SUCCESS)

    {

     /* The network cable is connected again. */

     printf("The network cable is connected again.\n\r");

     /* Print UDP Echo Client is available again. */

     printf("Webserver Application is available again.\n\r");

//#if 0

     // WWDebug: try this:

 /* Send command to Enable Nx driver. */

     printf("\r\n WWDebug : Try to re-enable link\n\r");

 nx_ip_driver_direct_command(&IpInstance, NX_LINK_ENABLE, &actual_status);

 tx_semaphore_put(&Semaphore);

//#endif

    }

    else

    {

     /* The network cable is connected. */

     printf("The network cable is connected.\n\r");

     /* Send command to Enable Nx driver. */

     nx_ip_driver_direct_command(&IpInstance, NX_LINK_ENABLE, &actual_status);

     tx_semaphore_put(&Semaphore);

    }

   }

  }

  else

  {

   if(0 == linkdown)

   {

    linkdown = 1;

    /* The network cable is not connected. */

    printf("The network cable is not connected.\n\r");

   }

  }

  tx_thread_sleep(60);

 }

}

/* USER CODE END 1 */

-----------------------------------------------------------------------------------------------------------