How to get AP's IP address

ftdiyun
Posts: 25
Joined: Tue Jul 19, 2016 5:32 pm

How to get AP's IP address

Postby ftdiyun » Mon Jul 25, 2016 10:05 am

Hi,

When the ESP8266 acting as a station, and connected to an AP, how can user know the AP's IP address? I went through the API docuement "2c-esp8266_non_os_sdk_api_reference_cn", I didn't find a proper API to do this. Can you provide some hints or solution to get AP's IP address? Thanks.

akouz
Posts: 27
Joined: Tue May 10, 2016 1:10 pm

Re: How to get AP's IP address

Postby akouz » Mon Jul 25, 2016 12:37 pm

Use command AT+CIFSR

For example, I've got the following replies (bold text) to that command:

+CIFSR:APIP,"192.168.4.1" - AP address
+CIFSR:APMAC,"1a:fe:34:fe:89:8d" - AP MAC
+CIFSR:STAIP,"192.168.1.104" - station address
+CIFSR:STAMAC,"18:fe:34:fe:89:8d" - station MAC

ftdiyun
Posts: 25
Joined: Tue Jul 19, 2016 5:32 pm

Re: How to get AP's IP address

Postby ftdiyun » Mon Jul 25, 2016 4:58 pm

Hi,

Thanks for your reply. I tried this using the latest AT firmware, but there is no information about AP's IP. Please check the information as below:

AT+CIFSR
+CIFSR:STAIP,"192.168.1.5"
+CIFSR:STAMAC,"18:fe:34:a6:01:a9"
OK

at+GMR
AT version:1.3.0.0(Jul 14 2016 18:54:01)
SDK version:2.0.0(656edbf)
compile time:Jul 22 2016 12:02:54
OK

Her Mary
Posts: 453
Joined: Mon Oct 27, 2014 11:09 am

Re: How to get AP's IP address

Postby Her Mary » Mon Jul 25, 2016 8:52 pm

The gateway should be the AP's IP address if DHCP is enabled. WiFi event "EVENT_STAMODE_GOT_IP" after registered callback by wifi_set_event_handler_cb.
AT command may be : AT+CIPSTA_CUR?

akouz
Posts: 27
Joined: Tue May 10, 2016 1:10 pm

Re: How to get AP's IP address

Postby akouz » Tue Jul 26, 2016 7:10 am

ftdiyun wrote:I tried this using the latest AT firmware, but there is no information about AP's IP


Perhaps you forgotten to enable AP by AT+CWMODE_CUR. Use either AT+CWMODE_CUR=2 or AT+CWMODE_CUR=3. Here is my initialisation sequence:

AT+CWMODE_CUR=3
AT+CWJAP_CUR="xxx","xxx"
AT+CIPMUX=1
AT+CIPSERVER=1,1300

After that I can query IP addresses:

AT+CIFSR

ftdiyun
Posts: 25
Joined: Tue Jul 19, 2016 5:32 pm

Re: How to get AP's IP address

Postby ftdiyun » Tue Jul 26, 2016 9:21 am

Hi akouz,

AT+CWMODE_CUR=3, means "softAP + station mode", the AP's IP address is the module its own SoftAP's address. It's not the gateway's IP address. Under this mode, "AT+CIFSR" commands do print-out its own SoftAP's address IP address, but not the gateway's IP address.

I am using "AT+CWMODE_CUR=1", means "station mode" only. Under this mode, "AT+CIFSR" commands doesn't print-out the connected AP's IP address (or gateway address).

The output message of command "AT+CIFSR" is not consistent for different mode.

Who is online

Users browsing this forum: No registered users and 2 guests