cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP: set IP address, mask, and Gateway address of stm32 remotely

abeba.1
Associate III

hii every one 

 

i have a question about setting up the ip of the STM32 MCU remotely 

 

when we want to do client server in udp or tcp on stm32 controller , we are used to set the ip address manually in the ioc file in general settings in the lwip section in the middleware tab .

 

and i was wondering if there is a way to set up any default ip of mine , and is there a way to change this ip remotly after i am connected to the stm32 .

 

my goal is to design an application that can give me the ability to access and change the ip and mask and gateway of my stm32 controller , i be very thankful for help and to know if there is a method to do that  

1 ACCEPTED SOLUTION

Accepted Solutions

You said, "we are used to set the ip address manually in the ioc file in general settings in the lwip section in the middleware tab" - so you already have this working?

So that code is your example!

That is the code that you browse, find the settings, then modify...

Did you try the internet search?

eg, https://www.google.com/search?q=LwIP+set+IP+address

View solution in original post

18 REPLIES 18
Javier1
Principal

The ioc file from cubeMx as i understood is just a point and click User Interface that generates code.

Here is what i would do:

  1. Just put your project inside the version control of your choice (git?)
  2. Change the ip and generate code with cubeMx
  3. do a git diff and take a look what cubeMx actually changed in your sourcefiles
  4. Now you know what file/s you should go to for changing the ip yourself :D
Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero

This is going to be more down to the IP stack that you use (LwIP) rather than specific to STM32 - so try searching in general for "LwIP set IP address" and similar ...

 

Also, as @Javier1 said, browse the generated code to see where these things get set - then change them from compile-time constants to run-time settings ...

can yo guys give an example code where to look for thanks 

 

You said, "we are used to set the ip address manually in the ioc file in general settings in the lwip section in the middleware tab" - so you already have this working?

So that code is your example!

That is the code that you browse, find the settings, then modify...

Did you try the internet search?

eg, https://www.google.com/search?q=LwIP+set+IP+address


@Javier1 wrote:
  1. Just put your project inside the version control of your choice (git?)

@abeba.1 If you don't already have version control, then I would certainly recommend that you should.

But you don't actually need it to do this - you can just use a simple copy:

  1. Generate your code in the normal way, with a fixed IP address specified via CubeMX
  2. Copy your entire project so a separate folder - where it will not get overwritten by re-generating.
  3. Now modify your project, via CubeMX, for a different IP address, and re-generate
  4. Now perform a diff between this project, and the copy of your original project

If you don't already have a diff utility, try WinMerge: https://winmerge.org/?lang=en

A diff utility is an invaluable tool.

 

abeba.1
Associate III

hii guyes thanks for help :)

abeba.1
Associate III

Duplicate - merged.

Please don't start multiple threads on the same topic.


hii everyone 

 

in the stm32 in the middleware section we can set the ip address manually in general settings in static dhcp section 

and compile the project and program it on my stm32 board .

 

lets say i manually set the ip to 198.162.127.100 so my server that is running on the stm32 board will be working with this ip .

lets say i want to remotly change the ip of the board (without compiling the project again ) to 198.162.127.101

and my question is this possible 

 

my need is to be able to give the board a desired ip without compiling and downloading the new firmware to the stm32 controller 

Use DHCP. Tell the DHCP server to allocate specific address to your board.

 

hii i researched this topic and i saw that in order for the dhcp server to assign ip address

this process is called reservation , and its done at the level of the dhcp server 

 

from what i see i need to know the mac address of my stm32 and then to search for a section in my dhcp server where i can enter the mac and the ip that i want so my stm32 boar will always get the same ip .

 

lets say that my board is connected to the network the dhcp server is out of my reach , i am not the administrator of the dhcp server on the network in order to set up the mac with the desired ip that i want  .

beside of that lets say my board doesn't have an access to the network that means that my local network needs to have a dhcp server in order to do the ip reservation , am i right ?  

 

second -is there away of accessing the configurations of the dhcp server on my network with terminal commands to put my stm32 mac address and my desired ip