cmbahadir / opcua-esp32

Embedded OPC UA Server on ESP32 based on open62541 stack
Mozilla Public License 2.0
115 stars 40 forks source link

Change server IP address #44

Closed MayRGSilva closed 1 year ago

MayRGSilva commented 1 year ago

Hi, I'm trying to change the IP address of the OPC UA server.

Everytime I run the code, the server starts with an IP in the range of "192.168.1.x", and with the network address 192.168.1.1 and the network mask 255.255.255.0.

This is a problem for me because when I run my setup in another network with a different network address (lets say 150.165.1.1), I cannot reach the server using an UAExpert client. Would you have a suggestion on how to change the server IP address?

image

cmbahadir commented 1 year ago

Hi,

Do you use an ethernet cabled connection or Wi-Fi? And also what are the values for below parameters in your sdkconfig;

CONFIG_EXAMPLE_CONNECT_WIFI= ?? CONFIG_USE_STATIC_IP= ?? CONFIG_ETHERNET_HELPER_STATIC_IP4_ADDRESS= ?? CONFIG_ETHERNET_HELPER_STATIC_GATEWAY= ?? CONFIG_ETHERNET_HELPER_STATIC_NETMASK= ??

MayRGSilva commented 1 year ago

Hi! I'm using Wi-fi connection.

The parameters are set like this:

Connection Configuration

CONFIG_EXAMPLE_CONNECT_WIFI=y CONFIG_EXAMPLE_CONNECT_ETHERNET is not set CONFIG_WIFI_SSID="LIEC_Wireless116" CONFIG_WIFI_PASSWORD="Industrial_IoT" CONFIG_USE_STATIC_IP is not set CONFIG_ETHERNET_HELPER_STATIC_IP4_ADDRESS="" CONFIG_ETHERNET_HELPER_STATIC_GATEWAY="" CONFIG_ETHERNET_HELPER_STATIC_NETMASK=""

end of Connection Configuration

MayRGSilva commented 1 year ago

Any ideas on how to solve this?

cmbahadir commented 1 year ago

As I can see from your config, you already got an IP from your gateway as "192.168.1.21", that is in the range of IPs provided by your gateway.

Once you are connected to the WIFI network (I suppose "LIEC_Wireless116"), you will get an IP address in the range of connected gateway.

So if "LIEC_Wireless116" assigns IP addresses from the range of "150.165.1.x" you should see something like below when the ESP32 got connected. (x's should be numbers)

I (7193) esp_netif_handlers: sta ip: 150.165.1.x, mask: 255.255.255.x, gw: 150.165.1.1

cmbahadir commented 1 year ago

Now it is also possible to set a static ip address for Wi-Fi connections with PR #45 .

@MayRGSilva Please get the latest and let me know of any problems.

MayRGSilva commented 1 year ago

Thank you very much @cmbahadir :)