how to set ip address in examples/protocols/http_server/simple/main/main.c

Sunbelt57
Posts: 10
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

how to set ip address in examples/protocols/http_server/simple/main/main.c

Postby Sunbelt57 » Wed Mar 05, 2025 1:25 am

all my ip addresses in my LAN start from 192.168.88.1 because of my ISP. So my DHCP reservation list goes from there up to 255. When trying to run the example program examples/protocols/http_server/simple/main/main.c, I get the output that says:

Code: Select all

I (438) example_connect: Connecting to extra ssid...
I (1508) wifi:state: 0 -> 2 (b0)
I (1511) wifi:state: 2 -> 3 (0)
I (1513) wifi:state: 3 -> 5 (10)
I (1526) wifi:connected with extra ssid, aid = 1, channel 11, HT20, bssid = 00:26:5a:fd:13:10
I (3005) tcpip_adapter: sta ip: 192.168.0.101, mask: 255.255.255.0, gw: 192.168.0.1
I (3010) example_connect: Connected to extra ssid
I (3013) example_connect: IPv4 address: 192.168.0.101
I (3021) APP: Starting server on port: '80'
I (3033) APP: Registering URI handlers
It connects to my wifi (extra ssid) but I have no way to get to 192.168.0.101 and my gateway is not 192.168.0.1

ESP_Sprite
Posts: 9985
Joined: Thu Nov 26, 2015 4:08 am

Re: how to set ip address in examples/protocols/http_server/simple/main/main.c

Postby ESP_Sprite » Wed Mar 05, 2025 2:55 am

Are you sure that SSID isn't running on a router or access point or whatever that has its own DHCP server?

Sunbelt57
Posts: 10
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

Re: how to set ip address in examples/protocols/http_server/simple/main/main.c

Postby Sunbelt57 » Wed Mar 05, 2025 2:58 am

I found this in components/tcpip_adapter/tcpip_adapter_lwip.c

Code: Select all

void tcpip_adapter_init(void)
{
    if (tcpip_inited == false) {
        tcpip_inited = true;
        tcpip_init(NULL, NULL);

        memset(esp_ip, 0, sizeof(tcpip_adapter_ip_info_t)*TCPIP_ADAPTER_IF_MAX);
        memset(esp_ip_old, 0, sizeof(tcpip_adapter_ip_info_t)*TCPIP_ADAPTER_IF_MAX);

        IP4_ADDR(&esp_ip[TCPIP_ADAPTER_IF_AP].ip, 192, 168 , 88, 5);
        IP4_ADDR(&esp_ip[TCPIP_ADAPTER_IF_AP].gw, 192, 168 , 88, 1);
        IP4_ADDR(&esp_ip[TCPIP_ADAPTER_IF_AP].netmask, 255, 255 , 255, 0);
    }
}
and changed the 3rd octet to 88, did a clean and remake and still same results. I checked the output of make and tcpip_adapter_lwip.c was being compiled.

Sunbelt57
Posts: 10
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

Re: how to set ip address in examples/protocols/http_server/simple/main/main.c

Postby Sunbelt57 » Wed Mar 05, 2025 3:08 am

the router with the wifi is in a different building than the router for 192.168.88.1.This one is 88.2. I tried changing the ssid to the other one and went to that location (the garage) and it logged onto that wifi ok but the same result. The main router has a DHCP reservation list where all the ip addresses are set to certain addresses and each time I've tested the AP and station examples with the ESP8266 the DHCP set the address to something not reserved and in the case of say the WebServer examples, I could display the results with the browser.

Sunbelt57
Posts: 10
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

Re: how to set ip address in examples/protocols/http_server/simple/main/main.c

Postby Sunbelt57 » Wed Mar 05, 2025 3:13 am

OK, I set the DHCP reservation list on the 2nd router for 192.168.88.4-6 and it shows at the bottom the dynamic clients with the MAC address of the ESP8266 chip but the website doesn't work.

Sunbelt57
Posts: 10
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

Re: how to set ip address in examples/protocols/http_server/simple/main/main.c

Postby Sunbelt57 » Wed Mar 05, 2025 3:25 am

It looks like the 2 routers can't both have DHCP reservation lists. The chip keeps showing up on the 1st router reserved as either 236 or 237 and as 5 on the 2nd one. They are both D-Link routers. I should try turning off the wifi on the 2nd router and recompile for the ssid in the garage and take it back up there.

Sunbelt57
Posts: 10
Joined: Wed Feb 12, 2025 5:41 pm
Location: Eastern Wyoming

Re: how to set ip address in examples/protocols/http_server/simple/main/main.c

Postby Sunbelt57 » Wed Mar 05, 2025 5:12 am

It started working as in the serial output shows the ip address assigned by the DHCP of the 1st router. It assigns it 192.168.88.234 and the browser showed "this URI doesn't exist" until you set it to: "192.168.88.234/hello". I'm not quite sure what I did to get it to work. I'll change the lwip.c file back to 192.168.0.1 and see what happens.

Who is online

Users browsing this forum: Google Adsense [Bot] and 35 guests